调整 合同、运力、基础配置、客商
This commit is contained in:
@@ -67,15 +67,44 @@
|
||||
</el-radio-group>
|
||||
</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-plan-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
|
||||
@@ -223,6 +252,9 @@ export default {
|
||||
},
|
||||
selectionList: [],
|
||||
boxType: '',
|
||||
vehicleOptions: [],
|
||||
vehicleOptionsLoading: false,
|
||||
vehicleOptionsRequestId: 0,
|
||||
option: {
|
||||
height: 'auto',
|
||||
calcHeight: 32,
|
||||
@@ -264,14 +296,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' },
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -513,7 +548,7 @@ export default {
|
||||
};
|
||||
},
|
||||
vehicleNoPlaceholder() {
|
||||
return this.form.vehicleType === '船舶' ? '输入船号模糊查询选择' : '输入车牌号模糊查询选择';
|
||||
return this.form.vehicleType === '船舶' ? '请选择船号' : '请选择车牌号';
|
||||
},
|
||||
ids() {
|
||||
let ids = [];
|
||||
@@ -537,9 +572,11 @@ export default {
|
||||
},
|
||||
handleVehicleTypeChange(vehicleType) {
|
||||
this.updateVehicleType(vehicleType);
|
||||
if (!this.form.id && this.form.vehicleNo) {
|
||||
if (!this.form.id) {
|
||||
this.form.vehicleNo = '';
|
||||
}
|
||||
this.vehicleOptions = [];
|
||||
this.loadVehicleOptions('');
|
||||
},
|
||||
updateVehicleType(vehicleType) {
|
||||
const mileageUnit = vehicleType === '船舶' ? '海里' : '公里';
|
||||
@@ -554,21 +591,33 @@ export default {
|
||||
mileageUnitColumn.value = mileageUnit;
|
||||
this.form.mileageUnit = mileageUnit;
|
||||
},
|
||||
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 (value === undefined || value === null || value === '') return '';
|
||||
@@ -724,6 +773,8 @@ export default {
|
||||
this.form.vehicleType = '车辆';
|
||||
this.form.mileageUnit = '公里';
|
||||
this.updateVehicleType(this.form.vehicleType);
|
||||
this.vehicleOptions = [];
|
||||
this.loadVehicleOptions('');
|
||||
}
|
||||
if (['edit', 'view'].includes(type)) {
|
||||
getDetail(this.form.id).then(res => {
|
||||
@@ -739,6 +790,8 @@ export default {
|
||||
}
|
||||
this.form = detail;
|
||||
this.updateVehicleType(detail.vehicleType);
|
||||
this.vehicleOptions = [];
|
||||
this.loadVehicleOptions(detail.vehicleNo || '');
|
||||
});
|
||||
}
|
||||
done();
|
||||
|
||||
Reference in New Issue
Block a user