⚡ 优化用户组织树展示与客商档案编辑锁定

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-11-09 22:55:12 +08:00
co-authored by Cursor
parent 1663b2d910
commit d2f756bc21
4 changed files with 49 additions and 20 deletions
+26 -8
View File
@@ -492,17 +492,35 @@ export const treeOption = {
nodeKey: 'id', nodeKey: 'id',
lazy: true, lazy: true,
treeLoad: function (node, resolve) { treeLoad: function (node, resolve) {
const parentId = node.level === 0 ? 0 : node.data.id; const toTreeNode = item => ({
getDeptLazyTree(parentId).then(res => {
resolve(
res.data.data.map(item => {
return {
...item, ...item,
leaf: !item.hasChildren, leaf: !item.hasChildren,
};
})
);
}); });
// 用户管理组织树从第二级开始展示:根层隐藏一级组织,直接展示其子节点
if (node.level === 0) {
getDeptLazyTree(0)
.then(res => {
const roots = res.data.data || [];
if (!roots.length) {
resolve([]);
return;
}
return Promise.all(roots.map(root => getDeptLazyTree(root.id))).then(childResults => {
const secondLevel = [];
childResults.forEach(childRes => {
(childRes.data.data || []).forEach(item => secondLevel.push(toTreeNode(item)));
});
resolve(secondLevel);
});
})
.catch(() => resolve([]));
return;
}
getDeptLazyTree(node.data.id)
.then(res => {
resolve((res.data.data || []).map(toTreeNode));
})
.catch(() => resolve([]));
}, },
addBtn: false, addBtn: false,
menu: false, menu: false,
+1 -1
View File
@@ -102,7 +102,7 @@
style="margin-bottom: 12px; background: #f5f7fa; padding: 6px 10px; border-radius: 4px" style="margin-bottom: 12px; background: #f5f7fa; padding: 6px 10px; border-radius: 4px"
> >
<span style="color: #606266; font-size: 13px" <span style="color: #606266; font-size: 13px"
>勾选多个菜单后点击「设置」,可批量配置数据权限;设置后菜单旁展示当前范围</span >仅展示菜单权限已勾选的菜单,已配置的数据权限会保留。勾选多个菜单后点击「设置」可批量配置</span
> >
<el-button type="primary" size="small" @click="openDataScopeSetting">设置</el-button> <el-button type="primary" size="small" @click="openDataScopeSetting">设置</el-button>
</el-row> </el-row>
+11 -3
View File
@@ -713,6 +713,12 @@ export default {
} }
this.selectDeptOnTree(deptId); this.selectDeptOnTree(deptId);
}, },
startDeptTreeFromSecondLevel(tree) {
if (!Array.isArray(tree) || !tree.length) {
return [];
}
return tree.flatMap(node => (Array.isArray(node.children) ? node.children : []));
},
findDeptIdByName(name, tree = this.permissionDeptTree) { findDeptIdByName(name, tree = this.permissionDeptTree) {
if (!name) return null; if (!name) return null;
for (const node of tree || []) { for (const node of tree || []) {
@@ -733,7 +739,7 @@ export default {
const tenantId = this.userInfo.tenantId || this.website.tenantId; const tenantId = this.userInfo.tenantId || this.website.tenantId;
try { try {
const res = await getDeptTree(tenantId); const res = await getDeptTree(tenantId);
this.permissionDeptTree = res.data.data || []; this.permissionDeptTree = this.startDeptTreeFromSecondLevel(res.data.data || []);
} catch (error) { } catch (error) {
this.$message.error('组织树加载失败'); this.$message.error('组织树加载失败');
return; return;
@@ -963,9 +969,11 @@ export default {
column.dicData = res.data.data; column.dicData = res.data.data;
}); });
getDeptTree(tenantId).then(res => { getDeptTree(tenantId).then(res => {
this.permissionDeptTree = res.data.data; // 用户管理组织从第二级开始展示:去掉一级根节点,保留其子节点
const deptTree = this.startDeptTreeFromSecondLevel(res.data.data || []);
this.permissionDeptTree = deptTree;
const column = this.findColumn(this.userOption.group, 'deptId'); const column = this.findColumn(this.userOption.group, 'deptId');
column.dicData = res.data.data; column.dicData = deptTree;
}); });
getPostList(tenantId).then(res => { getPostList(tenantId).then(res => {
this.postList = res.data.data; this.postList = res.data.data;
+9 -6
View File
@@ -310,6 +310,7 @@
v-model="archiveForm.customerCode" v-model="archiveForm.customerCode"
maxlength="20" maxlength="20"
show-word-limit show-word-limit
:disabled="Boolean(archiveForm.id)"
placeholder="请输入,留空则自动生成" placeholder="请输入,留空则自动生成"
/> />
</el-form-item> </el-form-item>
@@ -378,7 +379,7 @@
placeholder="请输入" placeholder="请输入"
maxlength="18" maxlength="18"
show-word-limit show-word-limit
:disabled="kingdeeLocked && Boolean(archiveForm.id)" :disabled="Boolean(archiveForm.id)"
@input=" @input="
archiveForm.unifiedCreditCode = String( archiveForm.unifiedCreditCode = String(
archiveForm.unifiedCreditCode || '' archiveForm.unifiedCreditCode || ''
@@ -394,7 +395,7 @@
placeholder="请输入" placeholder="请输入"
maxlength="100" maxlength="100"
show-word-limit show-word-limit
:disabled="kingdeeLocked" :disabled="kingdeeLocked && !archiveForm.id"
@blur="checkArchiveNameRisk" @blur="checkArchiveNameRisk"
/> />
<el-tooltip <el-tooltip
@@ -434,7 +435,7 @@
v-model="archiveForm.legalPerson" v-model="archiveForm.legalPerson"
maxlength="10" maxlength="10"
show-word-limit show-word-limit
:disabled="kingdeeLocked" :disabled="kingdeeLocked && !archiveForm.id"
/> />
</el-form-item> </el-form-item>
</el-col> </el-col>
@@ -535,7 +536,7 @@
<el-input <el-input
v-model="archiveForm.registeredCapital" v-model="archiveForm.registeredCapital"
maxlength="18" maxlength="18"
:disabled="kingdeeLocked" :disabled="kingdeeLocked && !archiveForm.id"
@input="value => handleDecimalInput('registeredCapital', value)" @input="value => handleDecimalInput('registeredCapital', value)"
/> />
</el-form-item> </el-form-item>
@@ -545,7 +546,7 @@
<el-input <el-input
v-model="archiveForm.paidInCapital" v-model="archiveForm.paidInCapital"
maxlength="18" maxlength="18"
:disabled="kingdeeLocked" :disabled="kingdeeLocked && !archiveForm.id"
@input="value => handleDecimalInput('paidInCapital', value)" @input="value => handleDecimalInput('paidInCapital', value)"
/> />
</el-form-item> </el-form-item>
@@ -4245,7 +4246,9 @@ export default {
'核准日期', '核准日期',
]); ]);
const scope = this.getBusinessLicenseOcrValue(fields, ['经营范围']); const scope = this.getBusinessLicenseOcrValue(fields, ['经营范围']);
if (code) this.archiveForm.unifiedCreditCode = code.replace(/\s/g, '').toUpperCase(); if (code && !this.archiveForm.id) {
this.archiveForm.unifiedCreditCode = code.replace(/\s/g, '').toUpperCase();
}
if (name) this.archiveForm.fullName = name; if (name) this.archiveForm.fullName = name;
if (name) this.checkArchiveNameRisk(); if (name) this.checkArchiveNameRisk();
if (legalPerson) this.archiveForm.legalPerson = legalPerson; if (legalPerson) this.archiveForm.legalPerson = legalPerson;