♻️ 运单管理公路配载改用可配载查询回查并清理自造判据
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -3690,6 +3690,7 @@ import {
|
||||
getVoucherImages as getProcessConfigVoucherImages,
|
||||
} from '@/api/business/process-config';
|
||||
import {
|
||||
getList as getWaybillList,
|
||||
getPunchRecords as getWaybillPunchRecords,
|
||||
locateVehicle,
|
||||
savePunchRecord,
|
||||
@@ -10392,25 +10393,38 @@ export default {
|
||||
this.onLoad(this.page, this.query);
|
||||
});
|
||||
},
|
||||
handleRoadLoading() {
|
||||
async handleRoadLoading() {
|
||||
if (!this.selectionList.length) {
|
||||
this.$message.warning('请选择至少一条数据');
|
||||
return;
|
||||
}
|
||||
const nonRoadWaybills = this.selectionList.filter(row => !this.waybillIsRoadTransport(row));
|
||||
if (nonRoadWaybills.length) {
|
||||
this.$message.warning('公路配载仅支持运输方式为“公路运输”的运单');
|
||||
const selectedIds = this.selectionList.map(row => row.id).filter(Boolean);
|
||||
if (!selectedIds.length) {
|
||||
this.$message.warning('请选择至少一条数据');
|
||||
return;
|
||||
}
|
||||
const unavailableWaybills = this.selectionList.filter(
|
||||
row =>
|
||||
!['processing', 'running'].includes(this.statusValue(row)) ||
|
||||
row.loadingId ||
|
||||
row.loadingManageId ||
|
||||
row.loadingNo
|
||||
);
|
||||
if (unavailableWaybills.length) {
|
||||
this.$message.warning('公路配载仅支持进行中且未配载的运单');
|
||||
// 可配载与否只看后端查询结果,前端不自行判状态与配载字段
|
||||
let loadableIds;
|
||||
try {
|
||||
const res = await getWaybillList(1, selectedIds.length, {
|
||||
loadableOnly: 1,
|
||||
ids: selectedIds.join(','),
|
||||
});
|
||||
loadableIds = new Set(extractRecords(res).map(row => String(row.id)));
|
||||
} 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;
|
||||
}
|
||||
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>
|
||||
|
||||
@@ -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 !== '自运') {
|
||||
|
||||
Reference in New Issue
Block a user