修复初始化加载人员的问题

This commit is contained in:
aixianling
2023-06-27 11:08:30 +08:00
parent 853dfc5988
commit 4d843a9917

View File

@@ -277,9 +277,7 @@ export default {
}, },
mounted() { mounted() {
this.getTree() this.getTree().then(this.getList)
this.getList()
if (this.value.length && this.isShowUser) { if (this.value.length && this.isShowUser) {
this.showUserList = JSON.parse(JSON.stringify(this.value.map(item => { this.showUserList = JSON.parse(JSON.stringify(this.value.map(item => {
return { return {
@@ -434,42 +432,35 @@ export default {
}, },
getList() { getList() {
this.loading = true if (!!this.search.departmentId) {
this.instance.post(this.action.users, null, { this.loading = true
params: { this.instance.post(this.action.users, null, {
...this.search, params: {
departmentId: this.search.departmentId, ...this.search,
listType: 0 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
} }
}).then(res => {
this.$nextTick(() => { if (res?.data) {
this.loading = false this.list = res.data.records.filter(v => {
}) return this.disabledList.indexOf(v.id) === -1
} else { }).map(v => {
this.loading = false return {
} ...v,
}).catch(() => { isChecked: false
this.loading = false }
}) })
this.search.total = res.data.total
if (!this.list.length) {
this.isCheckAll = false
}
}
}).finally(() => this.loading = false)
}
}, },
getTree() { getTree() {
this.instance.post(this.action.tree, null, { return this.instance.post(this.action.tree, null, {
params: {unitName: this.unitName} params: {unitName: this.unitName}
}).then(res => { }).then(res => {
if (res?.data) { if (res?.data) {
@@ -477,7 +468,7 @@ export default {
this.unitList = this.$arr2tree(origin, {parent: "parentid"}) this.unitList = this.$arr2tree(origin, {parent: "parentid"})
const defaultRoot = this.unitList.at(0)?.id const defaultRoot = this.unitList.at(0)?.id
this.defaultExpanded = [defaultRoot].filter(Boolean) || [] this.defaultExpanded = [defaultRoot].filter(Boolean) || []
this.search.departmentId = defaultRoot return this.search.departmentId = defaultRoot
} }
}) })
}, },