✨ 优化港口地图回填、合同展示与运单导入空值
地图选点回填国家省市区;合同选择显示编号/名称;常用数据组织筛选修正;运单详情将-1费用字段显示为空。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -215,7 +215,7 @@
|
||||
<el-option
|
||||
v-for="item in contractOptions"
|
||||
:key="item.id"
|
||||
:label="item.contractName"
|
||||
:label="formatContractOptionLabel(item)"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
@@ -3056,7 +3056,7 @@
|
||||
<el-option
|
||||
v-for="item in transportPlanImportContractOptions"
|
||||
:key="item.id"
|
||||
:label="item.contractName"
|
||||
:label="formatContractOptionLabel(item)"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
@@ -5242,6 +5242,7 @@ import { addressTypeOptions } from '@/option/base/common-address';
|
||||
import { packageOptions } from '@/option/business/common';
|
||||
import { formatUpdateUserName } from '@/utils/audit';
|
||||
import { getToken, isAdministrator } from '@/utils/auth';
|
||||
import { formatContractOptionLabel } from '@/utils/contract';
|
||||
import { openImportDialog } from '@/utils/import-excel';
|
||||
import { normalizeMapSearchResults, searchAmapPlaceText } from '@/utils/map-search';
|
||||
import { loadMeasurementUnitOptions } from '@/utils/measurement-unit';
|
||||
@@ -6590,6 +6591,7 @@ export default {
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
formatContractOptionLabel,
|
||||
initStandaloneFormPage() {
|
||||
if (!this.isStandaloneFormPage) return;
|
||||
const mode = this.$route.query.mode === 'edit' ? 'edit' : 'add';
|
||||
|
||||
@@ -317,6 +317,7 @@
|
||||
<script>
|
||||
import * as api from '@/api/business/master-order';
|
||||
import { fetchDriversByCarrierOrganizations } from '@/utils/carrier-org-resource';
|
||||
import { formatContractOptionLabel } from '@/utils/contract';
|
||||
import { loadMeasurementUnitOptions } from '@/utils/measurement-unit';
|
||||
import { isMobile } from '@/utils/validate';
|
||||
|
||||
@@ -904,9 +905,11 @@ export default {
|
||||
},
|
||||
carrierOptionLabel(item) {
|
||||
const duplicateCount = this.carrierOptions.filter(option => option.carrierName === item.carrierName).length;
|
||||
return duplicateCount > 1
|
||||
? `${item.carrierName}(${item.contractName || item.contractId})`
|
||||
: item.carrierName;
|
||||
if (duplicateCount <= 1) {
|
||||
return item.carrierName;
|
||||
}
|
||||
const contractLabel = formatContractOptionLabel(item);
|
||||
return contractLabel ? `${item.carrierName}(${contractLabel})` : item.carrierName;
|
||||
},
|
||||
driverOptionLabel(item) { return item.driverName || item.name || ''; },
|
||||
driverOptionKey(item) { return item.id || item.driverId || this.driverOptionLabel(item) || item.mobile; },
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
><el-option
|
||||
v-for="contract in contracts"
|
||||
:key="contract.id"
|
||||
:label="contract.contractName"
|
||||
:label="formatContractOptionLabel(contract)"
|
||||
:value="contract.id" /></el-select></el-form-item></el-col
|
||||
><el-col :span="6"
|
||||
><el-form-item label="总单号" required
|
||||
@@ -589,6 +589,7 @@ import { getList as getCargoTypeList } from '@/api/base/cargo-type';
|
||||
import { getLazyTree as getRegionLazyTree } from '@/api/base/region';
|
||||
import { getList as getCommonCargoList } from '@/api/business/common-cargo';
|
||||
import { exportBlob, importBlob } from '@/api/common';
|
||||
import { formatContractOptionLabel } from '@/utils/contract';
|
||||
import { downloadFileByUrl, downloadXls } from '@/utils/util';
|
||||
import { OfficeBuilding, Search } from '@element-plus/icons-vue';
|
||||
import { ElImageViewer } from 'element-plus';
|
||||
@@ -784,6 +785,7 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
formatContractOptionLabel,
|
||||
defaultQuantityUnit() {
|
||||
return this.quantityUnitOptions[0] || '吨';
|
||||
},
|
||||
|
||||
@@ -113,7 +113,7 @@
|
||||
<el-option
|
||||
v-for="item in contractOptions"
|
||||
:key="item.id"
|
||||
:label="item.contractName"
|
||||
:label="formatContractOptionLabel(item)"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
@@ -1098,6 +1098,7 @@ import {
|
||||
import { getDictionary as getSystemDictionary } from '@/api/system/dict';
|
||||
import { getDictionary } from '@/api/system/dictbiz';
|
||||
import { packageOptions } from '@/option/business/common';
|
||||
import { formatContractOptionLabel } from '@/utils/contract';
|
||||
import { loadMeasurementUnitOptions } from '@/utils/measurement-unit';
|
||||
import { normalizeMapSearchResults, searchAmapPlaceText } from '@/utils/map-search';
|
||||
import { downloadFileByUrl, downloadXls } from '@/utils/util';
|
||||
@@ -1533,6 +1534,7 @@ export default {
|
||||
if (this.isStandaloneFormPage) this.$nextTick(() => this.initStandaloneFormPage());
|
||||
},
|
||||
methods: {
|
||||
formatContractOptionLabel,
|
||||
loadQuantityUnitOptions() {
|
||||
if (this.quantityUnitLoading) return this.quantityUnitLoadPromise;
|
||||
this.quantityUnitLoading = true;
|
||||
|
||||
@@ -149,7 +149,7 @@
|
||||
<el-option
|
||||
v-for="item in contractOptions"
|
||||
:key="item.id"
|
||||
:label="item.contractName"
|
||||
:label="formatContractOptionLabel(item)"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
@@ -980,7 +980,7 @@
|
||||
<el-option
|
||||
v-for="item in transportPlanImportContractOptions"
|
||||
:key="item.id"
|
||||
:label="item.contractName"
|
||||
:label="formatContractOptionLabel(item)"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
@@ -2741,6 +2741,7 @@ import { addressTypeOptions } from '@/option/base/common-address';
|
||||
import { packageOptions } from '@/option/business/common';
|
||||
import { formatUpdateUserName } from '@/utils/audit';
|
||||
import { getToken, isAdministrator } from '@/utils/auth';
|
||||
import { formatContractOptionLabel } from '@/utils/contract';
|
||||
import { normalizeMapSearchResults, searchAmapPlaceText } from '@/utils/map-search';
|
||||
import { loadMeasurementUnitOptions } from '@/utils/measurement-unit';
|
||||
import { applyTableMenuWidth } from '@/utils/table-menu';
|
||||
@@ -3721,6 +3722,7 @@ export default {
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
formatContractOptionLabel,
|
||||
initStandaloneFormPage() {
|
||||
if (!this.isStandaloneFormPage) return;
|
||||
const mode = this.$route.query.mode === 'edit' ? 'edit' : 'add';
|
||||
|
||||
@@ -374,7 +374,7 @@
|
||||
<el-option
|
||||
v-for="item in contracts"
|
||||
:key="item.id"
|
||||
:label="item.contractName"
|
||||
:label="formatContractOptionLabel(item)"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
@@ -610,6 +610,7 @@ import { getList as getProjectList } from '@/api/business/project-apply';
|
||||
import { getList as getDriverList } from '@/api/transportCapacity/driver';
|
||||
import { getDictionary } from '@/api/system/dictbiz';
|
||||
import * as api from '@/api/business/waybill-manage';
|
||||
import { formatContractOptionLabel } from '@/utils/contract';
|
||||
import { downloadXls } from '@/utils/util';
|
||||
import SectionCard from '@/components/section-card/main.vue';
|
||||
|
||||
@@ -1297,6 +1298,31 @@ const carrierChange = value => {
|
||||
form.carrierName = item.carrierName || '';
|
||||
if (!isSelfOperated.value) form.carrierContractId = item.carrierContractId || '';
|
||||
};
|
||||
const firstNotEmpty = (...values) => values.find(value => String(value ?? '').trim()) ?? '';
|
||||
const OPTIONAL_NUMBER_EMPTY_SENTINELS = [-1];
|
||||
const normalizeOptionalImportNumber = (value, emptySentinels = OPTIONAL_NUMBER_EMPTY_SENTINELS) => {
|
||||
if (!String(value ?? '').trim()) return null;
|
||||
return emptySentinels.some(sentinel => Number(value) === sentinel) ? null : value;
|
||||
};
|
||||
const normalizeImportRow = row => ({
|
||||
...row,
|
||||
mileage: normalizeOptionalImportNumber(
|
||||
firstNotEmpty(row.mileage, row['里程'], row['里程(km)'], row['里程(公里)'])
|
||||
),
|
||||
otherFeeTotal: normalizeOptionalImportNumber(
|
||||
firstNotEmpty(row.otherFeeTotal, row['其他费用合计'])
|
||||
),
|
||||
unitPrice: normalizeOptionalImportNumber(firstNotEmpty(row.unitPrice, row['单价'])),
|
||||
freight: normalizeOptionalImportNumber(firstNotEmpty(row.freight, row['运费'])),
|
||||
freightTotal: normalizeOptionalImportNumber(firstNotEmpty(row.freightTotal, row['运费合计'])),
|
||||
transportType: firstNotEmpty(
|
||||
row.transportType,
|
||||
row['运输类型'],
|
||||
row['*运输类型'],
|
||||
row['运输方式'],
|
||||
row['*运输方式']
|
||||
),
|
||||
});
|
||||
const fileChange = async (file, list) => {
|
||||
if (!projectInfoReady.value) {
|
||||
ElMessage.warning('请先选择项目、客户合同和承运信息,再导入运单明细');
|
||||
@@ -1370,6 +1396,9 @@ const fileChange = async (file, list) => {
|
||||
item[key] ??
|
||||
'';
|
||||
});
|
||||
['mileage', 'unitPrice', 'freight', 'otherFeeTotal', 'freightTotal'].forEach(prop => {
|
||||
row[prop] = normalizeOptionalImportNumber(row[prop]);
|
||||
});
|
||||
row.actualStartDate = normalizeImportDate(row.actualStartDate);
|
||||
row.actualEndDate = normalizeImportDate(row.actualEndDate);
|
||||
row.planStartDate = normalizeImportDate(row.planStartDate);
|
||||
@@ -1656,31 +1685,6 @@ const removeSelectedRows = () => {
|
||||
rowSelection.value = [];
|
||||
refreshDuplicateFlags();
|
||||
};
|
||||
const firstNotEmpty = (...values) => values.find(value => String(value ?? '').trim()) ?? '';
|
||||
const normalizeOptionalImportNumber = (value, emptySentinels = []) => {
|
||||
if (!String(value ?? '').trim()) return null;
|
||||
return emptySentinels.some(sentinel => Number(value) === sentinel) ? null : value;
|
||||
};
|
||||
const normalizeImportRow = row => ({
|
||||
...row,
|
||||
mileage: normalizeOptionalImportNumber(
|
||||
firstNotEmpty(row.mileage, row['里程'], row['里程(km)'], row['里程(公里)']),
|
||||
[-1]
|
||||
),
|
||||
otherFeeTotal: normalizeOptionalImportNumber(
|
||||
firstNotEmpty(row.otherFeeTotal, row['其他费用合计'])
|
||||
),
|
||||
unitPrice: normalizeOptionalImportNumber(firstNotEmpty(row.unitPrice, row['单价'])),
|
||||
freight: normalizeOptionalImportNumber(firstNotEmpty(row.freight, row['运费'])),
|
||||
freightTotal: normalizeOptionalImportNumber(firstNotEmpty(row.freightTotal, row['运费合计'])),
|
||||
transportType: firstNotEmpty(
|
||||
row.transportType,
|
||||
row['运输类型'],
|
||||
row['*运输类型'],
|
||||
row['运输方式'],
|
||||
row['*运输方式']
|
||||
),
|
||||
});
|
||||
const normalizeOptionalPlanId = value => {
|
||||
if (value === undefined || value === null || value === '') return null;
|
||||
return Number(value) === -1 || Number(value) <= 0 ? null : value;
|
||||
|
||||
@@ -212,7 +212,7 @@
|
||||
<el-option
|
||||
v-for="item in contractOptions"
|
||||
:key="item.id"
|
||||
:label="item.contractName"
|
||||
:label="formatContractOptionLabel(item)"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
@@ -3642,6 +3642,7 @@ import { addressTypeOptions } from '@/option/base/common-address';
|
||||
import { packageOptions } from '@/option/business/common';
|
||||
import { formatUpdateUserName } from '@/utils/audit';
|
||||
import { getToken, isAdministrator } from '@/utils/auth';
|
||||
import { formatContractOptionLabel } from '@/utils/contract';
|
||||
import { wgs84ToGcj02 } from '@/utils/coordinate';
|
||||
import { openImportDialog } from '@/utils/import-excel';
|
||||
import { normalizeMapSearchResults, searchAmapPlaceText } from '@/utils/map-search';
|
||||
@@ -4724,6 +4725,7 @@ export default {
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
formatContractOptionLabel,
|
||||
// 页面被 keep-alive 缓存/卸载时调用,关闭本页所有 append-to-body 的弹窗,
|
||||
// 避免 Teleport 出去的 DOM 残留在 body 上盖住后续页面(详见 data 里的说明)。
|
||||
closeInnerDialogs() {
|
||||
@@ -6958,9 +6960,11 @@ export default {
|
||||
applyFormDetail(row) {
|
||||
this.suppressTransportTypeClear = true;
|
||||
this.form = { ...(row || {}) };
|
||||
['quantity', 'mileage', 'unitPrice'].forEach(prop => {
|
||||
if (Number(this.form[prop]) === -1) this.form[prop] = '';
|
||||
});
|
||||
['quantity', 'mileage', 'unitPrice', 'otherFeeTotal', 'freight', 'freightTotal'].forEach(
|
||||
prop => {
|
||||
if (this.isSentinelMinusOne(this.form[prop])) this.form[prop] = '';
|
||||
}
|
||||
);
|
||||
if ([this.form.planId, this.form.planName].some(value => Number(value) === -1)) {
|
||||
this.form.planId = '';
|
||||
this.form.planName = '';
|
||||
@@ -7371,17 +7375,17 @@ export default {
|
||||
this.form.quantityUnit || taskInfo.quantityUnit || goodsInfo.quantityUnit || '吨';
|
||||
const mileage = this.form.mileage || taskInfo.mileage || goodsInfo.mileage || '';
|
||||
this.form.mileage = this.normalizeMileageValue(mileage);
|
||||
this.form.unitPrice = this.form.unitPrice || taskInfo.unitPrice || goodsInfo.unitPrice || '';
|
||||
this.form.unitPrice = this.normalizeOptionalAmount(
|
||||
this.form.unitPrice || taskInfo.unitPrice || goodsInfo.unitPrice || ''
|
||||
);
|
||||
['quantity', 'mileage', 'unitPrice'].forEach(prop => {
|
||||
if (Number(this.form[prop]) === -1) this.form[prop] = '';
|
||||
if (this.isSentinelMinusOne(this.form[prop])) this.form[prop] = '';
|
||||
});
|
||||
this.form.priceUnit =
|
||||
this.form.priceUnit || taskInfo.priceUnit || goodsInfo.priceUnit || '元/吨';
|
||||
this.form.otherFeeTotal =
|
||||
this.form.otherFeeTotal || taskInfo.otherFeeTotal || goodsInfo.otherFeeTotal || '';
|
||||
if (Number(this.form.otherFeeTotal) === -1) {
|
||||
this.form.otherFeeTotal = '';
|
||||
}
|
||||
this.form.otherFeeTotal = this.normalizeOptionalAmount(
|
||||
this.form.otherFeeTotal || taskInfo.otherFeeTotal || goodsInfo.otherFeeTotal || ''
|
||||
);
|
||||
this.form.estimatedStartTime =
|
||||
this.form.estimatedStartTime ||
|
||||
taskInfo.estimatedStartTime ||
|
||||
@@ -7463,7 +7467,7 @@ export default {
|
||||
},
|
||||
taskFullFreightGroupUnitPrice(group = {}) {
|
||||
const prices = (group.rows || [])
|
||||
.map(cargo => String(cargo.unitPrice ?? '').trim())
|
||||
.map(cargo => this.normalizeOptionalAmount(cargo.unitPrice))
|
||||
.filter(Boolean);
|
||||
if (!prices.length || prices.some(price => price !== prices[0])) return '';
|
||||
return prices[0];
|
||||
@@ -7526,10 +7530,21 @@ export default {
|
||||
},
|
||||
formatTaskFullFreightNumber(value) {
|
||||
if (value === undefined || value === null || String(value).trim() === '') return '';
|
||||
const number = Number(value || 0);
|
||||
if (this.isSentinelMinusOne(value)) return '';
|
||||
const number = Number(value);
|
||||
if (!Number.isFinite(number)) return '';
|
||||
return Number(number.toFixed(2)).toString();
|
||||
},
|
||||
isSentinelMinusOne(value) {
|
||||
if (value === undefined || value === null || value === '') return false;
|
||||
return Number(value) === -1 || String(value).trim() === '-1';
|
||||
},
|
||||
normalizeOptionalAmount(value) {
|
||||
if (value === undefined || value === null || value === '' || this.isSentinelMinusOne(value)) {
|
||||
return '';
|
||||
}
|
||||
return value;
|
||||
},
|
||||
handleTaskCarrierTypeChange(value) {
|
||||
const nextValue = value || '承运商';
|
||||
this.form.carrierName = '';
|
||||
@@ -8082,7 +8097,9 @@ export default {
|
||||
}
|
||||
cargo.priceUnit = cargo.priceUnit || this.form.priceUnit || '元/吨';
|
||||
if (this.isBillingFieldEmpty(cargo.freightAmount)) {
|
||||
cargo.freightAmount = freightItems[index]?.freightAmount ?? '';
|
||||
cargo.freightAmount = this.normalizeOptionalAmount(
|
||||
freightItems[index]?.freightAmount ?? ''
|
||||
);
|
||||
}
|
||||
return cargo;
|
||||
});
|
||||
@@ -8274,8 +8291,10 @@ export default {
|
||||
},
|
||||
syncTaskInfoToRow(row) {
|
||||
row.taskEntryMode = row.taskEntryMode || 'simple';
|
||||
['quantity', 'mileage', 'unitPrice'].forEach(prop => {
|
||||
if (this.isBillingFieldEmpty(row[prop]) || Number(row[prop]) === -1) row[prop] = '';
|
||||
['quantity', 'mileage', 'unitPrice', 'otherFeeTotal'].forEach(prop => {
|
||||
if (this.isBillingFieldEmpty(row[prop]) || this.isSentinelMinusOne(row[prop])) {
|
||||
row[prop] = '';
|
||||
}
|
||||
});
|
||||
const taskInfo = {
|
||||
taskEntryMode: row.taskEntryMode,
|
||||
@@ -8300,7 +8319,7 @@ export default {
|
||||
priceUnit: row.priceUnit,
|
||||
taskRemark: row.taskRemark,
|
||||
};
|
||||
if (!this.isBillingFieldEmpty(row.otherFeeTotal) && Number(row.otherFeeTotal) !== -1) {
|
||||
if (!this.isBillingFieldEmpty(row.otherFeeTotal) && !this.isSentinelMinusOne(row.otherFeeTotal)) {
|
||||
taskInfo.otherFeeTotal = row.otherFeeTotal;
|
||||
} else {
|
||||
delete row.otherFeeTotal;
|
||||
@@ -8434,10 +8453,12 @@ export default {
|
||||
cargoName: row.cargoName || row.goodsName || '',
|
||||
packageType: row.packageType || row.package || '',
|
||||
specification: row.specification || row.spec || '',
|
||||
freightAmount: row.freightAmount ?? row.amount ?? row.totalAmount ?? '',
|
||||
freightAmount: this.normalizeOptionalAmount(
|
||||
row.freightAmount ?? row.amount ?? row.totalAmount ?? ''
|
||||
),
|
||||
};
|
||||
['quantity', 'mileage', 'unitPrice'].forEach(prop => {
|
||||
if (Number(cargo[prop]) === -1) cargo[prop] = '';
|
||||
['quantity', 'mileage', 'unitPrice', 'freightAmount'].forEach(prop => {
|
||||
if (this.isSentinelMinusOne(cargo[prop])) cargo[prop] = '';
|
||||
});
|
||||
return cargo;
|
||||
},
|
||||
@@ -8680,7 +8701,12 @@ export default {
|
||||
}
|
||||
},
|
||||
isBillingFieldEmpty(value) {
|
||||
return value === undefined || value === null || String(value).trim() === '';
|
||||
return (
|
||||
value === undefined ||
|
||||
value === null ||
|
||||
String(value).trim() === '' ||
|
||||
this.isSentinelMinusOne(value)
|
||||
);
|
||||
},
|
||||
ensureTransportTypeBeforeAddress() {
|
||||
if (!this.shippingInfoFormEnabled || !this.isBillingFieldEmpty(this.form.transportType)) {
|
||||
|
||||
Reference in New Issue
Block a user