1、调整导入运单

2、调整对账
This commit is contained in:
2026-09-09 14:43:38 +08:00
parent 6d4961f404
commit f78e61b433
7 changed files with 639 additions and 69 deletions
@@ -247,6 +247,9 @@
>
{{ row[column.prop] }}
</el-link>
<span v-else-if="column.money && column.prop === 'unitPrice'">
{{ formatUnitPrice(row) }}
</span>
<span v-else-if="column.money">
{{ formatMoney(row[column.prop], row.currency || form.currency) }}
</span>
@@ -259,6 +262,12 @@
<span v-else-if="column.prop === 'transportType'">
{{ transportTypeName(row[column.prop]) }}
</span>
<span v-else-if="column.prop === 'cargoName'">
{{ formatCargoNames(row) }}
</span>
<span v-else-if="column.prop === 'cargoType'">
{{ formatCargoTypes(row) }}
</span>
<span v-else>{{ displayValue(row[column.prop]) }}</span>
</template>
</el-table-column>
@@ -1078,6 +1087,7 @@ export default {
adjustRows: [],
pendingAdjustments: {},
sourceFeeSnapshots: {},
detailFeeCache: {}, // 缓存每个明细的费用明细数据(用于拼接货物名称和类型)
adjustChangeRecordVisible: false,
adjustChangeRecord: null,
adjustChangeRecordDetailRows: [],
@@ -1169,6 +1179,19 @@ export default {
});
return Array.from(names);
},
// 按 preSettlementDetailId 分组的明细数据(用于拼接货物名称和类型)
groupedDetails() {
const groups = {};
this.details.forEach(detail => {
// 优先使用 sourceDetailId,如果没有则使用 preSettlementDetailId
const groupKey = detail.sourceDetailId || detail.preSettlementDetailId || detail.id;
if (!groups[groupKey]) {
groups[groupKey] = [];
}
groups[groupKey].push(detail);
});
return groups;
},
filteredDetails() {
return this.details.filter(row =>
Object.entries(this.appliedDetailQuery).every(([field, keyword]) => {
@@ -1322,6 +1345,7 @@ export default {
this.adjustRows = [];
this.pendingAdjustments = {};
this.sourceFeeSnapshots = {};
this.detailFeeCache = {};
this.adjustDialog.activeTab = 'adjust';
this.adjustDialog.detailId = '';
this.adjustDialog.sourceDetailId = '';
@@ -1371,6 +1395,8 @@ export default {
partyB: detail.payeeName,
});
}
// 预加载所有明细的费用明细数据,用于拼接货物名称和类型
await this.loadAllDetailFees();
} finally {
this.loading = false;
}
@@ -1917,6 +1943,30 @@ export default {
this.normalizeAdjustRow(item, data.feeItemNames || [])
);
},
// 批量加载所有明细的费用明细数据,用于拼接货物名称和类型
async loadAllDetailFees() {
if (!this.details.length) return;
// 并发加载所有明细的费用数据
await Promise.all(
this.details.map(async detail => {
if (!detail.id) return;
try {
const response = await getDetailFees(detail.id);
const feeRows = response.data?.data || response.data || [];
// 缓存费用明细数据
if (Array.isArray(feeRows) && feeRows.length > 0) {
this.detailFeeCache[detail.id] = feeRows;
}
} catch (error) {
// 加载失败时使用明细本身的数据
console.warn(`加载明细 ${detail.id} 的费用数据失败:`, error);
}
})
);
},
// 明细列表只有汇总金额,费用项级别的原始金额需要按来源明细单独拉取并缓存为调整基准。
async ensureSourceFeeSnapshots() {
const targets = this.details.filter(row => {
@@ -2461,6 +2511,65 @@ export default {
if (!Number.isFinite(quantity)) return '-';
return `${quantity.toFixed(2)}${row.quantityUnit ? ` ${row.quantityUnit}` : ''}`;
},
// 拼接同一运单的货物名称
formatCargoNames(row) {
const detailId = row.id;
const feeRows = this.detailFeeCache[detailId] || [];
// 如果没有缓存数据或只有一条,返回原始值
if (feeRows.length <= 1) {
return this.displayValue(row.cargoName);
}
// 收集所有货物名称并去重
const names = feeRows
.map(item => item.cargoName)
.filter(name => name && String(name).trim())
.filter((name, index, arr) => arr.indexOf(name) === index);
return names.length > 0 ? names.join('、') : this.displayValue(row.cargoName);
},
// 拼接同一运单的货物类型
formatCargoTypes(row) {
const detailId = row.id;
const feeRows = this.detailFeeCache[detailId] || [];
// 如果没有缓存数据或只有一条,返回原始值
if (feeRows.length <= 1) {
return this.displayValue(row.cargoType);
}
// 收集所有货物类型并去重
const types = feeRows
.map(item => item.cargoType)
.filter(type => type && String(type).trim())
.filter((type, index, arr) => arr.indexOf(type) === index);
return types.length > 0 ? types.join('、') : this.displayValue(row.cargoType);
},
// 格式化运输单价,如果多个货物的单价不一样则显示'-'
formatUnitPrice(row) {
const detailId = row.id;
const feeRows = this.detailFeeCache[detailId] || [];
// 如果没有缓存数据或只有一条,返回原始值
if (feeRows.length <= 1) {
return this.formatMoney(row.unitPrice, row.currency || this.form.currency);
}
// 检查所有货物的运输单价是否一致
const prices = feeRows
.map(item => Number(item.unitPrice || 0))
.filter((price, index, arr) => arr.indexOf(price) === index);
// 如果单价不一致,返回'-'
if (prices.length > 1) {
return '-';
}
// 单价一致,返回该单价
return this.formatMoney(prices[0], row.currency || this.form.currency);
},
displayValue(value) {
return value === undefined || value === null || value === '' ? '-' : value;
},