✨ 组织类型接业务字典,并支持多所属组织与MK再提交
组织管理类型改为 organization_type;用户所属组织支持多选;提交MK前保留原审批状态以识别通过后再提交。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+76
-31
@@ -48,7 +48,7 @@
|
||||
</el-link>
|
||||
</template>
|
||||
<template #deptCategory="{ row }">
|
||||
<el-tag>{{ getDeptCategoryLabel(row.deptCategory) }}</el-tag>
|
||||
<el-tag>{{ row.deptCategoryName || getDeptCategoryLabel(row.deptCategory) }}</el-tag>
|
||||
</template>
|
||||
<template #status="{ row }">
|
||||
<el-tag :type="Number(row.status) === 1 ? 'success' : 'info'" class="status-text">
|
||||
@@ -181,18 +181,21 @@ import {
|
||||
clearNonTopDept,
|
||||
} from '@/api/system/dept';
|
||||
import { getLeaderList } from '@/api/system/user';
|
||||
import { getDictionary } from '@/api/system/dictbiz';
|
||||
import { getList as getCustomerArchiveList } from '@/api/vehicle/customer-archive';
|
||||
import { mapGetters } from 'vuex';
|
||||
import website from '@/config/website';
|
||||
import func from '@/utils/func';
|
||||
|
||||
const escapeRegExp = value => value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
const ORGANIZATION_TYPE_DICT_CODE = 'organization_type';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
form: {},
|
||||
leaderOptions: [],
|
||||
organizationTypeOptions: [],
|
||||
parentDeptCode: '',
|
||||
parentDept: null,
|
||||
carrierDialogVisible: false,
|
||||
@@ -315,6 +318,31 @@ export default {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: '金蝶部门代码',
|
||||
prop: 'kingdeeDeptCode',
|
||||
minWidth: 140,
|
||||
order: 65,
|
||||
maxlength: 64,
|
||||
showWordLimit: true,
|
||||
rules: [
|
||||
{
|
||||
validator: (rule, value, callback) => {
|
||||
const code = String(value || '').trim();
|
||||
if (!code) {
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
if (code.length > 64) {
|
||||
callback(new Error('金蝶部门代码不能超过64个字符'));
|
||||
return;
|
||||
}
|
||||
callback();
|
||||
},
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: '组织简称',
|
||||
prop: 'shortName',
|
||||
@@ -336,14 +364,7 @@ export default {
|
||||
{
|
||||
label: '组织类型',
|
||||
type: 'select',
|
||||
dicData: [
|
||||
{ label: '一级集团', value: 1 },
|
||||
{ label: '二级事业部', value: 2 },
|
||||
{ label: '部门', value: 3 },
|
||||
{ label: '三级分公司', value: 4 },
|
||||
{ label: '物流园区', value: 5 },
|
||||
{ label: '承运商', value: 6 },
|
||||
],
|
||||
dicData: [],
|
||||
dataType: 'number',
|
||||
minWidth: 120,
|
||||
order: 90,
|
||||
@@ -486,6 +507,7 @@ export default {
|
||||
// ignore storage errors
|
||||
}
|
||||
this.loadLeaderOptions();
|
||||
this.loadOrganizationTypeOptions();
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['userInfo', 'permission']),
|
||||
@@ -725,30 +747,52 @@ export default {
|
||||
});
|
||||
});
|
||||
},
|
||||
loadOrganizationTypeOptions() {
|
||||
return getDictionary({ code: ORGANIZATION_TYPE_DICT_CODE }).then(res => {
|
||||
const list = res.data.data || [];
|
||||
this.organizationTypeOptions = list
|
||||
.map(item => ({
|
||||
label: item.dictValue,
|
||||
value: Number(item.dictKey),
|
||||
}))
|
||||
.filter(item => item.label && !Number.isNaN(item.value));
|
||||
this.resetDeptCategoryOptions();
|
||||
// 字典异步返回后触发表格组织类型标签重绘
|
||||
if (Array.isArray(this.data) && this.data.length) {
|
||||
this.data = [...this.data];
|
||||
}
|
||||
});
|
||||
},
|
||||
resetDeptCategoryOptions() {
|
||||
const categoryColumn = this.findColumn(this.option.column, 'deptCategory');
|
||||
if (!categoryColumn) {
|
||||
return;
|
||||
}
|
||||
categoryColumn.dicData = [...this.organizationTypeOptions];
|
||||
},
|
||||
filterOrganizationTypeOptions(values) {
|
||||
const valueSet = new Set(values.map(Number));
|
||||
return this.organizationTypeOptions.filter(item => valueSet.has(Number(item.value)));
|
||||
},
|
||||
updateDeptCategoryOptions() {
|
||||
const categoryColumn = this.findColumn(this.option.column, 'deptCategory');
|
||||
const parent = this.parentDept;
|
||||
if (!parent) return;
|
||||
if (!parent || !categoryColumn) {
|
||||
return;
|
||||
}
|
||||
let dicData = [];
|
||||
if (this.isRootDept(parent)) {
|
||||
dicData =
|
||||
parent.deptName === '外部组织'
|
||||
? [{ label: '承运商', value: 6 }]
|
||||
: [{ label: '集团', value: 1 }];
|
||||
? this.filterOrganizationTypeOptions([6])
|
||||
: this.filterOrganizationTypeOptions([1]);
|
||||
} else if (Number(parent.deptCategory) === 1) {
|
||||
dicData = [
|
||||
{ label: '事业部', value: 2 },
|
||||
{ label: '部门', value: 3 },
|
||||
];
|
||||
dicData = this.filterOrganizationTypeOptions([2, 3]);
|
||||
} else if ([2, 3].includes(Number(parent.deptCategory))) {
|
||||
dicData = [
|
||||
{ label: '分公司', value: 4 },
|
||||
{ label: '物流园区', value: 5 },
|
||||
{ label: '承运商', value: 6 },
|
||||
];
|
||||
dicData = this.filterOrganizationTypeOptions([4, 5, 6]);
|
||||
}
|
||||
categoryColumn.dicData = dicData;
|
||||
if (!dicData.some(item => item.value === Number(this.form.deptCategory))) {
|
||||
if (!dicData.some(item => Number(item.value) === Number(this.form.deptCategory))) {
|
||||
this.form.deptCategory = dicData[0]?.value;
|
||||
}
|
||||
if (Number(this.form.deptCategory) === 6) {
|
||||
@@ -816,15 +860,13 @@ export default {
|
||||
});
|
||||
},
|
||||
getDeptCategoryLabel(deptCategory) {
|
||||
const categoryMap = {
|
||||
1: '集团',
|
||||
2: '事业部',
|
||||
3: '部门',
|
||||
4: '分公司',
|
||||
5: '物流园区',
|
||||
6: '承运商',
|
||||
};
|
||||
return categoryMap[Number(deptCategory)] || '-';
|
||||
if (deptCategory === null || deptCategory === undefined || deptCategory === '') {
|
||||
return '-';
|
||||
}
|
||||
const matched = this.organizationTypeOptions.find(
|
||||
item => Number(item.value) === Number(deptCategory)
|
||||
);
|
||||
return matched?.label || '-';
|
||||
},
|
||||
getLeaderValue(leaderId, field) {
|
||||
// func.split 空值时返回 '',需兼容为数组,避免表格 formatter 渲染崩溃导致列错位
|
||||
@@ -861,6 +903,7 @@ export default {
|
||||
rowSave(row, done, loading) {
|
||||
row.tenantId = row.tenantId || this.userInfo.tenantId || website.tenantId;
|
||||
row.deptCode = String(row.deptCode || '').trim();
|
||||
row.kingdeeDeptCode = String(row.kingdeeDeptCode || '').trim();
|
||||
row.leaderId = func.join(row.leaderId);
|
||||
this.normalizeTopParent(row);
|
||||
if (Number(row.deptCategory) === 6 && !row.carrierCustomerId) {
|
||||
@@ -891,6 +934,7 @@ export default {
|
||||
rowUpdate(row, index, done, loading) {
|
||||
row.tenantId = row.tenantId || this.userInfo.tenantId || website.tenantId;
|
||||
row.deptCode = String(row.deptCode || '').trim();
|
||||
row.kingdeeDeptCode = String(row.kingdeeDeptCode || '').trim();
|
||||
row.leaderId = func.join(row.leaderId);
|
||||
this.normalizeTopParent(row);
|
||||
if (Number(row.deptCategory) === 6 && !row.carrierCustomerId) {
|
||||
@@ -1026,6 +1070,7 @@ export default {
|
||||
const column = this.findColumn(this.option.column, 'parentId');
|
||||
column.value = '';
|
||||
column.addDisabled = false;
|
||||
this.resetDeptCategoryOptions();
|
||||
done();
|
||||
},
|
||||
currentChange(currentPage) {
|
||||
|
||||
Reference in New Issue
Block a user