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

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')
},
// 获取组织树选择器(懒加载)
orgOrgTreeSelector(data) {
orgTreeSelector(data) {
return request('orgTreeSelector', data, 'get')
},
// 获取用户选择器

View File

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

View File

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