@@ -89,26 +89,26 @@
|
||||
<el-col :span="8">
|
||||
<el-form-item label="承运商合同" prop="carrierContractId">
|
||||
<el-select
|
||||
v-model="form.carrierContractId"
|
||||
v-model="form.carrierOptionValue"
|
||||
filterable
|
||||
clearable
|
||||
:disabled="readonly || !form.projectId"
|
||||
style="width: 100%"
|
||||
:placeholder="form.projectId ? '请选择承运商合同' : '请先选择项目'"
|
||||
:placeholder="form.projectId ? '请选择承运商合同客商' : '请先选择项目'"
|
||||
@change="onCarrierContractChange"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in filteredCarrierContracts"
|
||||
:key="item.id"
|
||||
:label="formatContractLabel(item)"
|
||||
:value="item.id"
|
||||
v-for="item in filteredCarrierContractOptions"
|
||||
:key="item.optionValue"
|
||||
:label="item.optionLabel"
|
||||
:value="item.optionValue"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="承运商">
|
||||
<el-input v-model="form.carrierName" disabled placeholder="选择承运商合同后自动填充" />
|
||||
<el-input v-model="form.carrierName" disabled placeholder="选择承运商合同客商后自动填充" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
@@ -403,6 +403,9 @@ const createDefaultForm = () => ({
|
||||
customerName: '',
|
||||
carrierContractId: '',
|
||||
carrierContractName: '',
|
||||
carrierOptionValue: '',
|
||||
carrierPartyId: '',
|
||||
carrierPartyRole: '',
|
||||
carrierName: '',
|
||||
waybillMode: 'new',
|
||||
remark: '',
|
||||
@@ -442,6 +445,62 @@ const filteredCustomerContracts = computed(() => customerContracts.value);
|
||||
|
||||
const filteredCarrierContracts = computed(() => carrierContracts.value);
|
||||
|
||||
const parsePartyRows = (partyJson, fallbackName = '', partyRole = 'B') => {
|
||||
let rows = [];
|
||||
try {
|
||||
const parsed = partyJson ? JSON.parse(partyJson) : [];
|
||||
if (Array.isArray(parsed)) {
|
||||
rows = parsed
|
||||
.map(item => ({
|
||||
id: item.id || '',
|
||||
customerId: item.customerId || '',
|
||||
customerName: String(item.customerName || '').trim(),
|
||||
partyRole,
|
||||
}))
|
||||
.filter(item => item.customerName);
|
||||
}
|
||||
} catch (error) {
|
||||
rows = [];
|
||||
}
|
||||
if (rows.length) return rows;
|
||||
return String(fallbackName || '')
|
||||
.split(/[、,,]/)
|
||||
.map(name => name.trim())
|
||||
.filter(Boolean)
|
||||
.map(name => ({ id: '', customerId: '', customerName: name, partyRole }));
|
||||
};
|
||||
|
||||
const filteredCarrierContractOptions = computed(() => {
|
||||
const options = [];
|
||||
filteredCarrierContracts.value.forEach(contract => {
|
||||
const parties = [
|
||||
...parsePartyRows(contract.partyBJson, contract.partyB, 'B'),
|
||||
...parsePartyRows(contract.partyCJson, contract.partyC, 'C'),
|
||||
];
|
||||
if (!parties.length && contract.carrierName) {
|
||||
parties.push({
|
||||
id: '',
|
||||
customerId: '',
|
||||
customerName: contract.carrierName,
|
||||
partyRole: 'B',
|
||||
});
|
||||
}
|
||||
parties.forEach(party => {
|
||||
const roleLabel = party.partyRole === 'C' ? '丙方' : '乙方';
|
||||
const optionValue = [contract.id, party.id || '', party.customerName].join('__');
|
||||
options.push({
|
||||
...contract,
|
||||
optionValue,
|
||||
optionLabel: `${party.customerName}(${roleLabel}) - ${formatContractLabel(contract)}`,
|
||||
carrierPartyId: party.id || '',
|
||||
carrierPartyRole: party.partyRole,
|
||||
carrierName: party.customerName,
|
||||
});
|
||||
});
|
||||
});
|
||||
return options;
|
||||
});
|
||||
|
||||
const extractRecords = response => {
|
||||
const data = response?.data || response;
|
||||
if (Array.isArray(data)) return data;
|
||||
@@ -708,6 +767,10 @@ const normalizeContract = item => {
|
||||
projectId: normalized.projectId,
|
||||
partyA: normalized.partyA || '',
|
||||
partyB: normalized.partyB || '',
|
||||
partyC: normalized.partyC || '',
|
||||
partyAJson: normalized.partyAJson || '',
|
||||
partyBJson: normalized.partyBJson || '',
|
||||
partyCJson: normalized.partyCJson || '',
|
||||
customerName: normalized.customerName || normalized.partyA || '',
|
||||
carrierName: normalized.carrierName || normalized.partyB || '',
|
||||
};
|
||||
@@ -972,10 +1035,9 @@ const autoSelectSingleContracts = () => {
|
||||
form.customerContractId = customers[0].id;
|
||||
onCustomerContractChange(customers[0].id);
|
||||
}
|
||||
const carriers = filteredCarrierContracts.value;
|
||||
const carriers = filteredCarrierContractOptions.value;
|
||||
if (carriers.length === 1 && !form.carrierContractId) {
|
||||
form.carrierContractId = carriers[0].id;
|
||||
onCarrierContractChange(carriers[0].id);
|
||||
onCarrierContractChange(carriers[0].optionValue);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -987,6 +1049,9 @@ const onProjectChange = async id => {
|
||||
form.customerName = '';
|
||||
form.carrierContractId = '';
|
||||
form.carrierContractName = '';
|
||||
form.carrierOptionValue = '';
|
||||
form.carrierPartyId = '';
|
||||
form.carrierPartyRole = '';
|
||||
form.carrierName = '';
|
||||
customerContracts.value = [];
|
||||
carrierContracts.value = [];
|
||||
@@ -1005,9 +1070,15 @@ const onCustomerContractChange = id => {
|
||||
form.customerName = item?.customerName || item?.partyA || '';
|
||||
};
|
||||
|
||||
const onCarrierContractChange = id => {
|
||||
const item = filteredCarrierContracts.value.find(row => String(row.id) === String(id));
|
||||
const onCarrierContractChange = optionValue => {
|
||||
const item = filteredCarrierContractOptions.value.find(
|
||||
row => String(row.optionValue) === String(optionValue)
|
||||
);
|
||||
form.carrierOptionValue = item?.optionValue || '';
|
||||
form.carrierContractId = item?.id || '';
|
||||
form.carrierContractName = item?.contractName || '';
|
||||
form.carrierPartyId = item?.carrierPartyId || '';
|
||||
form.carrierPartyRole = item?.carrierPartyRole || '';
|
||||
form.carrierName = item?.carrierName || item?.partyB || '';
|
||||
};
|
||||
|
||||
|
||||
@@ -2904,10 +2904,33 @@ export default {
|
||||
buildRequestParams(params = {}) {
|
||||
return this.settlementType ? { ...params, settlementType: this.settlementType } : params;
|
||||
},
|
||||
syncBillingPlanOptions(contractId) {
|
||||
syncBillingPlanOptions(contractId, counterpartyName = '') {
|
||||
const contracts = [...this.updateContractOptions, ...this.contractOptions];
|
||||
const contract = contracts.find(item => String(item.id) === String(contractId));
|
||||
const plans = this.parseJson(contract?.billingPlanJson);
|
||||
let plans = this.parseJson(contract?.billingPlanJson);
|
||||
const targetName = String(
|
||||
counterpartyName ||
|
||||
this.updateFeeForm?.counterpartyName ||
|
||||
this.generateQuery?.counterpartyName ||
|
||||
this.currentDetail?.counterpartyName ||
|
||||
this.currentDetail?.carrierName ||
|
||||
this.currentDetail?.customerName ||
|
||||
''
|
||||
).trim();
|
||||
if (targetName) {
|
||||
const matched = plans.filter(
|
||||
item =>
|
||||
String(item.customerName || '').trim() === targetName ||
|
||||
String(item.partyRowId || '') ===
|
||||
String(this.updateFeeForm?.carrierPartyId || this.generateQuery?.carrierPartyId || '')
|
||||
);
|
||||
const hasBinding = plans.some(
|
||||
item => item.customerName || item.customerId || item.partyRowId
|
||||
);
|
||||
if (matched.length || hasBinding) {
|
||||
plans = matched;
|
||||
}
|
||||
}
|
||||
this.billingPlanOptions = plans.map((item, index) => ({
|
||||
id:
|
||||
item.id ||
|
||||
@@ -2916,11 +2939,16 @@ export default {
|
||||
item.planName ||
|
||||
item.billingPlanName ||
|
||||
`plan-${index}`,
|
||||
name: item.name || item.planName || item.billingPlanName || `计费方案${index + 1}`,
|
||||
name: [
|
||||
item.name || item.planName || item.billingPlanName || `计费方案${index + 1}`,
|
||||
item.customerName ? `(${item.customerName})` : '',
|
||||
].join(''),
|
||||
defaultPlan:
|
||||
item.defaultPlan === true ||
|
||||
item.defaultPlan === 1 ||
|
||||
['true', '1'].includes(String(item.defaultPlan).toLowerCase()),
|
||||
customerName: item.customerName || '',
|
||||
partyRowId: item.partyRowId || '',
|
||||
}));
|
||||
return this.billingPlanOptions;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user