修复业务模块bug

This commit is contained in:
2026-08-14 14:19:12 +08:00
parent 6bc9981ffc
commit 574b1a52f4
8 changed files with 1035 additions and 254 deletions
File diff suppressed because it is too large Load Diff
@@ -127,7 +127,7 @@
<el-row :gutter="16">
<template v-if="isRoad(route)">
<el-col v-if="route.carrierType === '承运商'" :span="6"><el-form-item label="承运商" required><el-select v-model="route.carrierName" filterable remote clearable placeholder="请选择" :remote-method="loadCarrierOptions" :loading="carrierLoading" @visible-change="visible => visible && loadCarrierOptions()"><el-option v-for="item in carrierOptions" :key="carrierOptionKey(item)" :label="carrierOptionLabel(item)" :value="carrierOptionLabel(item)" /></el-select></el-form-item></el-col>
<el-col :span="6"><el-form-item label="司机" :required="route.carrierType !== '承运商'"><el-select :ref="element => setDriverInput(route.segmentNo, element)" v-model="route.driverName" filterable remote clearable placeholder="请选择" :remote-method="loadDriverOptions" :loading="driverLoading" @visible-change="visible => visible && loadDriverOptions()" @change="value => handleDriverChange(route, value)"><el-option v-for="item in driverOptions" :key="driverOptionKey(item)" :label="driverOptionLabel(item)" :value="driverOptionLabel(item)" /></el-select></el-form-item></el-col>
<el-col :span="6"><el-form-item label="司机" :required="route.carrierType !== '承运商'"><el-autocomplete :ref="element => setDriverInput(route.segmentNo, element)" v-model="route.driverName" :debounce="300" :fetch-suggestions="fetchDriverSuggestions" clearable placeholder="请输入司机" :loading="driverLoading" @select="item => handleDriverSuggestionSelect(route, item)" /></el-form-item></el-col>
<el-col :span="6"><el-form-item :label="route.carrierType === '承运商' ? '手机号' : '司机手机号'" :required="route.carrierType !== '承运商'"><el-input v-model="route.driverPhone" placeholder="请输入" /></el-form-item></el-col>
<el-col :span="6"><el-form-item label="车牌号" required><el-input v-model="route.vehicleNo" placeholder="请输入" /></el-form-item></el-col>
<el-col v-if="route.carrierType !== '承运商'" :span="6"><el-form-item label="挂车车牌号" required><el-input v-model="route.trailerVehicleNo" placeholder="请输入" /></el-form-item></el-col>
@@ -527,7 +527,11 @@ export default {
this.carrierLoading = true;
try {
this.carrierOptions = unwrapRecords(
await getCustomerList(1, 20, { customerName: keyword, customerType: '承运商' })
await getCustomerList(1, 20, {
customerName: keyword,
customerType: '承运商',
status: 1,
})
);
} finally {
this.carrierLoading = false;
@@ -541,6 +545,23 @@ export default {
this.driverLoading = false;
}
},
fetchDriverSuggestions(queryString, callback) {
this.loadDriverOptions(String(queryString || '').trim())
.then(() =>
callback(
this.driverOptions.map(item => ({
...item,
value: this.driverOptionLabel(item),
}))
)
)
.catch(() => callback([]));
},
handleDriverSuggestionSelect(route, item = {}) {
route.driverName = this.driverOptionLabel(item);
route.driverId = item.id || item.driverId || '';
route.driverPhone = item.mobile || item.driverPhone || item.phone || route.driverPhone || '';
},
setDriverInput(segmentNo, element) {
if (element) this.driverInputs[segmentNo] = element;
else delete this.driverInputs[segmentNo];
@@ -137,21 +137,22 @@
label="货物名称"
min-width="130"
><template #default="{ row }"
><el-select
><el-autocomplete
v-model="row.cargoName"
filterable
allow-create
default-first-option
clearable
placeholder="请选择或输入"
placeholder="请输入货物名称"
:debounce="300"
:fetch-suggestions="
(queryString, callback) => fetchCargoSuggestions(queryString, callback, row.cargoTypePath)
"
:loading="isCargoOptionsLoading(row.cargoTypePath)"
@visible-change="visible => visible && loadCargoOptionsByType(row.cargoTypePath)"
@change="selectCargoName(row, $event)"
><el-option
v-for="cargo in getCargoOptionsByType(row.cargoTypePath)"
:key="cargo.id"
:label="cargo.cargoName"
:value="cargo.cargoName" /></el-select
@select="cargo => selectCargoSuggestion(row, cargo)"
><template #default="{ item }">
<div class="master-editor__cargo-autocomplete-item">
<span>{{ item.cargoName || item.name || '' }}</span>
<small v-if="item.cargoCode">{{ item.cargoCode }}</small>
</div>
</template></el-autocomplete
></template></el-table-column
><el-table-column label="货物类型" min-width="130"
><template #default="{ row }"
@@ -1062,6 +1063,45 @@ export default {
this.cargoOptionsLoadingMap = { ...this.cargoOptionsLoadingMap, [key]: false };
}
},
async fetchCargoSuggestions(queryString, callback, path = []) {
const keyword = String(queryString || '').trim();
const cargoType = this.getCargoTypeByPath(path);
const key = this.getCargoOptionsKey(path);
if (!keyword && !cargoType) {
callback([]);
return;
}
if (key) this.cargoOptionsLoadingMap = { ...this.cargoOptionsLoadingMap, [key]: true };
try {
const response = await getCommonCargoList(1, 50, {
allDept: 0,
...(cargoType
? {
secondCargoTypeName: cargoType.label,
secondCargoTypeCode: cargoType.cargoCode || cargoType.code || '',
}
: {}),
...(keyword ? { cargoName: keyword } : {}),
});
const options = this.responseRecords(response);
if (key) this.cargoOptionsMap = { ...this.cargoOptionsMap, [key]: options };
callback(
options.map(item => ({
...item,
value: item.cargoName || item.name || '',
}))
);
} catch (error) {
window.console.log(error);
callback([]);
} finally {
if (key) this.cargoOptionsLoadingMap = { ...this.cargoOptionsLoadingMap, [key]: false };
}
},
selectCargoSuggestion(goods, cargo = {}) {
goods.cargoName = cargo.cargoName || cargo.name || '';
Object.assign(goods, this.normalizeCargoRow(cargo, goods.cargoTypePath));
},
selectCargoName(goods, cargoName) {
if (!cargoName) return;
const cargo = this.getCargoOptionsByType(goods.cargoTypePath).find(