代码优化

This commit is contained in:
jeesite
2021-12-18 16:00:09 +08:00
parent f07973c7c7
commit 5a62f9d38d
5 changed files with 96 additions and 5 deletions

View File

@@ -51,6 +51,7 @@
<template>crud_cloud/controller.xml</template>
<template>crud_cloud/viewList.xml</template>
<template>crud_cloud/viewForm.xml</template>
<template>crud_cloud/viewIndex.xml</template>
<childTable>
<template>crud_cloud/mapper.xml</template>
<template>crud_cloud/entity.xml</template>

View File

@@ -2,9 +2,9 @@
<!-- Copyright (c) 2013-Now http://jeesite.com All rights reserved.
No deletion without permission, or be held responsible to law. -->
<template>
<name>vueIndex</name>
<filePath>vue/src/views/${urlPrefix}</filePath>
<fileName>index.vue</fileName>
<name>viewIndex</name>
<filePath>src/main/resources/views/${lastPackageName}/${moduleName}/${subModuleName}</filePath>
<fileName>${className}Index.html</fileName>
<content><![CDATA[
<% if(table.isTreeEntity){ %>
\<% layout('/layouts/default.html', {title: '${functionNameSimple}管理', libs: ['layout','zTree']}){ %>

View File

@@ -36,6 +36,7 @@
import { defineComponent, ref } from 'vue';
import { useI18n } from '/@/hooks/web/useI18n';
import { useMessage } from '/@/hooks/web/useMessage';
import { router } from '/@/router';
import { Icon } from '/@/components/Icon';
import { BasicForm, FormSchema, useForm } from '/@/components/Form';
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
@@ -62,7 +63,6 @@ for(c in table.columnList){
<% if(areaselectExists) { %>
import { areaTreeData } from '/@/api/sys/area';
<% } %>
import { router } from '/@/router';
const emit = defineEmits(['success', 'register']);

View File

@@ -83,6 +83,7 @@
import { defineComponent<% if(table.isTreeEntity){ %>, watch, nextTick<% } %> } from 'vue';
import { useI18n } from '/@/hooks/web/useI18n';
import { useMessage } from '/@/hooks/web/useMessage';
import { router } from '/@/router';
import { Icon } from '/@/components/Icon';
import { BasicTable, BasicColumn, useTable } from '/@/components/Table';
import { ${className}Delete, ${className}ListData } from '/@/api/${moduleName}${isNotEmpty(subModuleName)?'/'+subModuleName:''}/${className}';
@@ -113,7 +114,6 @@ for(c in table.columnList){
<% } %>
import { useDrawer } from '/@/components/Drawer';
import { FormProps } from '/@/components/Form';
import { router } from '/@/router';
import InputForm from './form.vue';
<% if(table.isTreeEntity){ %>

View File

@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2013-Now http://jeesite.com All rights reserved.
No deletion without permission, or be held responsible to law. -->
<template>
<name>viewIndex</name>
<filePath>${moduleName}/src/main/resources/views/${lastPackageName}/${moduleName}/${subModuleName}</filePath>
<fileName>${className}Index.html</fileName>
<content><![CDATA[
<% if(table.isTreeEntity){ %>
\<% layout('/layouts/default.html', {title: '${functionNameSimple}管理', libs: ['layout','zTree']}){ %>
<div class="ui-layout-west">
<div class="main-content">
<div class="box box-main">
<div class="box-header">
<div class="box-title">
<i class="fa icon-grid"></i> \${text('${functionNameSimple}')}
</div>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" id="btnExpand" title="\${text('展开')}" style="display:none;"><i class="fa fa-chevron-up"></i></button>
<button type="button" class="btn btn-box-tool" id="btnCollapse" title="\${text('折叠')}"><i class="fa fa-chevron-down"></i></button>
<button type="button" class="btn btn-box-tool" id="btnRefresh" title="\${text('刷新')}"><i class="fa fa-refresh"></i></button>
</div>
</div>
<div class="ui-layout-content">
<div id="tree" class="ztree"></div>
</div>
</div>
</div>
</div>
<div class="ui-layout-center">
<iframe id="mainFrame" name="mainFrame" class="ui-layout-content p0"
src="\${ctx}/${urlPrefix}/list"></iframe>
</div>
\<% } %>
<script>
// 初始化布局
$('body').layout({
west__initClosed: $(window).width() <= 767, // 是否默认关闭
west__size: 200
});
// 主页框架
var win = $("#mainFrame")[0].contentWindow;
// 树结构初始化加载
var setting = {view:{selectedMulti:false},data:{key:{title:"title"},simpleData:{enable:true}},
callback:{onClick:function(event, treeId, treeNode){
tree.expandNode(treeNode);
//win.$('button[type=reset]').click();
<% for(pk in table.pkList){ %>
win.$('#${pk.attrName}').val(treeNode.id);
<% } %>
win.page();
}}
}, tree, loadTree = function(){
js.ajaxSubmit("\${ctx}/${urlPrefix}/treeData?___t=" + new Date().getTime(), function(data){
tree = $.fn.zTree.init($("#tree"), setting, data);//.expandAll(true);
// 展开第一级节点
var nodes = tree.getNodesByParam("level", 0);
for(var i=0; i<nodes.length; i++) {
tree.expandNode(nodes[i], true, false, false);
}
// 展开第二级节点
// nodes = tree.getNodesByParam("level", 1);
// for(var i=0; i<nodes.length; i++) {
// tree.expandNode(nodes[i], true, false, false);
// }
}, null, null, js.text('loading.message'));
};loadTree();
// 工具栏按钮绑定
$('#btnExpand').click(function(){
tree.expandAll(true);
$(this).hide();
$('#btnCollapse').show();
});
$('#btnCollapse').click(function(){
tree.expandAll(false);
$(this).hide();
$('#btnExpand').show();
});
$('#btnRefresh').click(function(){
loadTree();
});
// 调用子页分页函数
function page(){
win.page();
}
</script>
<% } %>
]]>
</content>
</template>