优化树表管理代码生成模板,左树右表代码生成模板
This commit is contained in:
@@ -104,6 +104,11 @@ $('#dataGrid').dataGrid({
|
|||||||
treeGrid: true, // 启用树结构表格
|
treeGrid: true, // 启用树结构表格
|
||||||
defaultExpandLevel: 0, // 默认展开的层次
|
defaultExpandLevel: 0, // 默认展开的层次
|
||||||
expandNodeClearPostData: '<%
|
expandNodeClearPostData: '<%
|
||||||
|
if(table.isTreeEntity){
|
||||||
|
for(pk in table.pkList){
|
||||||
|
print(pk.attrName + ',');
|
||||||
|
}
|
||||||
|
}
|
||||||
for(c in table.columnList){
|
for(c in table.columnList){
|
||||||
if(c.isQuery == "1" && !c.isTreeEntityColumn && c.attrName != 'status'){
|
if(c.isQuery == "1" && !c.isTreeEntityColumn && c.attrName != 'status'){
|
||||||
print(c.attrName + ',');
|
print(c.attrName + ',');
|
||||||
@@ -112,7 +117,14 @@ $('#dataGrid').dataGrid({
|
|||||||
//# }
|
//# }
|
||||||
\//# // 加载成功后执行事件
|
\//# // 加载成功后执行事件
|
||||||
ajaxSuccess: function(data){
|
ajaxSuccess: function(data){
|
||||||
|
<% if(table.isTreeEntity){
|
||||||
|
for(pk in table.pkList){ %>
|
||||||
|
if ($('#${pk.attrName}').val() != ''){
|
||||||
|
$('#${pk.attrName}').val('');
|
||||||
|
$('#btnExpandTreeNode').click();
|
||||||
|
}
|
||||||
|
<% }
|
||||||
|
} %>
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@@ -19,12 +19,13 @@
|
|||||||
:title="t('${functionNameSimple}')"
|
:title="t('${functionNameSimple}')"
|
||||||
:search="true"
|
:search="true"
|
||||||
:toolbar="true"
|
:toolbar="true"
|
||||||
|
:showIcon="true"
|
||||||
:api="${className}TreeData"
|
:api="${className}TreeData"
|
||||||
:defaultExpandLevel="2"
|
:defaultExpandLevel="2"
|
||||||
@select="handleSelect"
|
v-model:selectedKeys="treeCodes"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<ListView :treeCode="treeCode" />
|
<ListView v-model:treeCodes="treeCodes" />
|
||||||
</PageWrapper>
|
</PageWrapper>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup name="${compNamePrefix}Index">
|
<script lang="ts" setup name="${compNamePrefix}Index">
|
||||||
@@ -36,11 +37,7 @@
|
|||||||
import ListView from './list.vue';
|
import ListView from './list.vue';
|
||||||
|
|
||||||
const { t } = useI18n('${moduleName}${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${className}');
|
const { t } = useI18n('${moduleName}${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${className}');
|
||||||
const treeCode = ref<string>('');
|
const treeCodes = ref<string[]>([]);
|
||||||
|
|
||||||
function handleSelect(keys: string[]) {
|
|
||||||
treeCode.value = keys[0];
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
<% } %>
|
<% } %>
|
||||||
<% %>
|
<% %>
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ if(table.isTreeEntity){
|
|||||||
( {{ record.${table.treeViewCodeAttrName} }} )
|
( {{ record.${table.treeViewCodeAttrName} }} )
|
||||||
</span>
|
</span>
|
||||||
<% } %>
|
<% } %>
|
||||||
<a @click="handleForm({ ${idParam} })">
|
<a @click="handleForm({ ${idParam} })" :title="record.${table.treeViewNameAttrName}">
|
||||||
{{ record.${table.treeViewNameAttrName} }}
|
{{ record.${table.treeViewNameAttrName} }}
|
||||||
</a>
|
</a>
|
||||||
<%
|
<%
|
||||||
@@ -71,7 +71,7 @@ if(table.isTreeEntity){
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
%>
|
%>
|
||||||
<a @click="handleForm({ ${idParam} })">
|
<a @click="handleForm({ ${idParam} })" :title="record.${c.attrName}">
|
||||||
{{ record.${c.attrName} }}
|
{{ record.${c.attrName} }}
|
||||||
</a>
|
</a>
|
||||||
<%
|
<%
|
||||||
@@ -154,6 +154,9 @@ if(table.isTreeEntity){
|
|||||||
import { BpmRuntimeTrace } from '/@/components/Bpm';
|
import { BpmRuntimeTrace } from '/@/components/Bpm';
|
||||||
<% } %>
|
<% } %>
|
||||||
import { FormProps } from '/@/components/Form';
|
import { FormProps } from '/@/components/Form';
|
||||||
|
<% if(table.isTreeEntity || isNotBlank(table.optionMap['leftTreeRightTableFk'])) { %>
|
||||||
|
import { isEmpty } from '/@/utils/is';
|
||||||
|
<% } %>
|
||||||
<% if(!@StringUtils.contains(table.tplCategory, '_route')) { %>
|
<% if(!@StringUtils.contains(table.tplCategory, '_route')) { %>
|
||||||
import InputForm from './form.vue';
|
import InputForm from './form.vue';
|
||||||
<% } %>
|
<% } %>
|
||||||
@@ -163,8 +166,10 @@ if(table.isTreeEntity){
|
|||||||
<% if(table.isTreeEntity || isNotBlank(table.optionMap['leftTreeRightTableFk'])){ %>
|
<% if(table.isTreeEntity || isNotBlank(table.optionMap['leftTreeRightTableFk'])){ %>
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
treeCode: String,
|
treeCodes: Array as PropType<String[]>,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits(['update:treeCodes']);
|
||||||
<% } %>
|
<% } %>
|
||||||
<% if(@StringUtils.contains(table.tplCategory, '_route')) { %>
|
<% 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[] = [
|
const tableColumns: BasicColumn[] = [
|
||||||
@@ -420,6 +430,11 @@ for(c in table.columnList){
|
|||||||
|| toBoolean(table.optionMap['isImportExport'])){ %>, getForm<% } %> }] = useTable({
|
|| toBoolean(table.optionMap['isImportExport'])){ %>, getForm<% } %> }] = useTable({
|
||||||
api: ${className}ListData,
|
api: ${className}ListData,
|
||||||
beforeFetch: (params) => {
|
beforeFetch: (params) => {
|
||||||
|
<% if(table.isTreeEntity){ %>
|
||||||
|
<% for(pk in table.pkList){ %>
|
||||||
|
params.${pk.attrName} = !isEmpty(props.treeCodes) ? props.treeCodes[0] : '';
|
||||||
|
<% } %>
|
||||||
|
<% } %>
|
||||||
return params;
|
return params;
|
||||||
},
|
},
|
||||||
columns: tableColumns,
|
columns: tableColumns,
|
||||||
@@ -440,25 +455,23 @@ for(c in table.columnList){
|
|||||||
<% if(table.isTreeEntity || isNotBlank(table.optionMap['leftTreeRightTableFk'])){ %>
|
<% if(table.isTreeEntity || isNotBlank(table.optionMap['leftTreeRightTableFk'])){ %>
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.treeCode,
|
() => props.treeCodes,
|
||||||
async () => {
|
async () => {
|
||||||
await getForm().setFieldsValue({
|
if (!isEmpty(props.treeCodes)) {
|
||||||
<% if (isNotBlank(table.optionMap['leftTreeRightTableFk'])) { %>
|
<% if (isNotBlank(table.optionMap['leftTreeRightTableFk'])) { %>
|
||||||
'${table.optionMap['leftTreeRightTableFk']}': props.treeCode,
|
await getForm().setFieldsValue({
|
||||||
<% }else if(table.isTreeEntity){ %>
|
'${table.optionMap['leftTreeRightTableFk']}': props.treeCodes[0],
|
||||||
<% for(pk in table.pkList){ %>
|
});
|
||||||
'${pk.attrName}': props.treeCode,
|
<% } %>
|
||||||
<% } %>
|
reload();
|
||||||
<% } %>
|
}
|
||||||
});
|
|
||||||
reload();
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
<% } %>
|
<% } %>
|
||||||
<% if(table.isTreeEntity){ %>
|
<% if(table.isTreeEntity){ %>
|
||||||
|
|
||||||
function fetchSuccess() {
|
function fetchSuccess() {
|
||||||
if (props.treeCode) {
|
if (!isEmpty(props.treeCodes)) {
|
||||||
nextTick(expandAll);
|
nextTick(expandAll);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user