From 437b348d06975db36a7a70771b17e84391dc2fe6 Mon Sep 17 00:00:00 2001 From: aixianling Date: Tue, 27 Jun 2023 10:57:12 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=83=A8=E9=97=A8?= =?UTF-8?q?=E6=A0=91=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/packages/common/AiUserSelecter.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/packages/common/AiUserSelecter.vue b/ui/packages/common/AiUserSelecter.vue index 2d251eed..bd7f9bf8 100644 --- a/ui/packages/common/AiUserSelecter.vue +++ b/ui/packages/common/AiUserSelecter.vue @@ -473,7 +473,8 @@ export default { params: {unitName: this.unitName} }).then(res => { if (res?.data) { - this.unitList = this.$arr2tree(res.data) + const origin = res.data.itemList || res.data + this.unitList = this.$arr2tree(origin, {parent: "parentid"}) const defaultRoot = this.unitList.at(0)?.id this.defaultExpanded = [defaultRoot].filter(Boolean) || [] this.search.departmentId = defaultRoot From 4d843a991752de514b308109cf6592636bf2461d Mon Sep 17 00:00:00 2001 From: aixianling Date: Tue, 27 Jun 2023 11:08:30 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E5=8A=A0=E8=BD=BD=E4=BA=BA=E5=91=98=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/packages/common/AiUserSelecter.vue | 63 ++++++++++++--------------- 1 file changed, 27 insertions(+), 36 deletions(-) diff --git a/ui/packages/common/AiUserSelecter.vue b/ui/packages/common/AiUserSelecter.vue index bd7f9bf8..593c9df1 100644 --- a/ui/packages/common/AiUserSelecter.vue +++ b/ui/packages/common/AiUserSelecter.vue @@ -277,9 +277,7 @@ export default { }, mounted() { - this.getTree() - this.getList() - + this.getTree().then(this.getList) if (this.value.length && this.isShowUser) { this.showUserList = JSON.parse(JSON.stringify(this.value.map(item => { return { @@ -434,42 +432,35 @@ export default { }, getList() { - this.loading = true - this.instance.post(this.action.users, null, { - params: { - ...this.search, - departmentId: this.search.departmentId, - listType: 0 - } - }).then(res => { - if (res.code == 0) { - this.list = res.data.records.filter(v => { - return this.disabledList.indexOf(v.id) === -1 - }).map(v => { - return { - ...v, - isChecked: false - } - }) - this.search.total = res.data.total - - if (!this.list.length) { - this.isCheckAll = false + if (!!this.search.departmentId) { + this.loading = true + this.instance.post(this.action.users, null, { + params: { + ...this.search, + departmentId: this.search.departmentId, + listType: 0 } - - this.$nextTick(() => { - this.loading = false - }) - } else { - this.loading = false - } - }).catch(() => { - this.loading = false - }) + }).then(res => { + if (res?.data) { + this.list = res.data.records.filter(v => { + return this.disabledList.indexOf(v.id) === -1 + }).map(v => { + return { + ...v, + isChecked: false + } + }) + this.search.total = res.data.total + if (!this.list.length) { + this.isCheckAll = false + } + } + }).finally(() => this.loading = false) + } }, getTree() { - this.instance.post(this.action.tree, null, { + return this.instance.post(this.action.tree, null, { params: {unitName: this.unitName} }).then(res => { if (res?.data) { @@ -477,7 +468,7 @@ export default { this.unitList = this.$arr2tree(origin, {parent: "parentid"}) const defaultRoot = this.unitList.at(0)?.id this.defaultExpanded = [defaultRoot].filter(Boolean) || [] - this.search.departmentId = defaultRoot + return this.search.departmentId = defaultRoot } }) },