@@ -4650,9 +4650,14 @@ export default {
|
||||
},
|
||||
taskCarrierValue: {
|
||||
get() {
|
||||
return this.form.carrierType === '自运'
|
||||
? this.form.carrierName || ''
|
||||
: this.form.carrierContractId || this.form.carrierName || '';
|
||||
if (this.form.carrierType === '自运') {
|
||||
return this.form.carrierName || '';
|
||||
}
|
||||
return this.taskCarrierOptionValue({
|
||||
carrierContractId: this.form.carrierContractId,
|
||||
carrierPartyId: this.form.carrierPartyId,
|
||||
carrierName: this.form.carrierName,
|
||||
});
|
||||
},
|
||||
set(value) {
|
||||
this.handleTaskCarrierChange(value);
|
||||
@@ -7290,6 +7295,8 @@ export default {
|
||||
this.form.carrierName = '';
|
||||
this.form.carrierId = '';
|
||||
this.form.carrierContractId = '';
|
||||
this.form.carrierPartyId = '';
|
||||
this.form.carrierPartyRole = '';
|
||||
this.hasProjectProcessConfig = false;
|
||||
this.waybillProcessConfigRows = [];
|
||||
return;
|
||||
@@ -7304,6 +7311,8 @@ export default {
|
||||
this.form.carrierName = '';
|
||||
this.form.carrierId = '';
|
||||
this.form.carrierContractId = '';
|
||||
this.form.carrierPartyId = '';
|
||||
this.form.carrierPartyRole = '';
|
||||
this.loadProjectProcessConfigState();
|
||||
this.loadTaskCarrierOptions(project);
|
||||
if (this.contractSelectEnabled) {
|
||||
@@ -7760,6 +7769,8 @@ export default {
|
||||
this.form.carrierName = '';
|
||||
this.form.carrierId = '';
|
||||
this.form.carrierContractId = '';
|
||||
this.form.carrierPartyId = '';
|
||||
this.form.carrierPartyRole = '';
|
||||
this.form.driverId = '';
|
||||
this.form.driverName = '';
|
||||
this.form.driverPhone = '';
|
||||
@@ -7814,7 +7825,9 @@ export default {
|
||||
},
|
||||
taskCarrierOptionValue(item = {}) {
|
||||
if (this.form.carrierType !== '自运') {
|
||||
return item.carrierContractId || item.value || item.id || '';
|
||||
if (item.value) return item.value;
|
||||
return [item.carrierContractId || item.id || '', item.carrierPartyId || '', item.carrierName || '']
|
||||
.join('__');
|
||||
}
|
||||
return (
|
||||
item.carrierName ||
|
||||
@@ -7852,55 +7865,76 @@ export default {
|
||||
names.forEach(append);
|
||||
return options;
|
||||
},
|
||||
parseContractPartyRows(partyJson, fallbackName = '', partyRole = 'B') {
|
||||
const rows = this.parseJsonArray(partyJson)
|
||||
.map(item => ({
|
||||
id: item.id || '',
|
||||
customerId: item.customerId || '',
|
||||
customerName: String(item.customerName || '').trim(),
|
||||
creditCode: item.creditCode || '',
|
||||
partyRole,
|
||||
}))
|
||||
.filter(item => item.customerName);
|
||||
if (rows.length) return rows;
|
||||
return String(fallbackName || '')
|
||||
.split(/[、,,]/)
|
||||
.map(name => name.trim())
|
||||
.filter(Boolean)
|
||||
.map(name => ({
|
||||
id: '',
|
||||
customerId: '',
|
||||
customerName: name,
|
||||
creditCode: '',
|
||||
partyRole,
|
||||
}));
|
||||
},
|
||||
getWaybillCarrierContractOptions(contracts = []) {
|
||||
const carrierNameCounts = contracts.reduce((counts, contract) => {
|
||||
const carrierName = String(
|
||||
contract.partyB ||
|
||||
contract.partyBName ||
|
||||
contract.contractPartyB ||
|
||||
contract.customerContractPartyB ||
|
||||
contract.secondParty ||
|
||||
contract.secondPartyName ||
|
||||
''
|
||||
).trim();
|
||||
if (carrierName) counts[carrierName] = (counts[carrierName] || 0) + 1;
|
||||
return counts;
|
||||
}, {});
|
||||
return contracts
|
||||
.map(contract => {
|
||||
const carrierName = String(
|
||||
const options = [];
|
||||
contracts.forEach(contract => {
|
||||
if (!contract?.id) return;
|
||||
const parties = [
|
||||
...this.parseContractPartyRows(contract.partyBJson, contract.partyB, 'B'),
|
||||
...this.parseContractPartyRows(contract.partyCJson, contract.partyC, 'C'),
|
||||
];
|
||||
if (!parties.length) {
|
||||
const fallbackName = String(
|
||||
contract.partyB ||
|
||||
contract.partyBName ||
|
||||
contract.contractPartyB ||
|
||||
contract.customerContractPartyB ||
|
||||
contract.secondParty ||
|
||||
contract.secondPartyName ||
|
||||
''
|
||||
contract.partyBName ||
|
||||
contract.contractPartyB ||
|
||||
contract.customerContractPartyB ||
|
||||
contract.secondParty ||
|
||||
contract.secondPartyName ||
|
||||
''
|
||||
).trim();
|
||||
if (!carrierName || !contract.id) return null;
|
||||
const contractIdentifier = contract.contractName || contract.contractNo || contract.id;
|
||||
return {
|
||||
if (fallbackName) {
|
||||
parties.push({
|
||||
id: '',
|
||||
customerId: '',
|
||||
customerName: fallbackName,
|
||||
creditCode: '',
|
||||
partyRole: 'B',
|
||||
});
|
||||
}
|
||||
}
|
||||
const contractIdentifier = contract.contractName || contract.contractNo || contract.id;
|
||||
parties.forEach(party => {
|
||||
const roleLabel = party.partyRole === 'C' ? '丙方' : '乙方';
|
||||
const optionValue = [contract.id, party.id || '', party.customerName].join('__');
|
||||
options.push({
|
||||
id: contract.id,
|
||||
carrierId:
|
||||
contract.partyBId ||
|
||||
contract.partyBUserId ||
|
||||
contract.contractPartyBId ||
|
||||
contract.customerContractPartyBId ||
|
||||
contract.secondPartyId ||
|
||||
contract.secondPartyUserId ||
|
||||
contract.carrierId ||
|
||||
'',
|
||||
value: contract.id,
|
||||
label:
|
||||
carrierNameCounts[carrierName] > 1
|
||||
? `${carrierName}(${contractIdentifier})`
|
||||
: carrierName,
|
||||
carrierName,
|
||||
fullName: carrierName,
|
||||
carrierId: party.customerId || '',
|
||||
value: optionValue,
|
||||
label: `${party.customerName}(${roleLabel}) - ${contractIdentifier}`,
|
||||
carrierName: party.customerName,
|
||||
fullName: party.customerName,
|
||||
carrierContractId: contract.id,
|
||||
};
|
||||
})
|
||||
.filter(Boolean);
|
||||
carrierPartyId: party.id || '',
|
||||
carrierPartyRole: party.partyRole,
|
||||
creditCode: party.creditCode || '',
|
||||
});
|
||||
});
|
||||
});
|
||||
return options;
|
||||
},
|
||||
resetWaybillCarrierContractState() {
|
||||
this.waybillCarrierContractRequestId += 1;
|
||||
@@ -7930,6 +7964,8 @@ export default {
|
||||
this.form.carrierName = '';
|
||||
this.form.carrierId = '';
|
||||
this.form.carrierContractId = '';
|
||||
this.form.carrierPartyId = '';
|
||||
this.form.carrierPartyRole = '';
|
||||
}
|
||||
return options;
|
||||
})
|
||||
@@ -8020,10 +8056,14 @@ export default {
|
||||
);
|
||||
if (this.form.carrierType !== '自运') {
|
||||
this.form.carrierContractId = carrier?.carrierContractId || '';
|
||||
this.form.carrierPartyId = carrier?.carrierPartyId || '';
|
||||
this.form.carrierPartyRole = carrier?.carrierPartyRole || '';
|
||||
this.form.carrierId = carrier?.carrierId || '';
|
||||
this.form.carrierName = carrier?.carrierName || '';
|
||||
} else {
|
||||
this.form.carrierId = carrier?.carrierContractId ? '' : carrier?.id || '';
|
||||
this.form.carrierPartyId = '';
|
||||
this.form.carrierPartyRole = '';
|
||||
this.form.carrierName = value || '';
|
||||
}
|
||||
// 承运商变更后清空司机/车辆,避免跨组织脏数据
|
||||
|
||||
Reference in New Issue
Block a user