lanan-system-vue/src/views/base/customer/ChooseCarDraw.vue

273 lines
8.1 KiB
Vue
Raw Normal View History

2024-08-03 16:16:28 +08:00
<template>
2024-08-03 21:51:33 +08:00
2024-08-03 16:16:28 +08:00
<!-- 对话框(添加 / 修改) -->
<el-drawer
title="选择车辆"
size="60%"
:visible.sync="drawVisible"
2024-08-03 21:51:33 +08:00
@close="cancelForm"
>
<div style="padding: 0 10px;margin-bottom: 70px">
2024-08-03 16:16:28 +08:00
<!-- 搜索工作栏 -->
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
2024-08-03 21:51:33 +08:00
2024-08-03 16:16:28 +08:00
<el-form-item label="车牌号" prop="licenseNumber">
<el-input v-model="queryParams.licenseNumber" placeholder="请输入车牌号" clearable
2024-08-03 21:51:33 +08:00
@keyup.enter.native="handleQuery"/>
2024-08-03 16:16:28 +08:00
</el-form-item>
2024-08-03 21:51:33 +08:00
<el-form-item label="车辆型号" prop="carModel" label-width="90">
<el-input v-model="queryParams.carModel" placeholder="请输入车辆型号" clearable @keyup.enter.native="handleQuery"/>
2024-08-03 16:16:28 +08:00
</el-form-item>
2024-08-03 21:51:33 +08:00
<el-form-item label="车辆品牌" prop="carBrand" label-width="90">
<el-input v-model="queryParams.carBrand" placeholder="请输入车辆品牌" clearable @keyup.enter.native="handleQuery"/>
2024-08-03 16:16:28 +08:00
</el-form-item>
2024-08-03 21:51:33 +08:00
<el-form-item label="发动机号" prop="engineNumber" label-width="90">
<el-input v-model="queryParams.engineNumber" placeholder="请输入发动机号" clearable
@keyup.enter.native="handleQuery"/>
2024-08-03 16:16:28 +08:00
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<!-- 操作工具栏 -->
2024-08-03 21:51:33 +08:00
<el-row>
<el-col :span="3">
2024-08-03 16:16:28 +08:00
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="openForm(undefined)"
2024-08-03 21:51:33 +08:00
v-hasPermi="['base:car-main:create']">新增
</el-button>
</el-col>
<el-col :span="3" v-for="car in multipleSelection">
<el-tag
:key="car.id"
type="danger"
@close="tagClose(car)"
closable>
{{car.licenseNumber}}
</el-tag>
2024-08-03 16:16:28 +08:00
</el-col>
</el-row>
2024-08-03 21:51:33 +08:00
<el-table
ref="multipleTable"
height="460"
v-loading="formLoading"
:data="list"
:stripe="true"
@select="selectRow"
@select-all="handleSelectAll"
:show-overflow-tooltip="true">
<el-table-column
type="selection"
width="55">
</el-table-column>
<el-table-column label="车牌号" align="center" prop="licenseNumber"/>
2024-08-08 10:09:18 +08:00
<el-table-column label="车辆品牌" align="center" prop="brandStr"/>
<el-table-column label="车辆型号" align="center" prop="modelStr"/>
2024-08-03 16:16:28 +08:00
<el-table-column label="发动机号码" align="center" prop="engineNumber" />
<el-table-column label="车架号" align="center" prop="vin" />
2024-08-03 21:51:33 +08:00
<el-table-column label="登记时间" align="center" prop="createTime" >
2024-08-03 16:16:28 +08:00
<template v-slot="scope">
2024-08-03 21:51:33 +08:00
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
2024-08-03 16:16:28 +08:00
</template>
</el-table-column>
2024-08-03 21:51:33 +08:00
2024-08-03 16:16:28 +08:00
</el-table>
2024-08-03 21:51:33 +08:00
<!-- 分页组件 -->
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
@pagination="getList"/>
</div>
<div style="position: absolute;bottom: 0;width: 100%;right: 0;padding: 5px 20px 0;z-index: 999;background: white;text-align: right">
<div class="demo-drawer__footer" >
<el-button @click="cancelForm"> </el-button>
<el-button type="primary" @click="submitForm" > </el-button>
</div>
</div>
<CarMainForm ref="formRef" @success="getList" />
2024-08-03 16:16:28 +08:00
</el-drawer>
2024-08-03 21:51:33 +08:00
<!-- 对话框(添加 / 修改) -->
2024-08-03 16:16:28 +08:00
</template>
<script>
import * as CarMainApi from '@/api/base/carmain';
2024-08-03 21:51:33 +08:00
import CarMainForm from '@/views/base/carmain/CarMainForm.vue';
2024-08-03 16:16:28 +08:00
export default {
name: "ChooseCarDraw",
2024-08-03 21:51:33 +08:00
components: {CarMainForm},
2024-08-03 16:16:28 +08:00
data() {
return {
// 弹出层标题
// 是否显示弹出层
drawVisible: false,
// 表单的加载中1修改时的数据加载2提交的按钮禁用
formLoading: false,
// 导出遮罩层
exportLoading: false,
// 显示搜索条件
showSearch: true,
//回参
2024-08-03 21:51:33 +08:00
formData: {},
// 总条数
total: 0,
2024-08-03 16:16:28 +08:00
// 车辆信息列表
list: [],
2024-08-03 21:51:33 +08:00
multipleSelection:[],
2024-08-03 16:16:28 +08:00
// 查询参数
queryParams: {
pageNo: 1,
pageSize: 10,
licenseNumber: null,
carModel: null,
carBrand: null,
2024-08-03 21:51:33 +08:00
engineNumber: null,
2024-08-03 16:16:28 +08:00
},
};
},
methods: {
/** 打开弹窗 */
2024-08-03 21:51:33 +08:00
async open(multipleSelection) {
2024-08-03 16:16:28 +08:00
this.drawVisible = true;
this.formLoading = true;
2024-08-03 21:51:33 +08:00
this.reset();
try {
2024-08-03 16:16:28 +08:00
const res = await CarMainApi.getCarMainPage(this.queryParams);
this.list = res.data.records;
this.total = res.data.total;
2024-08-04 10:43:41 +08:00
this.multipleSelection = JSON.parse(JSON.stringify(multipleSelection))
2024-08-03 21:51:33 +08:00
this.defaultChecked(multipleSelection)
} finally {
2024-08-03 16:16:28 +08:00
this.formLoading = false;
}
},
2024-08-03 21:51:33 +08:00
/**标签删除事件*/
tagClose(row){
2024-08-04 10:43:41 +08:00
const that = this;
2024-08-03 21:51:33 +08:00
let id1 = this.multipleSelection.findIndex(item => {
if (item.id == row.id) {
2024-08-04 10:43:41 +08:00
this.$nextTick(() => {
that.$refs.multipleTable.toggleRowSelection(
this.list.find( // 这是弹框表格的数据
carItem => item.id === carItem.id
), false);
});
2024-08-03 21:51:33 +08:00
return true
}
})
this.multipleSelection.splice(id1, 1)
},
/**选中*/
selectRow(val,row){
//当前点击是否勾选
let selectBool = val.length && val.indexOf(row) !== -1
if(!selectBool){
//取消勾选
this.multipleSelection.forEach((item,i) => {
if(item.id == row.id){
this.multipleSelection.splice(i,1)
}
})
}else{
//选中
this.multipleSelection.push(row)
}
},
/**全选*/
handleSelectAll(val){
if(val.length == this.list.length){ //全选
this.multipleSelection = this.multipleSelection.concat(val)
//去重
let obj = {}
let result = []
this.multipleSelection.forEach(item => {
if(!obj[item.id]){
result.push(item)
obj[item.id] = true
}
})
this.multipleSelection = result
}else{ //取消全选
this.list.forEach(item => {
this.multipleSelection.forEach((multItem,i) => {
if(item.id == multItem.id){
this.multipleSelection.splice(i,1)
}
})
})
}
},
/**设置默认选中*/
defaultChecked(multipleSelection) {
const that = this;
this.$nextTick(() => {
that.list.forEach((v, i) => {
multipleSelection.map(item => {
if (item.id === v.id){
that.$refs.multipleTable.toggleRowSelection(v, true);
}
})
});
});
},
cancelForm(){
this.drawVisible = false
},
/** 添加/修改操作 */
openForm(id) {
this.$refs["formRef"].open(id);
},
2024-08-03 16:16:28 +08:00
/** 查询列表 */
async getList() {
try {
2024-08-03 21:51:33 +08:00
this.formLoading = true
2024-08-03 16:16:28 +08:00
const res = await CarMainApi.getCarMainPage(this.queryParams);
this.list = res.data.records;
this.total = res.data.total;
2024-08-03 21:51:33 +08:00
this.defaultChecked(this.multipleSelection)
2024-08-03 16:16:28 +08:00
} finally {
2024-08-03 21:51:33 +08:00
this.formLoading = false
2024-08-03 16:16:28 +08:00
}
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNo = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
2024-08-03 21:51:33 +08:00
/**重置参数*/
reset() {
this.queryParams= {
pageNo: 1,
pageSize: 10,
licenseNumber: null,
carModel: null,
carBrand: null,
engineNumber: null,
}
},
2024-08-03 16:16:28 +08:00
/** 提交按钮 */
2024-08-03 21:51:33 +08:00
submitForm() {
this.drawVisible = false
this.$emit('success',this.multipleSelection)
2024-08-03 16:16:28 +08:00
},
}
};
</script>