6067d24e3b
Co-authored-by: Cursor <cursoragent@cursor.com>
707 lines
23 KiB
Vue
707 lines
23 KiB
Vue
<template>
|
|
<basic-container class="violation-record-page">
|
|
<avue-crud
|
|
:option="option"
|
|
:table-loading="loading"
|
|
:data="data"
|
|
v-model:page="page"
|
|
:permission="permissionList"
|
|
:before-open="beforeOpen"
|
|
v-model="form"
|
|
ref="crud"
|
|
@row-update="rowUpdate"
|
|
@row-save="rowSave"
|
|
@row-del="rowDel"
|
|
@search-change="searchChange"
|
|
@search-reset="searchReset"
|
|
@selection-change="selectionChange"
|
|
@current-change="currentChange"
|
|
@size-change="sizeChange"
|
|
@refresh-change="refreshChange"
|
|
@on-load="onLoad"
|
|
>
|
|
<template #menu-left>
|
|
<el-button
|
|
type="primary"
|
|
icon="el-icon-upload"
|
|
plain
|
|
v-if="hasPermission('violation_record_import')"
|
|
@click="handleImport"
|
|
>批量导入
|
|
</el-button>
|
|
<el-button
|
|
type="primary"
|
|
icon="el-icon-download"
|
|
plain
|
|
v-if="hasPermission('violation_record_template')"
|
|
@click="handleTemplate"
|
|
>下载模板
|
|
</el-button>
|
|
<el-button
|
|
type="primary"
|
|
icon="el-icon-download"
|
|
plain
|
|
v-if="hasPermission('violation_record_export')"
|
|
@click="handleExport"
|
|
>批量导出
|
|
</el-button>
|
|
<el-button
|
|
type="danger"
|
|
icon="el-icon-delete"
|
|
plain
|
|
v-if="hasPermission('violation_record_delete')"
|
|
@click="handleDelete"
|
|
>批量删除
|
|
</el-button>
|
|
</template>
|
|
<template #vehicleNo="{ row, index }">
|
|
<el-button type="primary" link @click="$refs.crud.rowView(row, index)">
|
|
{{ row.vehicleNo }}
|
|
</el-button>
|
|
</template>
|
|
<template #vehicleNoForm>
|
|
<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 #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 #driverNameForm>
|
|
<el-autocomplete
|
|
v-if="form.vehicleType !== '船舶'"
|
|
v-model="form.driverName"
|
|
:fetch-suggestions="fetchDriverOptions"
|
|
:disabled="boxType === 'view'"
|
|
clearable
|
|
placeholder="输入驾驶人模糊查询选择"
|
|
value-key="value"
|
|
class="violation-record-page__input"
|
|
/>
|
|
<el-input
|
|
v-else
|
|
v-model="form.driverName"
|
|
:disabled="boxType === 'view'"
|
|
clearable
|
|
maxlength="20"
|
|
placeholder="请输入船长"
|
|
/>
|
|
</template>
|
|
<template #fineAmountForm>
|
|
<el-input
|
|
v-model="form.fineAmount"
|
|
:disabled="boxType === 'view'"
|
|
inputmode="decimal"
|
|
placeholder="请输入"
|
|
@input="value => normalizeDecimalInput('fineAmount', value)"
|
|
>
|
|
<template #append>元</template>
|
|
</el-input>
|
|
</template>
|
|
<template #deductPointsForm>
|
|
<el-input
|
|
v-model="form.deductPoints"
|
|
:disabled="boxType === 'view'"
|
|
inputmode="numeric"
|
|
placeholder="请输入"
|
|
@input="value => normalizeIntegerInput('deductPoints', value)"
|
|
/>
|
|
</template>
|
|
<template #location-form>
|
|
<el-input
|
|
v-model="form.location"
|
|
:disabled="boxType === 'view'"
|
|
readonly
|
|
placeholder="点击地图选址"
|
|
@click="openLocationMapPicker"
|
|
/>
|
|
</template>
|
|
<template #processStatus="{ row }">
|
|
<span :class="row.processStatus === '未处理' ? 'violation-record-page__danger' : ''">
|
|
{{ row.processStatus }}
|
|
</span>
|
|
</template>
|
|
<template #attachments="{ row }">
|
|
<span>{{ formatAttachments(row.attachments) }}</span>
|
|
</template>
|
|
<template #attachmentsForm>
|
|
<vehicle-attachment-table v-model="form.attachments" :readonly="boxType === 'view'" />
|
|
</template>
|
|
<template #attachments-form>
|
|
<vehicle-attachment-table v-model="form.attachments" :readonly="boxType === 'view'" />
|
|
</template>
|
|
</avue-crud>
|
|
<empty-pagination
|
|
:page="page"
|
|
@size-change="sizeChange"
|
|
@current-change="currentChange"
|
|
@load="onLoad(page, query)"
|
|
/>
|
|
<el-dialog title="违章记录数据导入" append-to-body v-model="excelBox" width="555px">
|
|
<avue-form :option="excelOption" v-model="excelForm">
|
|
<template #excelTemplate>
|
|
<el-button type="primary" @click="handleTemplate">
|
|
点击下载<i class="el-icon-download el-icon--right"></i>
|
|
</el-button>
|
|
</template>
|
|
</avue-form>
|
|
</el-dialog>
|
|
<address-map-picker
|
|
v-model="locationMapPickerVisible"
|
|
:address="form.location"
|
|
@confirm="handleLocationMapConfirm"
|
|
/>
|
|
</basic-container>
|
|
</template>
|
|
|
|
<script>
|
|
import { add, getDetail, getList, remove, update } from '@/api/vehicle/violation-record';
|
|
import { getList as getVehicleList } from '@/api/transportCapacity/transport-vehicle';
|
|
import { getList as getShipList } from '@/api/transportCapacity/transport-ship';
|
|
import { getList as getDriverList } from '@/api/transportCapacity/driver';
|
|
import { getDeptTree } from '@/api/system/dept';
|
|
import { getDictionary } from '@/api/system/dictbiz';
|
|
import { exportBlob } from '@/api/common';
|
|
import { downloadXls } from '@/utils/util';
|
|
import { openImportDialog } from '@/utils/import-excel';
|
|
import { getToken, isAdministrator } from '@/utils/auth';
|
|
import { applyIncomingSearch, normalizeSearchRangeParams } from '@/utils/search-range';
|
|
import AddressMapPicker from '@/components/address-map-picker/main.vue';
|
|
import VehicleAttachmentTable from '@/components/vehicle-attachment-table/main.vue';
|
|
import { mapGetters } from 'vuex';
|
|
import { excelOption, exportColumns, option } from '@/option/vehicle/violation-record';
|
|
import NProgress from 'nprogress';
|
|
import 'nprogress/nprogress.css';
|
|
|
|
const createTimeRangeMap = {
|
|
createTimeRange: ['createTimeStart', 'createTimeEnd'],
|
|
};
|
|
|
|
export default {
|
|
components: {
|
|
AddressMapPicker,
|
|
VehicleAttachmentTable,
|
|
},
|
|
data() {
|
|
return {
|
|
form: {},
|
|
query: {},
|
|
loading: true,
|
|
excelBox: false,
|
|
locationMapPickerVisible: false,
|
|
excelForm: {},
|
|
isDetailLoading: false,
|
|
option,
|
|
excelOption,
|
|
page: {
|
|
pageSize: 10,
|
|
pageSizes: [10, 20, 50, 100],
|
|
currentPage: 1,
|
|
total: 0,
|
|
},
|
|
selectionList: [],
|
|
boxType: '',
|
|
vehicleOptions: [],
|
|
vehicleOptionsLoading: false,
|
|
vehicleOptionsRequestId: 0,
|
|
data: [],
|
|
};
|
|
},
|
|
created() {
|
|
this.initDeptTree();
|
|
this.initViolationTypeOptions();
|
|
},
|
|
computed: {
|
|
...mapGetters(['permission', 'userInfo']),
|
|
isAdmin() {
|
|
const authority = this.userInfo.authority || '';
|
|
return isAdministrator(this.userInfo);
|
|
},
|
|
permissionList() {
|
|
return {
|
|
addBtn: this.hasPermission('violation_record_add'),
|
|
viewBtn: this.hasPermission('violation_record_view'),
|
|
delBtn: this.hasPermission('violation_record_delete'),
|
|
editBtn: this.hasPermission('violation_record_edit'),
|
|
};
|
|
},
|
|
vehicleNoPlaceholder() {
|
|
return this.form.vehicleType === '船舶' ? '请选择船号' : '请选择车牌号';
|
|
},
|
|
ids() {
|
|
const ids = [];
|
|
this.selectionList.forEach(ele => {
|
|
ids.push(ele.id);
|
|
});
|
|
return ids.join(',');
|
|
},
|
|
},
|
|
watch: {
|
|
'form.vehicleType': {
|
|
handler(value, oldValue) {
|
|
this.updateVehicleTypeDisplays(value || '车辆', oldValue);
|
|
},
|
|
immediate: true,
|
|
},
|
|
'form.processStatus': {
|
|
handler(value) {
|
|
this.updateProcessResultDisplay(value || '未处理');
|
|
},
|
|
immediate: true,
|
|
},
|
|
},
|
|
methods: {
|
|
openLocationMapPicker() {
|
|
if (this.boxType !== 'view') {
|
|
this.locationMapPickerVisible = true;
|
|
}
|
|
},
|
|
handleLocationMapConfirm(payload) {
|
|
this.form.location = typeof payload === 'string' ? payload : payload?.address || '';
|
|
},
|
|
hasPermission(code) {
|
|
return this.isAdmin || this.validData(this.permission[code], false);
|
|
},
|
|
initDeptTree() {
|
|
getDeptTree(this.userInfo.tenantId).then(res => {
|
|
const column = this.findColumn(this.option.column, 'createDept');
|
|
column.dicData = res.data.data;
|
|
});
|
|
},
|
|
initViolationTypeOptions() {
|
|
getDictionary({ code: 'type_of_traffic_violation' }).then(res => {
|
|
const column = this.findColumn(this.option.column, 'violationType');
|
|
column.dicData = (res.data.data || []).map(item => ({
|
|
label: item.dictValue,
|
|
value: item.dictValue,
|
|
}));
|
|
});
|
|
},
|
|
updateVehicleTypeDisplays(vehicleType, oldValue) {
|
|
const vehicleTypeColumn = this.findColumn(this.option.column, 'vehicleType');
|
|
const vehicleNoColumn = this.findColumn(this.option.column, 'vehicleNo');
|
|
const driverColumn = this.findColumn(this.option.column, 'driverName');
|
|
const typeColumn = this.findColumn(this.option.column, 'violationType');
|
|
const itemColumn = this.findColumn(this.option.column, 'violationItem');
|
|
vehicleNoColumn.placeholder =
|
|
vehicleType === '船舶' ? '请选择船号' : '请选择车牌号';
|
|
driverColumn.label = vehicleType === '船舶' ? '船长' : '驾驶人';
|
|
typeColumn.display = vehicleType !== '船舶';
|
|
itemColumn.display = vehicleType === '船舶';
|
|
typeColumn.rules =
|
|
vehicleType === '船舶'
|
|
? []
|
|
: [{ required: true, message: '请选择类型', trigger: 'change' }];
|
|
itemColumn.rules =
|
|
vehicleType === '船舶'
|
|
? [
|
|
{ required: true, message: '请输入事项', trigger: 'blur' },
|
|
{ max: 100, message: '最多 100 个字符', trigger: 'blur' },
|
|
]
|
|
: [{ max: 100, message: '最多 100 个字符', trigger: 'blur' }];
|
|
vehicleTypeColumn.disabled = Boolean(this.form.id);
|
|
if (!this.isDetailLoading && oldValue && vehicleType !== oldValue) {
|
|
this.form.vehicleNo = '';
|
|
this.form.driverName = '';
|
|
this.vehicleOptions = [];
|
|
this.loadVehicleOptions('');
|
|
}
|
|
if (vehicleType === '船舶') {
|
|
this.form.violationType = undefined;
|
|
} else {
|
|
this.form.violationItem = undefined;
|
|
}
|
|
},
|
|
updateProcessResultDisplay(processStatus) {
|
|
const column = this.findColumn(this.option.column, 'processResult');
|
|
column.display = processStatus !== '未处理';
|
|
if (processStatus === '未处理') {
|
|
this.form.processResult = undefined;
|
|
}
|
|
},
|
|
handleVehicleSelectVisible(visible) {
|
|
if (visible && !this.vehicleOptions.length) this.loadVehicleOptions('');
|
|
},
|
|
loadVehicleOptions(queryString = '') {
|
|
const vehicleType = this.form.vehicleType || '车辆';
|
|
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 => {
|
|
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(() => {
|
|
if (requestId === this.vehicleOptionsRequestId) this.vehicleOptions = [];
|
|
})
|
|
.finally(() => {
|
|
if (requestId === this.vehicleOptionsRequestId) this.vehicleOptionsLoading = false;
|
|
});
|
|
},
|
|
fetchDriverOptions(queryString, callback) {
|
|
getDriverList(1, 20, { driverName: queryString })
|
|
.then(res => {
|
|
const records = res.data.data.records || [];
|
|
callback(records.map(item => ({ value: item.driverName })));
|
|
})
|
|
.catch(() => callback([]));
|
|
},
|
|
formatAttachments(value) {
|
|
if (!value) return '';
|
|
if (Array.isArray(value)) return `${value.length} 个`;
|
|
if (typeof value !== 'string') return '1 个';
|
|
try {
|
|
const attachments = JSON.parse(value);
|
|
return Array.isArray(attachments) ? `${attachments.length} 个` : '1 个';
|
|
} catch (error) {
|
|
return (
|
|
value
|
|
.split(',')
|
|
.map(item => item.trim())
|
|
.filter(Boolean).length + ' 个'
|
|
);
|
|
}
|
|
},
|
|
parseAttachments(value) {
|
|
if (!value || Array.isArray(value)) return value;
|
|
if (typeof value !== 'string') return [];
|
|
try {
|
|
const attachments = JSON.parse(value);
|
|
return Array.isArray(attachments) ? attachments : [];
|
|
} catch (error) {
|
|
return value
|
|
.split(',')
|
|
.map(item => ({ name: item.trim(), url: item.trim() }))
|
|
.filter(item => item.url);
|
|
}
|
|
},
|
|
stringifyAttachments(value) {
|
|
if (!value || typeof value === 'string') return value;
|
|
return JSON.stringify(value);
|
|
},
|
|
normalizeDecimalInput(prop, value) {
|
|
const sanitized = String(value ?? '').replace(/[^\d.]/g, '');
|
|
const [integerPart, ...decimalParts] = sanitized.split('.');
|
|
this.form[prop] = decimalParts.length
|
|
? `${integerPart || '0'}.${decimalParts.join('').slice(0, 2)}`
|
|
: integerPart;
|
|
},
|
|
normalizeIntegerInput(prop, value) {
|
|
this.form[prop] = String(value ?? '').replace(/\D/g, '');
|
|
},
|
|
normalizeRow(row) {
|
|
const values = { ...row };
|
|
values.vehicleType = values.vehicleType || '车辆';
|
|
values.processStatus = values.processStatus || '未处理';
|
|
if (values.vehicleNo) {
|
|
values.vehicleNo =
|
|
values.vehicleType === '船舶'
|
|
? values.vehicleNo.trim()
|
|
: values.vehicleNo.trim().toUpperCase();
|
|
}
|
|
if (values.processStatus === '未处理') {
|
|
values.processResult = undefined;
|
|
}
|
|
if (values.vehicleType === '船舶') {
|
|
values.violationType = undefined;
|
|
} else {
|
|
values.violationItem = undefined;
|
|
}
|
|
// 非必填项未填写时不要提交 -1 占位值
|
|
values.fineAmount = this.normalizeOptionalAmount(values.fineAmount);
|
|
values.deductPoints = this.normalizeOptionalAmount(values.deductPoints);
|
|
values.penaltyUnit = this.normalizeOptionalText(values.penaltyUnit);
|
|
values.processResult = this.normalizeOptionalText(values.processResult);
|
|
values.attachments = this.stringifyAttachments(values.attachments);
|
|
return values;
|
|
},
|
|
normalizeOptionalAmount(value) {
|
|
if (value === undefined || value === null || value === '' || Number(value) === -1) {
|
|
return null;
|
|
}
|
|
return value;
|
|
},
|
|
normalizeOptionalText(value) {
|
|
if (value === undefined || value === null) return null;
|
|
const text = String(value).trim();
|
|
return !text || text === '-1' ? null : text;
|
|
},
|
|
validateRow(row) {
|
|
if (row.vehicleType === '船舶' && !row.violationItem) {
|
|
this.$message.warning('请输入事项');
|
|
return false;
|
|
}
|
|
if (row.vehicleType !== '船舶' && !row.violationType) {
|
|
this.$message.warning('请选择类型');
|
|
return false;
|
|
}
|
|
if (
|
|
row.violationTime &&
|
|
new Date(row.violationTime.replace(/-/g, '/')).getTime() > Date.now()
|
|
) {
|
|
this.$message.warning('日期不能超过当前时间');
|
|
return false;
|
|
}
|
|
const fineAmount = this.normalizeOptionalAmount(row.fineAmount);
|
|
const deductPoints = this.normalizeOptionalAmount(row.deductPoints);
|
|
if (fineAmount !== null && Number(fineAmount) < 0) {
|
|
this.$message.warning('被罚金额不能小于 0');
|
|
return false;
|
|
}
|
|
if (
|
|
deductPoints !== null &&
|
|
(!Number.isInteger(Number(deductPoints)) ||
|
|
Number(deductPoints) < 0 ||
|
|
Number(deductPoints) > 15)
|
|
) {
|
|
this.$message.warning('被扣分数范围为 0-15 分');
|
|
return false;
|
|
}
|
|
return true;
|
|
},
|
|
rowSave(row, done, loading) {
|
|
const values = this.normalizeRow(row);
|
|
if (!this.validateRow(values)) {
|
|
loading();
|
|
return;
|
|
}
|
|
add(values).then(
|
|
() => {
|
|
this.onLoad(this.page);
|
|
this.$message({ type: 'success', message: '操作成功!' });
|
|
done();
|
|
},
|
|
error => {
|
|
window.console.log(error);
|
|
loading();
|
|
}
|
|
);
|
|
},
|
|
rowUpdate(row, index, done, loading) {
|
|
const values = this.normalizeRow(row);
|
|
if (!this.validateRow(values)) {
|
|
loading();
|
|
return;
|
|
}
|
|
update(values).then(
|
|
() => {
|
|
this.onLoad(this.page);
|
|
this.$message({ type: 'success', message: '操作成功!' });
|
|
done();
|
|
},
|
|
error => {
|
|
window.console.log(error);
|
|
loading();
|
|
}
|
|
);
|
|
},
|
|
rowDel(row) {
|
|
this.$confirm('确定删除该条数据,删除后不可恢复?', {
|
|
confirmButtonText: '确定',
|
|
cancelButtonText: '取消',
|
|
type: 'warning',
|
|
})
|
|
.then(() => remove(row.id))
|
|
.then(() => {
|
|
this.onLoad(this.page);
|
|
this.$message({ type: 'success', message: '操作成功!' });
|
|
});
|
|
},
|
|
handleDelete() {
|
|
if (this.selectionList.length === 0) {
|
|
this.$message.warning('请选择至少一条数据');
|
|
return;
|
|
}
|
|
this.$confirm('确定删除所选数据,删除后不可恢复?', {
|
|
confirmButtonText: '确定',
|
|
cancelButtonText: '取消',
|
|
type: 'warning',
|
|
})
|
|
.then(() => remove(this.ids))
|
|
.then(() => {
|
|
this.onLoad(this.page);
|
|
this.$message({ type: 'success', message: '操作成功!' });
|
|
this.$refs.crud.toggleSelection();
|
|
});
|
|
},
|
|
beforeOpen(done, type) {
|
|
this.boxType = type;
|
|
if (type === 'add') {
|
|
this.form = {
|
|
vehicleType: '车辆',
|
|
processStatus: '已处理',
|
|
attachments: [],
|
|
};
|
|
this.updateVehicleTypeDisplays('车辆');
|
|
this.vehicleOptions = [];
|
|
this.loadVehicleOptions('');
|
|
this.updateProcessResultDisplay('已处理');
|
|
}
|
|
if (['edit', 'view'].includes(type)) {
|
|
this.isDetailLoading = true;
|
|
getDetail(this.form.id)
|
|
.then(res => {
|
|
const detail = res.data.data;
|
|
detail.attachments = this.parseAttachments(detail.attachments);
|
|
detail.vehicleType = detail.vehicleType || '车辆';
|
|
detail.processStatus = detail.processStatus || '未处理';
|
|
detail.fineAmount = this.normalizeOptionalAmount(detail.fineAmount);
|
|
detail.deductPoints = this.normalizeOptionalAmount(detail.deductPoints);
|
|
detail.penaltyUnit = this.normalizeOptionalText(detail.penaltyUnit) || '';
|
|
detail.processResult = this.normalizeOptionalText(detail.processResult) || '';
|
|
this.form = detail;
|
|
this.updateVehicleTypeDisplays(detail.vehicleType);
|
|
this.vehicleOptions = [];
|
|
this.loadVehicleOptions(detail.vehicleNo || '');
|
|
this.updateProcessResultDisplay(detail.processStatus);
|
|
})
|
|
.finally(() => {
|
|
this.isDetailLoading = false;
|
|
});
|
|
}
|
|
done();
|
|
},
|
|
searchReset() {
|
|
this.query = {};
|
|
this.onLoad(this.page);
|
|
},
|
|
searchChange(params, done) {
|
|
this.query = this.buildQuery(params);
|
|
this.page.currentPage = 1;
|
|
this.onLoad(this.page);
|
|
done();
|
|
},
|
|
selectionChange(list) {
|
|
this.selectionList = list;
|
|
},
|
|
selectionClear() {
|
|
this.selectionList = [];
|
|
this.$refs.crud.toggleSelection();
|
|
},
|
|
currentChange(currentPage) {
|
|
this.page.currentPage = currentPage;
|
|
},
|
|
sizeChange(pageSize) {
|
|
this.page.pageSize = pageSize;
|
|
},
|
|
refreshChange() {
|
|
this.onLoad(this.page, this.query);
|
|
},
|
|
onLoad(page, params = {}) {
|
|
this.loading = true;
|
|
getList(page.currentPage, page.pageSize, this.buildQuery(params))
|
|
.then(res => {
|
|
const data = res.data.data;
|
|
this.page.total = data.total;
|
|
this.data = data.records;
|
|
this.selectionClear();
|
|
})
|
|
.finally(() => {
|
|
this.loading = false;
|
|
});
|
|
},
|
|
handleImport() {
|
|
openImportDialog(this, '违章记录');
|
|
},
|
|
handleExport() {
|
|
this.$confirm('是否导出违章记录数据?', '提示', {
|
|
confirmButtonText: '确定',
|
|
cancelButtonText: '取消',
|
|
type: 'warning',
|
|
}).then(() => {
|
|
NProgress.start();
|
|
exportBlob(
|
|
'/blade-transport/violation-record/export-violation-record',
|
|
this.buildExportParams(),
|
|
{ feedback: true }
|
|
)
|
|
.then(res => {
|
|
downloadXls(res.data, `违章记录${this.$dayjs().format('YYYY-MM-DD HH:mm:ss')}.xlsx`);
|
|
})
|
|
.finally(() => {
|
|
NProgress.done();
|
|
});
|
|
});
|
|
},
|
|
buildExportParams() {
|
|
return {
|
|
...this.buildQuery(),
|
|
ids: this.ids,
|
|
exportColumns: JSON.stringify(exportColumns),
|
|
[this.website.tokenHeader]: getToken(),
|
|
};
|
|
},
|
|
buildQuery(params = {}) {
|
|
return normalizeSearchRangeParams(applyIncomingSearch(this.query, params), createTimeRangeMap);
|
|
},
|
|
handleTemplate() {
|
|
exportBlob(
|
|
'/blade-transport/violation-record/export-template',
|
|
{ exportColumns: JSON.stringify(exportColumns), [this.website.tokenHeader]: getToken() },
|
|
{ feedback: true }
|
|
).then(res => {
|
|
downloadXls(res.data, '违章记录模板.xlsx');
|
|
});
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.violation-record-page {
|
|
:deep(.el-table th .cell),
|
|
:deep(.el-table td .cell) {
|
|
white-space: nowrap;
|
|
}
|
|
|
|
&__input {
|
|
width: 100%;
|
|
}
|
|
|
|
&__danger {
|
|
color: #f56c6c;
|
|
}
|
|
}
|
|
</style>
|