From bcadb44a8fa48f289837a1d93b9178666ece9f3e Mon Sep 17 00:00:00 2001 From: xuhuajiao <13476289682@163.com> Date: Thu, 17 Aug 2023 10:17:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A1=A3=E6=A1=88=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/system/archivesClass.js | 11 +++- .../archivesClassify/module/tableList.vue | 56 +++++++++++++------ 2 files changed, 48 insertions(+), 19 deletions(-) diff --git a/src/api/system/archivesClass.js b/src/api/system/archivesClass.js index 956e775..591cd86 100644 --- a/src/api/system/archivesClass.js +++ b/src/api/system/archivesClass.js @@ -9,6 +9,15 @@ export function FetchInitArchivesClass(params) { }) } +// 获取档案分类子集 +export function FetchSonArchivesClass(params) { + return request({ + url: 'api/archivesClass/getSonArchivesClass', + method: 'get', + params + }) +} + // 获取档案分类树 export function FetchArchivesClassTree(params) { return request({ @@ -42,4 +51,4 @@ export function del(data) { }) } -export default { add, edit, del, FetchInitArchivesClass, FetchArchivesClassTree } +export default { add, edit, del, FetchInitArchivesClass, FetchSonArchivesClass, FetchArchivesClassTree } diff --git a/src/views/system/archivesClassify/module/tableList.vue b/src/views/system/archivesClassify/module/tableList.vue index 04da8d8..ce7212b 100644 --- a/src/views/system/archivesClassify/module/tableList.vue +++ b/src/views/system/archivesClassify/module/tableList.vue @@ -104,9 +104,10 @@ ref="table" v-loading="crud.loading" lazy - :data="crud.data" - row-key="id" - :tree-props="{ children: 'childMenus', hasChildren: 'hasChildren' }" + :data="tableData" + :row-key="getRowKey" + :load="getSonClass" + :tree-props="{children: 'children', hasChildren: 'hasChildren'}" highlight-current-row @select-all="selectAll" @select="selectTr" @@ -178,6 +179,7 @@ export default { }, data() { return { + tableData: [], classifyOptions: [], categoryDatas: [], selections: [], @@ -210,17 +212,24 @@ export default { created() { }, methods: { + getRowKey(row) { + return row.id + }, // 获取数据前设置默认参数 [CRUD.HOOK.beforeRefresh]() { + this.tableData = [] this.crud.query.categoryId = this.selectedCategory.id }, - [CRUD.HOOK.afterRefresh]() { - }, - // 新增 - [CRUD.HOOK.beforeToAdd](crud, form) { - }, - // 新增/编辑后 - [CRUD.HOOK.afterSubmit]() { + [CRUD.HOOK.afterRefresh](crud) { + crud.data.forEach(function(item, index) { + if (item.sonNum !== 0) { + item.hasChildren = true + item.children = null + } else { + item.hasChildren = false + } + }) + this.tableData = this.crud.data }, // 提交前做的操作 [CRUD.HOOK.afterValidateCU](crud) { @@ -230,13 +239,8 @@ export default { }, changeIsTop(val) { if (this.crud.status.edit) { - if (val === '0') { - // const params = { - // 'fondsId': this.form.fondsId, - // 'fondsName': this.form.fondsName, - // 'status': 1 - // } - // this.getDepts(params) + if (val === '1') { + this.form.pid = null } } }, @@ -301,9 +305,25 @@ export default { }) } }, + getSonClass(tree, treeNode, resolve) { + setTimeout(() => { + crudClassify.FetchSonArchivesClass({ pid: tree.id }).then(res => { + const data = res.map(function(obj) { + if (obj.sonNum !== 0 && obj.sonNum) { + obj.hasChildren = true + obj.children = null + } else { + obj.hasChildren = false + } + return obj + }) + resolve(data) + }) + }, 100) + }, selectAll() { this.isAllSelect = !this.isAllSelect - const data = this.crud.data + const data = this.tableData this.toggleSelect(data, this.isAllSelect, 'all') }, // 选择某行