From 1ac741f78588d5463c5c497c7a3ba4021eb25ac8 Mon Sep 17 00:00:00 2001 From: b2894lxlx <517289602@qq.com> Date: Sun, 18 Oct 2026 20:35:28 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E5=AE=8C=E5=96=84=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E7=BB=93=E7=AE=97=E5=8D=95=E6=98=8E=E7=BB=86=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E3=80=81=E8=8D=89=E7=A8=BF=E5=88=B7=E6=96=B0=E4=B8=8E?= =?UTF-8?q?=E5=8E=86=E5=8F=B2=E8=BF=90=E5=8D=95=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- src/api/settlement/settlementImport.js | 10 + .../components/settlement-import-page.vue | 253 ++++++++++++++++-- src/views/settlement/settlement-import.vue | 201 ++++++++++++-- 3 files changed, 425 insertions(+), 39 deletions(-) diff --git a/src/api/settlement/settlementImport.js b/src/api/settlement/settlementImport.js index 131493b..e59c23f 100644 --- a/src/api/settlement/settlementImport.js +++ b/src/api/settlement/settlementImport.js @@ -53,3 +53,13 @@ export const confirm = data => request({ url: `${baseUrl}/confirm`, method: 'post', data, timeout: 120000 }); export const voidBatch = data => request({ url: `${baseUrl}/void`, method: 'post', data }); + +export const removeDraft = id => + request({ url: `${baseUrl}/remove`, method: 'post', params: { id } }); + +export const getHistoryWaybills = params => + request({ + url: `${baseUrl}/history-waybills`, + method: 'get', + params, + }); diff --git a/src/views/settlement/components/settlement-import-page.vue b/src/views/settlement/components/settlement-import-page.vue index e87995c..d417134 100644 --- a/src/views/settlement/components/settlement-import-page.vue +++ b/src/views/settlement/components/settlement-import-page.vue @@ -122,7 +122,7 @@
历史运单:按 项目+车号+运输完成日期+客户+承运商+起运地+目的地+货物名称 - 匹配已有运单(命中 1 条自动绑定,多条需手工指定运单号);提交时生成应收/应付明细与预/正式结算单,费用按导入单据,不新建运单 + 匹配尚未生成应收/应付的运单(命中 1 条自动绑定,多条可点「选择」弹窗挑选);提交时生成应收/应付明细与预/正式结算单,费用按导入单据,不新建运单
@@ -220,8 +220,32 @@ value-format="YYYY-MM-DD" placeholder="请选择" /> + + + +
+ + + 选择 + +
+ {{ formatCell(row, column) }} @@ -268,6 +300,41 @@ 确认导入 + + +
+ 仅展示相同项目、客户合同、承运商合同下,尚未生成当前结算类型应收/应付明细的运单 +
+ + + + + + + + + + + + +
@@ -279,6 +346,7 @@ import { QuestionFilled } from '@element-plus/icons-vue'; import dayjs from 'dayjs'; import * as api from '@/api/settlement/settlementImport'; import { getList as getContractList } from '@/api/business/contract-manage'; +import { getDictionary } from '@/api/system/dictbiz'; import { formatContractOptionLabel } from '@/utils/contract'; import { downloadXls } from '@/utils/util'; @@ -301,6 +369,12 @@ const carrierContracts = ref([]); const draftLoading = ref(false); const confirmLoading = ref(false); const readonly = ref(false); +const transportTypeOptions = ref([]); +const historyWaybillVisible = ref(false); +const historyWaybillLoading = ref(false); +const historyWaybillRows = ref([]); +const historyWaybillCurrent = ref(null); +const historyWaybillTargetRow = ref(null); const createDefaultForm = () => ({ id: undefined, @@ -406,7 +480,6 @@ const loadContractsByProject = async (projectId, projectName = '') => { const fixedDetailColumns = [ { prop: 'loadingIdentifier', label: '配载标识号', editor: 'input', minWidth: 140 }, - { prop: 'batchNo', label: '运单批次号', editor: 'input', minWidth: 140 }, { prop: 'originalNo', label: '原始单号', editor: 'input', minWidth: 130 }, { prop: 'vehicleNo', @@ -414,15 +487,30 @@ const fixedDetailColumns = [ editor: 'input', minWidth: 190, }, - { prop: 'driverName', label: '司机/船长', editor: 'input', minWidth: 120 }, - { prop: 'transportType', label: '运输方式', editor: 'input', minWidth: 110 }, - { prop: 'departureAddress', label: '起运地', editor: 'input', minWidth: 160 }, - { prop: 'arrivalAddress', label: '目的地', editor: 'input', minWidth: 160 }, + { prop: 'transportType', label: '运输方式', editor: 'select', minWidth: 120 }, + { prop: 'driverName', label: '司机/船长姓名', editor: 'input', minWidth: 120 }, + { prop: 'driverPhone', label: '司机/船长手机号', editor: 'input', minWidth: 140 }, + { prop: 'departureAddress', label: '发货地址', editor: 'input', minWidth: 160 }, + { prop: 'departureContact', label: '发货联系人', editor: 'input', minWidth: 120 }, + { prop: 'departurePhone', label: '发货联系人电话', editor: 'input', minWidth: 140 }, + { prop: 'arrivalAddress', label: '到货地址', editor: 'input', minWidth: 160 }, + { prop: 'arrivalContact', label: '收货联系人', editor: 'input', minWidth: 120 }, + { prop: 'arrivalPhone', label: '收货联系人电话', editor: 'input', minWidth: 140 }, { prop: 'cargoName', label: '货物名称', editor: 'input', minWidth: 140 }, - { prop: 'actualStartDate', label: '开始时间', editor: 'date', minWidth: 140 }, - { prop: 'actualEndDate', label: '运输完成日期', editor: 'date', minWidth: 140 }, - { prop: 'unitPrice', label: '单价', editor: 'number', minWidth: 100, feeField: false }, - { prop: 'transportFee', label: '运费', editor: 'number', minWidth: 100 }, + { prop: 'cargoType', label: '货物类型', editor: 'input', minWidth: 120 }, + { prop: 'packageType', label: '包装', editor: 'input', minWidth: 100 }, + { prop: 'quantity', label: '数量', editor: 'number', minWidth: 100 }, + { prop: 'quantityUnit', label: '数量单位', editor: 'input', minWidth: 100 }, + { prop: 'specification', label: '规格', editor: 'input', minWidth: 110 }, + { prop: 'model', label: '型号', editor: 'input', minWidth: 110 }, + { prop: 'mileage', label: '里程(km)', editor: 'optionalNumber', minWidth: 110 }, + { prop: 'unitPrice', label: '运输单价', editor: 'optionalNumber', minWidth: 100 }, + { prop: 'transportFee', label: '运输费', editor: 'number', minWidth: 100 }, + { prop: 'actualStartDate', label: '实际发货时间', editor: 'date', minWidth: 140 }, + { prop: 'actualEndDate', label: '实际完成时间', editor: 'date', minWidth: 140 }, + { prop: 'planStartDate', label: '预计发货时间', editor: 'date', minWidth: 140 }, + { prop: 'planEndDate', label: '预计完成时间', editor: 'date', minWidth: 140 }, + { prop: 'waybillIdentifier', label: '同一运单标识号', editor: 'input', minWidth: 140 }, ]; const detailColumns = computed(() => { @@ -439,8 +527,8 @@ const detailColumns = computed(() => { { prop: 'waybillNo', label: '运单号', - editor: 'input', - minWidth: 150, + editor: 'waybillSelect', + minWidth: 180, }, ] : []; @@ -532,9 +620,14 @@ const resolveCellValue = (row, column) => { const formatCell = (row, column) => { const value = resolveCellValue(row, column); - if (column.editor === 'number' || column.prop === 'settlementAmount') { + if ( + column.editor === 'number' || + column.editor === 'optionalNumber' || + column.prop === 'settlementAmount' + ) { if (value === '' || value === null || value === undefined) return ''; - return Number(value).toFixed(2); + const number = Number(value); + return Number.isFinite(number) ? number.toFixed(2) : ''; } return value ?? ''; }; @@ -560,11 +653,23 @@ const recalcSettlementAmount = row => { }; const updateNumberCell = (row, column, value) => { - const [integer = '', decimal = ''] = String(value || '') - .replace(/[^\d.]/g, '') - .split('.'); + const raw = String(value ?? '').trim(); + if (!raw) { + if (column.isFeeItem) { + if (!row.feeItems) row.feeItems = {}; + row.feeItems[column.prop] = ''; + row[column.prop] = ''; + } else { + row[column.prop] = column.editor === 'optionalNumber' ? '' : ''; + if (column.prop === 'transportFee') row.freight = ''; + if (column.prop === 'unitPrice') row.transportUnitPrice = ''; + } + recalcSettlementAmount(row); + return; + } + const [integer = '', decimal = ''] = raw.replace(/[^\d.]/g, '').split('.'); const normalized = - decimal || String(value || '').includes('.') ? `${integer}.${decimal.slice(0, 2)}` : integer; + decimal || raw.includes('.') ? `${integer}.${decimal.slice(0, 2)}` : integer; if (column.isFeeItem) { if (!row.feeItems) row.feeItems = {}; row.feeItems[column.prop] = normalized; @@ -637,6 +742,12 @@ const normalizeParsedRow = (item, index) => { loadingIdentifier: item.loadingIdentifier || item.loadingNo || '', transportFee: item.transportFee ?? item.freight ?? item['*运输费'] ?? item['运输费'] ?? '', unitPrice: item.unitPrice ?? item.transportUnitPrice ?? item['运输单价'] ?? item['单价'] ?? '', + mileage: item.mileage ?? item['里程(km)'] ?? item['里程'] ?? '', + quantity: item.quantity ?? item['*数量'] ?? item['数量'] ?? '', + quantityUnit: item.quantityUnit ?? item['*数量单位'] ?? item['数量单位'] ?? '', + model: item.model ?? item['型号'] ?? '', + specification: item.specification ?? item['规格'] ?? '', + cargoType: item.cargoType ?? item['*货物类型'] ?? item['货物类型'] ?? '', feeItems, }; row.transportUnitPrice = row.unitPrice; @@ -867,6 +978,74 @@ const leaveAfterConfirm = () => { router.push({ path: '/settlement/settlement-import' }); }; +const openHistoryWaybillDialog = async row => { + if (!form.projectId || !form.customerContractId || !form.carrierContractId) { + ElMessage.warning('请先选择项目、客户合同和承运商合同'); + return; + } + if (!form.settlementType) { + ElMessage.warning('请先选择结算类型'); + return; + } + historyWaybillTargetRow.value = row; + historyWaybillCurrent.value = null; + historyWaybillVisible.value = true; + historyWaybillLoading.value = true; + try { + const response = await api.getHistoryWaybills({ + projectId: form.projectId, + customerContractId: form.customerContractId, + carrierContractId: form.carrierContractId, + settlementType: form.settlementType, + }); + historyWaybillRows.value = unwrapData(response) || []; + } catch (error) { + historyWaybillRows.value = []; + ElMessage.error(error?.message || '加载历史运单失败'); + } finally { + historyWaybillLoading.value = false; + } +}; + +const applyHistoryWaybill = waybill => { + const target = historyWaybillTargetRow.value; + if (!target || !waybill) return; + target.waybillNo = waybill.waybillNo || ''; + target.matchedWaybillId = waybill.id; + target.vehicleNo = waybill.vehicleNo || target.vehicleNo; + target.departureAddress = waybill.departureAddress || target.departureAddress; + target.arrivalAddress = waybill.arrivalAddress || target.arrivalAddress; + target.cargoName = waybill.cargoName || target.cargoName; + target.cargoType = waybill.cargoType || target.cargoType; + target.quantity = waybill.quantity ?? target.quantity; + target.quantityUnit = waybill.quantityUnit || target.quantityUnit; + target.model = waybill.model || target.model; + target.mileage = + waybill.mileage === null || waybill.mileage === undefined ? target.mileage : waybill.mileage; + target.actualStartDate = waybill.actualStartDate + ? dayjs(waybill.actualStartDate).format('YYYY-MM-DD') + : target.actualStartDate; + target.actualEndDate = waybill.actualEndDate + ? dayjs(waybill.actualEndDate).format('YYYY-MM-DD') + : target.actualEndDate; + target.driverName = waybill.driverName || target.driverName; + refreshDuplicateFlags(); +}; + +const selectHistoryWaybill = row => { + applyHistoryWaybill(row); + historyWaybillVisible.value = false; +}; + +const confirmHistoryWaybill = () => { + if (!historyWaybillCurrent.value) { + ElMessage.warning('请选择一条运单'); + return; + } + applyHistoryWaybill(historyWaybillCurrent.value); + historyWaybillVisible.value = false; +}; + const downloadFailureExcel = async failureRows => { const response = await api.exportFailures({ feeItemNames: [...feeItemNames.value], @@ -910,7 +1089,7 @@ const saveDraft = async () => { if (batch.id) form.id = batch.id; if (batch.batchNo) form.batchNo = batch.batchNo; ElMessage.success('保存草稿成功'); - goBack(); + leaveAfterConfirm(); } catch (error) { ElMessage.error(error?.message || '保存草稿失败'); } finally { @@ -959,10 +1138,32 @@ const confirmImport = async () => { } }; +const loadTransportTypeOptions = async () => { + try { + const response = await getDictionary({ code: 'transport_type' }); + const list = unwrapData(response) || []; + transportTypeOptions.value = (Array.isArray(list) ? list : []) + .map(item => { + const label = item.dictValue || item.label || item.name || ''; + const value = item.dictValue || item.dictKey || item.value || label; + return label ? { label, value } : null; + }) + .filter(Boolean); + } catch (error) { + transportTypeOptions.value = [ + { label: '公路运输', value: '公路运输' }, + { label: '铁路运输', value: '铁路运输' }, + { label: '水路运输', value: '水路运输' }, + { label: '航空运输', value: '航空运输' }, + ]; + } +}; + const loadOptions = async () => { const response = await api.getOptions(); const options = unwrapData(response) || {}; projects.value = (options.projects || []).map(normalizeProject).filter(Boolean); + await loadTransportTypeOptions(); }; const loadDetail = async id => { @@ -1115,4 +1316,16 @@ onMounted(() => { padding-top: 16px; border-top: 1px solid #eff1f7; } + +.settlement-import-create__waybill-select { + display: flex; + align-items: center; + gap: 8px; +} + +.settlement-import-create__history-tip { + margin-bottom: 8px; + color: #909399; + font-size: 13px; +} diff --git a/src/views/settlement/settlement-import.vue b/src/views/settlement/settlement-import.vue index 6cf0d43..0d4bb95 100644 --- a/src/views/settlement/settlement-import.vue +++ b/src/views/settlement/settlement-import.vue @@ -23,8 +23,8 @@
- 查询 - 重置 + 搜索 + 清空 {{ searchExpanded ? '收起' : '展开' }} @@ -43,6 +43,7 @@ > 新增 + 刷新
@@ -53,6 +54,13 @@ {{ row.batchNo || '-' }} + + +