【底座】优化机构复制功能

This commit is contained in:
xuyuxiang
2026-03-15 00:51:49 +08:00
parent 4204fa248e
commit 951fe23d3a
5 changed files with 100 additions and 32 deletions

View File

@@ -39,7 +39,7 @@ export default {
return request('detail', data, 'get') return request('detail', data, 'get')
}, },
// 获取组织树选择器(懒加载) // 获取组织树选择器(懒加载)
orgOrgTreeSelector(data) { orgTreeSelector(data) {
return request('orgTreeSelector', data, 'get') return request('orgTreeSelector', data, 'get')
}, },
// 获取用户选择器 // 获取用户选择器

View File

@@ -8,11 +8,11 @@
:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }" :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
placeholder="请选择目标上级机构" placeholder="请选择目标上级机构"
allow-clear allow-clear
tree-default-expand-all
:tree-data="treeData" :tree-data="treeData"
v-model:treeExpandedKeys="treeDefaultExpandedKeys"
:field-names="treeFieldNames" :field-names="treeFieldNames"
selectable="false"
tree-line tree-line
:load-data="onLoadData"
/> />
<a-alert <a-alert
class="mt-3" class="mt-3"
@@ -44,10 +44,30 @@
// 定义机构元素 // 定义机构元素
const treeData = ref([]) const treeData = ref([])
const submitLoading = ref(false) const submitLoading = ref(false)
const treeDefaultExpandedKeys = ref([])
const treeFieldNames = { children: 'children', label: 'name', value: 'id' } const treeFieldNames = { children: 'children', label: 'name', value: 'id' }
// 选中的ID列表 // 选中的ID列表
const ids = ref([]) const ids = ref([])
// 加载懒加载树(无需展开到指定节点时使用)
const loadLazyTree = () => {
return bizOrgApi.orgTreeSelector().then((res) => {
treeData.value = [
{
id: '0',
parentId: '-1',
name: '顶级',
children: res.map((item) => {
return {
...item,
isLeaf: item.isLeaf === undefined ? false : item.isLeaf
}
}),
isLeaf: false
}
]
treeDefaultExpandedKeys.value.push('0')
})
}
// 打开抽屉 // 打开抽屉
const onOpen = (idParam) => { const onOpen = (idParam) => {
visible.value = true visible.value = true
@@ -55,16 +75,30 @@
if (idParam) { if (idParam) {
ids.value = idParam.map((item) => item.id) ids.value = idParam.map((item) => item.id)
} }
// 获取机构树并加入顶级 // 懒加载
bizOrgApi.orgTreeSelector().then((res) => { loadLazyTree()
treeData.value = [ }
{ // 懒加载子节点
id: '0', const onLoadData = (treeNode) => {
parentId: '-1', return new Promise((resolve) => {
name: '顶级', if (treeNode.dataRef.children) {
children: res resolve()
} return
] }
bizOrgApi
.orgTreeSelector({
parentId: treeNode.dataRef.id
})
.then((res) => {
treeNode.dataRef.children = res.map((item) => {
return {
...item,
isLeaf: item.isLeaf === undefined ? false : item.isLeaf
}
})
treeData.value = [...treeData.value]
resolve()
})
}) })
} }
// 关闭抽屉 // 关闭抽屉

View File

