♻️ 运单管理公路配载改用可配载查询回查并清理自造判据
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -3690,6 +3690,7 @@ import {
|
|||||||
getVoucherImages as getProcessConfigVoucherImages,
|
getVoucherImages as getProcessConfigVoucherImages,
|
||||||
} from '@/api/business/process-config';
|
} from '@/api/business/process-config';
|
||||||
import {
|
import {
|
||||||
|
getList as getWaybillList,
|
||||||
getPunchRecords as getWaybillPunchRecords,
|
getPunchRecords as getWaybillPunchRecords,
|
||||||
locateVehicle,
|
locateVehicle,
|
||||||
savePunchRecord,
|
savePunchRecord,
|
||||||
@@ -10392,25 +10393,38 @@ export default {
|
|||||||
this.onLoad(this.page, this.query);
|
this.onLoad(this.page, this.query);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
handleRoadLoading() {
|
async handleRoadLoading() {
|
||||||
if (!this.selectionList.length) {
|
if (!this.selectionList.length) {
|
||||||
this.$message.warning('请选择至少一条数据');
|
this.$message.warning('请选择至少一条数据');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const nonRoadWaybills = this.selectionList.filter(row => !this.waybillIsRoadTransport(row));
|
const selectedIds = this.selectionList.map(row => row.id).filter(Boolean);
|
||||||
if (nonRoadWaybills.length) {
|
if (!selectedIds.length) {
|
||||||
this.$message.warning('公路配载仅支持运输方式为“公路运输”的运单');
|
this.$message.warning('请选择至少一条数据');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const unavailableWaybills = this.selectionList.filter(
|
// 可配载与否只看后端查询结果,前端不自行判状态与配载字段
|
||||||
row =>
|
let loadableIds;
|
||||||
!['processing', 'running'].includes(this.statusValue(row)) ||
|
try {
|
||||||
row.loadingId ||
|
const res = await getWaybillList(1, selectedIds.length, {
|
||||||
row.loadingManageId ||
|
loadableOnly: 1,
|
||||||
row.loadingNo
|
ids: selectedIds.join(','),
|
||||||
);
|
});
|
||||||
if (unavailableWaybills.length) {
|
loadableIds = new Set(extractRecords(res).map(row => String(row.id)));
|
||||||
this.$message.warning('公路配载仅支持进行中且未配载的运单');
|
} catch (error) {
|
||||||
|
this.$message.error('校验运单可配载状态失败,请重试');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const rejectedRows = this.selectionList.filter(row => !loadableIds.has(String(row.id)));
|
||||||
|
if (rejectedRows.length) {
|
||||||
|
const rejectedText = rejectedRows
|
||||||
|
.map(row => {
|
||||||
|
const reason = this.roadLoadingRejectReason(row);
|
||||||
|
const no = row.waybillNo || row.id || '';
|
||||||
|
return reason ? `${no}(${reason})` : `${no}`;
|
||||||
|
})
|
||||||
|
.join('、');
|
||||||
|
this.$message.warning(`${rejectedText};公路配载仅支持公路、待执行且未配载的运单`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -10433,6 +10447,13 @@ export default {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
// 仅用于给被后端判定为不可配载的运单配一句可读原因,不改判据
|
||||||
|
roadLoadingRejectReason(row = {}) {
|
||||||
|
if (!this.waybillIsRoadTransport(row)) return '非公路运输';
|
||||||
|
if (String(row.businessStatus || '') !== 'pending') return '状态不是待执行';
|
||||||
|
if (row.loadingNo) return '已关联配载单';
|
||||||
|
return '';
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -3701,18 +3701,17 @@ export default {
|
|||||||
try {
|
try {
|
||||||
const query = {
|
const query = {
|
||||||
...this.buildQueryParams(this.candidateQuery),
|
...this.buildQueryParams(this.candidateQuery),
|
||||||
// 待执行(需接单未接)与进行中(无需接单或已接单)均可配载
|
// 公路、待执行、未配载、非拒单的判定都在后端开关内,前端不再拼这些条件
|
||||||
businessStatus: 'pending,running',
|
loadableOnly: 1,
|
||||||
onlyUnassignedLoading: 1,
|
|
||||||
// 仅查当前账户所属组织及子组织下的运单
|
// 仅查当前账户所属组织及子组织下的运单
|
||||||
allDept: 0,
|
allDept: 0,
|
||||||
...(this.dialogMode === 'add' ? { transportType: 'road' } : {}),
|
|
||||||
};
|
};
|
||||||
const transportType = this.getCandidateTransportTypeQuery(query.transportType);
|
// 可配载开关已按公路词表过滤,再带上新增模式筛选框的精确取值会漏掉「公路运输」这类历史写法
|
||||||
|
if (this.dialogMode === 'add') delete query.transportType;
|
||||||
const res = await getWaybillList(
|
const res = await getWaybillList(
|
||||||
this.candidatePage.currentPage,
|
this.candidatePage.currentPage,
|
||||||
this.candidatePage.pageSize,
|
this.candidatePage.pageSize,
|
||||||
{ ...query, transportType }
|
query
|
||||||
);
|
);
|
||||||
const page = unwrapPage(res);
|
const page = unwrapPage(res);
|
||||||
this.candidateRows = page.records;
|
this.candidateRows = page.records;
|
||||||
@@ -3721,13 +3720,6 @@ export default {
|
|||||||
this.candidateLoading = false;
|
this.candidateLoading = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getCandidateTransportTypeQuery(value) {
|
|
||||||
const normalized = String(value || '')
|
|
||||||
.trim()
|
|
||||||
.toLowerCase();
|
|
||||||
if (['road', '公路运输'].includes(normalized)) return 'road,公路运输';
|
|
||||||
return value || '';
|
|
||||||
},
|
|
||||||
handleCandidateSearch() {
|
handleCandidateSearch() {
|
||||||
this.candidatePage.currentPage = 1;
|
this.candidatePage.currentPage = 1;
|
||||||
this.loadCandidateWaybills();
|
this.loadCandidateWaybills();
|
||||||
@@ -3769,8 +3761,31 @@ export default {
|
|||||||
const exists = new Set(
|
const exists = new Set(
|
||||||
this.selectedWaybillRows.map(row => String(row.id || row.waybillNo))
|
this.selectedWaybillRows.map(row => String(row.id || row.waybillNo))
|
||||||
);
|
);
|
||||||
|
// 一张配载单的全部子运单必须同项目:以已选运单(无已选时以本批首张)的项目为准
|
||||||
|
const anchorRow = [...this.selectedWaybillRows, ...selectedRows].find(row =>
|
||||||
|
this.waybillProjectKey(row)
|
||||||
|
);
|
||||||
|
const anchorKey = anchorRow ? this.waybillProjectKey(anchorRow) : '';
|
||||||
|
const mismatchedRows = anchorKey
|
||||||
|
? selectedRows.filter(
|
||||||
|
row => this.waybillProjectKey(row) && this.waybillProjectKey(row) !== anchorKey
|
||||||
|
)
|
||||||
|
: [];
|
||||||
|
if (mismatchedRows.length) {
|
||||||
|
const anchorName = anchorRow.projectName || anchorRow.projectId;
|
||||||
|
const mismatchedText = mismatchedRows
|
||||||
|
.map(
|
||||||
|
row =>
|
||||||
|
`${row.waybillNo || row.id}(项目:${row.projectName || row.projectId || '未知'})`
|
||||||
|
)
|
||||||
|
.join('、');
|
||||||
|
this.$message.warning(
|
||||||
|
`运单 ${mismatchedText} 与已选运单项目「${anchorName}」不一致,不能加入同一配载单`
|
||||||
|
);
|
||||||
|
}
|
||||||
const nextRows = [...this.selectedWaybillRows];
|
const nextRows = [...this.selectedWaybillRows];
|
||||||
selectedRows.forEach(row => {
|
selectedRows.forEach(row => {
|
||||||
|
if (mismatchedRows.includes(row)) return;
|
||||||
const key = String(row.id || row.waybillNo);
|
const key = String(row.id || row.waybillNo);
|
||||||
if (!exists.has(key)) {
|
if (!exists.has(key)) {
|
||||||
nextRows.push(row);
|
nextRows.push(row);
|
||||||
@@ -3789,6 +3804,9 @@ export default {
|
|||||||
async addSelectedWaybills() {
|
async addSelectedWaybills() {
|
||||||
await this.addWaybillRows(this.candidateSelection);
|
await this.addWaybillRows(this.candidateSelection);
|
||||||
},
|
},
|
||||||
|
waybillProjectKey(row = {}) {
|
||||||
|
return String(row.projectId || row.projectName || '').trim();
|
||||||
|
},
|
||||||
removeSelectedWaybill(index) {
|
removeSelectedWaybill(index) {
|
||||||
this.selectedWaybillRows.splice(index, 1);
|
this.selectedWaybillRows.splice(index, 1);
|
||||||
this.rebuildSummaryFromWaybills();
|
this.rebuildSummaryFromWaybills();
|
||||||
@@ -4442,10 +4460,9 @@ export default {
|
|||||||
}
|
}
|
||||||
this.taskCarrierLoading = true;
|
this.taskCarrierLoading = true;
|
||||||
try {
|
try {
|
||||||
const projectIds = [
|
// 配载单只有一个项目,承运商合同也必须属于该项目
|
||||||
...new Set(this.selectedWaybillRows.map(row => row.projectId).filter(Boolean)),
|
const projectId = this.selectedWaybillRows.map(row => row.projectId).find(Boolean);
|
||||||
];
|
const response = await loadingApi.getCarrierContracts(projectId ? [projectId] : []);
|
||||||
const response = await loadingApi.getCarrierContracts(projectIds);
|
|
||||||
if (requestId !== this.taskCarrierRequestId) return [];
|
if (requestId !== this.taskCarrierRequestId) return [];
|
||||||
const contracts = response.data?.data || response.data || [];
|
const contracts = response.data?.data || response.data || [];
|
||||||
if (this.dialogForm.carrierType !== '自运') {
|
if (this.dialogForm.carrierType !== '自运') {
|
||||||
|
|||||||
Reference in New Issue
Block a user