♻️ 运单管理公路配载改用可配载查询回查并清理自造判据

This commit is contained in:
2026-10-18 14:51:33 +08:00
parent 2ae817ec38
commit 847f09b14d
3 changed files with 68 additions and 16432 deletions
+34 -17
View File
@@ -3701,18 +3701,17 @@ export default {
try {
const query = {
...this.buildQueryParams(this.candidateQuery),
// 待执行(需接单未接)与进行中(无需接单或已接单)均可配载
businessStatus: 'pending,running',
onlyUnassignedLoading: 1,
// 公路、待执行、未配载、非拒单的判定都在后端开关内,前端不再拼这些条件
loadableOnly: 1,
// 仅查当前账户所属组织及子组织下的运单
allDept: 0,
...(this.dialogMode === 'add' ? { transportType: 'road' } : {}),
};
const transportType = this.getCandidateTransportTypeQuery(query.transportType);
// 可配载开关已按公路词表过滤,再带上新增模式筛选框的精确取值会漏掉「公路运输」这类历史写法
if (this.dialogMode === 'add') delete query.transportType;
const res = await getWaybillList(
this.candidatePage.currentPage,
this.candidatePage.pageSize,
{ ...query, transportType }
query
);
const page = unwrapPage(res);
this.candidateRows = page.records;
@@ -3721,13 +3720,6 @@ export default {
this.candidateLoading = false;
}
},
getCandidateTransportTypeQuery(value) {
const normalized = String(value || '')
.trim()
.toLowerCase();
if (['road', '公路运输'].includes(normalized)) return 'road,公路运输';
return value || '';
},
handleCandidateSearch() {
this.candidatePage.currentPage = 1;
this.loadCandidateWaybills();
@@ -3769,8 +3761,31 @@ export default {
const exists = new Set(
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];
selectedRows.forEach(row => {
if (mismatchedRows.includes(row)) return;
const key = String(row.id || row.waybillNo);
if (!exists.has(key)) {
nextRows.push(row);
@@ -3789,6 +3804,9 @@ export default {
async addSelectedWaybills() {
await this.addWaybillRows(this.candidateSelection);
},
waybillProjectKey(row = {}) {
return String(row.projectId || row.projectName || '').trim();
},
removeSelectedWaybill(index) {
this.selectedWaybillRows.splice(index, 1);
this.rebuildSummaryFromWaybills();
@@ -4442,10 +4460,9 @@ export default {
}
this.taskCarrierLoading = true;
try {
const projectIds = [
...new Set(this.selectedWaybillRows.map(row => row.projectId).filter(Boolean)),
];
const response = await loadingApi.getCarrierContracts(projectIds);
// 配载单只有一个项目,承运商合同也必须属于该项目
const projectId = this.selectedWaybillRows.map(row => row.projectId).find(Boolean);
const response = await loadingApi.getCarrierContracts(projectId ? [projectId] : []);
if (requestId !== this.taskCarrierRequestId) return [];
const contracts = response.data?.data || response.data || [];
if (this.dialogForm.carrierType !== '自运') {