@@ -8,11 +8,11 @@
:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }" :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
placeholder="请选择目标上级组织" placeholder="请选择目标上级组织"
allow-clear allow-clear
tree-default-expand-all
:tree-data="treeData" :tree-data="treeData"
v-model:treeExpandedKeys="treeDefaultExpandedKeys"
:field-names="treeFieldNames" :field-names="treeFieldNames"
selectable="false"
tree-line tree-line
:load-data="onLoadData"
/> />
<a-alert <a-alert
class="mt-3" class="mt-3"
@@ -44,10 +44,30 @@
// 定义机构元素 // 定义机构元素
const treeData = ref([]) const treeData = ref([])
const submitLoading = ref(false) const submitLoading = ref(false)
const treeDefaultExpandedKeys = ref([])
const treeFieldNames = { children: 'children', label: 'name', value: 'id' } const treeFieldNames = { children: 'children', label: 'name', value: 'id' }
// 选中的ID列表 // 选中的ID列表
const ids = ref([]) const ids = ref([])
// 加载懒加载树(无需展开到指定节点时使用)
const loadLazyTree = () => {
return orgApi.orgTreeSelector().then((res) => {
treeData.value = [
{
id: '0',
parentId: '-1',
name: '顶级',
children: res.map((item) => {
return {
...item,
isLeaf: item.isLeaf === undefined ? false : item.isLeaf
}
}),
isLeaf: false
}
]
treeDefaultExpandedKeys.value.push('0')
})
}
// 打开抽屉 // 打开抽屉
const onOpen = (idParam) => { const onOpen = (idParam) => {
visible.value = true visible.value = true
@@ -55,16 +75,30 @@
if (idParam) { if (idParam) {
ids.value = idParam.map((item) => item.id) ids.value = idParam.map((item) => item.id)
} }
// 获取机构树并加入顶级 // 懒加载
orgApi.orgOrgTreeSelector().then((res) => { loadLazyTree()
treeData.value = [ }
{ // 懒加载子节点
id: '0', const onLoadData = (treeNode) => {
parentId: '-1', return new Promise((resolve) => {
name: '顶级', if (treeNode.dataRef.children) {
children: res resolve()
} return
] }
orgApi
.orgTreeSelector({
parentId: treeNode.dataRef.id
})
.then((res) => {
treeNode.dataRef.children = res.map((item) => {
return {
...item,
isLeaf: item.isLeaf === undefined ? false : item.isLeaf
}
})
treeData.value = [...treeData.value]
resolve()
})
}) })
} }
// 关闭抽屉 // 关闭抽屉

View File

@@ -100,7 +100,7 @@
} }
// 加载全量树(用于需要展开到指定节点的场景) // 加载全量树(用于需要展开到指定节点的场景)
const loadFullTree = () => { const loadFullTree = () => {
return orgApi.orgOrgTreeSelector({ searchKey: '' }).then((res) => { return orgApi.orgTreeSelector({ searchKey: '' }).then((res) => {
if (res !== null) { if (res !== null) {
treeData.value = [ treeData.value = [
{ {
@@ -117,7 +117,7 @@
} }
// 加载懒加载树(无需展开到指定节点时使用) // 加载懒加载树(无需展开到指定节点时使用)
const loadLazyTree = () => { const loadLazyTree = () => {
return orgApi.orgOrgTreeSelector().then((res) => { return orgApi.orgTreeSelector().then((res) => {
treeData.value = [ treeData.value = [
{ {
id: '0', id: '0',
@@ -187,7 +187,7 @@
return return
} }
orgApi orgApi
.orgOrgTreeSelector({ .orgTreeSelector({
parentId: treeNode.dataRef.id parentId: treeNode.dataRef.id
}) })
.then((res) => { .then((res) => {
@@ -238,7 +238,7 @@
// 传递设计器需要的API // 传递设计器需要的API
const selectorApiFunction = { const selectorApiFunction = {
orgTreeApi: (param) => { orgTreeApi: (param) => {
return orgApi.orgOrgTreeSelector(param).then((data) => { return orgApi.orgTreeSelector(param).then((data) => {
return Promise.resolve(data) return Promise.resolve(data)
}) })
}, },

View File

@@ -419,7 +419,7 @@
// 传递设计器需要的API // 传递设计器需要的API
const selectorApiFunction = { const selectorApiFunction = {
orgTreeApi: (param) => { orgTreeApi: (param) => {
return orgApi.orgOrgTreeSelector(param).then((data) => { return orgApi.orgTreeSelector(param).then((data) => {
return Promise.resolve(data) return Promise.resolve(data)
}) })
}, },