1 |
- var datas={},root="",schemeRoot="",genTableListContentVm=new Vue({el:"#genTableListContent",data:function(){return{pageLoading:!0,pageDictMap:{}}},computed:{formBaseUrl:function(){return getRelativePath()+"getTableForm.html?editType="},dataLogicTypeDict:function(){return this.pageDictMap.data_logic_type},requestPrefix:function(){var e=window.__CODEGEN_CONFIG__;return e.gatewayRoute+e.direwolfAdmin+"/codegen"}},created:function(){var t=this;checkPagePermission(t.requestPrefix+"/checkGenTablePermission");var e=new ProjectConfig;root=e.proxyPath+t.requestPrefix,schemeRoot=e.proxyPath+window.__CODEGEN_CONFIG__.gatewayRoute+window.__CODEGEN_CONFIG__.direwolfAdmin+"/genScheme",initDicts();var o="获取字典信息";axios.get(dictUrl+"data_logic_type").then(function(e){t.pageDictMap=getDataFromAxiosResponse(e,o).data,t.pageLoading=!1}).catch(function(e){axiosErrorTips(e,o+"异常")})},mounted:function(){$("#searchBtn").on("click",queryProcess),$("#canSearchBtn").on("click",cancelSearch),$("#genCodeBtn").on("click",genCode),$("#editBtn").on("click",editTable),$("#importFromDb").on("click",importFromDb),$("#genMenuBtn").on("click",createMenu),$("#refreshBtn").on("click",queryProcess)}});function initDicts(){$.ajax({url:root+"/genTableDict",type:"post",contentType:"application/json; charset=UTF-8",success:function(e){datas=e,initTable()},error:function(){toastr.error("操作失败")}})}function initTable(){var e=root+"/genTableData";$("#gen-table").bootstrapTable({url:e,columns:[{checkbox:!0},{field:"name",title:"名称",sortable:!0,formatter:function(e,t,o){return'<a href="#" onclick="viewTableDel(\''+t.id+"')\">"+e+"</a>"}},{field:"tableAlias",title:"记录别名",sortable:!0},{field:"comments",title:"说明"},{field:"className",title:"类名",sortable:!0},{field:"dataLogicType",title:"数据类型",sortable:!0,formatter:function(e,t,o){return datas.data_logic_type[e]}},{field:"genDatasource.dsName",title:"数据源",sortable:!0},{title:"操作",formatter:function(e,t,o){return initLink(t)}}],pagination:!0,clickToSelect:!0,singleSelect:!0,pageSize:10,sortOrder:"desc",pageList:[10,20,30],queryParams:function(e){return queryProcessParam(e)},sidePagination:"server",silentSort:!1})}function queryProcess(){var e=queryProcessParam(null);$("#gen-table").bootstrapTable("refresh",{url:root+"/genTableData",query:e})}function cancelSearch(){$("#genTableForm .form-control").val(null),queryProcess()}function genCode(){var c=$("#gen-table").bootstrapTable("getSelections");0!==c.length?1<c.length?toastr.error("请至多选择一条数据"):openDialog("生成代码",getRelativePath()+"genCodeForm.html?genTable.id="+c[0].id,{yes:function(e,t){return t.find("iframe")[0].contentWindow.doSubmit(function(e){setTimeout(function(){parentWindow&&parentWindow.toastr?parentWindow.toastr.success(e.message):Vue&&direwolfCommonTips("success",e.message)},100)}),!0}},{btn:["生成","下载","取消"],btn2:function(e,t){var o,a,n=$(t.find("iframe")[0].contentWindow.document),r=n.find("#category").val(),i=n.find("#style").val(),s=schemeRoot+"/refreshSchemeForm?genTable.id="+c[0].id+"&category="+r+"&style="+i,l=$.parseJSON($.ajax({url:s,async:!1}).responseText);return null!=l&&void 0!==l.type&&"success"===l.type?void 0!==l.data.genScheme&&((o=l.data.genScheme).id?((a=new XMLHttpRequest).open("GET",schemeRoot+"/download?id="+o.id,!0),a.responseType="blob",a.onload=function(e){var t,o;a.getResponseHeader("Content-Length")?(t=a.response,o=a.getResponseHeader("fileName"),saveBlobToLocal(o,t)):a.response.text().then(function(e){showError(JSON.parse(e).message)})},a.send()):showError("请先生成代码再下载")):showError("获取计划信息失败"),!1},btn3:function(e){setTimeout(function(){getLayerInstance().close(e)},100)}}):toastr.error("请至少选择一条数据")}function showError(e){parentWindow&&parentWindow.toastr?parentWindow.toastr.error(e):Vue&&direwolfCommonTips("error",e)}function editTable(){var e,t=$("#gen-table").bootstrapTable("getSelections");0!==t.length?1<t.length?toastr.error("请至多选择一条数据"):(e={width:"1000px",height:"650px",full:!1,callback:function(){queryProcess()}},openDialog("修改表单",getRelativePath()+"genTableForm.html?id="+t[0].id,e)):toastr.error("请至少选择一条数据")}function viewTableDel(e){openDialogView("查看表单",getRelativePath()+"genTableForm.html?viewType=view&id="+e,{width:"1000px",height:"650px",full:!1})}function importFromDb(){var e={width:"800px",height:"500px",full:!1,callback:function(){var e=queryProcessParam(null);$("#gen-table").bootstrapTable("refresh",{url:root+"/genTableData",query:e})}};openDialog("导入表单",getRelativePath()+"importTableFromDB.html",e)}function createMenu(){var t=$("#gen-table").bootstrapTable("getSelections");0!==t.length?1<t.length?toastr.error("请至多选择一条数据"):$.ajax({url:schemeRoot+"/isCodeCreate?genTable.id="+t[0].id,type:"post",contentType:"application/json; charset=UTF-8",success:function(e){"success"===e.type?openDialog("创建菜单",getRelativePath()+"createMenuList.html?genTable.id="+t[0].id,{width:"750px",height:"550px",full:!1}):toastr.error(e.message)},error:function(){toastr.error("操作失败")}}):toastr.error("请至少选择一条数据")}function editTables(e){var t={width:"1000px",height:"650px",full:!1,callback:function(){queryProcess()}};openDialog("修改表单",getRelativePath()+"genTableForm.html?id="+e,t)}function queryProcessParam(e){var t={name:$("#name").val(),tableAlias:$("#tableAlias").val(),dataLogicType:$("#dataLogicType").val()};return null!=e&&(t.order=e.order,t.limit=e.limit,t.offset=e.offset,t.search=e.search,t.sort=e.sort),t}function syncTable(e){var t={width:"800px",height:"600px",full:!1,callback:function(){queryProcess()}};openDialog("同步数据库",getRelativePath()+"syncTableList.html?id="+e,t)}function deleteTable(e){direwolfCommonConfirm("确认要删除该条记录并删除对应的数据库表?","删除确认",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"},function(){$.ajax({url:root+"/deleteTable?id="+e,type:"post",contentType:"application/json; charset=UTF-8",success:function(e){"success"===e.type?queryProcess():toastr.error(e.message,"操作失败")},error:function(){toastr.error("操作失败")}})})}function initLink(e){var t="<div class='btn-group'><a data-toggle='tooltip' data-placement='top' title='修改' style='margin:1px' class='btn btn-primary btn-xs' id='edit_"+e.id+"'\tonclick=editTables('"+e.id+"'); onmouseenter=jQuery(this).tooltip('show');><i class='fa fa-pencil-square-o fa-fw'></i></a>";e.id,e.id;return t+("<a data-toggle='tooltip' data-placement='top' title='删除' style='margin:1px' class='btn btn-danger btn-xs' id='delete_"+e.id+"'\tonclick=deleteTable('"+e.id+"'); onmouseenter=jQuery(this).tooltip('show');><i class='fa fa-trash fa-fw'></i></a>")+("<a data-toggle='tooltip' data-placement='top' title='同步数据库'\tstyle='margin:1px' class='btn btn-primary btn-xs' id='sync_"+e.id+"'\tonclick=syncTable('"+e.id+"'); onmouseenter=jQuery(this).tooltip('show');><i class='fa fa-database fa-fw'></i></a></div>")+("<div title='' style='float: left; cursor: pointer;margin:3px;display:none;' class='ui-pg-div ui-inline-edit' id='actionLink_"+e.task_id+"'><a href='#'></a></div>")}
|