fix bug
This commit is contained in:
@@ -60,16 +60,16 @@
|
||||
</el-button>
|
||||
</template>
|
||||
<template #previousMonthMileage="{ row }">
|
||||
<span>{{ formatMileage(row.previousMonthMileage, row.mileageUnit) }}</span>
|
||||
<span>{{ formatMileage(row.previousMonthMileage) }}</span>
|
||||
</template>
|
||||
<template #currentMonthMileage="{ row }">
|
||||
<span>{{ formatMileage(row.currentMonthMileage, row.mileageUnit) }}</span>
|
||||
<span>{{ formatMileage(row.currentMonthMileage) }}</span>
|
||||
</template>
|
||||
<template #monthlyMileage="{ row }">
|
||||
<span>{{ formatMileage(row.monthlyMileage, row.mileageUnit) }}</span>
|
||||
<span>{{ formatMileage(row.monthlyMileage) }}</span>
|
||||
</template>
|
||||
<template #totalMileage="{ row }">
|
||||
<span>{{ formatMileage(row.totalMileage, row.mileageUnit) }}</span>
|
||||
<span>{{ formatMileage(row.totalMileage) }}</span>
|
||||
</template>
|
||||
<template #vehicleNoForm>
|
||||
<el-autocomplete
|
||||
@@ -77,7 +77,7 @@
|
||||
:fetch-suggestions="fetchVehicleOptions"
|
||||
:disabled="Boolean(form.id)"
|
||||
clearable
|
||||
:placeholder="vehicleNoPlaceholder"
|
||||
placeholder="输入车牌号模糊查询选择"
|
||||
value-key="value"
|
||||
class="mileage-record-page__input"
|
||||
/>
|
||||
@@ -176,7 +176,6 @@
|
||||
<script>
|
||||
import { add, getDetail, getList, remove, update } from '@/api/vehicle/mileage-record';
|
||||
import { getList as getVehicleList } from '@/api/transportCapacity/transport-vehicle';
|
||||
import { getList as getShipList } from '@/api/transportCapacity/transport-ship';
|
||||
import { getDeptTree } from '@/api/system/dept';
|
||||
import { exportBlob } from '@/api/common';
|
||||
import { downloadXls } from '@/utils/util';
|
||||
@@ -234,9 +233,6 @@ export default {
|
||||
editBtn: this.hasPermission('mileage_record_edit'),
|
||||
};
|
||||
},
|
||||
vehicleNoPlaceholder() {
|
||||
return this.form.vehicleType === '船舶' ? '输入船号模糊查询选择' : '输入车牌号模糊查询选择';
|
||||
},
|
||||
ids() {
|
||||
const ids = [];
|
||||
this.selectionList.forEach(ele => {
|
||||
@@ -245,42 +241,10 @@ export default {
|
||||
return ids.join(',');
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
'form.vehicleType': {
|
||||
handler(value) {
|
||||
this.updateVehicleTypeDisplays(value || '车辆');
|
||||
},
|
||||
immediate: true,
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
hasPermission(code) {
|
||||
return this.isAdmin || this.validData(this.permission[code], false);
|
||||
},
|
||||
updateVehicleTypeDisplays(vehicleType) {
|
||||
const isShip = vehicleType === '船舶';
|
||||
const unit = isShip ? '海里' : '公里';
|
||||
const vehicleTypeColumn = this.findColumn(this.option.column, 'vehicleType');
|
||||
const labelMap = {
|
||||
previousMonthMileage: isShip ? '上月统计航程数' : '上月统计里程数',
|
||||
currentMonthMileage: isShip ? '本月统计航程数' : '本月统计里程数',
|
||||
monthlyMileage: isShip ? '本月航行航程数' : '本月行驶里程数',
|
||||
totalMileage: isShip ? '累计航程数' : '累计行驶里程数',
|
||||
totalMileageStart: isShip ? '累计航程' : '累计行驶里程',
|
||||
totalMileageEnd: isShip ? '累计航程数结束值' : '累计行驶里程数结束值',
|
||||
};
|
||||
Object.keys(labelMap).forEach(prop => {
|
||||
const column = this.findColumn(this.option.column, prop);
|
||||
column.label = labelMap[prop];
|
||||
});
|
||||
vehicleTypeColumn.disabled = Boolean(this.form.id);
|
||||
const unitColumn = this.findColumn(this.option.column, 'mileageUnit');
|
||||
unitColumn.value = unit;
|
||||
this.form.mileageUnit = unit;
|
||||
if (!this.form.id && this.form.vehicleNo) {
|
||||
this.form.vehicleNo = '';
|
||||
}
|
||||
},
|
||||
initDeptTree() {
|
||||
getDeptTree(this.userInfo.tenantId).then(res => {
|
||||
const column = this.findColumn(this.option.column, 'createDept');
|
||||
@@ -288,26 +252,18 @@ export default {
|
||||
});
|
||||
},
|
||||
fetchVehicleOptions(queryString, callback) {
|
||||
const vehicleType = this.form.vehicleType || '车辆';
|
||||
const request = vehicleType === '船舶' ? getShipList : getVehicleList;
|
||||
const params =
|
||||
vehicleType === '船舶' ? { shipIdentifierNo: queryString } : { plateNo: queryString };
|
||||
request(1, 20, params)
|
||||
getVehicleList(1, 20, { plateNo: queryString })
|
||||
.then(res => {
|
||||
const records = res.data.data.records || [];
|
||||
callback(
|
||||
records.map(item => ({
|
||||
value: vehicleType === '船舶' ? item.shipIdentifierNo || item.shipName : item.plateNo,
|
||||
}))
|
||||
);
|
||||
callback(records.map(item => ({ value: item.plateNo })));
|
||||
})
|
||||
.catch(() => callback([]));
|
||||
},
|
||||
formatMileage(value, unit) {
|
||||
formatMileage(value) {
|
||||
if (this.isEmpty(value)) {
|
||||
return '';
|
||||
}
|
||||
return `${value} ${unit || '公里'}`;
|
||||
return `${value} 公里`;
|
||||
},
|
||||
formatAttachments(value) {
|
||||
if (!value) return '';
|
||||
@@ -356,13 +312,10 @@ export default {
|
||||
},
|
||||
normalizeRow(row) {
|
||||
const values = { ...row };
|
||||
values.vehicleType = values.vehicleType || '车辆';
|
||||
values.mileageUnit = values.vehicleType === '船舶' ? '海里' : '公里';
|
||||
values.vehicleType = '车辆';
|
||||
values.mileageUnit = '公里';
|
||||
if (values.vehicleNo) {
|
||||
values.vehicleNo =
|
||||
values.vehicleType === '船舶'
|
||||
? values.vehicleNo.trim()
|
||||
: values.vehicleNo.trim().toUpperCase();
|
||||
values.vehicleNo = values.vehicleNo.trim().toUpperCase();
|
||||
}
|
||||
const previousMonthMileage = this.toNumber(values.previousMonthMileage);
|
||||
const currentMonthMileage = this.toNumber(values.currentMonthMileage);
|
||||
@@ -391,12 +344,11 @@ export default {
|
||||
return true;
|
||||
},
|
||||
validateRow(row) {
|
||||
const isShip = row.vehicleType === '船舶';
|
||||
const mileageFields = [
|
||||
['previousMonthMileage', isShip ? '上月统计航程数' : '上月统计里程数'],
|
||||
['currentMonthMileage', isShip ? '本月统计航程数' : '本月统计里程数'],
|
||||
['monthlyMileage', isShip ? '本月航行航程数' : '本月行驶里程数'],
|
||||
['totalMileage', isShip ? '累计航程数' : '累计行驶里程数'],
|
||||
['previousMonthMileage', '上月统计里程数'],
|
||||
['currentMonthMileage', '本月统计里程数'],
|
||||
['monthlyMileage', '本月行驶里程数'],
|
||||
['totalMileage', '累计行驶里程数'],
|
||||
];
|
||||
if (!mileageFields.every(([prop, label]) => this.validateMileage(row[prop], label))) {
|
||||
return false;
|
||||
@@ -411,11 +363,7 @@ export default {
|
||||
monthlyMileage !== null &&
|
||||
this.toMoney(currentMonthMileage - previousMonthMileage) !== this.toMoney(monthlyMileage)
|
||||
) {
|
||||
this.$message.warning(
|
||||
isShip
|
||||
? '本月航行航程数应等于本月统计航程数减去上月统计航程数'
|
||||
: '本月行驶里程数应等于本月统计里程数减去上月统计里程数'
|
||||
);
|
||||
this.$message.warning('本月行驶里程数应等于本月统计里程数减去上月统计里程数');
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
@@ -423,9 +371,7 @@ export default {
|
||||
currentMonthMileage !== null &&
|
||||
totalMileage < currentMonthMileage
|
||||
) {
|
||||
this.$message.warning(
|
||||
isShip ? '累计航程数应大于等于本月统计航程数' : '累计行驶里程数应大于等于本月统计里程数'
|
||||
);
|
||||
this.$message.warning('累计行驶里程数应大于等于本月统计里程数');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -502,16 +448,14 @@ export default {
|
||||
if (type === 'add') {
|
||||
this.form.vehicleType = '车辆';
|
||||
this.form.mileageUnit = '公里';
|
||||
this.updateVehicleTypeDisplays(this.form.vehicleType);
|
||||
}
|
||||
if (['edit', 'view'].includes(type)) {
|
||||
getDetail(this.form.id).then(res => {
|
||||
const detail = res.data.data;
|
||||
detail.attachments = this.parseAttachments(detail.attachments);
|
||||
detail.vehicleType = detail.vehicleType || this.form.vehicleType || '车辆';
|
||||
detail.mileageUnit = detail.vehicleType === '船舶' ? '海里' : '公里';
|
||||
detail.vehicleType = '车辆';
|
||||
detail.mileageUnit = '公里';
|
||||
this.form = detail;
|
||||
this.updateVehicleTypeDisplays(detail.vehicleType);
|
||||
});
|
||||
}
|
||||
done();
|
||||
@@ -591,7 +535,10 @@ export default {
|
||||
};
|
||||
},
|
||||
buildQuery(params = {}) {
|
||||
return normalizeSearchRangeParams({ ...params, ...this.query }, createTimeRangeMap);
|
||||
return normalizeSearchRangeParams(
|
||||
{ ...params, ...this.query, vehicleType: '车辆' },
|
||||
createTimeRangeMap
|
||||
);
|
||||
},
|
||||
handleTemplate() {
|
||||
exportBlob(
|
||||
|
||||
Reference in New Issue
Block a user