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

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,6 +432,7 @@ export default {
}, },
getList() { getList() {
if (!!this.search.departmentId) {
this.loading = true this.loading = true
this.instance.post(this.action.users, null, { this.instance.post(this.action.users, null, {
params: { params: {
@@ -442,7 +441,7 @@ export default {
listType: 0 listType: 0
} }
}).then(res => { }).then(res => {
if (res.code == 0) { if (res?.data) {
this.list = res.data.records.filter(v => { this.list = res.data.records.filter(v => {
return this.disabledList.indexOf(v.id) === -1 return this.disabledList.indexOf(v.id) === -1
}).map(v => { }).map(v => {
@@ -452,24 +451,16 @@ export default {
} }
}) })
this.search.total = res.data.total this.search.total = res.data.total
if (!this.list.length) { if (!this.list.length) {
this.isCheckAll = false this.isCheckAll = false
} }
this.$nextTick(() => {
this.loading = false
})
} else {
this.loading = false
} }
}).catch(() => { }).finally(() => this.loading = false)
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
} }
}) })
}, },