✨ 组织编码/平台公司、合同计费客商角色与基础模块查看按钮
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -299,25 +299,27 @@
|
||||
><el-radio label="system">系统生成</el-radio
|
||||
><el-radio label="manual">账单导入生成</el-radio></el-radio-group
|
||||
>
|
||||
<el-table :data="plans" border class="change-table"
|
||||
><el-table-column type="index" label="序号" width="70" /><el-table-column
|
||||
prop="planName"
|
||||
label="方案名称"
|
||||
min-width="220"
|
||||
/><el-table-column label="默认方案" min-width="120"
|
||||
><template #default="{ row }">{{
|
||||
row.defaultPlan ? '是' : '否'
|
||||
}}</template></el-table-column
|
||||
><el-table-column prop="remark" label="备注" min-width="260" /><el-table-column
|
||||
v-if="!pageReadonly"
|
||||
label="操作"
|
||||
width="180"
|
||||
><template #default="{ row, $index }"
|
||||
><el-link type="primary" @click="editPlan(row, $index)">编辑</el-link
|
||||
><el-link type="danger" @click="plans.splice($index, 1)">删除</el-link></template
|
||||
></el-table-column
|
||||
></el-table
|
||||
>
|
||||
<el-table :data="plans" border class="change-table">
|
||||
<el-table-column type="index" label="序号" width="70" />
|
||||
<el-table-column prop="planName" label="方案名称" min-width="180" />
|
||||
<el-table-column label="适用客商" min-width="180">
|
||||
<template #default="{ row }">
|
||||
{{ row.customerName || billingPlanCustomerLabel(row) || '-' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="remark" label="备注" min-width="200" />
|
||||
<el-table-column v-if="!pageReadonly" label="操作" width="180">
|
||||
<template #default="{ row, $index }">
|
||||
<el-link type="primary" @click="editPlan(row, $index)">编辑</el-link>
|
||||
<el-link type="danger" @click="plans.splice($index, 1)">删除</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-else label="操作" width="100">
|
||||
<template #default="{ row, $index }">
|
||||
<el-link type="primary" @click="editPlan(row, $index)">查看</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</section>
|
||||
|
||||
<section class="change-section">
|
||||
@@ -491,7 +493,9 @@
|
||||
v-model="planDialogVisible"
|
||||
:value="planEditor"
|
||||
:index="planEditorIndex"
|
||||
:readonly="pageReadonly"
|
||||
:settlement-currency="form.settlementCurrency"
|
||||
:party-options="billingPartyOptions"
|
||||
@save="savePlan"
|
||||
/>
|
||||
|
||||
@@ -630,6 +634,45 @@ const normalizeCustomPeriods = (periods = []) =>
|
||||
endDay: Number(item?.endDay) > 0 ? Number(item.endDay) : '',
|
||||
}));
|
||||
|
||||
const createPartyRow = (row = {}) => ({
|
||||
id: row.id || `${Date.now()}${Math.floor(Math.random() * 1000)}`,
|
||||
customerId: row.customerId || '',
|
||||
customerName: row.customerName || '',
|
||||
creditCode: row.creditCode || row.unifiedCreditCode || '',
|
||||
contactId: row.contactId || '',
|
||||
contactName: row.contactName || '',
|
||||
contactPhone: row.contactPhone || '',
|
||||
});
|
||||
|
||||
const partyRoleLabel = role => {
|
||||
if (role === 'A') return '甲方';
|
||||
if (role === 'B') return '乙方';
|
||||
if (role === 'C') return '丙方';
|
||||
return role || '';
|
||||
};
|
||||
|
||||
const normalizePartyRows = (partyJson, fallbackName, requireOne) => {
|
||||
const rows = (() => {
|
||||
if (Array.isArray(partyJson)) return partyJson;
|
||||
if (!partyJson) return [];
|
||||
try {
|
||||
const data = JSON.parse(partyJson);
|
||||
return Array.isArray(data) ? data : [];
|
||||
} catch (error) {
|
||||
return [];
|
||||
}
|
||||
})().map(item => createPartyRow(item));
|
||||
if (rows.length) return rows;
|
||||
if (fallbackName) {
|
||||
return String(fallbackName)
|
||||
.split(/[、,]/)
|
||||
.map(name => name.trim())
|
||||
.filter(Boolean)
|
||||
.map(name => createPartyRow({ customerName: name }));
|
||||
}
|
||||
return requireOne ? [createPartyRow()] : [];
|
||||
};
|
||||
|
||||
export default {
|
||||
components: { BillingPlanEditor, ContractAttachmentSection, ElImageViewer, OpenFileViewer },
|
||||
data() {
|
||||
@@ -637,6 +680,9 @@ export default {
|
||||
form: {},
|
||||
period: [],
|
||||
plans: [],
|
||||
partyARows: [],
|
||||
partyBRows: [],
|
||||
partyCRows: [],
|
||||
attachments: [],
|
||||
contractFiles: [],
|
||||
contractFileRows: [],
|
||||
@@ -675,7 +721,7 @@ export default {
|
||||
settlementModeDictOptions: [],
|
||||
contractFormatDictOptions: [],
|
||||
planDialogVisible: false,
|
||||
planEditor: { planName: '', defaultPlan: false, remark: '', rules: [] },
|
||||
planEditor: { planName: '', remark: '', rules: [] },
|
||||
planEditorIndex: -1,
|
||||
billingElements: [
|
||||
'按重量',
|
||||
@@ -756,6 +802,29 @@ export default {
|
||||
isSettlementRuleChange() {
|
||||
return this.form.changeType === '结算规则变更';
|
||||
},
|
||||
/**
|
||||
* 计费方案适用客商:客户合同仅甲方;承运商合同仅乙方、丙方
|
||||
*/
|
||||
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,
|
||||
label: `${partyRoleLabel(row.partyRole)}-${row.customerName || row.customerId}`,
|
||||
partyRole: row.partyRole,
|
||||
partyRowId: row.id,
|
||||
customerId: row.customerId,
|
||||
customerName: row.customerName,
|
||||
}));
|
||||
},
|
||||
changeAttachmentLocationOptions() {
|
||||
if (this.isSettlementRuleChange) {
|
||||
return ['变更材料'];
|
||||
@@ -890,6 +959,9 @@ export default {
|
||||
};
|
||||
this.changeMaterials = this.parse(data.changeAttachmentsJson);
|
||||
this.period = data.startDate && data.endDate ? [data.startDate, data.endDate] : [];
|
||||
this.partyARows = normalizePartyRows(data.partyAJson, data.partyA, true);
|
||||
this.partyBRows = normalizePartyRows(data.partyBJson, data.partyB, true);
|
||||
this.partyCRows = normalizePartyRows(data.partyCJson, data.partyC, false);
|
||||
this.plans = this.parse(data.billingPlanJson);
|
||||
this.attachments = this.mergeChangeAttachments(
|
||||
this.parse(data.attachmentsJson),
|
||||
@@ -1048,10 +1120,32 @@ export default {
|
||||
.replace(/\D/g, '')
|
||||
.replace(/^0+/, '');
|
||||
},
|
||||
addPlan() { this.planEditorIndex = -1; this.planEditor = { planName: `计费方案${this.plans.length + 1}`, defaultPlan: !this.plans.length, remark: '', rules: [{}] }; this.planDialogVisible = true; },
|
||||
editPlan(row, index) { this.planEditorIndex = index; this.planEditor = JSON.parse(JSON.stringify(row)); this.planDialogVisible = true; },
|
||||
toggleDefaultPlan(value) { if (value) this.plans.forEach(item => { item.defaultPlan = false; }); },
|
||||
savePlan(value, index) { if (index < 0) this.plans.push(value); else this.plans.splice(index, 1, value); if (value.defaultPlan) this.plans.forEach((item, current) => { if (current !== (index < 0 ? this.plans.length - 1 : index)) item.defaultPlan = false; }); },
|
||||
addPlan() {
|
||||
this.planEditorIndex = -1;
|
||||
this.planEditor = {
|
||||
planName: `计费方案${this.plans.length + 1}`,
|
||||
remark: '',
|
||||
rules: [{}],
|
||||
};
|
||||
this.planDialogVisible = true;
|
||||
},
|
||||
editPlan(row, index) {
|
||||
this.planEditorIndex = index;
|
||||
this.planEditor = JSON.parse(JSON.stringify(row));
|
||||
this.planDialogVisible = true;
|
||||
},
|
||||
billingPlanCustomerLabel(row) {
|
||||
const matched = this.billingPartyOptions.find(
|
||||
item => String(item.partyRowId) === String(row.partyRowId)
|
||||
);
|
||||
return matched?.label || row.customerName || '';
|
||||
},
|
||||
savePlan(value, index) {
|
||||
const nextPlan = { ...value };
|
||||
delete nextPlan.defaultPlan;
|
||||
if (index < 0) this.plans.push(nextPlan);
|
||||
else this.plans.splice(index, 1, nextPlan);
|
||||
},
|
||||
handleSettlementTypeChange(value) { if (value !== '月结') { this.settlementRule.billCycleType = ''; this.settlementRule.billCutoffDay = ''; this.settlementRule.customPeriods = []; } else if (this.settlementRule.billCycleType === '自定义多周期') this.settlementRule.customPeriods = normalizeCustomPeriods(this.settlementRule.customPeriods || []); else this.settlementRule.customPeriods = []; if (value !== '固定天数周期结算') this.settlementRule.cycleDays = ''; },
|
||||
handleCycleTypeChange(value) { if (value !== '固定截单日') this.settlementRule.billCutoffDay = ''; if (value === '自定义多周期') this.settlementRule.customPeriods = normalizeCustomPeriods(this.settlementRule.customPeriods || []); else this.settlementRule.customPeriods = []; },
|
||||
attachmentUrl(row = {}) { return row.url || row.link || row.fileUrl || row.downloadUrl || row.domain || ''; },
|
||||
|
||||
Reference in New Issue
Block a user