oil-station/fuintAdmin/src/views/setting/device/content/youqiji.vue

313 lines
8.6 KiB
Vue
Raw Normal View History

2024-08-16 18:26:19 +08:00
<template>
2024-10-19 18:03:31 +08:00
<div class="aainer">
<div class="wit-b">
2024-08-16 18:26:19 +08:00
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
<el-form-item label="" prop="legalRepresentativeContact">
<el-select
v-model="queryParams.deviceType"
clearable
placeholder="请选择设备类型"
>
<el-option v-for="item in deviceTypeList" :key="item" :label="item" :value="item">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="" prop="deviceName">
<el-input
v-model="queryParams.deviceName"
placeholder="请输入设备名称"
clearable
style="width: 240px;"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="">
<el-date-picker
v-model="beginTime"
style="width: 140px"
type="date"
placeholder="交易开始日期">
</el-date-picker>
<el-date-picker
v-model="endTime"
style="width: 140px"
type="date"
placeholder="交易结束日期">
</el-date-picker>
</el-form-item>
<el-form-item style="float: right;margin-right: 0px">
<el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
<el-button
type="primary"
@click="handleAdd"
>新增设备</el-button>
</el-form-item>
</el-form>
<!-- v-hasPermi="['setting:app:add']"-->
<div style="height: 70vh;overflow: auto">
<el-table :data="tableData" style="width: 100%" border>
<el-table-column align="center" type="index" label="序号"></el-table-column>
<el-table-column align="center" prop="deviceType" label="设备类型"></el-table-column>
<el-table-column align="center" prop="deviceName" label="设备名称"></el-table-column>
<el-table-column align="center" prop="deviceId" label="设备id"></el-table-column>
<el-table-column align="center" prop="createName" label="创建人"></el-table-column>
<el-table-column align="center" prop="createTime" label="创建时间"></el-table-column>
<el-table-column label="操作" align="center" width="200" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-view"
@click="edit(scope.row)"
>编辑</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="del(scope.row)"
>删除</el-button>
</template>
<!-- v-hasPermi="['setting:app:delete']"-->
</el-table-column>
</el-table>
</div>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.page"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</div>
2024-10-19 18:03:31 +08:00
<el-dialog :title="title" :close-on-click-modal="false" :visible.sync="open" width="24%" append-to-body>
<el-form :model="deviceInfo" ref="deviceForm" label-width="95px" :rules="rule">
2024-08-16 18:26:19 +08:00
<el-form-item label="设备类型" prop="deviceType">
<el-select
v-model="deviceInfo.deviceType"
clearable
placeholder="设备类型"
style="width: 300px;"
>
<el-option v-for="item in deviceTypeList" :key="item" :label="item" :value="item">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="设备名称" prop="deviceName">
<el-input v-model="deviceInfo.deviceName" style="width: 300px;"></el-input>
</el-form-item>
<el-form-item v-if="deviceInfo.deviceType !== 'BY'" label="设备id" prop="deviceId">
<el-input v-model="deviceInfo.deviceId" style="width: 300px;"></el-input>
</el-form-item>
<el-form-item label="" prop="deviceId1">
2024-10-19 18:03:31 +08:00
<div style="color: red; width: 300px; font-size: 12px; line-height: 15px">DDLY的设备ID需要找业务人员获取DD是集线器IDLY是门店ID
2024-08-16 18:26:19 +08:00
BY的设备ID创建后将自动生成请把设备ID提供给BY技术人员进行配置 </div>
</el-form-item>
<el-form-item>
2024-09-16 16:30:12 +08:00
<el-button @click="open = false">取消</el-button>
<el-button type="primary" @click="submitForm('deviceForm')">提交</el-button>
2024-08-16 18:26:19 +08:00
</el-form-item>
</el-form>
</el-dialog>
</div>
</template>
<script>
import {
addOilEngineConfigApi,
delOilEngineConfigApi,
editOilEngineConfigApi,
getListByPageApi
} from "@/api/seeting/youqiji";
export default {
name: "youqiji",
data() {
return {
tableData: [],
deviceTypeList: [
"BY",
"LY",
"DD",
],
// 日期范围
dateRange: [],
beginTime:"",
endTime:"",
deviceInfo: {
id: null, // 自增id
deviceType: 'BY',
deviceName: '',
deviceId: '',
},
rule: {
deviceType: [{required: true, message: '请选择设备类型', trigger: 'blur'},],
deviceName: [{required: true, message: '请填写设备名称', trigger: 'blur'},],
deviceId: [{required: true, message: '请填写设备ID', trigger: 'blur'},],
},
// 是否显示弹出层
open: false,
title:"",
total:0,
// 查询参数
queryParams: {
page: 1,
pageSize: 10,
orgName:'',
orgId:'',
legalRepresentativeContact:'',
appStatus:'',
},
};
},
created() {
this.getList()
this.getDeptList()
},
methods: {
getList(){
let dateRange = []
if (this.beginTime && this.endTime) {
dateRange.push(this.beginTime.toLocaleDateString())
dateRange.push(this.endTime.toLocaleDateString())
}
getListByPageApi(this.addDateRange(this.queryParams, dateRange)).then(res=>{
this.tableData = res.data.records;
this.total = res.data.total
})
},
submitForm(formName) {
this.$refs[formName].validate(valid => {
if (valid) {
// 表单验证通过,可以提交数据
// 示例:调用 API 提交数据
this.submitDeviceInfo();
} else {
// 表单验证失败,不执行任何操作
return false;
}
});
},
submitDeviceInfo() {
// 在这里调用接口提交设备信息数据
if (this.deviceInfo.id) {
editOilEngineConfigApi(this.deviceInfo).then(res=>{
if(res.code === 200) {
this.getList()
this.open = false
}
})
}else {
addOilEngineConfigApi(this.deviceInfo).then(res=>{
if(res.code === 200) {
this.getList()
this.open = false
}
})
}
},
handleQuery(){
this.getList()
},
resetQuery(){
this.queryParams = {
page: 1,
pageSize: 10,
deviceName:'',
},
this.getList()
},
handleAdd(e) {
this.clean()
this.open = true;
2024-10-19 18:03:31 +08:00
this.title = "新增设备"
2024-08-16 18:26:19 +08:00
},
edit(e) {
this.clean()
this.open = true;
2024-10-19 18:03:31 +08:00
this.title = "编辑设备"
2024-08-16 18:26:19 +08:00
this.deviceInfo = e
console.log('提交设备信息数据:', this.deviceInfo);
},
del(e) {
this.$confirm('是否删除本条数据, 删除后无法恢复?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
delOilEngineConfigApi(e.id).then(res=>{
if (res.code == 200) {
this.$message({
type: 'success',
message: '删除成功!'
});
this.getList()
}
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
});
},
clean() {
this.deviceInfo= {
id: null, // 自增id
deviceType: 'BY',
deviceName: '',
deviceId: '',
}
},
}
};
</script>
<style lang="scss" scoped>
.common-dialog >>> .el-upload--picture-card {
width: 60px;
height: 50px;
line-height: 60px;
}
2024-10-19 18:03:31 +08:00
.aainer{
background: #f5f7f8;
box-sizing: border-box;
padding: 10px;
}
.wit-b{
background: #fff;
border-radius: 8px;
box-sizing: border-box;
padding: 15px;
height: 87vh;
2024-08-16 18:26:19 +08:00
}
</style>