✨ 完善导入结算单明细编辑、草稿刷新与历史运单选择
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -122,7 +122,7 @@
|
||||
</div>
|
||||
<div>
|
||||
历史运单:按 项目+车号+运输完成日期+客户+承运商+起运地+目的地+货物名称
|
||||
匹配已有运单(命中 1 条自动绑定,多条需手工指定运单号);提交时生成应收/应付明细与预/正式结算单,费用按导入单据,不新建运单
|
||||
匹配尚未生成应收/应付的运单(命中 1 条自动绑定,多条可点「选择」弹窗挑选);提交时生成应收/应付明细与预/正式结算单,费用按导入单据,不新建运单
|
||||
</div>
|
||||
</template>
|
||||
<el-icon class="settlement-import-create__label-tip"><QuestionFilled /></el-icon>
|
||||
@@ -220,8 +220,32 @@
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="请选择"
|
||||
/>
|
||||
<el-select
|
||||
v-else-if="column.editor === 'select' && column.prop === 'transportType'"
|
||||
v-model="row[column.prop]"
|
||||
clearable
|
||||
filterable
|
||||
placeholder="请选择运输方式"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in transportTypeOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
<div
|
||||
v-else-if="column.editor === 'waybillSelect'"
|
||||
class="settlement-import-create__waybill-select"
|
||||
>
|
||||
<el-input v-model="row.waybillNo" clearable placeholder="运单号" />
|
||||
<el-link type="primary" :underline="false" @click="openHistoryWaybillDialog(row)">
|
||||
选择
|
||||
</el-link>
|
||||
</div>
|
||||
<el-input
|
||||
v-else-if="column.editor === 'number'"
|
||||
v-else-if="column.editor === 'number' || column.editor === 'optionalNumber'"
|
||||
:model-value="resolveCellValue(row, column)"
|
||||
inputmode="decimal"
|
||||
:placeholder="`请输入${column.label}`"
|
||||
@@ -233,6 +257,14 @@
|
||||
:placeholder="`请输入${column.label}`"
|
||||
/>
|
||||
</template>
|
||||
<template v-else-if="column.editor === 'waybillSelect' && !readonly">
|
||||
<div class="settlement-import-create__waybill-select">
|
||||
<span>{{ row.waybillNo || '-' }}</span>
|
||||
<el-link type="primary" :underline="false" @click="openHistoryWaybillDialog(row)">
|
||||
选择
|
||||
</el-link>
|
||||
</div>
|
||||
</template>
|
||||
<span v-else>{{ formatCell(row, column) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -268,6 +300,41 @@
|
||||
确认导入
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<el-dialog
|
||||
v-model="historyWaybillVisible"
|
||||
title="选择历史运单"
|
||||
width="960px"
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
>
|
||||
<div class="settlement-import-create__history-tip">
|
||||
仅展示相同项目、客户合同、承运商合同下,尚未生成当前结算类型应收/应付明细的运单
|
||||
</div>
|
||||
<el-table
|
||||
v-loading="historyWaybillLoading"
|
||||
:data="historyWaybillRows"
|
||||
border
|
||||
max-height="420"
|
||||
highlight-current-row
|
||||
@row-dblclick="selectHistoryWaybill"
|
||||
@current-change="row => (historyWaybillCurrent = row)"
|
||||
>
|
||||
<el-table-column prop="waybillNo" label="运单号" min-width="140" />
|
||||
<el-table-column prop="vehicleNo" label="车号" min-width="120" />
|
||||
<el-table-column prop="departureAddress" label="起运地" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="arrivalAddress" label="目的地" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="cargoName" label="货物名称" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="actualEndDate" label="完成日期" min-width="120" />
|
||||
<el-table-column prop="quantity" label="数量" width="90" />
|
||||
<el-table-column prop="quantityUnit" label="数量单位" width="90" />
|
||||
<el-table-column prop="mileage" label="里程" width="90" />
|
||||
</el-table>
|
||||
<template #footer>
|
||||
<el-button @click="historyWaybillVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="confirmHistoryWaybill">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user