This commit is contained in:
2026-07-27 17:19:36 +08:00
parent e50d1b8fda
commit 1c7532e0de
132 changed files with 7066 additions and 1241 deletions
+56 -20
View File
@@ -63,8 +63,9 @@
<el-autocomplete
v-model="form.vehicleNo"
:fetch-suggestions="fetchVehicleOptions"
:disabled="boxType === 'view'"
clearable
placeholder="输入车牌号/船号查询选择"
:placeholder="vehicleNoPlaceholder"
value-key="value"
class="accident-record-page__input"
/>
@@ -72,6 +73,24 @@
<template #attachments="{ row }">
<span>{{ formatAttachments(row.attachments) }}</span>
</template>
<template #attachmentsForm>
<vehicle-attachment-upload
v-model="form.attachments"
:readonly="boxType === 'view'"
button-text="新增"
button-icon="el-icon-plus"
:show-tip="false"
/>
</template>
<template #attachments-form>
<vehicle-attachment-upload
v-model="form.attachments"
:readonly="boxType === 'view'"
button-text="新增"
button-icon="el-icon-plus"
:show-tip="false"
/>
</template>
</avue-crud>
<empty-pagination
:page="page"
@@ -80,7 +99,7 @@
@load="onLoad(page, query)"
/>
<el-dialog title="事故记录数据导入" append-to-body v-model="excelBox" width="555px">
<avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter">
<avue-form :option="excelOption" v-model="excelForm">
<template #excelTemplate>
<el-button type="primary" @click="handleTemplate">
点击下载<i class="el-icon-download el-icon--right"></i>
@@ -98,6 +117,7 @@ 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';
import { openImportDialog } from '@/utils/import-excel';
import { getToken } from '@/utils/auth';
import { mapGetters } from 'vuex';
import { excelOption, option } from '@/option/vehicle/accident-record';
@@ -112,6 +132,7 @@ export default {
loading: true,
excelBox: false,
excelForm: {},
isDetailLoading: false,
option,
excelOption,
page: {
@@ -121,6 +142,7 @@ export default {
total: 0,
},
selectionList: [],
boxType: '',
data: [],
};
},
@@ -141,6 +163,9 @@ export default {
editBtn: this.hasPermission('accident_record_edit'),
};
},
vehicleNoPlaceholder() {
return this.form.vehicleType === '船舶' ? '输入船号模糊查询选择' : '输入车牌号模糊查询选择';
},
ids() {
const ids = [];
this.selectionList.forEach(ele => {
@@ -151,8 +176,8 @@ export default {
},
watch: {
'form.vehicleType': {
handler(value) {
this.updateVehicleTypeDisplays(value || '车辆');
handler(value, oldValue) {
this.updateVehicleTypeDisplays(value || '车辆', oldValue);
},
immediate: true,
},
@@ -167,10 +192,13 @@ export default {
column.dicData = res.data.data;
});
},
updateVehicleTypeDisplays(vehicleType) {
updateVehicleTypeDisplays(vehicleType, oldValue) {
const vehicleTypeColumn = this.findColumn(this.option.column, 'vehicleType');
const vehicleNoColumn = this.findColumn(this.option.column, 'vehicleNo');
vehicleNoColumn.placeholder =
vehicleType === '船舶' ? '输入船号模糊查询选择' : '输入车牌号模糊查询选择';
vehicleTypeColumn.disabled = Boolean(this.form.id);
if (!this.form.id && this.form.vehicleNo) {
if (!this.isDetailLoading && oldValue && vehicleType !== oldValue && this.form.vehicleNo) {
this.form.vehicleNo = '';
}
},
@@ -227,7 +255,10 @@ export default {
const values = { ...row };
values.vehicleType = values.vehicleType || '车辆';
if (values.vehicleNo) {
values.vehicleNo = values.vehicleNo.trim().toUpperCase();
values.vehicleNo =
values.vehicleType === '船舶'
? values.vehicleNo.trim()
: values.vehicleNo.trim().toUpperCase();
}
values.attachments = this.stringifyAttachments(values.attachments);
return values;
@@ -329,6 +360,7 @@ export default {
});
},
beforeOpen(done, type) {
this.boxType = type;
if (type === 'add') {
this.form = {
vehicleType: '车辆',
@@ -336,12 +368,18 @@ export default {
this.updateVehicleTypeDisplays('车辆');
}
if (['edit', 'view'].includes(type)) {
getDetail(this.form.id).then(res => {
const detail = res.data.data;
detail.attachments = this.parseAttachments(detail.attachments);
this.form = detail;
this.updateVehicleTypeDisplays(detail.vehicleType);
});
this.isDetailLoading = true;
getDetail(this.form.id)
.then(res => {
const detail = res.data.data;
detail.attachments = this.parseAttachments(detail.attachments);
detail.vehicleType = detail.vehicleType || '车辆';
this.form = detail;
this.updateVehicleTypeDisplays(detail.vehicleType);
})
.finally(() => {
this.isDetailLoading = false;
});
}
done();
},
@@ -385,12 +423,7 @@ export default {
});
},
handleImport() {
this.excelBox = true;
},
uploadAfter(res, done) {
this.excelBox = false;
this.onLoad(this.page);
done();
openImportDialog(this, '事故记录');
},
handleExport() {
this.$confirm('是否导出事故记录数据?', '提示', {
@@ -399,7 +432,10 @@ export default {
type: 'warning',
}).then(() => {
NProgress.start();
exportBlob('/blade-transport/accident-record/export-accident-record', this.buildExportParams())
exportBlob(
'/blade-transport/accident-record/export-accident-record',
this.buildExportParams()
)
.then(res => {
downloadXls(res.data, `事故记录${this.$dayjs().format('YYYY-MM-DD HH:mm:ss')}.xlsx`);
})
+27 -8
View File
@@ -63,6 +63,7 @@
<el-autocomplete
v-model="form.vehicleNo"
:fetch-suggestions="fetchVehicleOptions"
:disabled="boxType === 'view'"
clearable
placeholder="输入车牌号/船号查询选择"
value-key="value"
@@ -72,6 +73,24 @@
<template #attachments="{ row }">
<span>{{ formatAttachments(row.attachments) }}</span>
</template>
<template #attachmentsForm>
<vehicle-attachment-upload
v-model="form.attachments"
:readonly="boxType === 'view'"
button-text="新增"
button-icon="el-icon-plus"
:show-tip="false"
/>
</template>
<template #attachments-form>
<vehicle-attachment-upload
v-model="form.attachments"
:readonly="boxType === 'view'"
button-text="新增"
button-icon="el-icon-plus"
:show-tip="false"
/>
</template>
</avue-crud>
<empty-pagination
:page="page"
@@ -80,7 +99,7 @@
@load="onLoad(page, query)"
/>
<el-dialog title="年检记录数据导入" append-to-body v-model="excelBox" width="555px">
<avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter">
<avue-form :option="excelOption" v-model="excelForm">
<template #excelTemplate>
<el-button type="primary" @click="handleTemplate">
点击下载<i class="el-icon-download el-icon--right"></i>
@@ -98,6 +117,7 @@ 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';
import { openImportDialog } from '@/utils/import-excel';
import { getToken } from '@/utils/auth';
import { mapGetters } from 'vuex';
import { excelOption, option } from '@/option/vehicle/annual-inspection-record';
@@ -121,6 +141,7 @@ export default {
total: 0,
},
selectionList: [],
boxType: '',
data: [],
};
},
@@ -332,6 +353,7 @@ export default {
});
},
beforeOpen(done, type) {
this.boxType = type;
if (type === 'add') {
this.form = {
vehicleType: '车辆',
@@ -389,12 +411,7 @@ export default {
});
},
handleImport() {
this.excelBox = true;
},
uploadAfter(res, done) {
this.excelBox = false;
this.onLoad(this.page);
done();
openImportDialog(this, '年检记录');
},
handleExport() {
this.$confirm('是否导出年检记录数据?', '提示', {
@@ -424,7 +441,9 @@ export default {
},
handleTemplate() {
exportBlob(
`/blade-transport/annual-inspection-record/export-template?${this.website.tokenHeader}=${getToken()}`
`/blade-transport/annual-inspection-record/export-template?${
this.website.tokenHeader
}=${getToken()}`
).then(res => {
downloadXls(res.data, '年检记录模板.xlsx');
});
+121 -46
View File
@@ -17,14 +17,14 @@
@on-load="onLoad"
>
<template #menu-left>
<el-button
type="primary"
icon="el-icon-plus"
plain
v-if="hasPermission('credit_score_quantification_add')"
@click="openConfig()"
>新增
</el-button>
<el-button
type="primary"
icon="el-icon-plus"
plain
v-if="hasPermission('credit_score_quantification_add')"
@click="openConfig()"
>新增
</el-button>
<el-button
type="primary"
icon="el-icon-upload"
@@ -49,9 +49,9 @@
@click="handleExport"
>批量导出
</el-button>
<el-button
type="danger"
icon="el-icon-delete"
<el-button
type="danger"
icon="el-icon-delete"
plain
v-if="hasPermission('credit_score_quantification_delete')"
@click="handleDelete"
@@ -109,7 +109,7 @@
</avue-crud>
<el-dialog title="评分量化表数据导入" append-to-body v-model="excelBox" width="555px">
<avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter">
<avue-form :option="excelOption" v-model="excelForm">
<template #excelTemplate>
<el-button type="primary" @click="handleTemplate">
点击下载<i class="el-icon-download el-icon--right"></i>
@@ -127,8 +127,14 @@
@closed="resetConfig"
>
<div class="score-config">
<div class="section-title">评分量化表</div>
<el-form :model="configForm" label-width="110px" class="base-form" :disabled="readonly">
<div class="section-title dialog-section-title">评分量化表</div>
<el-form
:model="configForm"
label-position="right"
label-width="auto"
class="base-form"
:disabled="readonly"
>
<el-form-item label="评定表名称" required>
<el-input v-model="configForm.name" maxlength="30" show-word-limit />
</el-form-item>
@@ -138,7 +144,7 @@
</el-form>
<div class="section-head">
<div class="section-title">评分表</div>
<div class="section-title dialog-section-title">评分表</div>
</div>
<el-table :data="configForm.categories" border class="config-table">
<el-table-column label="序号" type="index" width="70" align="center" />
@@ -154,13 +160,8 @@
</el-table>
<div class="section-head standard-head">
<div class="section-title">评估标准</div>
<el-button
type="primary"
icon="el-icon-plus"
v-if="!readonly"
@click="openStandard()"
>
<div class="section-title dialog-section-title">评估标准</div>
<el-button type="primary" icon="el-icon-plus" v-if="!readonly" @click="openStandard()">
添加
</el-button>
</div>
@@ -168,7 +169,9 @@
<el-table-column label="序号" type="index" width="70" align="center" />
<el-table-column label="信用等级" prop="creditLevel" width="120" align="center" />
<el-table-column label="得分率" width="160" align="center">
<template #default="{ row }">{{ row.scoreRateLower }}% - {{ row.scoreRateUpper }}%</template>
<template #default="{ row }"
>{{ row.scoreRateLower }}% - {{ row.scoreRateUpper }}%</template
>
</el-table-column>
<el-table-column label="最大资金使用额度(万元)" width="210" align="center">
<template #default="{ row }">
@@ -179,7 +182,9 @@
<el-table-column label="操作" width="160" align="center">
<template #default="{ row, $index }">
<el-button type="primary" text @click="openStandard(row, $index)">编辑</el-button>
<el-button type="danger" text v-if="!readonly" @click="removeStandard($index)">删除</el-button>
<el-button type="danger" text v-if="!readonly" @click="removeStandard($index)"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
@@ -215,7 +220,9 @@
<el-table-column label="操作" width="160" align="center">
<template #default="{ row, $index }">
<el-button type="primary" text @click="openItem(row, $index)">编辑</el-button>
<el-button type="danger" text v-if="!readonly" @click="removeItem($index)">删除</el-button>
<el-button type="danger" text v-if="!readonly" @click="removeItem($index)"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
@@ -226,7 +233,7 @@
</el-dialog>
<el-dialog title="评分项目详情" append-to-body v-model="itemBox" width="76%">
<el-form :model="itemForm" label-width="100px" :disabled="readonly">
<el-form :model="itemForm" label-position="right" label-width="auto" :disabled="readonly">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="评分项目" required>
@@ -248,7 +255,12 @@
<el-input v-model="option.optionName" maxlength="100" placeholder="选项描述" />
<el-input-number v-model="option.score" :min="0" :precision="2" placeholder="分值" />
<span class="score-unit"></span>
<el-button type="danger" text v-if="!readonly && itemForm.options.length > 1" @click="removeOption(index)">
<el-button
type="danger"
text
v-if="!readonly && itemForm.options.length > 1"
@click="removeOption(index)"
>
删除
</el-button>
</div>
@@ -263,19 +275,36 @@
</el-dialog>
<el-dialog title="评估标准设置" append-to-body v-model="standardBox" width="76%">
<el-form :model="standardForm" label-width="170px" :disabled="readonly">
<el-form :model="standardForm" label-position="right" label-width="auto" :disabled="readonly">
<el-row :gutter="20">
<el-col :span="8">
<el-form-item label="信用等级" required>
<el-input v-model="standardForm.creditLevel" maxlength="30" />
<el-select v-model="standardForm.creditLevel" placeholder="请选择信用等级" clearable>
<el-option
v-for="item in creditLevelOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="得分率(%)" required>
<div class="range-input">
<el-input-number v-model="standardForm.scoreRateLower" :min="0" :max="100" :precision="0" />
<el-input-number
v-model="standardForm.scoreRateLower"
:min="0"
:max="100"
:precision="0"
/>
<span></span>
<el-input-number v-model="standardForm.scoreRateUpper" :min="0" :max="100" :precision="0" />
<el-input-number
v-model="standardForm.scoreRateUpper"
:min="0"
:max="100"
:precision="0"
/>
</div>
</el-form-item>
</el-col>
@@ -303,7 +332,12 @@
</el-col>
</el-row>
<el-form-item label="标准说明">
<el-input v-model="standardForm.standardDescription" type="textarea" maxlength="500" show-word-limit />
<el-input
v-model="standardForm.standardDescription"
type="textarea"
maxlength="500"
show-word-limit
/>
</el-form-item>
</el-form>
<template #footer>
@@ -325,6 +359,7 @@ import {
} from '@/api/vehicle/credit-score-quantification';
import { exportBlob } from '@/api/common';
import { downloadXls } from '@/utils/util';
import { openImportDialog } from '@/utils/import-excel';
import { getToken } from '@/utils/auth';
import { mapGetters } from 'vuex';
import NProgress from 'nprogress';
@@ -361,13 +396,21 @@ export default {
2: { label: '停用', type: 'info' },
3: { label: '草稿', type: 'warning' },
},
creditLevelOptions: ['A', 'B', 'C', 'D', 'E', 'F'].map(item => ({
label: item,
value: item,
})),
option: {
height: 'auto',
calcHeight: 32,
dialogWidth: 760,
labelPosition: 'right',
tip: false,
searchShow: true,
searchMenuSpan: 6,
searchMenuSpan: 24,
searchIcon: true,
searchIndex: 8,
searchMenuPosition: 'right',
border: true,
index: true,
indexLabel: '序号',
@@ -421,7 +464,6 @@ export default {
type: 'date',
format: 'YYYY-MM-DD 00:00:00',
valueFormat: 'YYYY-MM-DD 00:00:00',
search: true,
hide: true,
display: false,
},
@@ -431,13 +473,13 @@ export default {
type: 'date',
format: 'YYYY-MM-DD 23:59:59',
valueFormat: 'YYYY-MM-DD 23:59:59',
search: true,
hide: true,
display: false,
},
],
},
excelOption: {
labelPosition: 'right',
submitBtn: false,
emptyBtn: false,
column: [
@@ -452,7 +494,8 @@ export default {
res: 'data',
},
tip: '请上传 .xls,.xlsx 标准格式文件',
action: '/blade-transport/credit-score-quantification/import-credit-score-quantification',
action:
'/blade-transport/credit-score-quantification/import-credit-score-quantification',
},
{
label: '模板下载',
@@ -532,7 +575,8 @@ export default {
...category,
items: (category.items || []).map(item => ({
...item,
options: item.options && item.options.length ? item.options : [{ optionName: '', score: 0 }],
options:
item.options && item.options.length ? item.options : [{ optionName: '', score: 0 }],
})),
};
});
@@ -601,9 +645,26 @@ export default {
this.standardForm = row ? JSON.parse(JSON.stringify(row)) : this.emptyStandard();
this.standardBox = true;
},
hasDuplicateCreditLevel(creditLevel, currentIndex = -1) {
const level = String(creditLevel || '').trim();
return this.configForm.standards.some(
(item, index) => index !== currentIndex && String(item.creditLevel || '').trim() === level
);
},
isValidCreditLevel(creditLevel) {
return this.creditLevelOptions.some(item => item.value === String(creditLevel || '').trim());
},
saveStandard() {
if (!this.standardForm.creditLevel || !this.standardForm.creditLevel.trim()) {
this.$message.warning('请输入信用等级');
if (!this.standardForm.creditLevel) {
this.$message.warning('请选择信用等级');
return;
}
if (!this.isValidCreditLevel(this.standardForm.creditLevel)) {
this.$message.warning('信用等级只能选择A/B/C/D/E/F');
return;
}
if (this.hasDuplicateCreditLevel(this.standardForm.creditLevel, this.currentStandardIndex)) {
this.$message.warning('信用等级不能重复');
return;
}
if (
@@ -624,6 +685,7 @@ export default {
return;
}
const standard = JSON.parse(JSON.stringify(this.standardForm));
standard.creditLevel = String(standard.creditLevel || '').trim();
if (this.currentStandardIndex >= 0) {
this.configForm.standards.splice(this.currentStandardIndex, 1, standard);
} else {
@@ -652,6 +714,17 @@ export default {
}
}
}
const creditLevels = this.configForm.standards
.map(item => String(item.creditLevel || '').trim())
.filter(Boolean);
if (creditLevels.some(level => !this.isValidCreditLevel(level))) {
this.$message.warning('评估标准中的信用等级只能选择A/B/C/D/E/F');
return false;
}
if (new Set(creditLevels).size !== creditLevels.length) {
this.$message.warning('评估标准中的信用等级不能重复');
return false;
}
return true;
},
saveConfig() {
@@ -749,12 +822,7 @@ export default {
});
},
handleImport() {
this.excelBox = true;
},
uploadAfter(res, done) {
this.excelBox = false;
this.onLoad(this.page);
done();
openImportDialog(this, '评分量化表');
},
handleExport() {
this.$confirm('是否导出评分量化表数据?', '提示', {
@@ -784,7 +852,9 @@ export default {
},
handleTemplate() {
exportBlob(
`/blade-transport/credit-score-quantification/export-template?${this.website.tokenHeader}=${getToken()}`
`/blade-transport/credit-score-quantification/export-template?${
this.website.tokenHeader
}=${getToken()}`
).then(res => {
downloadXls(res.data, '评分量化表模板.xlsx');
});
@@ -808,12 +878,17 @@ export default {
align-items: center;
justify-content: space-between;
margin: 24px 0 12px;
.section-title {
margin: 0;
}
}
.section-title {
margin: 18px 0 12px;
font-size: 20px;
font-weight: 700;
line-height: 20px;
color: #303133;
}
+131 -33
View File
@@ -151,11 +151,11 @@
ref="archiveForm"
:model="archiveForm"
:rules="formRules"
label-position="top"
label-position="right"
:disabled="readonly"
class="archive-form"
>
<div class="section-title">基本信息</div>
<div class="section-title dialog-section-title">基本信息</div>
<el-alert
type="warning"
:closable="false"
@@ -164,7 +164,7 @@
class="archive-rule-alert"
/>
<el-row :gutter="18">
<el-col :span="6">
<el-col v-if="readonly" :span="6">
<el-form-item label="客商编号" prop="customerCode">
<el-input v-model="archiveForm.customerCode" disabled placeholder="保存后自动生成" />
</el-form-item>
@@ -221,7 +221,11 @@
v-model="archiveForm.unifiedCreditCode"
maxlength="18"
show-word-limit
@input="archiveForm.unifiedCreditCode = String(archiveForm.unifiedCreditCode || '').toUpperCase()"
@input="
archiveForm.unifiedCreditCode = String(
archiveForm.unifiedCreditCode || ''
).toUpperCase()
"
/>
</el-form-item>
</el-col>
@@ -335,16 +339,23 @@
</el-col>
<el-col :span="12">
<el-form-item label="备注" prop="remark">
<el-input v-model="archiveForm.remark" type="textarea" maxlength="500" show-word-limit />
<el-input
v-model="archiveForm.remark"
type="textarea"
maxlength="500"
show-word-limit
/>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div class="section-head">
<div class="section-title">资质附件</div>
<div class="section-title dialog-section-title">资质附件</div>
<div v-if="!readonly" class="section-actions">
<el-button type="primary" icon="el-icon-upload" @click="addAttachment">OCR上传识别</el-button>
<el-button type="primary" icon="el-icon-upload" @click="addAttachment"
>OCR上传识别</el-button
>
<el-button type="primary" icon="el-icon-plus" @click="addAttachment">添加附件</el-button>
<el-button icon="el-icon-download" @click="downloadAttachments">批量下载</el-button>
</div>
@@ -352,7 +363,7 @@
<el-alert
type="info"
:closable="false"
title="支持 JPG、PNG、PDF,单文件大小不超过 10MB;正式客商需上传公司营业执照、道路运输证等核心材料。"
title="支持 JPG、PNG、PDF、Word、Excel、PPT,单文件大小不超过 10MB;正式客商需上传公司营业执照、道路运输证等核心材料。"
class="archive-rule-alert"
/>
<el-alert
@@ -377,7 +388,16 @@
</el-table-column>
<el-table-column label="文件名称" min-width="180">
<template #default="{ row }">
<el-input v-model="row.name" :disabled="readonly" maxlength="100" />
<vehicle-attachment-upload
v-model="row.files"
:readonly="readonly"
:multiple="false"
accept=".jpg,.jpeg,.png,.pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx"
:max-size="10"
button-text="上传文件"
:show-tip="false"
@success="file => handleQualificationUploadSuccess(file, row)"
/>
</template>
</el-table-column>
<el-table-column label="附件描述" min-width="220">
@@ -387,27 +407,24 @@
</el-table-column>
<el-table-column label="文件大小" min-width="120">
<template #default="{ row }">
<el-input v-model="row.size" :disabled="readonly" maxlength="30" />
<span>{{ row.size || '-' }}</span>
</template>
</el-table-column>
<el-table-column label="上传人" min-width="120">
<template #default="{ row }">
<el-input v-model="row.uploadUserName" :disabled="readonly" maxlength="30" />
<span>{{ row.uploadUserName || '-' }}</span>
</template>
</el-table-column>
<el-table-column label="上传时间" min-width="170">
<template #default="{ row }">
<el-date-picker
v-model="row.uploadTime"
type="datetime"
value-format="YYYY-MM-DD HH:mm:ss"
:disabled="readonly"
/>
<span>{{ row.uploadTime || '-' }}</span>
</template>
</el-table-column>
<el-table-column label="操作" width="90" align="center" v-if="!readonly">
<template #default="{ $index }">
<el-button type="danger" text @click="qualificationFiles.splice($index, 1)">删除</el-button>
<el-button type="danger" text @click="qualificationFiles.splice($index, 1)"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
@@ -437,7 +454,12 @@
<el-table-column label="最终得分" prop="finalScore" width="110" align="center" />
<el-table-column label="额度" min-width="150">
<template #default="{ row }">
<el-input-number v-model="row.applyCreditLimit" :min="0" :precision="2" :disabled="readonly" />
<el-input-number
v-model="row.applyCreditLimit"
:min="0"
:precision="2"
:disabled="readonly"
/>
</template>
</el-table-column>
<el-table-column label="信用等级" min-width="130">
@@ -450,8 +472,15 @@
<el-table-column label="操作" width="210" align="center">
<template #default="{ row, $index }">
<el-button type="primary" text @click="openScore(row)">评分明细</el-button>
<el-button type="success" text v-if="!readonly" @click="finishScore(row)">完成评分</el-button>
<el-button type="danger" text v-if="!readonly" @click="archiveForm.scores.splice($index, 1)">
<el-button type="success" text v-if="!readonly" @click="finishScore(row)"
>完成评分</el-button
>
<el-button
type="danger"
text
v-if="!readonly"
@click="archiveForm.scores.splice($index, 1)"
>
删除
</el-button>
</template>
@@ -500,7 +529,13 @@
</template>
</el-dialog>
<el-dialog title="评分明细" append-to-body v-model="scoreBox" width="88%" class="archive-dialog">
<el-dialog
title="评分明细"
append-to-body
v-model="scoreBox"
width="88%"
class="archive-dialog"
>
<el-table :data="currentScore.details" border class="score-detail-table">
<el-table-column label="序号" type="index" width="70" align="center" />
<el-table-column label="评分类目" prop="categoryName" min-width="130" />
@@ -530,7 +565,12 @@
</el-table-column>
<el-table-column label="复评得分" width="130" align="center">
<template #default="{ row }">
<el-input-number v-model="row.reviewScore" :min="0" :precision="2" :disabled="readonly" />
<el-input-number
v-model="row.reviewScore"
:min="0"
:precision="2"
:disabled="readonly"
/>
</template>
</el-table-column>
<el-table-column label="得分说明" prop="scoreDescription" min-width="220" />
@@ -746,7 +786,10 @@ export default {
searchBtnText: '查询',
emptyBtnText: '重置',
searchShow: true,
searchMenuSpan: 6,
searchMenuSpan: 24,
searchIcon: true,
searchIndex: 8,
searchMenuPosition: 'right',
border: true,
index: true,
indexLabel: '序号',
@@ -877,12 +920,20 @@ export default {
},
missingQualificationText() {
if (this.archiveForm.accessType !== 'formal') return '';
const types = this.qualificationFiles.map(item => item.type || item.name).filter(Boolean);
const types = this.qualificationFiles
.filter(item => item.url)
.map(item => item.type || item.name)
.filter(Boolean);
const missing = ['公司营业执照', '道路运输证'].filter(
item => !types.some(type => String(type).includes(item))
);
return missing.length ? `缺失核心资质材料:${missing.join('、')}` : '';
},
uploadHeaders() {
return {
[this.website.tokenHeader]: getToken(),
};
},
},
methods: {
hasPermission(code) {
@@ -902,7 +953,14 @@ export default {
};
},
emptyContact() {
return { contactName: '', contactPhone: '', email: '', positionName: '', isDefault: 0, remark: '' };
return {
contactName: '',
contactPhone: '',
email: '',
positionName: '',
isDefault: 0,
remark: '',
};
},
emptyReceiptAccount() {
return {
@@ -976,16 +1034,26 @@ export default {
if (Array.isArray(value)) return value;
try {
const list = JSON.parse(value);
return Array.isArray(list) ? list : [];
return Array.isArray(list)
? list.map(item => ({
...item,
files: item.url ? [item] : [],
}))
: [];
} catch (error) {
return String(value)
.split(',')
.map(item => ({ name: item.trim(), url: item.trim() }))
.filter(item => item.url);
.filter(item => item.url)
.map(item => ({
...item,
files: [item],
}));
}
},
stringifyAttachments(list) {
const files = (list || [])
.filter(item => item.url)
.map(item => ({
type: String(item.type || '').trim(),
name: String(item.name || '').trim(),
@@ -995,7 +1063,7 @@ export default {
uploadTime: String(item.uploadTime || '').trim(),
url: String(item.url || '').trim(),
}))
.filter(item => item.type || item.name || item.url);
.filter(item => item.url);
return files.length ? JSON.stringify(files) : '';
},
addAttachment() {
@@ -1007,8 +1075,25 @@ export default {
uploadUserName: this.userInfo.realName || this.userInfo.userName || '',
uploadTime: this.$dayjs().format('YYYY-MM-DD HH:mm:ss'),
url: '',
files: [],
});
},
formatAttachmentSize(size) {
if (!size) return '';
const byteSize = Number(size);
if (!Number.isFinite(byteSize)) return String(size);
const mb = byteSize / 1024 / 1024;
if (mb >= 1) return `${mb.toFixed(2)} MB`;
return `${(byteSize / 1024).toFixed(2)} KB`;
},
handleQualificationUploadSuccess(file, row) {
row.name = file.name || row.name || '资质附件';
row.size = this.formatAttachmentSize(file.size || row.size);
row.uploadUserName = this.userInfo.realName || this.userInfo.userName || '';
row.uploadTime = this.$dayjs().format('YYYY-MM-DD HH:mm:ss');
row.url = file.url || row.url || '';
row.files = [file];
},
downloadAttachments() {
const files = this.qualificationFiles.filter(item => item.url);
if (!files.length) {
@@ -1051,7 +1136,9 @@ export default {
if (row && row.id) {
getDetail(row.id).then(res => {
this.archiveForm = this.normalizeDetail(res.data.data);
this.qualificationFiles = this.parseAttachments(this.archiveForm.qualificationAttachments);
this.qualificationFiles = this.parseAttachments(
this.archiveForm.qualificationAttachments
);
this.archiveBox = true;
});
return;
@@ -1089,7 +1176,9 @@ export default {
? archive.customerType.join(',')
: archive.customerType;
archive.qualificationAttachments = this.stringifyAttachments(this.qualificationFiles);
archive.contacts = (archive.contacts || []).filter(item => item.contactName || item.contactPhone);
archive.contacts = (archive.contacts || []).filter(
item => item.contactName || item.contactPhone
);
archive.receiptAccounts = (archive.receiptAccounts || []).filter(
item => item.accountName || item.bankAccount
);
@@ -1161,7 +1250,9 @@ export default {
}
},
scoreOptionChange(detail, optionValue) {
const option = this.parseScoreOptions(detail.optionsJson).find(item => item.value === optionValue);
const option = this.parseScoreOptions(detail.optionsJson).find(
item => item.value === optionValue
);
const score = Number(option?.score || 0);
detail.selfScore = score;
detail.reviewScore = score;
@@ -1327,7 +1418,10 @@ export default {
type: 'warning',
}).then(() => {
NProgress.start();
exportBlob('/blade-transport/customer-archive/export-customer-archive', this.buildExportParams())
exportBlob(
'/blade-transport/customer-archive/export-customer-archive',
this.buildExportParams()
)
.then(res => {
downloadXls(res.data, `客商档案${this.$dayjs().format('YYYY-MM-DD HH:mm:ss')}.xlsx`);
})
@@ -1375,6 +1469,10 @@ export default {
align-items: center;
justify-content: space-between;
margin: 18px 0 12px;
.section-title {
margin: 0;
}
}
.section-actions {
+15 -8
View File
@@ -63,6 +63,7 @@
<el-autocomplete
v-model="form.vehicleNo"
:fetch-suggestions="fetchVehicleOptions"
:disabled="boxType === 'view'"
clearable
placeholder="输入车牌号模糊查询选择"
value-key="value"
@@ -72,9 +73,15 @@
<template #attachments="{ row }">
<span>{{ formatAttachments(row.attachments) }}</span>
</template>
<template #attachmentsForm>
<vehicle-attachment-upload v-model="form.attachments" :readonly="boxType === 'view'" />
</template>
<template #attachments-form>
<vehicle-attachment-upload v-model="form.attachments" :readonly="boxType === 'view'" />
</template>
</avue-crud>
<el-dialog title="ETC记录数据导入" append-to-body v-model="excelBox" width="555px">
<avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter">
<avue-form :option="excelOption" v-model="excelForm">
<template #excelTemplate>
<el-button type="primary" @click="handleTemplate">
点击下载<i class="el-icon-download el-icon--right"></i>
@@ -91,6 +98,7 @@ import { getList as getVehicleList } from '@/api/transportCapacity/transport-veh
import { getDeptTree } from '@/api/system/dept';
import { exportBlob } from '@/api/common';
import { downloadXls } from '@/utils/util';
import { openImportDialog } from '@/utils/import-excel';
import { getToken } from '@/utils/auth';
import { mapGetters } from 'vuex';
import { excelOption, option } from '@/option/vehicle/etc-record';
@@ -114,6 +122,7 @@ export default {
total: 0,
},
selectionList: [],
boxType: '',
data: [],
};
},
@@ -308,6 +317,7 @@ export default {
});
},
beforeOpen(done, type) {
this.boxType = type;
if (type === 'add') {
this.form = { dataSource: '手工录入' };
}
@@ -360,12 +370,7 @@ export default {
});
},
handleImport() {
this.excelBox = true;
},
uploadAfter(res, done) {
this.excelBox = false;
this.onLoad(this.page);
done();
openImportDialog(this, 'ETC记录');
},
handleExport() {
this.$confirm('是否导出ETC记录数据?', '提示', {
@@ -391,7 +396,9 @@ export default {
};
},
handleTemplate() {
exportBlob(`/blade-transport/etc-record/export-template?${this.website.tokenHeader}=${getToken()}`).then(res => {
exportBlob(
`/blade-transport/etc-record/export-template?${this.website.tokenHeader}=${getToken()}`
).then(res => {
downloadXls(res.data, 'ETC记录模板.xlsx');
});
},
+235 -51
View File
@@ -64,19 +64,27 @@
v-model="form.vehicleNo"
:fetch-suggestions="fetchVehicleOptions"
clearable
placeholder="输入车牌号/船号模糊查询选择"
:placeholder="vehicleNoPlaceholder"
value-key="value"
class="insurance-record-page__vehicle-input"
/>
</template>
<template #policyFileForm>
<div class="insurance-record-page__upload">
<div class="insurance-record-page__upload-icon">OCR</div>
<div class="insurance-record-page__upload-text">
<strong>上传图片,自动识别填写</strong>
<span>支持JPGPNGPDF上传</span>
<div class="insurance-record-page__upload-info">
<div class="insurance-record-page__upload-icon" aria-hidden="true">
<span class="insurance-record-page__upload-card">
<span></span>
</span>
</div>
<div class="insurance-record-page__upload-text">
<strong>上传图片,自动识别填写</strong>
<span>支持JPGPNGPDF上传</span>
</div>
</div>
<el-upload
v-if="hasPermission('insurance_record_ocr')"
class="insurance-record-page__upload-action"
:action="recognizeUrl"
:data="recognizeData"
:headers="uploadHeaders"
@@ -84,9 +92,40 @@
:on-success="handleRecognizeSuccess"
:on-error="handleRecognizeError"
accept=".jpg,.jpeg,.png,.pdf"
v-if="hasPermission('insurance_record_ocr')"
>
<el-button type="primary" plain>上传文件</el-button>
<el-button class="insurance-record-page__upload-button" type="primary" plain>
上传文件
</el-button>
</el-upload>
</div>
</template>
<template #policyFile-form>
<div class="insurance-record-page__upload">
<div class="insurance-record-page__upload-info">
<div class="insurance-record-page__upload-icon" aria-hidden="true">
<span class="insurance-record-page__upload-card">
<span></span>
</span>
</div>
<div class="insurance-record-page__upload-text">
<strong>上传图片,自动识别填写</strong>
<span>支持JPGPNGPDF上传</span>
</div>
</div>
<el-upload
v-if="hasPermission('insurance_record_ocr')"
class="insurance-record-page__upload-action"
:action="recognizeUrl"
:data="recognizeData"
:headers="uploadHeaders"
:show-file-list="false"
:on-success="handleRecognizeSuccess"
:on-error="handleRecognizeError"
accept=".jpg,.jpeg,.png,.pdf"
>
<el-button class="insurance-record-page__upload-button" type="primary" plain>
上传文件
</el-button>
</el-upload>
</div>
</template>
@@ -98,7 +137,7 @@
@load="onLoad(page, query)"
/>
<el-dialog title="保险记录数据导入" append-to-body v-model="excelBox" width="555px">
<avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter">
<avue-form :option="excelOption" v-model="excelForm">
<template #excelTemplate>
<el-button type="primary" @click="handleTemplate">
点击下载<i class="el-icon-download el-icon--right"></i>
@@ -116,6 +155,7 @@ 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';
import { openImportDialog } from '@/utils/import-excel';
import { getToken } from '@/utils/auth';
import { mapGetters } from 'vuex';
import { excelOption, option } from '@/option/vehicle/insurance-record';
@@ -130,6 +170,7 @@ export default {
loading: true,
excelBox: false,
excelForm: {},
isDetailLoading: false,
option,
excelOption,
page: {
@@ -159,6 +200,9 @@ export default {
editBtn: this.hasPermission('insurance_record_edit'),
};
},
vehicleNoPlaceholder() {
return this.form.vehicleType === '船舶' ? '输入船号模糊查询选择' : '输入车牌号模糊查询选择';
},
ids() {
const ids = [];
this.selectionList.forEach(ele => {
@@ -181,10 +225,26 @@ export default {
};
},
},
watch: {
'form.vehicleType': {
handler(value, oldValue) {
this.updateVehicleTypeDisplays(value || '车辆', oldValue);
},
immediate: true,
},
},
methods: {
hasPermission(code) {
return this.isAdmin || this.validData(this.permission[code], false);
},
updateVehicleTypeDisplays(vehicleType, oldValue) {
const vehicleNoColumn = this.findColumn(this.option.column, 'vehicleNo');
vehicleNoColumn.placeholder =
vehicleType === '船舶' ? '输入船号模糊查询选择' : '输入车牌号模糊查询选择';
if (!this.isDetailLoading && oldValue && vehicleType !== oldValue && this.form.vehicleNo) {
this.form.vehicleNo = '';
}
},
initDeptTree() {
getDeptTree(this.userInfo.tenantId).then(res => {
const column = this.findColumn(this.option.column, 'createDept');
@@ -195,9 +255,7 @@ export default {
const vehicleType = this.form.vehicleType || '车辆';
const request = vehicleType === '船舶' ? getShipList : getVehicleList;
const params =
vehicleType === '船舶'
? { shipIdentifierNo: queryString }
: { plateNo: queryString };
vehicleType === '船舶' ? { shipIdentifierNo: queryString } : { plateNo: queryString };
request(1, 20, params)
.then(res => {
const records = res.data.data.records || [];
@@ -211,8 +269,12 @@ export default {
},
normalizeRow(row) {
const values = { ...row };
values.vehicleType = values.vehicleType || '车辆';
if (values.vehicleNo) {
values.vehicleNo = values.vehicleNo.trim().toUpperCase();
values.vehicleNo =
values.vehicleType === '船舶'
? values.vehicleNo.trim()
: values.vehicleNo.trim().toUpperCase();
}
if (values.policyNo) {
values.policyNo = values.policyNo.trim();
@@ -305,9 +367,17 @@ export default {
this.form.ocrTemplate = '紫金-机动车交强险';
}
if (['edit', 'view'].includes(type)) {
getDetail(this.form.id).then(res => {
this.form = res.data.data;
});
this.isDetailLoading = true;
getDetail(this.form.id)
.then(res => {
this.form = {
...res.data.data,
vehicleType: res.data.data.vehicleType || '车辆',
};
})
.finally(() => {
this.isDetailLoading = false;
});
}
done();
},
@@ -351,12 +421,7 @@ export default {
});
},
handleImport() {
this.excelBox = true;
},
uploadAfter(res, done) {
this.excelBox = false;
this.onLoad(this.page);
done();
openImportDialog(this, '保险记录');
},
handleExport() {
this.$confirm('是否导出保险记录数据?', '提示', {
@@ -365,7 +430,10 @@ export default {
type: 'warning',
}).then(() => {
NProgress.start();
exportBlob('/blade-transport/insurance-record/export-insurance-record', this.buildExportParams())
exportBlob(
'/blade-transport/insurance-record/export-insurance-record',
this.buildExportParams()
)
.then(res => {
downloadXls(res.data, `保险记录${this.$dayjs().format('YYYY-MM-DD HH:mm:ss')}.xlsx`);
})
@@ -383,7 +451,9 @@ export default {
},
handleTemplate() {
exportBlob(
`/blade-transport/insurance-record/export-template?${this.website.tokenHeader}=${getToken()}`
`/blade-transport/insurance-record/export-template?${
this.website.tokenHeader
}=${getToken()}`
).then(res => {
downloadXls(res.data, '保险记录模板.xlsx');
});
@@ -417,39 +487,153 @@ export default {
&__vehicle-input {
width: 100%;
}
}
&__upload {
display: flex;
align-items: center;
gap: 18px;
min-height: 88px;
padding: 18px 24px;
border: 1px dashed #8c8c8c;
border-radius: 6px;
}
:global(.insurance-record-page__upload) {
display: flex;
align-items: center;
justify-content: space-between;
min-height: 116px;
padding: 26px 46px 26px 32px;
border: 2px dashed #8b8b8b;
border-radius: 12px;
background: #fff;
}
&__upload-icon {
display: flex;
align-items: center;
justify-content: center;
width: 44px;
height: 44px;
color: #606266;
border: 2px solid #8c8c8c;
border-radius: 6px;
font-weight: 600;
}
:global(.insurance-record-page__upload-info) {
display: flex;
align-items: center;
min-width: 0;
}
&__upload-text {
display: flex;
flex: 1;
:global(.insurance-record-page__upload-icon) {
position: relative;
display: flex;
align-items: center;
justify-content: center;
width: 56px;
height: 56px;
margin-right: 30px;
color: #707070;
}
:global(.insurance-record-page__upload-icon::before),
:global(.insurance-record-page__upload-icon::after) {
position: absolute;
width: 14px;
height: 14px;
content: '';
}
:global(.insurance-record-page__upload-icon::before) {
top: 0;
left: 0;
border-top: 4px solid currentColor;
border-left: 4px solid currentColor;
border-radius: 4px 0 0;
}
:global(.insurance-record-page__upload-icon::after) {
right: 0;
bottom: 0;
border-right: 4px solid currentColor;
border-bottom: 4px solid currentColor;
border-radius: 0 0 4px;
}
:global(.insurance-record-page__upload-card) {
position: relative;
display: flex;
align-items: center;
justify-content: center;
width: 36px;
height: 28px;
border: 4px solid currentColor;
border-radius: 4px;
}
:global(.insurance-record-page__upload-card::before),
:global(.insurance-record-page__upload-card::after) {
position: absolute;
content: '';
}
:global(.insurance-record-page__upload-card::before) {
top: 7px;
left: 9px;
width: 8px;
height: 8px;
border: 3px solid currentColor;
border-radius: 2px;
}
:global(.insurance-record-page__upload-card::after) {
top: 8px;
right: 7px;
width: 8px;
height: 3px;
background: currentColor;
box-shadow: 0 8px 0 currentColor;
}
:global(.insurance-record-page__upload-card span) {
position: absolute;
right: 7px;
bottom: 5px;
width: 10px;
height: 3px;
background: currentColor;
}
:global(.insurance-record-page__upload-text) {
display: flex;
flex-direction: column;
gap: 8px;
color: #303133;
font-size: 20px;
line-height: 1.25;
}
:global(.insurance-record-page__upload-text strong) {
font-weight: 700;
}
:global(.insurance-record-page__upload-text span) {
color: #303133;
font-weight: 500;
}
:global(.insurance-record-page__upload-action) {
flex: 0 0 auto;
margin-left: 24px;
}
:global(.insurance-record-page__upload-action .el-upload) {
display: block;
}
:global(.insurance-record-page__upload-button) {
min-width: 156px;
height: 58px;
border-radius: 8px;
font-size: 20px;
font-weight: 500;
}
@media (max-width: 768px) {
:global(.insurance-record-page__upload) {
align-items: stretch;
flex-direction: column;
gap: 6px;
color: #303133;
gap: 18px;
padding: 22px;
}
span {
color: #606266;
}
:global(.insurance-record-page__upload-action) {
margin-left: 0;
}
:global(.insurance-record-page__upload-button) {
width: 100%;
}
}
</style>
+178 -38
View File
@@ -59,6 +59,17 @@
{{ row.vehicleNo }}
</el-button>
</template>
<template #vehicleNoForm>
<el-autocomplete
v-model="form.vehicleNo"
:fetch-suggestions="fetchVehicleOptions"
:disabled="boxType === 'view'"
clearable
:placeholder="vehicleNoPlaceholder"
value-key="value"
class="maintenance-plan-page__input"
/>
</template>
<template #mileage="{ row }">
<span>{{ formatMileage(row.mileage, row.mileageUnit) }}</span>
</template>
@@ -68,9 +79,27 @@
<template #attachments="{ row }">
<span>{{ formatAttachments(row.attachments) }}</span>
</template>
<template #attachmentsForm>
<vehicle-attachment-upload
v-model="form.attachments"
:readonly="boxType === 'view'"
button-text="新增"
button-icon="el-icon-plus"
:show-tip="false"
/>
</template>
<template #attachments-form>
<vehicle-attachment-upload
v-model="form.attachments"
:readonly="boxType === 'view'"
button-text="新增"
button-icon="el-icon-plus"
:show-tip="false"
/>
</template>
</avue-crud>
<el-dialog title="保养记录数据导入" append-to-body v-model="excelBox" width="555px">
<avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter">
<avue-form :option="excelOption" v-model="excelForm">
<template #excelTemplate>
<el-button type="primary" @click="handleTemplate">
点击下载<i class="el-icon-download el-icon--right"></i>
@@ -83,9 +112,12 @@
<script>
import { getList, getDetail, add, update, remove } from '@/api/vehicle/maintenance-plan';
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';
import { openImportDialog } from '@/utils/import-excel';
import { formatUpdateUserName } from '@/utils/audit';
import { getToken } from '@/utils/auth';
import { mapGetters } from 'vuex';
@@ -116,13 +148,20 @@ export default {
total: 0,
},
selectionList: [],
boxType: '',
option: {
height: 'auto',
calcHeight: 32,
dialogWidth: 980,
dialogWidth: 960,
labelPosition: 'right',
labelWidth: 'auto',
searchLabelWidth: 160,
tip: false,
searchShow: true,
searchMenuSpan: 6,
searchMenuSpan: 24,
searchIcon: true,
searchIndex: 8,
searchMenuPosition: 'right',
border: true,
index: true,
viewBtn: true,
@@ -141,6 +180,8 @@ export default {
],
value: '车辆',
search: true,
span: 24,
change: ({ value }) => this.handleVehicleTypeChange(value || '车辆'),
rules: [{ required: true, message: '请选择车船类型', trigger: 'change' }],
},
{
@@ -149,6 +190,8 @@ export default {
slot: true,
search: true,
minWidth: 130,
span: 12,
placeholder: '输入车牌号/船号查询选择',
rules: [
{ required: true, message: '请输入车牌号/船号', trigger: 'blur' },
{ max: 30, message: '最多 30 个字符', trigger: 'blur' },
@@ -157,6 +200,8 @@ export default {
{
label: '保养人',
prop: 'maintainer',
span: 12,
placeholder: '请输入',
rules: [{ max: 20, message: '最多 20 个字符', trigger: 'blur' }],
},
{
@@ -166,6 +211,8 @@ export default {
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
minWidth: 170,
span: 12,
placeholder: '请选择',
rules: [{ required: true, message: '请选择保养时间', trigger: 'click' }],
},
{
@@ -175,6 +222,9 @@ export default {
precision: 2,
minWidth: 130,
slot: true,
span: 12,
append: '公里',
placeholder: '请输入',
rules: [{ validator: validateNonNegative, trigger: 'blur' }],
},
{
@@ -187,11 +237,14 @@ export default {
],
value: '公里',
hide: true,
display: false,
},
{
label: '保养项目',
prop: 'maintenanceItem',
minWidth: 160,
span: 12,
placeholder: '请输入',
rules: [{ max: 100, message: '最多 100 个字符', trigger: 'blur' }],
},
{
@@ -199,6 +252,9 @@ export default {
prop: 'cost',
type: 'number',
precision: 2,
append: '元',
span: 12,
placeholder: '请输入',
rules: [
{ required: true, message: '请输入费用', trigger: 'blur' },
{ validator: validateNonNegative, trigger: 'blur' },
@@ -207,12 +263,16 @@ export default {
{
label: '店名',
prop: 'storeName',
span: 12,
placeholder: '请输入',
rules: [{ max: 50, message: '最多 50 个字符', trigger: 'blur' }],
},
{
label: '联系电话',
prop: 'contactPhone',
minWidth: 150,
span: 12,
placeholder: '请输入',
rules: [{ max: 20, message: '最多 20 个字符', trigger: 'blur' }],
},
{
@@ -221,6 +281,7 @@ export default {
minWidth: 180,
overHidden: true,
span: 24,
placeholder: '地图选址',
rules: [{ max: 100, message: '最多 100 个字符', trigger: 'blur' }],
},
{
@@ -230,6 +291,8 @@ export default {
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
minWidth: 170,
span: 12,
placeholder: '请选择',
},
{
label: '下次保养里程/航程',
@@ -238,34 +301,29 @@ export default {
precision: 2,
minWidth: 170,
slot: true,
span: 12,
append: '公里',
placeholder: '请输入',
rules: [{ validator: validateNonNegative, trigger: 'blur' }],
},
{
label: '附件',
prop: 'attachments',
type: 'upload',
listType: 'text',
multiple: true,
accept: '.jpg,.jpeg,.png,.pdf',
propsHttp: {
res: 'data',
url: 'link',
name: 'name',
},
action: '/blade-resource/oss/endpoint/put-file',
span: 24,
minWidth: 100,
slot: true,
},
{
label: '备注',
prop: 'remark',
type: 'textarea',
minRows: 4,
minRows: 5,
span: 24,
hide: true,
placeholder: '请输入',
rules: [{ max: 500, message: '最多 500 个字符', trigger: 'blur' }],
},
{
label: '附件',
prop: 'attachments',
span: 24,
minWidth: 100,
slot: true,
formslot: true,
},
{
label: '创建时间',
prop: 'createTime',
@@ -341,6 +399,7 @@ export default {
],
},
excelOption: {
labelPosition: 'right',
submitBtn: false,
emptyBtn: false,
column: [
@@ -385,6 +444,9 @@ export default {
editBtn: this.hasPermission('maintenance_plan_edit'),
};
},
vehicleNoPlaceholder() {
return this.form.vehicleType === '船舶' ? '输入船号模糊查询选择' : '输入车牌号模糊查询选择';
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
@@ -397,6 +459,41 @@ export default {
hasPermission(code) {
return this.isAdmin || this.validData(this.permission[code], false);
},
handleVehicleTypeChange(vehicleType) {
this.updateVehicleType(vehicleType);
if (!this.form.id && this.form.vehicleNo) {
this.form.vehicleNo = '';
}
},
updateVehicleType(vehicleType) {
const mileageUnit = vehicleType === '船舶' ? '海里' : '公里';
const mileageColumn = this.findColumn(this.option.column, 'mileage');
const nextMaintenanceMileageColumn = this.findColumn(
this.option.column,
'nextMaintenanceMileage'
);
const mileageUnitColumn = this.findColumn(this.option.column, 'mileageUnit');
mileageColumn.append = mileageUnit;
nextMaintenanceMileageColumn.append = mileageUnit;
mileageUnitColumn.value = mileageUnit;
this.form.mileageUnit = mileageUnit;
},
fetchVehicleOptions(queryString, callback) {
const vehicleType = this.form.vehicleType || '车辆';
const request = vehicleType === '船舶' ? getShipList : getVehicleList;
const params =
vehicleType === '船舶' ? { shipIdentifierNo: queryString } : { plateNo: queryString };
request(1, 20, params)
.then(res => {
const records = res.data.data.records || [];
callback(
records.map(item => ({
value: vehicleType === '船舶' ? item.shipIdentifierNo || item.shipName : item.plateNo,
}))
);
})
.catch(() => callback([]));
},
formatMileage(value, unit) {
if (value === undefined || value === null || value === '') return '';
return `${Math.max(Number(value), 0)} ${unit || '公里'}`;
@@ -409,12 +506,20 @@ export default {
const attachments = JSON.parse(value);
return Array.isArray(attachments) ? `${attachments.length}` : '1 个';
} catch (error) {
return value
.split(',')
.map(item => item.trim())
.filter(Boolean).length + ' 个';
return (
value
.split(',')
.map(item => item.trim())
.filter(Boolean).length + ' 个'
);
}
},
isEmpty(value) {
return value === undefined || value === null || value === '';
},
toNumber(value) {
return this.isEmpty(value) ? null : Number(value);
},
parseAttachments(value) {
if (!value || Array.isArray(value)) return value;
if (typeof value !== 'string') return [];
@@ -440,14 +545,31 @@ export default {
},
normalizeRow(row) {
const values = { ...row };
if (!values.mileageUnit) {
values.mileageUnit = values.vehicleType === '船舶' ? '海里' : '公里';
}
values.vehicleType = values.vehicleType || '车辆';
values.mileageUnit = values.vehicleType === '船舶' ? '海里' : '公里';
values.attachments = this.stringifyAttachments(values.attachments);
return values;
},
validateRow(row) {
const mileage = this.toNumber(row.mileage);
const nextMaintenanceMileage = this.toNumber(row.nextMaintenanceMileage);
if (
mileage !== null &&
nextMaintenanceMileage !== null &&
nextMaintenanceMileage <= mileage
) {
this.$message.warning('下次保养里程/航程应大于本次里程/航程数');
return false;
}
return true;
},
rowSave(row, done, loading) {
add(this.normalizeRow(row)).then(
const values = this.normalizeRow(row);
if (!this.validateRow(values)) {
loading();
return;
}
add(values).then(
() => {
this.onLoad(this.page);
this.$message({ type: 'success', message: '操作成功!' });
@@ -460,7 +582,12 @@ export default {
);
},
rowUpdate(row, index, done, loading) {
update(this.normalizeRow(row)).then(
const values = this.normalizeRow(row);
if (!this.validateRow(values)) {
loading();
return;
}
update(values).then(
() => {
this.onLoad(this.page);
this.$message({ type: 'success', message: '操作成功!' });
@@ -502,11 +629,20 @@ export default {
});
},
beforeOpen(done, type) {
this.boxType = type;
if (type === 'add') {
this.form.vehicleType = '车辆';
this.form.mileageUnit = '公里';
this.updateVehicleType(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 || '车辆';
detail.mileageUnit = detail.vehicleType === '船舶' ? '海里' : '公里';
this.form = detail;
this.updateVehicleType(detail.vehicleType);
});
}
done();
@@ -551,12 +687,7 @@ export default {
});
},
handleImport() {
this.excelBox = true;
},
uploadAfter(res, done) {
this.excelBox = false;
this.onLoad(this.page);
done();
openImportDialog(this, '保养记录');
},
handleExport() {
this.$confirm('是否导出保养记录数据?', '提示', {
@@ -565,7 +696,10 @@ export default {
type: 'warning',
}).then(() => {
NProgress.start();
exportBlob('/blade-transport/maintenance-plan/export-maintenance-plan', this.buildExportParams())
exportBlob(
'/blade-transport/maintenance-plan/export-maintenance-plan',
this.buildExportParams()
)
.then(res => {
downloadXls(res.data, `保养记录${this.$dayjs().format('YYYY-MM-DD HH:mm:ss')}.xlsx`);
})
@@ -583,7 +717,9 @@ export default {
},
handleTemplate() {
exportBlob(
`/blade-transport/maintenance-plan/export-template?${this.website.tokenHeader}=${getToken()}`
`/blade-transport/maintenance-plan/export-template?${
this.website.tokenHeader
}=${getToken()}`
).then(res => {
downloadXls(res.data, '保养记录模板.xlsx');
});
@@ -598,5 +734,9 @@ export default {
:deep(.el-table td .cell) {
white-space: nowrap;
}
&__input {
width: 100%;
}
}
</style>
+175 -46
View File
@@ -59,15 +59,44 @@
{{ row.vehicleNo }}
</el-button>
</template>
<template #vehicleNoForm>
<el-autocomplete
v-model="form.vehicleNo"
:fetch-suggestions="fetchVehicleOptions"
:disabled="boxType === 'view'"
clearable
:placeholder="vehicleNoPlaceholder"
value-key="value"
class="maintenance-record-page__input"
/>
</template>
<template #mileage="{ row }">
<span>{{ formatMileage(row.mileage, row.mileageUnit) }}</span>
</template>
<template #attachments="{ row }">
<span>{{ formatAttachments(row.attachments) }}</span>
</template>
<template #attachmentsForm>
<vehicle-attachment-upload
v-model="form.attachments"
:readonly="boxType === 'view'"
button-text="新增"
button-icon="el-icon-plus"
:show-tip="false"
/>
</template>
<template #attachments-form>
<vehicle-attachment-upload
v-model="form.attachments"
:readonly="boxType === 'view'"
button-text="新增"
button-icon="el-icon-plus"
:show-tip="false"
/>
</template>
</avue-crud>
<el-dialog title="维修记录数据导入" append-to-body v-model="excelBox" width="555px">
<avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter">
<avue-form :option="excelOption" v-model="excelForm">
<template #excelTemplate>
<el-button type="primary" @click="handleTemplate">
点击下载<i class="el-icon-download el-icon--right"></i>
@@ -80,9 +109,12 @@
<script>
import { getList, getDetail, add, update, remove } from '@/api/vehicle/maintenance-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';
import { openImportDialog } from '@/utils/import-excel';
import { formatUpdateUserName } from '@/utils/audit';
import { getToken } from '@/utils/auth';
import { mapGetters } from 'vuex';
@@ -106,6 +138,7 @@ export default {
loading: true,
excelBox: false,
excelForm: {},
isDetailLoading: false,
page: {
pageSize: 10,
pageSizes: [10, 20, 50, 100],
@@ -113,13 +146,20 @@ export default {
total: 0,
},
selectionList: [],
boxType: '',
option: {
height: 'auto',
calcHeight: 32,
dialogWidth: 980,
dialogWidth: 960,
labelPosition: 'right',
labelWidth: 'auto',
searchLabelWidth: 160,
tip: false,
searchShow: true,
searchMenuSpan: 6,
searchMenuSpan: 24,
searchIcon: true,
searchIndex: 8,
searchMenuPosition: 'right',
border: true,
index: true,
viewBtn: true,
@@ -138,14 +178,19 @@ export default {
],
value: '车辆',
search: true,
span: 24,
change: ({ value }) => this.updateVehicleType(value || '车辆'),
rules: [{ required: true, message: '请选择车船类型', trigger: 'change' }],
},
{
label: '车牌号/船号',
prop: 'vehicleNo',
slot: true,
formslot: true,
search: true,
minWidth: 130,
span: 12,
placeholder: '输入车牌号/船号查询选择',
rules: [
{ required: true, message: '请输入车牌号/船号', trigger: 'blur' },
{ max: 30, message: '最多 30 个字符', trigger: 'blur' },
@@ -154,6 +199,8 @@ export default {
{
label: '维修人',
prop: 'maintainer',
span: 12,
placeholder: '请输入',
rules: [{ max: 20, message: '最多 20 个字符', trigger: 'blur' }],
},
{
@@ -163,12 +210,16 @@ export default {
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
minWidth: 170,
span: 12,
placeholder: '日期时间选择器',
rules: [{ required: true, message: '请选择维修时间', trigger: 'click' }],
},
{
label: '维修位置',
prop: 'location',
minWidth: 160,
span: 12,
placeholder: '请输入',
rules: [{ max: 100, message: '最多 100 个字符', trigger: 'blur' }],
},
{
@@ -176,6 +227,8 @@ export default {
prop: 'replacedPart',
minWidth: 160,
overHidden: true,
span: 12,
placeholder: '请输入',
rules: [{ max: 200, message: '最多 200 个字符', trigger: 'blur' }],
},
{
@@ -183,6 +236,9 @@ export default {
prop: 'cost',
type: 'number',
precision: 2,
append: '元',
span: 12,
placeholder: '请输入',
rules: [
{ required: true, message: '请输入费用', trigger: 'blur' },
{ validator: validateNonNegative, trigger: 'blur' },
@@ -192,14 +248,27 @@ export default {
label: '维修单位',
prop: 'company',
minWidth: 180,
span: 12,
placeholder: '请输入',
rules: [{ max: 50, message: '最多 50 个字符', trigger: 'blur' }],
},
{
label: '联系方式',
prop: 'contact',
minWidth: 150,
span: 12,
placeholder: '请输入',
rules: [{ max: 20, message: '最多 20 个字符', trigger: 'blur' }],
},
{
label: '地址',
prop: 'address',
minWidth: 180,
overHidden: true,
span: 24,
placeholder: '地图选址',
rules: [{ max: 100, message: '最多 100 个字符', trigger: 'blur' }],
},
{
label: '出厂时间',
prop: 'factoryTime',
@@ -207,6 +276,8 @@ export default {
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
minWidth: 170,
span: 12,
placeholder: '日期时间选择器',
},
{
label: '里程/航程数',
@@ -214,7 +285,10 @@ export default {
type: 'number',
precision: 2,
minWidth: 130,
append: '公里',
slot: true,
span: 12,
placeholder: '请输入',
rules: [{ validator: validateNonNegative, trigger: 'blur' }],
},
{
@@ -229,38 +303,22 @@ export default {
hide: true,
},
{
label: '地址',
prop: 'address',
minWidth: 180,
overHidden: true,
label: '备注',
prop: 'remark',
type: 'textarea',
minRows: 5,
span: 24,
rules: [{ max: 100, message: '最多 100 个字符', trigger: 'blur' }],
hide: true,
placeholder: '请输入',
rules: [{ max: 500, message: '最多 500 个字符', trigger: 'blur' }],
},
{
label: '附件',
prop: 'attachments',
type: 'upload',
listType: 'text',
multiple: true,
accept: '.jpg,.jpeg,.png,.pdf',
propsHttp: {
res: 'data',
url: 'link',
name: 'name',
},
action: '/blade-resource/oss/endpoint/put-file',
span: 24,
minWidth: 100,
slot: true,
},
{
label: '备注',
prop: 'remark',
type: 'textarea',
minRows: 4,
span: 24,
hide: true,
rules: [{ max: 500, message: '最多 500 个字符', trigger: 'blur' }],
formslot: true,
},
{
label: '创建时间',
@@ -337,6 +395,7 @@ export default {
],
},
excelOption: {
labelPosition: 'right',
submitBtn: false,
emptyBtn: false,
column: [
@@ -381,6 +440,9 @@ export default {
editBtn: this.hasPermission('maintenance_record_edit'),
};
},
vehicleNoPlaceholder() {
return this.form.vehicleType === '船舶' ? '输入船号模糊查询选择' : '输入车牌号模糊查询选择';
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
@@ -389,10 +451,50 @@ export default {
return ids.join(',');
},
},
watch: {
'form.vehicleType': {
handler(value, oldValue) {
this.updateVehicleType(value || '车辆', oldValue);
},
immediate: true,
},
},
methods: {
hasPermission(code) {
return this.isAdmin || this.validData(this.permission[code], false);
},
updateVehicleType(vehicleType, oldValue) {
const mileageUnit = vehicleType === '船舶' ? '海里' : '公里';
const vehicleTypeColumn = this.findColumn(this.option.column, 'vehicleType');
const vehicleNoColumn = this.findColumn(this.option.column, 'vehicleNo');
const mileageColumn = this.findColumn(this.option.column, 'mileage');
const mileageUnitColumn = this.findColumn(this.option.column, 'mileageUnit');
vehicleNoColumn.placeholder =
vehicleType === '船舶' ? '输入船号模糊查询选择' : '输入车牌号模糊查询选择';
vehicleTypeColumn.disabled = Boolean(this.form.id);
mileageColumn.append = mileageUnit;
mileageUnitColumn.value = mileageUnit;
this.form.mileageUnit = mileageUnit;
if (!this.isDetailLoading && oldValue && vehicleType !== oldValue && this.form.vehicleNo) {
this.form.vehicleNo = '';
}
},
fetchVehicleOptions(queryString, callback) {
const vehicleType = this.form.vehicleType || '车辆';
const request = vehicleType === '船舶' ? getShipList : getVehicleList;
const params =
vehicleType === '船舶' ? { shipIdentifierNo: queryString } : { plateNo: queryString };
request(1, 20, params)
.then(res => {
const records = res.data.data.records || [];
callback(
records.map(item => ({
value: vehicleType === '船舶' ? item.shipIdentifierNo || item.shipName : item.plateNo,
}))
);
})
.catch(() => callback([]));
},
formatMileage(value, unit) {
if (value === undefined || value === null || value === '') return '';
return `${Math.max(Number(value), 0)} ${unit || '公里'}`;
@@ -405,10 +507,12 @@ export default {
const attachments = JSON.parse(value);
return Array.isArray(attachments) ? `${attachments.length}` : '1 个';
} catch (error) {
return value
.split(',')
.map(item => item.trim())
.filter(Boolean).length + ' 个';
return (
value
.split(',')
.map(item => item.trim())
.filter(Boolean).length + ' 个'
);
}
},
parseAttachments(value) {
@@ -436,8 +540,13 @@ export default {
},
normalizeRow(row) {
const values = { ...row };
if (!values.mileageUnit) {
values.mileageUnit = values.vehicleType === '船舶' ? '海里' : '公里';
values.vehicleType = values.vehicleType || '车辆';
values.mileageUnit = values.vehicleType === '船舶' ? '海里' : '公里';
if (values.vehicleNo) {
values.vehicleNo =
values.vehicleType === '船舶'
? values.vehicleNo.trim()
: values.vehicleNo.trim().toUpperCase();
}
values.attachments = this.stringifyAttachments(values.attachments);
return values;
@@ -498,12 +607,28 @@ export default {
});
},
beforeOpen(done, type) {
this.boxType = type;
if (type === 'add') {
this.form = {
vehicleType: '车辆',
mileageUnit: '公里',
};
this.updateVehicleType('车辆');
}
if (['edit', 'view'].includes(type)) {
getDetail(this.form.id).then(res => {
const detail = res.data.data;
detail.attachments = this.parseAttachments(detail.attachments);
this.form = detail;
});
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.mileageUnit = detail.vehicleType === '船舶' ? '海里' : '公里';
this.form = detail;
this.updateVehicleType(detail.vehicleType);
})
.finally(() => {
this.isDetailLoading = false;
});
}
done();
},
@@ -547,12 +672,7 @@ export default {
});
},
handleImport() {
this.excelBox = true;
},
uploadAfter(res, done) {
this.excelBox = false;
this.onLoad(this.page);
done();
openImportDialog(this, '维修记录');
},
handleExport() {
this.$confirm('是否导出维修记录数据?', '提示', {
@@ -561,7 +681,10 @@ export default {
type: 'warning',
}).then(() => {
NProgress.start();
exportBlob('/blade-transport/maintenance-record/export-maintenance-record', this.buildExportParams())
exportBlob(
'/blade-transport/maintenance-record/export-maintenance-record',
this.buildExportParams()
)
.then(res => {
downloadXls(res.data, `维修记录${this.$dayjs().format('YYYY-MM-DD HH:mm:ss')}.xlsx`);
})
@@ -579,7 +702,9 @@ export default {
},
handleTemplate() {
exportBlob(
`/blade-transport/maintenance-record/export-template?${this.website.tokenHeader}=${getToken()}`
`/blade-transport/maintenance-record/export-template?${
this.website.tokenHeader
}=${getToken()}`
).then(res => {
downloadXls(res.data, '维修记录模板.xlsx');
});
@@ -594,5 +719,9 @@ export default {
:deep(.el-table td .cell) {
white-space: nowrap;
}
&__input {
width: 100%;
}
}
</style>
+162 -25
View File
@@ -59,20 +59,57 @@
{{ row.vehicleNo }}
</el-button>
</template>
<template #previousMonthMileage="{ row }">
<span>{{ formatMileage(row.previousMonthMileage, row.mileageUnit) }}</span>
</template>
<template #currentMonthMileage="{ row }">
<span>{{ formatMileage(row.currentMonthMileage, row.mileageUnit) }}</span>
</template>
<template #monthlyMileage="{ row }">
<span>{{ formatMileage(row.monthlyMileage, row.mileageUnit) }}</span>
</template>
<template #totalMileage="{ row }">
<span>{{ formatMileage(row.totalMileage, row.mileageUnit) }}</span>
</template>
<template #vehicleNoForm>
<el-autocomplete
v-model="form.vehicleNo"
:fetch-suggestions="fetchVehicleOptions"
:disabled="Boolean(form.id)"
clearable
placeholder="输入车牌号模糊查询选择"
:placeholder="vehicleNoPlaceholder"
value-key="value"
class="mileage-record-page__input"
/>
</template>
<template #totalMileageStart-search="{ row }">
<div class="mileage-record-page__range">
<el-input
v-model="row.totalMileageStart"
clearable
placeholder="请输入"
type="number"
class="mileage-record-page__range-input"
/>
<span class="mileage-record-page__range-separator">-</span>
<el-input
v-model="row.totalMileageEnd"
clearable
placeholder="请输入"
type="number"
class="mileage-record-page__range-input"
/>
</div>
</template>
<template #attachments="{ row }">
<span>{{ formatAttachments(row.attachments) }}</span>
</template>
<template #attachmentsForm>
<vehicle-attachment-upload v-model="form.attachments" :readonly="boxType === 'view'" />
</template>
<template #attachments-form>
<vehicle-attachment-upload v-model="form.attachments" :readonly="boxType === 'view'" />
</template>
</avue-crud>
<empty-pagination
:page="page"
@@ -81,7 +118,7 @@
@load="onLoad(page, query)"
/>
<el-dialog title="里程记录数据导入" append-to-body v-model="excelBox" width="555px">
<avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter">
<avue-form :option="excelOption" v-model="excelForm">
<template #excelTemplate>
<el-button type="primary" @click="handleTemplate">
点击下载<i class="el-icon-download el-icon--right"></i>
@@ -95,9 +132,11 @@
<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';
import { openImportDialog } from '@/utils/import-excel';
import { getToken } from '@/utils/auth';
import { mapGetters } from 'vuex';
import { excelOption, option } from '@/option/vehicle/mileage-record';
@@ -121,6 +160,7 @@ export default {
total: 0,
},
selectionList: [],
boxType: '',
data: [],
};
},
@@ -141,6 +181,9 @@ export default {
editBtn: this.hasPermission('mileage_record_edit'),
};
},
vehicleNoPlaceholder() {
return this.form.vehicleType === '船舶' ? '输入船号模糊查询选择' : '输入车牌号模糊查询选择';
},
ids() {
const ids = [];
this.selectionList.forEach(ele => {
@@ -149,10 +192,43 @@ 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];
column.append = unit;
});
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');
@@ -160,13 +236,27 @@ export default {
});
},
fetchVehicleOptions(queryString, callback) {
getVehicleList(1, 20, { plateNo: queryString })
const vehicleType = this.form.vehicleType || '车辆';
const request = vehicleType === '船舶' ? getShipList : getVehicleList;
const params =
vehicleType === '船舶' ? { shipIdentifierNo: queryString } : { plateNo: queryString };
request(1, 20, params)
.then(res => {
const records = res.data.data.records || [];
callback(records.map(item => ({ value: item.plateNo })));
callback(
records.map(item => ({
value: vehicleType === '船舶' ? item.shipIdentifierNo || item.shipName : item.plateNo,
}))
);
})
.catch(() => callback([]));
},
formatMileage(value, unit) {
if (this.isEmpty(value)) {
return '';
}
return `${value} ${unit || '公里'}`;
},
formatAttachments(value) {
if (!value) return '';
if (Array.isArray(value)) return `${value.length}`;
@@ -211,12 +301,21 @@ export default {
},
normalizeRow(row) {
const values = { ...row };
values.vehicleType = values.vehicleType || '车辆';
values.mileageUnit = values.vehicleType === '船舶' ? '海里' : '公里';
if (values.vehicleNo) {
values.vehicleNo = values.vehicleNo.trim().toUpperCase();
values.vehicleNo =
values.vehicleType === '船舶'
? values.vehicleNo.trim()
: values.vehicleNo.trim().toUpperCase();
}
const previousMonthMileage = this.toNumber(values.previousMonthMileage);
const currentMonthMileage = this.toNumber(values.currentMonthMileage);
if (this.isEmpty(values.monthlyMileage) && previousMonthMileage !== null && currentMonthMileage !== null) {
if (
this.isEmpty(values.monthlyMileage) &&
previousMonthMileage !== null &&
currentMonthMileage !== null
) {
values.monthlyMileage = this.toMoney(currentMonthMileage - previousMonthMileage);
}
values.attachments = this.stringifyAttachments(values.attachments);
@@ -237,11 +336,12 @@ export default {
return true;
},
validateRow(row) {
const isShip = row.vehicleType === '船舶';
const mileageFields = [
['previousMonthMileage', '上月统计里程'],
['currentMonthMileage', '本月统计里程'],
['monthlyMileage', '本月行驶里程'],
['totalMileage', '累计行驶里程'],
['previousMonthMileage', isShip ? '上月统计航程数' : '上月统计里程'],
['currentMonthMileage', isShip ? '本月统计航程数' : '本月统计里程'],
['monthlyMileage', isShip ? '本月航行航程数' : '本月行驶里程'],
['totalMileage', isShip ? '累计航程数' : '累计行驶里程'],
];
if (!mileageFields.every(([prop, label]) => this.validateMileage(row[prop], label))) {
return false;
@@ -256,11 +356,21 @@ export default {
monthlyMileage !== null &&
this.toMoney(currentMonthMileage - previousMonthMileage) !== this.toMoney(monthlyMileage)
) {
this.$message.warning('本月行驶里程应等于本月统计里程减去上月统计里程');
this.$message.warning(
isShip
? '本月航行航程数应等于本月统计航程数减去上月统计航程数'
: '本月行驶里程数应等于本月统计里程数减去上月统计里程数'
);
return false;
}
if (totalMileage !== null && currentMonthMileage !== null && totalMileage < currentMonthMileage) {
this.$message.warning('累计行驶里程应大于等于本月统计里程');
if (
totalMileage !== null &&
currentMonthMileage !== null &&
totalMileage < currentMonthMileage
) {
this.$message.warning(
isShip ? '累计航程数应大于等于本月统计航程数' : '累计行驶里程数应大于等于本月统计里程数'
);
return false;
}
return true;
@@ -331,19 +441,32 @@ export default {
});
},
beforeOpen(done, type) {
this.boxType = type;
const vehicleNoColumn = this.findColumn(this.option.column, 'vehicleNo');
vehicleNoColumn.disabled = type !== 'add';
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 === '船舶' ? '海里' : '公里';
this.form = detail;
this.updateVehicleTypeDisplays(detail.vehicleType);
});
}
done();
},
searchReset() {
this.query = {};
if (this.$refs.crud?.search) {
this.$refs.crud.search.totalMileageStart = undefined;
this.$refs.crud.search.totalMileageEnd = undefined;
}
this.onLoad(this.page);
},
searchChange(params, done) {
@@ -382,12 +505,7 @@ export default {
});
},
handleImport() {
this.excelBox = true;
},
uploadAfter(res, done) {
this.excelBox = false;
this.onLoad(this.page);
done();
openImportDialog(this, '里程记录');
},
handleExport() {
this.$confirm('是否导出里程记录数据?', '提示', {
@@ -396,7 +514,10 @@ export default {
type: 'warning',
}).then(() => {
NProgress.start();
exportBlob('/blade-transport/mileage-record/export-mileage-record', this.buildExportParams())
exportBlob(
'/blade-transport/mileage-record/export-mileage-record',
this.buildExportParams()
)
.then(res => {
downloadXls(res.data, `里程记录${this.$dayjs().format('YYYY-MM-DD HH:mm:ss')}.xlsx`);
})
@@ -413,11 +534,11 @@ export default {
};
},
handleTemplate() {
exportBlob(`/blade-transport/mileage-record/export-template?${this.website.tokenHeader}=${getToken()}`).then(
res => {
downloadXls(res.data, '里程记录模板.xlsx');
}
);
exportBlob(
`/blade-transport/mileage-record/export-template?${this.website.tokenHeader}=${getToken()}`
).then(res => {
downloadXls(res.data, '里程记录模板.xlsx');
});
},
},
};
@@ -433,5 +554,21 @@ export default {
&__input {
width: 100%;
}
&__range {
display: flex;
align-items: center;
gap: 8px;
width: 100%;
}
&__range-input {
width: 150px;
}
&__range-separator {
color: #606266;
line-height: 32px;
}
}
</style>
+53 -25
View File
@@ -63,8 +63,9 @@
<el-autocomplete
v-model="form.vehicleNo"
:fetch-suggestions="fetchVehicleOptions"
:disabled="boxType === 'view'"
clearable
placeholder="输入车牌号/船号查询选择"
:placeholder="vehicleNoPlaceholder"
value-key="value"
class="oil-electric-record-page__input"
/>
@@ -72,9 +73,15 @@
<template #attachments="{ row }">
<span>{{ formatAttachments(row.attachments) }}</span>
</template>
<template #attachmentsForm>
<vehicle-attachment-upload v-model="form.attachments" :readonly="boxType === 'view'" />
</template>
<template #attachments-form>
<vehicle-attachment-upload v-model="form.attachments" :readonly="boxType === 'view'" />
</template>
</avue-crud>
<el-dialog title="油电记录数据导入" append-to-body v-model="excelBox" width="555px">
<avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter">
<avue-form :option="excelOption" v-model="excelForm">
<template #excelTemplate>
<el-button type="primary" @click="handleTemplate">
点击下载<i class="el-icon-download el-icon--right"></i>
@@ -92,6 +99,7 @@ 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';
import { openImportDialog } from '@/utils/import-excel';
import { getToken } from '@/utils/auth';
import { mapGetters } from 'vuex';
import { excelOption, option } from '@/option/vehicle/oil-electric-record';
@@ -106,6 +114,7 @@ export default {
loading: true,
excelBox: false,
excelForm: {},
isDetailLoading: false,
option,
excelOption,
page: {
@@ -115,6 +124,7 @@ export default {
total: 0,
},
selectionList: [],
boxType: '',
data: [],
};
},
@@ -135,6 +145,9 @@ export default {
editBtn: this.hasPermission('oil_electric_record_edit'),
};
},
vehicleNoPlaceholder() {
return this.form.vehicleType === '船舶' ? '输入船号模糊查询选择' : '输入车牌号模糊查询选择';
},
ids() {
const ids = [];
this.selectionList.forEach(ele => {
@@ -145,8 +158,8 @@ export default {
},
watch: {
'form.vehicleType': {
handler() {
this.updateVehicleType();
handler(value, oldValue) {
this.updateVehicleType(value || '车辆', oldValue);
},
immediate: true,
},
@@ -167,8 +180,11 @@ export default {
column.dicData = res.data.data;
});
},
updateVehicleType() {
if (!this.form.id && this.form.vehicleNo) {
updateVehicleType(vehicleType, oldValue) {
const vehicleNoColumn = this.findColumn(this.option.column, 'vehicleNo');
vehicleNoColumn.placeholder =
vehicleType === '船舶' ? '输入船号模糊查询选择' : '输入车牌号模糊查询选择';
if (!this.isDetailLoading && oldValue && vehicleType !== oldValue && this.form.vehicleNo) {
this.form.vehicleNo = '';
}
},
@@ -238,7 +254,10 @@ export default {
values.vehicleType = values.vehicleType || '车辆';
values.dataSource = values.dataSource || '手工录入';
if (values.vehicleNo) {
values.vehicleNo = values.vehicleType === '船舶' ? values.vehicleNo.trim() : values.vehicleNo.trim().toUpperCase();
values.vehicleNo =
values.vehicleType === '船舶'
? values.vehicleNo.trim()
: values.vehicleNo.trim().toUpperCase();
}
if (values.feeType === '充电') {
values.oilProduct = undefined;
@@ -341,17 +360,26 @@ export default {
});
},
beforeOpen(done, type) {
this.boxType = type;
if (type === 'add') {
this.form = { vehicleType: '车辆', feeType: '加油', dataSource: '手工录入' };
this.updateVehicleType('车辆');
this.updateFeeType('加油');
}
if (['edit', 'view'].includes(type)) {
getDetail(this.form.id).then(res => {
const detail = res.data.data;
detail.attachments = this.parseAttachments(detail.attachments);
this.form = detail;
this.updateFeeType(detail.feeType);
});
this.isDetailLoading = true;
getDetail(this.form.id)
.then(res => {
const detail = res.data.data;
detail.attachments = this.parseAttachments(detail.attachments);
detail.vehicleType = detail.vehicleType || '车辆';
this.form = detail;
this.updateVehicleType(detail.vehicleType);
this.updateFeeType(detail.feeType);
})
.finally(() => {
this.isDetailLoading = false;
});
}
done();
},
@@ -395,12 +423,7 @@ export default {
});
},
handleImport() {
this.excelBox = true;
},
uploadAfter(res, done) {
this.excelBox = false;
this.onLoad(this.page);
done();
openImportDialog(this, '油电记录');
},
handleExport() {
this.$confirm('是否导出油电记录数据?', '提示', {
@@ -409,7 +432,10 @@ export default {
type: 'warning',
}).then(() => {
NProgress.start();
exportBlob('/blade-transport/oil-electric-record/export-oil-electric-record', this.buildExportParams())
exportBlob(
'/blade-transport/oil-electric-record/export-oil-electric-record',
this.buildExportParams()
)
.then(res => {
downloadXls(res.data, `油电记录${this.$dayjs().format('YYYY-MM-DD HH:mm:ss')}.xlsx`);
})
@@ -426,11 +452,13 @@ export default {
};
},
handleTemplate() {
exportBlob(`/blade-transport/oil-electric-record/export-template?${this.website.tokenHeader}=${getToken()}`).then(
res => {
downloadXls(res.data, '油电记录模板.xlsx');
}
);
exportBlob(
`/blade-transport/oil-electric-record/export-template?${
this.website.tokenHeader
}=${getToken()}`
).then(res => {
downloadXls(res.data, '油电记录模板.xlsx');
});
},
},
};
+56 -25
View File
@@ -63,8 +63,9 @@
<el-autocomplete
v-model="form.vehicleNo"
:fetch-suggestions="fetchVehicleOptions"
:disabled="boxType === 'view'"
clearable
placeholder="输入车牌号/船号查询选择"
:placeholder="vehicleNoPlaceholder"
value-key="value"
class="other-expense-record-page__input"
/>
@@ -72,9 +73,15 @@
<template #attachments="{ row }">
<span>{{ formatAttachments(row.attachments) }}</span>
</template>
<template #attachmentsForm>
<vehicle-attachment-upload v-model="form.attachments" :readonly="boxType === 'view'" />
</template>
<template #attachments-form>
<vehicle-attachment-upload v-model="form.attachments" :readonly="boxType === 'view'" />
</template>
</avue-crud>
<el-dialog title="其他费用记录数据导入" append-to-body v-model="excelBox" width="555px">
<avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter">
<avue-form :option="excelOption" v-model="excelForm">
<template #excelTemplate>
<el-button type="primary" @click="handleTemplate">
点击下载<i class="el-icon-download el-icon--right"></i>
@@ -92,6 +99,7 @@ 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';
import { openImportDialog } from '@/utils/import-excel';
import { getToken } from '@/utils/auth';
import { mapGetters } from 'vuex';
import { excelOption, option } from '@/option/vehicle/other-expense-record';
@@ -106,6 +114,7 @@ export default {
loading: true,
excelBox: false,
excelForm: {},
isDetailLoading: false,
option,
excelOption,
page: {
@@ -115,6 +124,7 @@ export default {
total: 0,
},
selectionList: [],
boxType: '',
data: [],
};
},
@@ -135,6 +145,9 @@ export default {
editBtn: this.hasPermission('other_expense_record_edit'),
};
},
vehicleNoPlaceholder() {
return this.form.vehicleType === '船舶' ? '输入船号模糊查询选择' : '输入车牌号模糊查询选择';
},
ids() {
const ids = [];
this.selectionList.forEach(ele => {
@@ -145,8 +158,8 @@ export default {
},
watch: {
'form.vehicleType': {
handler() {
this.updateVehicleType();
handler(value, oldValue) {
this.updateVehicleType(value || '车辆', oldValue);
},
immediate: true,
},
@@ -161,8 +174,11 @@ export default {
column.dicData = res.data.data;
});
},
updateVehicleType() {
if (!this.form.id && this.form.vehicleNo) {
updateVehicleType(vehicleType, oldValue) {
const vehicleNoColumn = this.findColumn(this.option.column, 'vehicleNo');
vehicleNoColumn.placeholder =
vehicleType === '船舶' ? '输入船号模糊查询选择' : '输入车牌号模糊查询选择';
if (!this.isDetailLoading && oldValue && vehicleType !== oldValue && this.form.vehicleNo) {
this.form.vehicleNo = '';
}
},
@@ -223,7 +239,10 @@ export default {
values.vehicleType = values.vehicleType || '车辆';
values.dataSource = values.dataSource || '手工录入';
if (values.vehicleNo) {
values.vehicleNo = values.vehicleType === '船舶' ? values.vehicleNo.trim() : values.vehicleNo.trim().toUpperCase();
values.vehicleNo =
values.vehicleType === '船舶'
? values.vehicleNo.trim()
: values.vehicleNo.trim().toUpperCase();
}
values.attachments = this.stringifyAttachments(values.attachments);
return values;
@@ -320,19 +339,28 @@ export default {
});
},
beforeOpen(done, type) {
this.boxType = type;
if (type === 'add') {
this.form = {
vehicleType: '车辆',
expenseDate: this.$dayjs().format('YYYY-MM-DD'),
dataSource: '手工录入',
};
this.updateVehicleType('车辆');
}
if (['edit', 'view'].includes(type)) {
getDetail(this.form.id).then(res => {
const detail = res.data.data;
detail.attachments = this.parseAttachments(detail.attachments);
this.form = detail;
});
this.isDetailLoading = true;
getDetail(this.form.id)
.then(res => {
const detail = res.data.data;
detail.attachments = this.parseAttachments(detail.attachments);
detail.vehicleType = detail.vehicleType || '车辆';
this.form = detail;
this.updateVehicleType(detail.vehicleType);
})
.finally(() => {
this.isDetailLoading = false;
});
}
done();
},
@@ -386,12 +414,7 @@ export default {
});
},
handleImport() {
this.excelBox = true;
},
uploadAfter(res, done) {
this.excelBox = false;
this.onLoad(this.page);
done();
openImportDialog(this, '其他费用记录');
},
handleExport() {
this.$confirm('是否导出其他费用记录数据?', '提示', {
@@ -400,9 +423,15 @@ export default {
type: 'warning',
}).then(() => {
NProgress.start();
exportBlob('/blade-transport/other-expense-record/export-other-expense-record', this.buildExportParams())
exportBlob(
'/blade-transport/other-expense-record/export-other-expense-record',
this.buildExportParams()
)
.then(res => {
downloadXls(res.data, `其他费用记录${this.$dayjs().format('YYYY-MM-DD HH:mm:ss')}.xlsx`);
downloadXls(
res.data,
`其他费用记录${this.$dayjs().format('YYYY-MM-DD HH:mm:ss')}.xlsx`
);
})
.finally(() => {
NProgress.done();
@@ -417,11 +446,13 @@ export default {
};
},
handleTemplate() {
exportBlob(`/blade-transport/other-expense-record/export-template?${this.website.tokenHeader}=${getToken()}`).then(
res => {
downloadXls(res.data, '其他费用记录模板.xlsx');
}
);
exportBlob(
`/blade-transport/other-expense-record/export-template?${
this.website.tokenHeader
}=${getToken()}`
).then(res => {
downloadXls(res.data, '其他费用记录模板.xlsx');
});
},
},
};
+28 -9
View File
@@ -63,8 +63,9 @@
<el-autocomplete
v-model="form.vehicleNo"
:fetch-suggestions="fetchVehicleOptions"
:disabled="boxType === 'view'"
clearable
placeholder="输入关键字"
placeholder="输入车牌号查询选择"
value-key="value"
class="tire-replacement-record-page__input"
/>
@@ -72,6 +73,24 @@
<template #attachments="{ row }">
<span>{{ formatAttachments(row.attachments) }}</span>
</template>
<template #attachmentsForm>
<vehicle-attachment-upload
v-model="form.attachments"
:readonly="boxType === 'view'"
button-text="新增"
button-icon="el-icon-plus"
:show-tip="false"
/>
</template>
<template #attachments-form>
<vehicle-attachment-upload
v-model="form.attachments"
:readonly="boxType === 'view'"
button-text="新增"
button-icon="el-icon-plus"
:show-tip="false"
/>
</template>
</avue-crud>
<empty-pagination
:page="page"
@@ -80,7 +99,7 @@
@load="onLoad(page, query)"
/>
<el-dialog title="换胎记录数据导入" append-to-body v-model="excelBox" width="555px">
<avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter">
<avue-form :option="excelOption" v-model="excelForm">
<template #excelTemplate>
<el-button type="primary" @click="handleTemplate">
点击下载<i class="el-icon-download el-icon--right"></i>
@@ -97,6 +116,7 @@ import { getList as getVehicleList } from '@/api/transportCapacity/transport-veh
import { getDeptTree } from '@/api/system/dept';
import { exportBlob } from '@/api/common';
import { downloadXls } from '@/utils/util';
import { openImportDialog } from '@/utils/import-excel';
import { getToken } from '@/utils/auth';
import { mapGetters } from 'vuex';
import { excelOption, option } from '@/option/vehicle/tire-replacement-record';
@@ -120,6 +140,7 @@ export default {
total: 0,
},
selectionList: [],
boxType: '',
data: [],
};
},
@@ -289,6 +310,7 @@ export default {
});
},
beforeOpen(done, type) {
this.boxType = type;
if (type === 'add') {
this.form = {};
}
@@ -341,12 +363,7 @@ export default {
});
},
handleImport() {
this.excelBox = true;
},
uploadAfter(res, done) {
this.excelBox = false;
this.onLoad(this.page);
done();
openImportDialog(this, '换胎记录');
},
handleExport() {
this.$confirm('是否导出换胎记录数据?', '提示', {
@@ -376,7 +393,9 @@ export default {
},
handleTemplate() {
exportBlob(
`/blade-transport/tire-replacement-record/export-template?${this.website.tokenHeader}=${getToken()}`
`/blade-transport/tire-replacement-record/export-template?${
this.website.tokenHeader
}=${getToken()}`
).then(res => {
downloadXls(res.data, '换胎记录模板.xlsx');
});
+44 -19
View File
@@ -63,8 +63,9 @@
<el-autocomplete
v-model="form.vehicleNo"
:fetch-suggestions="fetchVehicleOptions"
:disabled="boxType === 'view'"
clearable
placeholder="输入车牌号/船号模糊查询选择"
:placeholder="vehicleNoPlaceholder"
value-key="value"
class="transport-change-record-page__input"
/>
@@ -72,9 +73,15 @@
<template #attachments="{ row }">
<span>{{ formatAttachments(row.attachments) }}</span>
</template>
<template #attachmentsForm>
<vehicle-attachment-upload v-model="form.attachments" :readonly="boxType === 'view'" />
</template>
<template #attachments-form>
<vehicle-attachment-upload v-model="form.attachments" :readonly="boxType === 'view'" />
</template>
</avue-crud>
<el-dialog title="变更记录数据导入" append-to-body v-model="excelBox" width="555px">
<avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter">
<avue-form :option="excelOption" v-model="excelForm">
<template #excelTemplate>
<el-button type="primary" @click="handleTemplate">
点击下载<i class="el-icon-download el-icon--right"></i>
@@ -92,6 +99,7 @@ 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';
import { openImportDialog } from '@/utils/import-excel';
import { getToken } from '@/utils/auth';
import { mapGetters } from 'vuex';
import { excelOption, option } from '@/option/vehicle/transport-change-record';
@@ -106,6 +114,7 @@ export default {
loading: true,
excelBox: false,
excelForm: {},
isDetailLoading: false,
option,
excelOption,
page: {
@@ -115,6 +124,7 @@ export default {
total: 0,
},
selectionList: [],
boxType: '',
data: [],
};
},
@@ -135,6 +145,9 @@ export default {
editBtn: this.hasPermission('transport_change_record_edit'),
};
},
vehicleNoPlaceholder() {
return this.form.vehicleType === '船舶' ? '输入船号模糊查询选择' : '输入车牌号模糊查询选择';
},
ids() {
const ids = [];
this.selectionList.forEach(ele => {
@@ -145,8 +158,8 @@ export default {
},
watch: {
'form.vehicleType': {
handler(value) {
this.updateVehicleType(value || '车辆');
handler(value, oldValue) {
this.updateVehicleType(value || '车辆', oldValue);
},
immediate: true,
},
@@ -161,8 +174,11 @@ export default {
column.dicData = res.data.data;
});
},
updateVehicleType() {
if (!this.form.id && this.form.vehicleNo) {
updateVehicleType(vehicleType, oldValue) {
const vehicleNoColumn = this.findColumn(this.option.column, 'vehicleNo');
vehicleNoColumn.placeholder =
vehicleType === '船舶' ? '输入船号模糊查询选择' : '输入车牌号模糊查询选择';
if (!this.isDetailLoading && oldValue && vehicleType !== oldValue && this.form.vehicleNo) {
this.form.vehicleNo = '';
}
},
@@ -219,7 +235,10 @@ export default {
const values = { ...row };
values.vehicleType = values.vehicleType || '车辆';
if (values.vehicleNo) {
values.vehicleNo = values.vehicleType === '船舶' ? values.vehicleNo.trim() : values.vehicleNo.trim().toUpperCase();
values.vehicleNo =
values.vehicleType === '船舶'
? values.vehicleNo.trim()
: values.vehicleNo.trim().toUpperCase();
}
values.attachments = this.stringifyAttachments(values.attachments);
return values;
@@ -301,15 +320,24 @@ export default {
});
},
beforeOpen(done, type) {
this.boxType = type;
if (type === 'add') {
this.form = { vehicleType: '车辆' };
this.updateVehicleType('车辆');
}
if (['edit', 'view'].includes(type)) {
getDetail(this.form.id).then(res => {
const detail = res.data.data;
detail.attachments = this.parseAttachments(detail.attachments);
this.form = detail;
});
this.isDetailLoading = true;
getDetail(this.form.id)
.then(res => {
const detail = res.data.data;
detail.attachments = this.parseAttachments(detail.attachments);
detail.vehicleType = detail.vehicleType || '车辆';
this.form = detail;
this.updateVehicleType(detail.vehicleType);
})
.finally(() => {
this.isDetailLoading = false;
});
}
done();
},
@@ -353,12 +381,7 @@ export default {
});
},
handleImport() {
this.excelBox = true;
},
uploadAfter(res, done) {
this.excelBox = false;
this.onLoad(this.page);
done();
openImportDialog(this, '变更记录');
},
handleExport() {
this.$confirm('是否导出变更记录数据?', '提示', {
@@ -388,7 +411,9 @@ export default {
},
handleTemplate() {
exportBlob(
`/blade-transport/transport-change-record/export-template?${this.website.tokenHeader}=${getToken()}`
`/blade-transport/transport-change-record/export-template?${
this.website.tokenHeader
}=${getToken()}`
).then(res => {
downloadXls(res.data, '变更记录模板.xlsx');
});
+78 -26
View File
@@ -63,8 +63,9 @@
<el-autocomplete
v-model="form.vehicleNo"
:fetch-suggestions="fetchVehicleOptions"
:disabled="boxType === 'view'"
clearable
placeholder="输入车牌号/船号模糊查询选择"
:placeholder="vehicleNoPlaceholder"
value-key="value"
class="violation-record-page__input"
/>
@@ -74,12 +75,20 @@
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" clearable maxlength="20" placeholder="请输入船长" />
<el-input
v-else
v-model="form.driverName"
:disabled="boxType === 'view'"
clearable
maxlength="20"
placeholder="请输入船长"
/>
</template>
<template #processStatus="{ row }">
<span :class="row.processStatus === '未处理' ? 'violation-record-page__danger' : ''">
@@ -89,6 +98,24 @@
<template #attachments="{ row }">
<span>{{ formatAttachments(row.attachments) }}</span>
</template>
<template #attachmentsForm>
<vehicle-attachment-upload
v-model="form.attachments"
:readonly="boxType === 'view'"
button-text="新增"
button-icon="el-icon-plus"
:show-tip="false"
/>
</template>
<template #attachments-form>
<vehicle-attachment-upload
v-model="form.attachments"
:readonly="boxType === 'view'"
button-text="新增"
button-icon="el-icon-plus"
:show-tip="false"
/>
</template>
</avue-crud>
<empty-pagination
:page="page"
@@ -97,7 +124,7 @@
@load="onLoad(page, query)"
/>
<el-dialog title="违章记录数据导入" append-to-body v-model="excelBox" width="555px">
<avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter">
<avue-form :option="excelOption" v-model="excelForm">
<template #excelTemplate>
<el-button type="primary" @click="handleTemplate">
点击下载<i class="el-icon-download el-icon--right"></i>
@@ -116,6 +143,7 @@ import { getList as getDriverList } from '@/api/transportCapacity/driver';
import { getDeptTree } from '@/api/system/dept';
import { exportBlob } from '@/api/common';
import { downloadXls } from '@/utils/util';
import { openImportDialog } from '@/utils/import-excel';
import { getToken } from '@/utils/auth';
import { mapGetters } from 'vuex';
import { excelOption, option } from '@/option/vehicle/violation-record';
@@ -130,6 +158,7 @@ export default {
loading: true,
excelBox: false,
excelForm: {},
isDetailLoading: false,
option,
excelOption,
page: {
@@ -139,6 +168,7 @@ export default {
total: 0,
},
selectionList: [],
boxType: '',
data: [],
};
},
@@ -159,6 +189,9 @@ export default {
editBtn: this.hasPermission('violation_record_edit'),
};
},
vehicleNoPlaceholder() {
return this.form.vehicleType === '船舶' ? '输入船号模糊查询选择' : '输入车牌号模糊查询选择';
},
ids() {
const ids = [];
this.selectionList.forEach(ele => {
@@ -169,8 +202,8 @@ export default {
},
watch: {
'form.vehicleType': {
handler(value) {
this.updateVehicleTypeDisplays(value || '车辆');
handler(value, oldValue) {
this.updateVehicleTypeDisplays(value || '车辆', oldValue);
},
immediate: true,
},
@@ -191,15 +224,22 @@ export default {
column.dicData = res.data.data;
});
},
updateVehicleTypeDisplays(vehicleType) {
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 === '船舶';
vehicleTypeColumn.disabled = Boolean(this.form.id);
if (!this.isDetailLoading && oldValue && vehicleType !== oldValue) {
this.form.vehicleNo = '';
this.form.driverName = '';
}
if (vehicleType === '船舶') {
this.form.violationType = undefined;
} else {
@@ -217,9 +257,7 @@ export default {
const vehicleType = this.form.vehicleType || '车辆';
const request = vehicleType === '船舶' ? getShipList : getVehicleList;
const params =
vehicleType === '船舶'
? { shipIdentifierNo: queryString }
: { plateNo: queryString };
vehicleType === '船舶' ? { shipIdentifierNo: queryString } : { plateNo: queryString };
request(1, 20, params)
.then(res => {
const records = res.data.data.records || [];
@@ -277,7 +315,10 @@ export default {
values.vehicleType = values.vehicleType || '车辆';
values.processStatus = values.processStatus || '未处理';
if (values.vehicleNo) {
values.vehicleNo = values.vehicleNo.trim().toUpperCase();
values.vehicleNo =
values.vehicleType === '船舶'
? values.vehicleNo.trim()
: values.vehicleNo.trim().toUpperCase();
}
if (values.processStatus === '未处理') {
values.processResult = undefined;
@@ -291,7 +332,10 @@ export default {
return values;
},
validateRow(row) {
if (row.violationTime && new Date(row.violationTime.replace(/-/g, '/')).getTime() > Date.now()) {
if (
row.violationTime &&
new Date(row.violationTime.replace(/-/g, '/')).getTime() > Date.now()
) {
this.$message.warning('时间不能超过当前时间');
return false;
}
@@ -378,6 +422,7 @@ export default {
});
},
beforeOpen(done, type) {
this.boxType = type;
if (type === 'add') {
this.form = {
vehicleType: '车辆',
@@ -387,13 +432,20 @@ export default {
this.updateProcessResultDisplay('未处理');
}
if (['edit', 'view'].includes(type)) {
getDetail(this.form.id).then(res => {
const detail = res.data.data;
detail.attachments = this.parseAttachments(detail.attachments);
this.form = detail;
this.updateVehicleTypeDisplays(detail.vehicleType);
this.updateProcessResultDisplay(detail.processStatus);
});
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 || '未处理';
this.form = detail;
this.updateVehicleTypeDisplays(detail.vehicleType);
this.updateProcessResultDisplay(detail.processStatus);
})
.finally(() => {
this.isDetailLoading = false;
});
}
done();
},
@@ -437,12 +489,7 @@ export default {
});
},
handleImport() {
this.excelBox = true;
},
uploadAfter(res, done) {
this.excelBox = false;
this.onLoad(this.page);
done();
openImportDialog(this, '违章记录');
},
handleExport() {
this.$confirm('是否导出违章记录数据?', '提示', {
@@ -451,7 +498,10 @@ export default {
type: 'warning',
}).then(() => {
NProgress.start();
exportBlob('/blade-transport/violation-record/export-violation-record', this.buildExportParams())
exportBlob(
'/blade-transport/violation-record/export-violation-record',
this.buildExportParams()
)
.then(res => {
downloadXls(res.data, `违章记录${this.$dayjs().format('YYYY-MM-DD HH:mm:ss')}.xlsx`);
})
@@ -469,7 +519,9 @@ export default {
},
handleTemplate() {
exportBlob(
`/blade-transport/violation-record/export-template?${this.website.tokenHeader}=${getToken()}`
`/blade-transport/violation-record/export-template?${
this.website.tokenHeader
}=${getToken()}`
).then(res => {
downloadXls(res.data, '违章记录模板.xlsx');
});