From d2b790702b5ff3a9dac9882598c911c5322da882 Mon Sep 17 00:00:00 2001 From: thinkgem Date: Sat, 29 Mar 2025 22:22:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=A0=91=E8=A1=A8=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=EF=BC=8C=E5=B7=A6=E6=A0=91=E5=8F=B3=E8=A1=A8=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E7=94=9F=E6=88=90=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/gen/view/dataGridScript.html | 14 ++++++- .../templates/modules/gen/vue/vueIndex.xml | 11 ++---- .../templates/modules/gen/vue/vueList.xml | 39 ++++++++++++------- 3 files changed, 43 insertions(+), 21 deletions(-) diff --git a/modules/core/src/main/resources/templates/modules/gen/view/dataGridScript.html b/modules/core/src/main/resources/templates/modules/gen/view/dataGridScript.html index ac566ad4..56e6f347 100644 --- a/modules/core/src/main/resources/templates/modules/gen/view/dataGridScript.html +++ b/modules/core/src/main/resources/templates/modules/gen/view/dataGridScript.html @@ -104,6 +104,11 @@ $('#dataGrid').dataGrid({ treeGrid: true, // 启用树结构表格 defaultExpandLevel: 0, // 默认展开的层次 expandNodeClearPostData: '<% + if(table.isTreeEntity){ + for(pk in table.pkList){ + print(pk.attrName + ','); + } + } for(c in table.columnList){ if(c.isQuery == "1" && !c.isTreeEntityColumn && c.attrName != 'status'){ print(c.attrName + ','); @@ -112,7 +117,14 @@ $('#dataGrid').dataGrid({ //# } \//# // 加载成功后执行事件 ajaxSuccess: function(data){ - + <% if(table.isTreeEntity){ + for(pk in table.pkList){ %> + if ($('#${pk.attrName}').val() != ''){ + $('#${pk.attrName}').val(''); + $('#btnExpandTreeNode').click(); + } + <% } + } %> } }); \ No newline at end of file diff --git a/modules/core/src/main/resources/templates/modules/gen/vue/vueIndex.xml b/modules/core/src/main/resources/templates/modules/gen/vue/vueIndex.xml index 90bc28b9..313b87de 100644 --- a/modules/core/src/main/resources/templates/modules/gen/vue/vueIndex.xml +++ b/modules/core/src/main/resources/templates/modules/gen/vue/vueIndex.xml @@ -19,12 +19,13 @@ :title="t('${functionNameSimple}')" :search="true" :toolbar="true" + :showIcon="true" :api="${className}TreeData" :defaultExpandLevel="2" - @select="handleSelect" + v-model:selectedKeys="treeCodes" /> - + <% } %> <% %> diff --git a/modules/core/src/main/resources/templates/modules/gen/vue/vueList.xml b/modules/core/src/main/resources/templates/modules/gen/vue/vueList.xml index 90f6bac9..6c76bcd2 100644 --- a/modules/core/src/main/resources/templates/modules/gen/vue/vueList.xml +++ b/modules/core/src/main/resources/templates/modules/gen/vue/vueList.xml @@ -154,6 +154,9 @@ if(table.isTreeEntity){ import { BpmRuntimeTrace } from '/@/components/Bpm'; <% } %> import { FormProps } from '/@/components/Form'; + <% if(table.isTreeEntity || isNotBlank(table.optionMap['leftTreeRightTableFk'])) { %> + import { isEmpty } from '/@/utils/is'; + <% } %> <% if(!@StringUtils.contains(table.tplCategory, '_route')) { %> import InputForm from './form.vue'; <% } %> @@ -163,8 +166,10 @@ if(table.isTreeEntity){ <% if(table.isTreeEntity || isNotBlank(table.optionMap['leftTreeRightTableFk'])){ %> const props = defineProps({ - treeCode: String, + treeCodes: Array as PropType, }); + + const emit = defineEmits(['update:treeCodes']); <% } %> <% if(@StringUtils.contains(table.tplCategory, '_route')) { %> @@ -273,6 +278,11 @@ if(table.isTreeEntity){ <% } %> <% } %> ], + <% if(table.isTreeEntity || isNotBlank(table.optionMap['leftTreeRightTableFk'])) { %> + resetFunc: async () => { + emit('update:treeCodes', []); + }, + <% } %> }; const tableColumns: BasicColumn[] = [ @@ -420,6 +430,11 @@ for(c in table.columnList){ || toBoolean(table.optionMap['isImportExport'])){ %>, getForm<% } %> }] = useTable({ api: ${className}ListData, beforeFetch: (params) => { + <% if(table.isTreeEntity){ %> + <% for(pk in table.pkList){ %> + params.${pk.attrName} = !isEmpty(props.treeCodes) ? props.treeCodes[0] : ''; + <% } %> + <% } %> return params; }, columns: tableColumns, @@ -440,25 +455,23 @@ for(c in table.columnList){ <% if(table.isTreeEntity || isNotBlank(table.optionMap['leftTreeRightTableFk'])){ %> watch( - () => props.treeCode, + () => props.treeCodes, async () => { - await getForm().setFieldsValue({ - <% if (isNotBlank(table.optionMap['leftTreeRightTableFk'])) { %> - '${table.optionMap['leftTreeRightTableFk']}': props.treeCode, - <% }else if(table.isTreeEntity){ %> - <% for(pk in table.pkList){ %> - '${pk.attrName}': props.treeCode, - <% } %> - <% } %> - }); - reload(); + if (!isEmpty(props.treeCodes)) { + <% if (isNotBlank(table.optionMap['leftTreeRightTableFk'])) { %> + await getForm().setFieldsValue({ + '${table.optionMap['leftTreeRightTableFk']}': props.treeCodes[0], + }); + <% } %> + reload(); + } }, ); <% } %> <% if(table.isTreeEntity){ %> function fetchSuccess() { - if (props.treeCode) { + if (!isEmpty(props.treeCodes)) { nextTick(expandAll); } }