diff --git a/ui/packages/common/AiUserSelecter.vue b/ui/packages/common/AiUserSelecter.vue index 2d251eed..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,49 +432,43 @@ 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) { - 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 + return this.search.departmentId = defaultRoot } }) },