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 64c0443f..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
@@ -56,7 +56,7 @@ if(table.isTreeEntity){
( {{ record.${table.treeViewCodeAttrName} }} )
<% } %>
-
+
{{ record.${table.treeViewNameAttrName} }}
<%
@@ -71,7 +71,7 @@ if(table.isTreeEntity){
continue;
}
%>
-
+
{{ record.${c.attrName} }}
<%
@@ -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);
}
}