调整业务模块
This commit is contained in:
@@ -571,17 +571,17 @@ const buildCarrierContractOptions = contractRows => {
|
||||
item => String(item.contractCategory || '').trim() === '承运商合同'
|
||||
);
|
||||
const nameCounts = validContracts.reduce((result, item) => {
|
||||
const name = String(item.partyB || '').trim();
|
||||
const name = String(item.partyA || item.partyAName || '').trim();
|
||||
if (name) result[name] = (result[name] || 0) + 1;
|
||||
return result;
|
||||
}, {});
|
||||
return validContracts
|
||||
.map(contract => {
|
||||
const carrierName = String(contract.partyB || '').trim();
|
||||
const carrierName = String(contract.partyA || contract.partyAName || '').trim();
|
||||
if (!contract.id || !carrierName) return null;
|
||||
const identifier = contract.contractName || contract.contractNo || contract.id;
|
||||
return {
|
||||
id: contract.partyBId || contract.customerId || '',
|
||||
id: contract.partyAId || contract.partyAUserId || contract.customerId || '',
|
||||
carrierContractId: contract.id,
|
||||
carrierName,
|
||||
label: nameCounts[carrierName] > 1 ? `${carrierName}(${identifier})` : carrierName,
|
||||
@@ -607,7 +607,11 @@ const syncCarrierOptions = () => {
|
||||
carrierOptions.value = [];
|
||||
return;
|
||||
}
|
||||
const carrierId = customerContract?.partyBId || customerContract?.customerId || '';
|
||||
const carrierId =
|
||||
customerContract?.partyBId ||
|
||||
customerContract?.partyBUserId ||
|
||||
customerContract?.customerId ||
|
||||
'';
|
||||
carrierOptions.value = [{ id: carrierId, carrierName, label: carrierName, value: carrierName }];
|
||||
form.carrierId = carrierId;
|
||||
form.carrierIds = carrierId ? [carrierId] : [];
|
||||
|
||||
@@ -5413,8 +5413,8 @@ export default {
|
||||
}
|
||||
},
|
||||
fillSelfOperatedCarrierFromContract(contract = {}) {
|
||||
if (this.form.carrierType !== '自运' || this.waybillHasCarrierContracts === true) return;
|
||||
const carrierName = String(contract.partyB || '').trim();
|
||||
if (this.form.carrierType !== '自运') return;
|
||||
const carrierName = String(contract.partyB || contract.partyBName || '').trim();
|
||||
if (!carrierName) return;
|
||||
const exists = this.taskCarrierOptions.some(
|
||||
item => String(item.value || item.carrierName || '') === carrierName
|
||||
@@ -5462,17 +5462,18 @@ export default {
|
||||
},
|
||||
getWaybillCarrierContractOptions(contracts = []) {
|
||||
const carrierNameCounts = contracts.reduce((counts, contract) => {
|
||||
const carrierName = String(contract.partyB || '').trim();
|
||||
const carrierName = String(contract.partyA || contract.partyAName || '').trim();
|
||||
if (carrierName) counts[carrierName] = (counts[carrierName] || 0) + 1;
|
||||
return counts;
|
||||
}, {});
|
||||
return contracts
|
||||
.map(contract => {
|
||||
const carrierName = String(contract.partyB || '').trim();
|
||||
const carrierName = String(contract.partyA || contract.partyAName || '').trim();
|
||||
if (!carrierName || !contract.id) return null;
|
||||
const contractIdentifier = contract.contractName || contract.contractNo || contract.id;
|
||||
return {
|
||||
id: contract.id,
|
||||
carrierId: contract.partyAId || contract.partyAUserId || contract.customerId || '',
|
||||
value: contract.id,
|
||||
label:
|
||||
carrierNameCounts[carrierName] > 1
|
||||
@@ -5581,28 +5582,15 @@ export default {
|
||||
return Promise.all([contractPromise, detailPromise])
|
||||
.then(([carrierContractOptions, options]) => {
|
||||
if (requestId !== this.taskCarrierRequestId) return this.taskCarrierOptions;
|
||||
if (carrierTypeAtRequest === '自运' && carrierContractOptions?.length) {
|
||||
const selfCarrierOptions = carrierContractOptions.map(item => ({
|
||||
...item,
|
||||
value: item.carrierName,
|
||||
}));
|
||||
this.taskCarrierOptions = selfCarrierOptions;
|
||||
const hasCurrentCarrier = selfCarrierOptions.some(
|
||||
item => String(item.value || '') === String(this.form.carrierName || '')
|
||||
);
|
||||
if (!hasCurrentCarrier) {
|
||||
this.form.carrierName = selfCarrierOptions[0].carrierName;
|
||||
this.form.carrierId = '';
|
||||
}
|
||||
return selfCarrierOptions;
|
||||
}
|
||||
this.taskCarrierOptions = options || [];
|
||||
if (carrierTypeAtRequest === '自运') {
|
||||
this.taskCarrierOptions = [];
|
||||
const customerContract = this.contractOptions.find(
|
||||
item => String(item.id) === String(this.form.contractId)
|
||||
);
|
||||
this.fillSelfOperatedCarrierFromContract(customerContract);
|
||||
return this.taskCarrierOptions;
|
||||
}
|
||||
this.taskCarrierOptions = options || [];
|
||||
return this.taskCarrierOptions;
|
||||
})
|
||||
.finally(() => {
|
||||
|
||||
Reference in New Issue
Block a user