调整 合同、运力、基础配置、客商

This commit is contained in:
2026-09-14 23:43:20 +08:00
parent f1e2313e4c
commit 79aa4f9fae
33 changed files with 1490 additions and 395 deletions
+75 -23
View File
@@ -60,15 +60,44 @@
</el-button>
</template>
<template #vehicleNoForm>
<el-autocomplete
<el-select
v-model="form.vehicleNo"
:fetch-suggestions="fetchVehicleOptions"
:disabled="boxType === 'view'"
clearable
:loading="vehicleOptionsLoading"
:placeholder="vehicleNoPlaceholder"
value-key="value"
class="maintenance-record-page__input"
/>
clearable
filterable
remote
:remote-method="loadVehicleOptions"
@visible-change="handleVehicleSelectVisible"
>
<el-option
v-for="item in vehicleOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</template>
<template #vehicleNo-form>
<el-select
v-model="form.vehicleNo"
:disabled="boxType === 'view'"
:loading="vehicleOptionsLoading"
:placeholder="vehicleNoPlaceholder"
clearable
filterable
remote
:remote-method="loadVehicleOptions"
@visible-change="handleVehicleSelectVisible"
>
<el-option
v-for="item in vehicleOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</template>
<template #address-form>
<el-input
@@ -197,6 +226,9 @@ export default {
},
selectionList: [],
boxType: '',
vehicleOptions: [],
vehicleOptionsLoading: false,
vehicleOptionsRequestId: 0,
option: {
height: 'auto',
calcHeight: 32,
@@ -237,15 +269,17 @@ export default {
{
label: '车牌号/船号',
prop: 'vehicleNo',
type: 'select',
slot: true,
formslot: true,
search: true,
searchType: 'input',
minWidth: 130,
span: 12,
placeholder: '输入车牌号/船号查询选择',
placeholder: '请选择车牌号/船号',
rules: [
{ required: true, message: '请输入车牌号/船号', trigger: 'blur' },
{ max: 30, message: '最多 30 个字符', trigger: 'blur' },
{ required: true, message: '请选择车牌号/船号', trigger: 'change' },
{ max: 30, message: '最多 30 个字符', trigger: 'change' },
],
},
{
@@ -487,7 +521,7 @@ export default {
};
},
vehicleNoPlaceholder() {
return this.form.vehicleType === '船舶' ? '输入船号模糊查询选择' : '输入车牌号模糊查询选择';
return this.form.vehicleType === '船舶' ? '请选择船号' : '请选择车牌号';
},
ids() {
let ids = [];
@@ -524,30 +558,44 @@ export default {
const mileageColumn = this.findColumn(this.option.column, 'mileage');
const mileageUnitColumn = this.findColumn(this.option.column, 'mileageUnit');
vehicleNoColumn.placeholder =
vehicleType === '船舶' ? '输入船号模糊查询选择' : '输入车牌号模糊查询选择';
vehicleType === '船舶' ? '请选择船号' : '请选择车牌号';
vehicleTypeColumn.disabled = Boolean(this.form.id);
mileageColumn.label = `里程/航程数(${mileageUnit}`;
mileageUnitColumn.value = mileageUnit;
this.form.mileageUnit = mileageUnit;
if (!this.isDetailLoading && oldValue && vehicleType !== oldValue && this.form.vehicleNo) {
if (!this.isDetailLoading && oldValue && vehicleType !== oldValue) {
this.form.vehicleNo = '';
this.vehicleOptions = [];
this.loadVehicleOptions('');
}
},
fetchVehicleOptions(queryString, callback) {
handleVehicleSelectVisible(visible) {
if (visible && !this.vehicleOptions.length) this.loadVehicleOptions('');
},
loadVehicleOptions(queryString = '') {
const vehicleType = this.form.vehicleType || '车辆';
const request = vehicleType === '船舶' ? getShipList : getVehicleList;
const params =
vehicleType === '船舶' ? { shipIdentifierNo: queryString } : { plateNo: queryString };
const isShip = vehicleType === '船舶';
const request = isShip ? getShipList : getVehicleList;
const params = isShip ? { shipIdentifierNo: queryString } : { plateNo: queryString };
const requestId = ++this.vehicleOptionsRequestId;
this.vehicleOptionsLoading = true;
request(1, 20, params)
.then(res => {
const records = res.data.data.records || [];
callback(
records.map(item => ({
value: vehicleType === '船舶' ? item.shipIdentifierNo || item.shipName : item.plateNo,
}))
);
if (requestId !== this.vehicleOptionsRequestId) return;
const values = (res.data.data.records || [])
.map(item => (isShip ? item.shipIdentifierNo || item.shipName : item.plateNo))
.filter(Boolean);
this.vehicleOptions = [...new Set(values)].map(value => ({ label: value, value }));
if (this.form.vehicleNo && !this.vehicleOptions.some(item => item.value === this.form.vehicleNo)) {
this.vehicleOptions.unshift({ label: this.form.vehicleNo, value: this.form.vehicleNo });
}
})
.catch(() => callback([]));
.catch(() => {
if (requestId === this.vehicleOptionsRequestId) this.vehicleOptions = [];
})
.finally(() => {
if (requestId === this.vehicleOptionsRequestId) this.vehicleOptionsLoading = false;
});
},
formatMileage(value, unit) {
if (this.normalizeMileageValue(value) === null) return '';
@@ -681,6 +729,8 @@ export default {
mileageUnit: '公里',
};
this.updateVehicleType('车辆');
this.vehicleOptions = [];
this.loadVehicleOptions('');
}
if (['edit', 'view'].includes(type)) {
this.isDetailLoading = true;
@@ -693,6 +743,8 @@ export default {
detail.mileage = this.normalizeMileageValue(detail.mileage);
this.form = detail;
this.updateVehicleType(detail.vehicleType);
this.vehicleOptions = [];
this.loadVehicleOptions(detail.vehicleNo || '');
})
.finally(() => {
this.isDetailLoading = false;