pull/23/head
孙萌 2023-11-08 17:07:22 +08:00
parent af0a38da60
commit 53f0908869
1 changed files with 58 additions and 22 deletions

View File

@ -18,7 +18,7 @@
<div class="table-tr"> <div class="table-tr">
<div v-for="item, index in rightList" :key="index"> <div v-for="item, index in rightList" :key="index">
<div v-for="item1, index1 in item"> <div v-for="item1, index1 in item">
<div :class="item1=='1'?'sel':'no-sel'" @click="changeType(index,index1)"></div> <div :class="item1 == '1' ? 'sel' : 'no-sel'" @click="changeType(index, index1)"></div>
</div> </div>
</div> </div>
</div> </div>
@ -32,6 +32,10 @@ export default {
data() { data() {
return { return {
inputData: [], inputData: [],
nowSel: {
index: -1,
value: 0,
},
leftList: ['1#平均温度', leftList: ['1#平均温度',
'2#平均温度', '2#平均温度',
'1#平均湿度', '1#平均湿度',
@ -45,7 +49,7 @@ export default {
'水温', '水温',
], ],
rightList: ['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'], rightList: ['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'],
} }
}, },
mounted() { mounted() {
@ -53,20 +57,20 @@ export default {
}, },
methods: { methods: {
checkTime(i) { checkTime(i) {
if (i < 10) { if (i < 10) {
i = "0" + i; i = "0" + i;
} }
return i; return i;
}, },
padString(str, length) { padString(str, length) {
return str.padStart(length, '0'); return str.padStart(length, '0');
}, },
getList(data){ getList(data) {
var num = data var num = data
var num1 = this.padString(num.toString(2), 16) var num1 = this.padString(num.toString(2), 16)
var openListNew = num1.split("") var openListNew = num1.split("")
var list=openListNew.reverse() var list = openListNew.reverse()
return list return list
}, },
dataInit() { dataInit() {
@ -77,9 +81,9 @@ export default {
this.api.getReadControlSensorInputSynthesis(data).then((res) => { this.api.getReadControlSensorInputSynthesis(data).then((res) => {
if (res.data.code == 200) { if (res.data.code == 200) {
this.inputData = res.data.data; this.inputData = res.data.data;
this.leftList.forEach((el,index)=>{ this.leftList.forEach((el, index) => {
this.rightList[index]=this.getList(this.inputData['212'+this.checkTime(index)]) this.rightList[index] = this.getList(this.inputData['212' + this.checkTime(index)])
}) })
this.$forceUpdate(); this.$forceUpdate();
} else { } else {
@ -89,22 +93,48 @@ export default {
}, },
// //
myReverse(arr) { myReverse(arr) {
return [...arr].reverse() return [...arr].reverse()
}, },
changeType(index,index1){ changeType(index, index1) {
if(this.rightList[index][index1]=='1'){ var store = this.$store.state
this.rightList[index][index1]='0' const that = this
}else{ if (this.rightList[index][index1] == '1') {
this.rightList[index][index1]='1' this.rightList[index][index1] = '0'
} else {
this.rightList[index][index1] = '1'
} }
this.$forceUpdate(); this.$forceUpdate();
var num =this.myReverse(this.rightList[index]).join(""); var num = this.myReverse(this.rightList[index]).join("");
var dataNum = { var dataNum = {
target: { target: {
value: parseInt(num, 2), value: parseInt(num, 2),
}, },
}; };
this.changeBtn('212'+this.checkTime(index),dataNum)
if (this.nowSel.index == -1) {
this.changeBtn('212' + this.checkTime(index), dataNum)
this.nowSel.index = index
this.nowSel.value = parseInt(num, 2)
} else {
if (this.nowSel.index == index) {
this.changeBtn('212' + this.checkTime(index), dataNum)
this.nowSel.index = index
this.nowSel.value = parseInt(num, 2)
} else {
var code = '212' + this.checkTime(this.nowSel.index)
var data = {
equipmentId: store.equipmentList[store.equipmentIndex - 1].deviceId,
regAddress: code,
num: this.nowSel.value,
};
this.nowSel.index = -1
this.nowSel.value = 0
that.changeData(data);
this.changeBtn('212' + this.checkTime(index), dataNum)
}
}
}, },
changeBtn(code, el) { changeBtn(code, el) {
var store = this.$store.state var store = this.$store.state
@ -164,10 +194,16 @@ export default {
type: "success", type: "success",
}); });
this.dataInit(); this.dataInit();
} else { } else {
this.$message.error("请求出错"); this.$message.error("请求出错");
} }
this.timer = null if (this.nowSel.index != -1) {
this.timer = null
this.nowSel.index = -1
this.nowSel.value = 0
}
}); });
}, },
}, },