✨ 正式结算保存草稿与同步入口,项目申请平台公司多选等业务优化

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-14 12:59:27 +08:00
parent 5bc1f69a7f
commit 74780b8777
10 changed files with 219 additions and 75 deletions
+76 -21
View File
@@ -231,6 +231,9 @@
<el-select
v-model="form.undertakeDeptId"
placeholder="请选择"
multiple
collapse-tags
collapse-tags-tooltip
clearable
filterable
:disabled="isBasicInfoReadonly"
@@ -956,7 +959,7 @@ const emptyForm = () => ({
projectShortName: '',
businessDeptId: '',
businessDeptName: '',
undertakeDeptId: '',
undertakeDeptId: [],
undertakeDeptName: '',
projectSource: '',
sourceRemark: '',
@@ -1146,7 +1149,15 @@ export default {
{ max: 20, message: '项目简称不能超过20个字符', trigger: 'blur' },
],
businessDeptId: [{ required: true, message: '请选择业务部门', trigger: 'change' }],
undertakeDeptId: [{ required: true, message: '请选择平台公司', trigger: 'change' }],
undertakeDeptId: [
{
type: 'array',
required: true,
min: 1,
message: '请选择平台公司',
trigger: 'change',
},
],
businessMode: [{ required: true, message: '请选择业务模式', trigger: 'change' }],
customerNames: [{ required: true, message: '请选择客户名称', trigger: 'change' }],
carrierNames: [{ required: true, message: '请选择下游承运商', trigger: 'change' }],
@@ -1508,13 +1519,13 @@ export default {
this.businessDeptTreeOptions = [{ label, value: detail.businessDeptId }];
this.deptOptions = [{ label, rawLabel: label, value: detail.businessDeptId }];
}
if (detail.undertakeDeptId) {
this.platformCompanyOptions = [
{
label: detail.undertakeDeptName || String(detail.undertakeDeptId),
value: detail.undertakeDeptId,
},
];
const undertakeDeptIds = this.parseUndertakeDeptIds(detail.undertakeDeptId);
const undertakeDeptNames = this.parseUndertakeDeptNames(detail.undertakeDeptName);
if (undertakeDeptIds.length) {
this.platformCompanyOptions = undertakeDeptIds.map((id, index) => ({
label: undertakeDeptNames[index] || String(id),
value: id,
}));
}
},
resolvePublicDictOptions(options, currentValue) {
@@ -1860,6 +1871,8 @@ export default {
this.form = {
...form,
...situation,
undertakeDeptId: this.parseUndertakeDeptIds(form.undertakeDeptId),
undertakeDeptName: form.undertakeDeptName || '',
customerNames: this.getCustomerRowNames(customerRows, 'customer') || form.customerNames,
carrierNames: this.getCustomerRowNames(carrierRows, 'carrier') || form.carrierNames,
};
@@ -2026,8 +2039,13 @@ export default {
});
},
normalizeSubmitForm(options = {}) {
const undertakeDeptIds = this.parseUndertakeDeptIds(this.form.undertakeDeptId);
const undertakeDeptName =
this.resolveUndertakeDeptNames(undertakeDeptIds) || this.form.undertakeDeptName || '';
const submitRow = {
...this.form,
undertakeDeptId: undertakeDeptIds.join(','),
undertakeDeptName,
fundLimit: this.formatAmount(this.form.fundLimit),
receivableLimit: this.formatAmount(this.form.receivableLimit),
...Object.fromEntries(
@@ -2419,11 +2437,40 @@ export default {
this.$refs.projectForm?.validateField('businessDeptId');
},
handleUndertakeDeptChange(value) {
const id = Array.isArray(value) ? value.at(-1) : value;
const dept = this.platformCompanyOptions.find(item => String(item.value) === String(id));
this.form.undertakeDeptName = dept ? dept.label : '';
const ids = this.parseUndertakeDeptIds(value);
this.form.undertakeDeptId = ids;
this.form.undertakeDeptName = this.resolveUndertakeDeptNames(ids);
this.$refs.projectForm?.validateField('undertakeDeptId');
},
parseUndertakeDeptIds(value) {
if (Array.isArray(value)) {
return value
.map(item => String(item ?? '').trim())
.filter(item => item && item !== '-1');
}
return String(value ?? '')
.split(/[,,]/)
.map(item => item.trim())
.filter(item => item && item !== '-1');
},
parseUndertakeDeptNames(value) {
return String(value ?? '')
.split(/[,,、]/)
.map(item => item.trim())
.filter(Boolean);
},
resolveUndertakeDeptNames(ids = []) {
return ids
.map(id => {
const dept = this.platformCompanyOptions.find(item => String(item.value) === String(id));
return dept?.label || '';
})
.filter(Boolean)
.join('、');
},
firstUndertakeDeptId(value) {
return this.parseUndertakeDeptIds(value)[0] || '';
},
// 由部门 id 反查「根 → 该节点」的 id 路径,供级联回显(找不到返回 null)
findDeptPath(id, tree = [], parents = []) {
const target = Array.isArray(id) ? id.at(-1) : id;
@@ -2462,15 +2509,23 @@ export default {
});
},
ensureCurrentPlatformOption() {
const id = this.form.undertakeDeptId;
if (!id) return;
const exists = this.platformCompanyOptions.some(item => String(item.value) === String(id));
if (!exists) {
this.platformCompanyOptions.unshift({
label: this.form.undertakeDeptName || String(id),
value: id,
});
}
const ids = this.parseUndertakeDeptIds(this.form.undertakeDeptId);
if (!ids.length) return;
const names = this.parseUndertakeDeptNames(this.form.undertakeDeptName);
ids.forEach((id, index) => {
const exists = this.platformCompanyOptions.some(item => String(item.value) === String(id));
if (!exists) {
this.platformCompanyOptions.unshift({
label: names[index] || String(id),
value: id,
});
}
});
// 选项 value 与已选 ID 类型对齐,避免回显失败
this.form.undertakeDeptId = ids.map(id => {
const matched = this.platformCompanyOptions.find(item => String(item.value) === String(id));
return matched ? matched.value : id;
});
},
excludeExternalOrganization(list = []) {
return list.reduce((result, item) => {