This commit is contained in:
2026-08-27 12:54:17 +08:00
parent 2c08d0c362
commit 3a262216c7
14 changed files with 181 additions and 143 deletions
+61 -13
View File
@@ -51,15 +51,33 @@
row.vehicleNo
}}</el-link>
</template>
<template #vehicleTypeForm>
<span v-if="boxType === 'view'">{{ form.vehicleType || '' }}</span>
<el-radio-group v-else v-model="form.vehicleType" @change="handleVehicleTypeChange">
<el-radio value="车辆">车辆</el-radio>
<el-radio value="船舶">船舶</el-radio>
</el-radio-group>
</template>
<template #vehicleNoForm>
<el-autocomplete
<el-select
v-model="form.vehicleNo"
:disabled="boxType === 'view'"
:fetch-suggestions="fetchVehicleOptions"
:loading="vehicleOptionsLoading"
:placeholder="vehicleNoPlaceholder"
clearable
value-key="value"
/>
filterable
remote
:remote-method="loadVehicleOptions"
class="equipment-ledger-page__vehicle-select"
@visible-change="handleVehicleSelectVisible"
>
<el-option
v-for="item in vehicleOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</template>
<template #equipmentCodeForm>
<el-input v-model="form.equipmentCode" disabled />
@@ -68,10 +86,10 @@
<span>{{ formatAttachments(row.attachments) }}</span>
</template>
<template #attachmentsForm>
<vehicle-attachment-upload v-model="form.attachments" :readonly="boxType === 'view'" />
<vehicle-attachment-table v-model="form.attachments" :readonly="boxType === 'view'" />
</template>
<template #attachments-form>
<vehicle-attachment-upload v-model="form.attachments" :readonly="boxType === 'view'" />
<vehicle-attachment-table v-model="form.attachments" :readonly="boxType === 'view'" />
</template>
</avue-crud>
<empty-pagination
@@ -107,12 +125,16 @@ import { getDictionary } from '@/api/system/dictbiz';
import { getToken } from '@/utils/auth';
import { openImportDialog } from '@/utils/import-excel';
import { downloadXls } from '@/utils/util';
import VehicleAttachmentTable from '@/components/vehicle-attachment-table/main.vue';
import { mapGetters } from 'vuex';
import { excelOption, option } from '@/option/vehicle/equipment-ledger';
import NProgress from 'nprogress';
import 'nprogress/nprogress.css';
export default {
components: {
VehicleAttachmentTable,
},
data() {
return {
form: {},
@@ -121,6 +143,9 @@ export default {
excelBox: false,
excelForm: {},
boxType: '',
vehicleOptions: [],
vehicleOptionsLoading: false,
vehicleOptionsRequestId: 0,
option,
excelOption,
data: [],
@@ -171,19 +196,34 @@ export default {
);
});
},
fetchVehicleOptions(queryString, callback) {
handleVehicleTypeChange() {
this.form.vehicleNo = '';
this.vehicleOptions = [];
this.loadVehicleOptions('');
},
handleVehicleSelectVisible(visible) {
if (visible && !this.vehicleOptions.length) this.loadVehicleOptions('');
},
loadVehicleOptions(queryString = '') {
const isShip = this.form.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 => {
callback(
(res.data.data.records || []).map(item => ({
value: isShip ? item.shipIdentifierNo || item.shipName : item.plateNo,
}))
);
if (requestId !== this.vehicleOptionsRequestId) return;
const values = (res.data.data.records || [])
.map(item => (isShip ? item.shipIdentifierNo : item.plateNo))
.filter(Boolean);
this.vehicleOptions = [...new Set(values)].map(value => ({ label: value, value }));
})
.catch(() => callback([]));
.catch(() => {
if (requestId === this.vehicleOptionsRequestId) this.vehicleOptions = [];
})
.finally(() => {
if (requestId === this.vehicleOptionsRequestId) this.vehicleOptionsLoading = false;
});
},
formatAttachments(value) {
if (!value) return '';
@@ -254,6 +294,8 @@ export default {
if (type === 'add') {
getNextEquipmentCode().then(res => {
this.form = { vehicleType: '车辆', equipmentCode: res.data.data };
this.vehicleOptions = [];
this.loadVehicleOptions('');
done();
});
return;
@@ -264,6 +306,8 @@ export default {
...res.data.data,
attachments: this.parseAttachments(res.data.data.attachments),
};
this.vehicleOptions = [];
this.loadVehicleOptions(this.form.vehicleNo || '');
done();
});
return;
@@ -335,6 +379,10 @@ export default {
<style lang="scss" scoped>
.equipment-ledger-page {
&__vehicle-select {
width: 100%;
}
:deep(.el-table th .cell),
:deep(.el-table td .cell) {
white-space: nowrap;