✨ 组织编码/平台公司、合同计费客商角色与基础模块查看按钮
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1685,12 +1685,21 @@ export default {
|
||||
{ role: 'C', label: '丙方', rows: this.partyCRows },
|
||||
];
|
||||
},
|
||||
/**
|
||||
* 计费方案适用客商:
|
||||
* - 客户合同:仅甲方(仅 1 个甲方时编辑器自动选中)
|
||||
* - 承运商合同:仅乙方、丙方(应付明细按这些方案生成)
|
||||
*/
|
||||
billingPartyOptions() {
|
||||
const category = String(this.form.contractCategory || '').trim();
|
||||
const allowedRoles =
|
||||
category === '承运商合同' ? ['B', 'C'] : category === '客户合同' ? ['A'] : ['A', 'B', 'C'];
|
||||
return [
|
||||
...this.partyARows.map(row => ({ ...row, partyRole: 'A' })),
|
||||
...this.partyBRows.map(row => ({ ...row, partyRole: 'B' })),
|
||||
...this.partyCRows.map(row => ({ ...row, partyRole: 'C' })),
|
||||
]
|
||||
.filter(row => allowedRoles.includes(row.partyRole))
|
||||
.filter(row => row.customerName || row.customerId)
|
||||
.map(row => ({
|
||||
value: row.id,
|
||||
@@ -2315,7 +2324,6 @@ export default {
|
||||
if (!this.validatePartyRows(true)) return false;
|
||||
return (
|
||||
this.validateBillingPlanBindings() &&
|
||||
this.validateBillingPlanDefault() &&
|
||||
this.validateSettlementRules() &&
|
||||
this.validatePaymentRatios()
|
||||
);
|
||||
@@ -2911,10 +2919,17 @@ export default {
|
||||
validateBillingPlanBindings() {
|
||||
if (!this.billingPlanRows.length) return true;
|
||||
const partyIds = new Set(this.billingPartyOptions.map(item => String(item.partyRowId)));
|
||||
const category = String(this.form.contractCategory || '').trim();
|
||||
const roleHint =
|
||||
category === '承运商合同'
|
||||
? '请选择乙方或丙方客商'
|
||||
: category === '客户合同'
|
||||
? '请选择甲方客商'
|
||||
: '请选择适用客商';
|
||||
for (let index = 0; index < this.billingPlanRows.length; index += 1) {
|
||||
const plan = this.billingPlanRows[index];
|
||||
if (!plan.partyRowId || !partyIds.has(String(plan.partyRowId))) {
|
||||
this.$message.warning(`计费方案第${index + 1}个请选择适用客商`);
|
||||
this.$message.warning(`计费方案第${index + 1}个${roleHint}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -3169,21 +3184,13 @@ export default {
|
||||
openBillingPlan(row = {}, index = -1) {
|
||||
this.billingPlanIndex = index;
|
||||
this.billingPlanForm =
|
||||
index < 0
|
||||
? { planName: '', transportMode: '', defaultPlan: false, remark: '', rules: [] }
|
||||
: clone(row);
|
||||
index < 0 ? { planName: '', transportMode: '', remark: '', rules: [] } : clone(row);
|
||||
this.billingPlanBox = true;
|
||||
this.$nextTick(() => this.$refs.billingPlanEditor?.ensureTransportModes?.());
|
||||
},
|
||||
saveBillingPlan(plan, index) {
|
||||
const nextPlan = clone(plan);
|
||||
if (this.isDefaultBillingPlan(nextPlan)) {
|
||||
this.billingPlanRows.forEach((item, itemIndex) => {
|
||||
if (itemIndex !== index && item.transportMode === nextPlan.transportMode) {
|
||||
item.defaultPlan = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
delete nextPlan.defaultPlan;
|
||||
if (index < 0) this.billingPlanRows.push(nextPlan);
|
||||
else this.billingPlanRows.splice(index, 1, nextPlan);
|
||||
this.billingPlanBox = false;
|
||||
@@ -3193,31 +3200,6 @@ export default {
|
||||
this.billingPlanRows.splice(index, 1);
|
||||
});
|
||||
},
|
||||
isDefaultBillingPlan(plan) {
|
||||
return (
|
||||
plan?.defaultPlan === true ||
|
||||
plan?.defaultPlan === 1 ||
|
||||
['true', '1'].includes(String(plan?.defaultPlan).toLowerCase())
|
||||
);
|
||||
},
|
||||
validateBillingPlanDefault() {
|
||||
if (!this.billingPlanRows.length) return true;
|
||||
const defaultCountByTransportMode = this.billingPlanRows.reduce((result, plan) => {
|
||||
const transportMode = plan.transportMode || '';
|
||||
result[transportMode] =
|
||||
(result[transportMode] || 0) + Number(this.isDefaultBillingPlan(plan));
|
||||
return result;
|
||||
}, {});
|
||||
const invalidTransportMode = Object.entries(defaultCountByTransportMode).find(
|
||||
([, count]) => count > 1
|
||||
);
|
||||
if (invalidTransportMode) {
|
||||
const [transportMode, count] = invalidTransportMode;
|
||||
this.$message.warning(`运输方式“${transportMode}”仅支持配置一个默认计费方案`);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
isFixedCycleSettlementType(value) {
|
||||
return value === '按固定天数周期' || value === '固定天数周期结算';
|
||||
},
|
||||
@@ -3551,8 +3533,7 @@ export default {
|
||||
return list
|
||||
.map(item => {
|
||||
if (!item || typeof item !== 'object') return String(item ?? '');
|
||||
const name = item.planName || item.name || '未命名方案';
|
||||
return item.defaultPlan ? `${name}(默认)` : name;
|
||||
return item.planName || item.name || '未命名方案';
|
||||
})
|
||||
.filter(Boolean)
|
||||
.join('、');
|
||||
|
||||
Reference in New Issue
Block a user