oil-station/fuintAdmin/src/views/oilConfig/oilGun/list.vue

724 lines
19 KiB
Vue
Raw Normal View History

2024-08-16 18:26:19 +08:00
<template>
2024-10-25 14:56:56 +08:00
<div class="app-container">
<div class="card-change">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
<el-form-item label="" prop="gunName">
<el-input
v-model="queryParams.gunName"
placeholder="油枪名称"
clearable
style="width: 240px;"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="" prop="numberId">
<el-select v-model="queryParams.numberId" placeholder="请选择油品油号" >
<el-option
v-for="option in selectOilTypeByPrice"
:key="option.numberId"
:label="option.oilType +' '+option.oilName"
:value="option.numberId"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="">
<el-date-picker
v-model="beginTime"
style="width: 160px"
type="date"
placeholder="开始日期">
</el-date-picker>
<el-date-picker
v-model="endTime"
style="width: 160px"
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="gunAdd()"
v-hasPermi="['oilConfig:oilGun:list:add']"
>新增油枪
</el-button>
</el-form-item>
</el-form>
<div>
2024-10-31 09:22:25 +08:00
<div style="width: 100%;overflow: auto;height: 72vh">
<el-table ref="tables"
2024-08-16 18:26:19 +08:00
v-loading="loading"
:data="gunList"
border
:default-sort="defaultSort">
<el-table-column align="center" type="index" label="序号"></el-table-column>
<el-table-column label="油枪名称" align="center" prop="gunName"/>
2024-10-25 14:56:56 +08:00
<el-table-column label="所属油罐" align="center" prop="tankName"/>
2024-08-16 18:26:19 +08:00
<el-table-column label="油品-油号" align="center" prop="oilNumber"></el-table-column>
<el-table-column label="关联员工" align="center" prop="tankName">
2024-10-25 14:56:56 +08:00
<template slot-scope="scope">
{{ jsonChange(scope.row.staffList) }}
</template>
2024-08-16 18:26:19 +08:00
</el-table-column>
<el-table-column label="设备ID" align="center" prop="deviceName"/>
<el-table-column label="设备枪号" align="center" prop="oilMachineGunNumber"/>
<el-table-column label="状态" align="center" prop="status"/>
2024-10-25 14:56:56 +08:00
<el-table-column label="操作人" align="center" prop="realName"/>
2024-08-16 18:26:19 +08:00
<el-table-column label="操作时间" align="center" prop="createTime"/>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
@click="gunEdit(scope.row)"
v-hasPermi="['oilConfig:oilGun:list:update']"
2024-10-25 14:56:56 +08:00
>修改
</el-button>
2024-08-16 18:26:19 +08:00
<el-button
size="mini"
type="text"
v-hasPermi="['oilConfig:oilGun:list:del']"
@click="delGun(scope.row)"
2024-10-25 14:56:56 +08:00
>删除
</el-button>
2024-08-16 18:26:19 +08:00
</template>
</el-table-column>
</el-table>
2024-10-31 09:22:25 +08:00
</div>
2024-08-16 18:26:19 +08:00
</div>
2024-10-25 14:56:56 +08:00
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.page"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</div>
<el-dialog
:title="title"
:visible.sync="dialogVisible"
2024-10-31 17:53:24 +08:00
width="30%"
2024-10-25 14:56:56 +08:00
:before-close="handleClose"
:close-on-click-modal="false">
2024-10-31 17:53:24 +08:00
<el-form :model="gunForm" :rules="rules" ref="gunForm" label-width="110px" class="demo-ruleForm">
2024-10-25 14:56:56 +08:00
<el-form-item label="油枪名称" prop="gunName">
2024-10-31 17:53:24 +08:00
<el-input placeholder="请输入内容" v-model="gunForm.gunName" class="input-with-select">
2024-10-25 14:56:56 +08:00
<el-select style="width: 110px" v-model="gunForm.select" slot="append" placeholder="选择油枪"
@change="chooseName">
2024-08-16 18:26:19 +08:00
<el-option
2024-10-25 14:56:56 +08:00
v-for="option in 50"
:key="option"
:label="option + '号枪'"
:value="option + '号枪'"
2024-08-16 18:26:19 +08:00
></el-option>
</el-select>
2024-10-25 14:56:56 +08:00
</el-input>
</el-form-item>
2024-10-31 17:53:24 +08:00
<el-form-item label="关联油品油号" prop="numberId">
<el-select v-model="gunForm.numberId" style="width: 100%" placeholder="请选择油品油号" @change="changeNumber(gunForm.numberId)">
2024-10-31 15:54:59 +08:00
<el-option
2024-10-31 17:53:24 +08:00
v-for="option in selectOilTypeByPrice"
:key="option.numberId"
:label="option.oilType +' '+option.oilName"
:value="option.numberId"
2024-10-31 15:54:59 +08:00
></el-option>
</el-select>
</el-form-item>
2024-10-25 14:56:56 +08:00
<el-form-item label="所属油罐" prop="tankId">
2024-10-31 17:53:24 +08:00
<el-select style="width: 100%" v-model="gunForm.tankId" placeholder="请选择所属油罐" @change="changeTank">
2024-10-25 14:56:56 +08:00
<el-option
v-for="option in tankList"
:key="option.id"
:label="option.tankName"
:value="option.id"
></el-option>
</el-select>
</el-form-item>
2024-10-31 15:54:59 +08:00
<el-form-item label="关联员工" prop="status">
2024-10-25 14:56:56 +08:00
<el-radio v-model="staffStatus" label="全部员工">全部员工</el-radio>
<el-radio v-model="staffStatus" label="指定员工">指定员工</el-radio>
</el-form-item>
<el-form-item v-if="staffStatus == '指定员工'" label="选择员工" prop="staffId">
<el-select
v-model="staffIds"
clearable
2024-10-31 17:53:24 +08:00
placeholder="请选择员工(多选)"
style="width: 100%"
2024-10-25 14:56:56 +08:00
multiple
collapse-tags
>
<el-option v-for="item in staffList" :key="item.id" :label="item.realName" :value="item.id+''">
<span style="float: left">{{ item.realName }}</span>
<span style="float: right; color: #8492a6; font-size: 13px">{{ item.mobile }}</span>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-radio-group v-model="gunForm.status">
<el-radio
v-for="dict in dict.type.zhzt"
:key="dict.value"
:label="dict.label"
:value="dict.value"
@change="handleIsopenSelect"
/>
</el-radio-group>
</el-form-item>
<el-form-item label="设备ID" prop="staffId">
<el-select
v-model="gunForm.deviceId"
clearable
placeholder=""
2024-10-31 17:53:24 +08:00
style="width: 100%"
2024-10-25 14:56:56 +08:00
>
<el-option v-for="item in youjiList" :key="item.id" :label="item.deviceName" :value="item.id">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="设备枪号" prop="name">
2024-10-31 17:53:24 +08:00
<el-input v-model="gunForm.oilMachineGunNumber"></el-input>
<div style="font-size: 12px;width: 100%; color: #999999;line-height: 22px">
2024-10-25 14:56:56 +08:00
请确保输入的集线器正确的枪号否则出现设备显示屏与一件加油页面显示数据不一致例如00010002···
</div>
</el-form-item>
2024-10-31 17:53:24 +08:00
<div style="text-align: center">
2024-10-25 14:56:56 +08:00
<el-button @click="dialogVisible = false,getList()"> </el-button>
2024-10-31 17:53:24 +08:00
<el-button type="primary" @click="submitForm()"> </el-button>
</div>
2024-10-25 14:56:56 +08:00
</el-form>
</el-dialog>
</div>
2024-08-16 18:26:19 +08:00
</template>
<script>
import {
getGunApi,
insertGunApi,
updateGunApi,
selectTankByNumberApi,
delGunApi,
getGunListpageApi
} from "@/api/oilConfig/oilGuns";
import {cleanTankApi} from "@/api/oilConfig/oilTank";
import {queryStaffs} from "@/api/order/staff";
import {getListByPageApi} from "@/api/seeting/youqiji";
2024-10-25 14:56:56 +08:00
import {getOilNameListApi} from "@/api/oilPrice";
2024-08-16 18:26:19 +08:00
2024-10-25 14:56:56 +08:00
export default {
name: 'oilqiang',
dicts: ['zhzt'],
2024-08-16 18:26:19 +08:00
2024-10-25 14:56:56 +08:00
data() {
return {
queryParams: {
page: 1,
pageSize: 10
},
beginTime: "",
endTime: "",
selectOilTypeByPrice:[],
total: '',
staffIds: [],
staffList: [],
youjiList: [],
// 默认排序
// defaultSort: {prop: 'createTime', order: 'descending'},
defaultSort: '',
title: "",
dialogVisible: false,
loading: false,
list: [],
// 判断当前窗口是新增还是修改该
judgement: false,
tankList: [],
gunList: [],
c: '',
gunForm: {
id: '',
gunName: '',
tankId: '',
status: '',
storeId: '',
createTime: '',
updateTime: '',
createBy: '',
updateBy: '',
numberId: '',
oilMachineGunNumber: '',
select: '',
2024-08-16 18:26:19 +08:00
staffStatus: '全部员工',
2024-10-25 14:56:56 +08:00
staffList: '',
deviceId: '',
deviceName: '',
2024-08-16 18:26:19 +08:00
2024-10-25 14:56:56 +08:00
},
staffStatus: '全部员工',
statusOut: '',
ruleForm: {
name: '',
region: '',
date1: '',
date2: '',
delivery: false,
type: [],
select: '请选择',
resource: '',
desc: ''
},
rules: {
gunName: [
{required: true, message: '请输入油枪名称', trigger: 'blur'},
],
tankId: [
{required: true, message: '请选择所属油罐', trigger: 'change'}
],
2024-10-31 17:53:24 +08:00
numberId: [
{required: true, message: '请选择关联油品油号', trigger: 'change'}
],
2024-08-16 18:26:19 +08:00
}
2024-10-25 14:56:56 +08:00
}
},
async created() {
let this_ = this
await this_.getList()
await this_.getStaffList()
await this_.getyouji()
await this_.getOilNameList()
},
watch: {
dialogVisible: function (newValue, oldValue) {
if (oldValue) {
this.$refs["gunForm"].resetFields();
}
}
},
methods: {
2024-10-31 17:53:24 +08:00
changeTank(){
// 查询numberId
for (let tankListKey in this.tankList) {
if (parseInt(this.gunForm.tankId) === parseInt(this.tankList[tankListKey].id)) {
this.gunForm.numberId = parseInt(this.tankList[tankListKey].numberId);
}
}
},
changeNumber(numberId){
this.gunForm.tankId = ''
this.selectTankByNumber(numberId)
},
2024-10-25 14:56:56 +08:00
getOilNameList() {
var this_ = this
getOilNameListApi().then(response => {
var list = response.data
this_.selectOilTypeByPrice = list
});
2024-08-16 18:26:19 +08:00
},
2024-10-25 14:56:56 +08:00
handleIsopenSelect() {
this.$forceUpdate()
2024-08-16 18:26:19 +08:00
},
2024-10-25 14:56:56 +08:00
getList() {
this.gunList = []
let dateRange = []
if (this.beginTime && this.endTime) {
dateRange.push(this.beginTime.toLocaleDateString())
dateRange.push(this.endTime.toLocaleDateString())
2024-08-16 18:26:19 +08:00
}
2024-10-25 14:56:56 +08:00
getGunListpageApi(this.addDateRange(this.queryParams, dateRange)).then(response => {
this.gunList = response.data.records;
this.total = response.data.total;
})
2024-08-16 18:26:19 +08:00
},
2024-10-25 14:56:56 +08:00
getStaffList() {
queryStaffs().then(response => {
this.staffList = response.data;
})
},
getyouji() {
let queryParams = {
page: 1,
pageSize: 100000
}
getListByPageApi(queryParams).then(res => {
this.youjiList = res.data.records;
})
},
// 添加油枪
gunAdd(numberId) {
let this_ = this;
this_.dialogVisible = true;
this_.judgement = false;
this_.staffIds = [],
2024-08-16 18:26:19 +08:00
this.cler()
2024-10-25 14:56:56 +08:00
// 清空数据
this_.gunForm.status = '启用'
this_.title = '添加油枪'
this_.selectTankByNumber(numberId)
},
gunEdit(data) {
let this_ = this;
this_.staffIds = [],
2024-08-16 18:26:19 +08:00
this_.dialogVisible = true;
2024-10-25 14:56:56 +08:00
this_.judgement = true;
this.cler()
this_.gunForm = data;
this_.statusOut = data.status;
this_.title = '修改油枪'
2024-08-16 18:26:19 +08:00
2024-10-25 14:56:56 +08:00
this_.selectTankByNumber(data.numberId)
},
2024-08-16 18:26:19 +08:00
2024-10-25 14:56:56 +08:00
delGun(id) {
this.$confirm('此操作将删除油枪信息,请谨慎操作!是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let fil = {
id: id
}
delGunApi(fil).then(response => {
this.dialogVisible = false;
2024-08-16 18:26:19 +08:00
this.$message({
2024-10-25 14:56:56 +08:00
type: 'success',
message: '删除成功!'
2024-08-16 18:26:19 +08:00
});
2024-10-25 14:56:56 +08:00
this.getList();
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消'
2024-08-16 18:26:19 +08:00
});
2024-10-25 14:56:56 +08:00
});
},
// 搜索按钮操作
handleQuery() {
this.queryParams.page = 1;
this.getList();
},
resetQuery() {
this.queryParams = {
tankName: '',
page: 1,
pageSize: 10
};
this.beginTime = ''
this.endTime = ''
this.getList();
},
submitForm() {
this.$refs["gunForm"].validate((valid) => {
if (valid) {
// 查询numberId
for (let tankListKey in this.tankList) {
if (parseInt(this.gunForm.tankId) === parseInt(this.tankList[tankListKey].id)) {
this.gunForm.numberId = parseInt(this.tankList[tankListKey].numberId);
2024-08-16 18:26:19 +08:00
}
}
2024-10-25 14:56:56 +08:00
let staff = [];
this.staffIds.forEach(id => {
let matchingStaff = this.staffList.find(staff => staff.id === Number(id));
let names = {
id: id,
realName: matchingStaff ? matchingStaff.realName : id
}
staff.push(names)
});
this.gunForm.staffList = JSON.stringify(staff)
this.youjiList.forEach(id => {
if (id.id == this.gunForm.deviceId) {
this.gunForm.deviceName = id.deviceName
}
})
2024-08-16 18:26:19 +08:00
2024-10-25 14:56:56 +08:00
this.gunForm.staffStatus = this.staffStatus
2024-08-16 18:26:19 +08:00
2024-10-25 14:56:56 +08:00
if (!this.gunForm.id) {
insertGunApi(this.gunForm).then(response => {
console.log("response", response)
if (response.code == 200) {
this.$modal.msgSuccess("新增成功");
this.dialogVisible = false;
this.getList();
2024-08-16 18:26:19 +08:00
2024-10-25 14:56:56 +08:00
} else {
2024-08-16 18:26:19 +08:00
2024-10-25 14:56:56 +08:00
}
}).catch(reason => {
});
} else {
console.log("111111", this.gunForm)
updateGunApi(this.gunForm).then(response => {
if (response.code == 200) {
this.$modal.msgSuccess("修改成功");
this.dialogVisible = false;
this.getList();
this.dialogVisible = false
2024-08-16 18:26:19 +08:00
2024-10-25 14:56:56 +08:00
}
});
}
2024-08-16 18:26:19 +08:00
2024-10-25 14:56:56 +08:00
} else {
return false;
}
});
// this.getList();
},
chooseName() {
var this_ = this
this_.gunForm.gunName = this_.gunForm.select
},
handleClose() {
this.dialogVisible = false;
},
2024-08-16 18:26:19 +08:00
2024-10-25 14:56:56 +08:00
// 查询油罐信息
selectTankByNumber(data) {
let numberId = '';
if (data) {
numberId = data
}
selectTankByNumberApi(numberId).then(response => {
this.tankList = response.data;
});
},
cler() {
this.gunForm = {
id: '',
gunName: '',
tankId: '',
status: '',
storeId: '',
createTime: '',
updateTime: '',
createBy: '',
updateBy: '',
numberId: '',
oilMachineGunNumber: '',
select: '',
staffStatus: '全部员工',
staffList: '',
deviceId: '',
deviceName: '',
2024-08-16 18:26:19 +08:00
2024-10-25 14:56:56 +08:00
}
},
jsonChange(data) {
if (data) {
let a = JSON.parse(data);
let b = a.map(res => res.realName).join(',');
return b
} else {
return '--'
}
2024-08-16 18:26:19 +08:00
2024-10-25 14:56:56 +08:00
},
2024-08-16 18:26:19 +08:00
}
2024-10-25 14:56:56 +08:00
}
</script>
2024-08-16 18:26:19 +08:00
2024-10-25 14:56:56 +08:00
<style scoped lang="scss">
.app-container {
height: 100%;
}
.bor-bai {
width: 100%;
border-radius: 10px;
box-sizing: border-box;
padding: 20px;
background: #fff;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1);
margin-bottom: 20px;
}
.title_ {
font-weight: bold;
font-size: 18px;
color: #333333;
}
.wrap-box {
width: 100%;
display: flex;
flex-wrap: wrap;
}
.oil-box {
}
.clearfix:before,
.clearfix:after {
display: table;
content: "";
}
.clearfix:after {
clear: both
}
.box-card {
width: 100%;
}
.conten-box {
width: 100%;
border: 1px solid #ebeef5;
margin: 20px 0px;
}
.conten-top {
border-bottom: 1px solid #ebeef5;
box-sizing: border-box;
padding: 18px 20px;
}
.conten-bottom {
box-sizing: border-box;
padding: 20px 20px;
display: flex;
flex-wrap: wrap;
}
.cardbox {
height: 87px;
width: 278px;
margin-right: 35px;
margin-bottom: 35px;
box-sizing: border-box;
padding: 10px;
border-radius: 10px;
//width: 19%;
background-size: 40% 70%;
background-color: #f9f9f9;
position: relative;
}
.boxborder {
border-color: #FF9655;
border: 1px solid;
}
.cardbox-rd {
position: absolute;
right: 5px;
bottom: 0px;
width: 50px;
height: 50px;
}
.act-cardbox {
margin-right: 35px;
height: 87px;
width: 278px;
position: relative;
overflow: hidden;
//margin-right: 10px;
margin-bottom: 35px;
box-sizing: border-box;
padding: 10px;
border-radius: 10px;
//width: 19%;
//background: url(../../../assets/images/jybjj.png) center no-repeat;
background-size: 40% 70%;
background-color: #fff9f5;
color: #FF9655 !important;
}
.cardboxb {
position: absolute;
/*width: 50px;*/
width: auto;
height: 20px;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-size: 12px;
left: 0px;
bottom: 0px;
padding: 5px 10px;
background: linear-gradient(312deg, #FF8646 0%, #FFA360 100%);
border-radius: 0px 10px 0px 10px;
}
.actcolor {
color: #FF9655 !important;
}
.cardbox-top {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
color: #5b5e62;
font-size: 12px;
font-family: Source Han Sans CN;
//font-weight: 400;
}
.cardbox-title {
width: 100%;
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
font-size: 28px;
//margin: 15px 0px;
}
.cardbox-gunName {
font-family: YouSheBiaoTiHei, YouSheBiaoTiHei;
font-weight: 400;
font-size: 28px;
//color: #FF9655;
//line-height: 0px;
//text-align: center;
//font-style: normal;
//text-transform: none;
}
.cardbox-bottom {
display: flex;
align-items: center;
justify-content: flex-end;
width: 100%;
color: #5b5e62;
font-size: 14px;
}
.input-box {
display: flex;
align-items: center;
}
.box-top {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
}
2024-08-16 18:26:19 +08:00
</style>