机构管理:机构树显示逻辑修改

This commit is contained in:
高云鹏 2024-07-17 13:53:50 +08:00
parent 45d662dac5
commit a2a9047349

View File

@ -39,9 +39,10 @@
v-model="formModel[item.prop]" v-model="formModel[item.prop]"
:disabled="formDisabled" :disabled="formDisabled"
lazy lazy
:data="treeData"
:load="loadSelectTreeData" :load="loadSelectTreeData"
check-strictly check-strictly
value-key="id"
node-key="id"
:props="treeSelectReplaceProps" :props="treeSelectReplaceProps"
:placeholder="item.placeholder" :placeholder="item.placeholder"
></el-tree-select> ></el-tree-select>
@ -346,7 +347,9 @@ const submitAddForm = () => {
ElMessage.success('编辑成功') ElMessage.success('编辑成功')
getInstitutionList() getInstitutionList()
dialogVible.value = false dialogVible.value = false
refreshTreeData(rightClickMenuData.value!.parentOrgId).then(() => {
refreshTreeData(formModel.value.parentOrgId) refreshTreeData(formModel.value.parentOrgId)
})
} else { } else {
ElMessage.error(res?.msg ?? '编辑失败') ElMessage.error(res?.msg ?? '编辑失败')
} }
@ -466,7 +469,6 @@ const treeReplaceProps = {
} }
const treeSelectReplaceProps = { const treeSelectReplaceProps = {
label: 'name', label: 'name',
value: 'id',
children: 'children', children: 'children',
} }
const loadTreeData = (node: Node, resolve: any) => { const loadTreeData = (node: Node, resolve: any) => {
@ -487,6 +489,8 @@ const loadTreeData = (node: Node, resolve: any) => {
}) })
} }
const loadSelectTreeData = (node: Node, resolve: any) => { const loadSelectTreeData = (node: Node, resolve: any) => {
console.log(node)
if (node.level === 0) { if (node.level === 0) {
return getTreeData(null) return getTreeData(null)
.then((res) => { .then((res) => {
@ -527,6 +531,8 @@ const initData = () => {
.then((res) => { .then((res) => {
console.log(res) console.log(res)
treeData.value = [...res] treeData.value = [...res]
console.log(treeData.value)
nextTick(() => { nextTick(() => {
treeRef.value?.setCurrentKey(res[0]?.id!, false) treeRef.value?.setCurrentKey(res[0]?.id!, false)
clickTreeMenuData.value = res[0] clickTreeMenuData.value = res[0]
@ -543,6 +549,7 @@ const initData = () => {
} }
const clickTreeMenuData = ref<getTreeDataReturnType>() const clickTreeMenuData = ref<getTreeDataReturnType>()
const refreshTreeData = (parentOrgId: string | number | null) => { const refreshTreeData = (parentOrgId: string | number | null) => {
return new Promise((resolve) => {
const data = parentOrgId === 0 || parentOrgId === '0' ? null : parentOrgId const data = parentOrgId === 0 || parentOrgId === '0' ? null : parentOrgId
getTreeData(data).then((res) => { getTreeData(data).then((res) => {
console.log('res,', res) console.log('res,', res)
@ -552,6 +559,8 @@ const refreshTreeData = (parentOrgId: string | number | null) => {
} else { } else {
treeData.value = [...res] treeData.value = [...res]
} }
resolve(true)
})
}) })
} }
const treeNodeClick = (nodeData: getTreeDataReturnType, node: Node) => { const treeNodeClick = (nodeData: getTreeDataReturnType, node: Node) => {