调整预结算、正式结算

This commit is contained in:
2026-08-24 00:59:08 +08:00
parent 44e31fbd22
commit e1bade226f
13 changed files with 1009 additions and 360 deletions
+44 -7
View File
@@ -1002,6 +1002,7 @@ const defaultTransportType = '';
const defaultCandidateTransportType = '';
const AMAP_KEY = '653b7cf105ad7fb8ec9b2f5198ade315';
const AMAP_SECURITY_CODE = '5aab65c632e48ebae0d0e28f5b28e21a';
const loadingCreateWaybillsStorageKey = 'loading-manage-create-waybills';
let detailAmapLoader;
const createSearchForm = () => ({
@@ -1111,6 +1112,18 @@ const parseJsonArray = value => {
}
};
const parseIdJsonArray = value => {
if (Array.isArray(value)) return value.map(id => String(id));
if (typeof value !== 'string' || !value.trim()) return [];
try {
const normalizedValue = value.replace(/(^\s*\[\s*|,\s*)(-?\d{16,})(\s*(?=,|\]))/g, '$1"$2"$3');
const result = JSON.parse(normalizedValue);
return Array.isArray(result) ? result.map(id => String(id)) : [];
} catch (error) {
return [];
}
};
const uniqueText = (rows, prop) =>
[
...new Set(
@@ -1361,7 +1374,7 @@ export default {
if (linkedRows[index]?.id || linkedRows[index]?.waybillId) {
return linkedRows[index].id || linkedRows[index].waybillId;
}
const ids = parseJsonArray(row.waybillIdsJson);
const ids = parseIdJsonArray(row.waybillIdsJson);
return ids[index] || '';
},
async openWaybillDetail(row = {}) {
@@ -1545,11 +1558,25 @@ export default {
};
actionMap[type]?.();
},
initStandaloneFormPage() {
async initStandaloneFormPage() {
if (!this.isStandaloneFormPage) return;
this.openLoadingDialog(this.$route.query.mode === 'edit' ? 'edit' : 'add', {
const mode = this.$route.query.mode === 'edit' ? 'edit' : 'add';
await this.openLoadingDialog(mode, {
id: this.$route.query.id,
});
if (mode === 'add') await this.consumeLoadingCreateWaybills();
},
async consumeLoadingCreateWaybills() {
const raw = sessionStorage.getItem(loadingCreateWaybillsStorageKey);
if (!raw) return;
sessionStorage.removeItem(loadingCreateWaybillsStorageKey);
try {
const payload = JSON.parse(raw);
if (payload?.source !== 'waybill-manage' || !Array.isArray(payload.rows)) return;
await this.addWaybillRows(payload.rows);
} catch (error) {
ElMessage.warning('待配载运单数据读取失败,请重新选择');
}
},
async openLoadingDialog(mode, row) {
if (['add', 'edit'].includes(mode) && !this.isStandaloneFormPage) {
@@ -1863,7 +1890,7 @@ export default {
}
},
async restoreWaybillRows(idsJson, loadingSubNos) {
const ids = parseJsonArray(idsJson).filter(Boolean);
const ids = parseIdJsonArray(idsJson).filter(Boolean);
if (ids.length) {
const rows = await Promise.all(
ids.map(id =>
@@ -1927,11 +1954,13 @@ export default {
candidateSelectionChange(rows) {
this.candidateSelection = rows || [];
},
async addSelectedWaybills() {
async addWaybillRows(rows = []) {
const waybillRows = Array.isArray(rows) ? rows.filter(Boolean) : [];
if (!waybillRows.length) return;
this.candidateAdding = true;
try {
const selectedRows = await Promise.all(
this.candidateSelection.map(async row => {
waybillRows.map(async row => {
if (!row.id) return row;
try {
const res = await getWaybillDetail(row.id);
@@ -1961,6 +1990,9 @@ export default {
this.candidateAdding = false;
}
},
async addSelectedWaybills() {
await this.addWaybillRows(this.candidateSelection);
},
removeSelectedWaybill(index) {
this.selectedWaybillRows.splice(index, 1);
this.rebuildSummaryFromWaybills();
@@ -1972,7 +2004,12 @@ export default {
.map(row => row.waybillNo)
.filter(Boolean)
.join('');
this.dialogForm.waybillIdsJson = JSON.stringify(rows.map(row => row.id).filter(Boolean));
this.dialogForm.waybillIdsJson = JSON.stringify(
rows
.map(row => row.id)
.filter(Boolean)
.map(id => String(id))
);
this.dialogForm.projectName = uniqueText(rows, 'projectName');
this.dialogForm.customerName = uniqueText(rows, 'customerName');
this.dialogForm.originalNo = uniqueText(rows, 'originalNo');