oil-station/fuintAdmin/src/views/oilConfig/oilGun/list.vue
DESKTOP-369JRHT\12997 46e0745947 积分设置
2023-11-09 18:31:36 +08:00

382 lines
11 KiB
Vue

<template>
<div class="app-container">
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>油枪管理</span>
</div>
<div class="conten-box" v-for="(item,index) in gunList" :key="index">
<div class="conten-top" style="display: flex; justify-content: space-between;">
<div>{{item.oilType}} {{item.oilName}}</div>
<div>
<el-button
type="primary"
icon="el-icon-plus"
@click="gunAdd(item.numberId)"
>新增油枪</el-button>
</div>
</div>
<div class="conten-bottom">
<div class="cardbox" :class="{ 'act-cardbox': item.status == '启用' }" v-for="(item,index) in item.oilGunList" :key="index">
<div class="cardbox-top" :class="{ 'actcolor':item.status == '启用' }">
<div>{{item.tankName}}</div>
<div style="cursor: pointer" ><i class="el-icon-edit" @click="gunEdit(item)"></i> <i class="el-icon-delete" @click="delGun(item.id)"></i></div>
</div>
<div class="cardbox-title">
<div>{{item.gunName}}</div>
</div>
<div class="cardbox-bottom" :class="{ 'actcolor':item.status == '启用' }">
<div>ID:{{ item.id }}</div>
</div>
<div class="cardboxb" v-if="item.oilMachineGunNumber != null ">
<i class="el-icon-share"></i>
<div>{{item.oilMachineGunNumber}}</div>
</div>
</div>
</div>
</div>
</el-card>
<el-dialog
title="编辑油枪"
:visible.sync="dialogVisible"
width="30%"
:before-close="handleClose"
:close-on-click-modal="false">
<el-form :model="gunForm" :rules="rules" ref="gunForm" label-width="100px" class="demo-ruleForm">
<el-form-item label="油枪名称" prop="gunName">
<el-input placeholder="请输入内容" v-model="gunForm.gunName" class="input-with-select">
<el-select v-model="gunForm.select" slot="append" placeholder="选择油枪" @change="chooseName">
<el-option
v-for="option in 50"
:key="option"
:label="option + '号枪'"
:value="option + '号枪'"
></el-option>
</el-select>
</el-input>
</el-form-item>
<el-form-item label="油机枪号" prop="name">
<el-input v-model="gunForm.oilMachineGunNumber"></el-input>
<div style="font-size: 12px;color: #999999">油机连接模式下 绑定油机系统中的枪号信息与当前枪号绑定</div>
</el-form-item>
<el-form-item label="所属油罐" prop="tankId">
<el-select v-model="gunForm.tankId" placeholder="请选择所属油罐">
<el-option
v-for="option in tankList"
:key="option.id"
:label="option.tankName"
:value="option.id"
></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>
<span slot="footer" class="dialog-footer">
<!--/* <el-button v-if="judgement" type="danger" @click="delGun()" style="float: left;">删除</el-button>*/-->
<el-button @click="dialogVisible = false">取 消</el-button>
<el-button type="primary" @click="submitForm()"> </el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import {getGunApi, insertGunApi, updateGunApi,selectTankByNumberApi,delGunApi} from "@/api/oilConfig/oilGuns";
import {cleanTankApi} from "@/api/oilConfig/oilTank";
export default {
name: 'oilqiang',
dicts: ['zhzt'],
data(){
return{
dialogVisible: false,
list:[
{type:1,xb:'you'},
{type:1,xb:'meiyou'},
{type:1,xb:'you'},
{type:1,xb:'you'},
{type:2,xb:'you'},
{type:1,xb:'you'},
{type:1,xb:'you'},
{type:1,xb:'you'},
],
// 判断当前窗口是新增还是修改该
judgement:false,
tankList: [],
gunList: [],
gunForm: {
id: '',
gunName: '',
tankId: '',
status: '',
storeId: '',
createTime: '',
updateTime: '',
createBy: '',
updateBy: '',
numberId: '',
oilMachineGunNumber: '',
select: ''
},
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' }
],
}
}
},
async created() {
let this_ = this
await this_.getList()
},
methods:{
handleIsopenSelect() {
this.$forceUpdate()
},
getList() {
getGunApi().then(response => {
this.gunList = response.data;
})
},
// 添加油枪
gunAdd(numberId){
let this_ = this;
this_.dialogVisible = true;
this_.judgement = false;
this_.gunForm = {} // 清空数据
this_.gunForm.status = '启用'
this_.selectTankByNumber(numberId)
},
gunEdit(data) {
let this_ = this;
this_.dialogVisible = true;
this_.judgement = true;
console.log("datadatadata",data)
this_.gunForm = data;
this_.statusOut = data.status;
this_.selectTankByNumber(data.numberId)
},
delGun(id) {
this.$confirm('此操作将删除油枪信息,请谨慎操作!是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let fil = {
id: id
}
delGunApi(fil).then(response => {
this.dialogVisible = false;
this.$message({
type: 'success',
message: '删除成功!'
});
this.getList();
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消'
});
});
},
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);
}
}
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();
}else {
}
}).catch(reason => {
});
} else {
updateGunApi(this.gunForm).then(response => {
if (response.code == 200) {
this.$modal.msgSuccess("修改成功");
this.dialogVisible = false;
// this.getList();
}
});
}
this.dialogVisible = false
} else {
return false;
}
});
this.getList();
},
chooseName() {
var this_ = this
this_.gunForm.gunName = this_.gunForm.select
},
handleClose(){
this.dialogVisible = false;
},
// 查询油罐信息
selectTankByNumber(data) {
let numberId = data
selectTankByNumberApi(numberId).then(response => {
this.tankList = response.data;
});
}
}
}
</script>
<style scoped>
.app-container{
height: 100%;
}
.text {
font-size: 14px;
}
.item {
margin-bottom: 18px;
}
.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{
margin-right: 10px;
margin-bottom: 10px;
box-sizing: border-box;
padding: 10px;
border-radius: 4px;
width: 19%;
background: url(../../../assets/images/jybjj.png) center no-repeat;
background-size:40% 70%;
background-color: #f9f9f9;
}
.act-cardbox{
position: relative;
overflow: hidden;
margin-right: 10px;
margin-bottom: 10px;
box-sizing: border-box;
padding: 10px;
border-radius: 4px;
width: 19%;
background: url(../../../assets/images/jybjj.png) center no-repeat;
background-size:40% 70%;
background-color: #ecf5ff;
color: #409eff !important;
}
.cardboxb{
position: absolute;
width: 50px;
height: 20px;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-size: 14px;
left: 0px;
bottom: 0px;
background: #409eff;
}
.actcolor{
color: #409eff !important;
}
.cardbox-top{
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
color: #5b5e62;
font-size: 14px;
}
.cardbox-title{
width: 100%;
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
font-size: 28px;
margin: 15px 0px;
}
.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;
}
</style>