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 v-for="item, index in rightList" :key="index">
<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>
@ -32,6 +32,10 @@ export default {
data() {
return {
inputData: [],
nowSel: {
index: -1,
value: 0,
},
leftList: ['1#平均温度',
'2#平均温度',
'1#平均湿度',
@ -58,15 +62,15 @@ export default {
}
return i;
},
},
padString(str, length) {
return str.padStart(length, '0');
},
getList(data){
getList(data) {
var num = data
var num1 = this.padString(num.toString(2), 16)
var openListNew = num1.split("")
var list=openListNew.reverse()
var list = openListNew.reverse()
return list
},
dataInit() {
@ -77,9 +81,9 @@ export default {
this.api.getReadControlSensorInputSynthesis(data).then((res) => {
if (res.data.code == 200) {
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();
} else {
@ -90,21 +94,47 @@ export default {
//
myReverse(arr) {
return [...arr].reverse()
},
changeType(index,index1){
if(this.rightList[index][index1]=='1'){
this.rightList[index][index1]='0'
}else{
this.rightList[index][index1]='1'
},
changeType(index, index1) {
var store = this.$store.state
const that = this
if (this.rightList[index][index1] == '1') {
this.rightList[index][index1] = '0'
} else {
this.rightList[index][index1] = '1'
}
this.$forceUpdate();
var num =this.myReverse(this.rightList[index]).join("");
var num = this.myReverse(this.rightList[index]).join("");
var dataNum = {
target: {
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) {
var store = this.$store.state
@ -164,10 +194,16 @@ export default {
type: "success",
});
this.dataInit();
} else {
this.$message.error("请求出错");
}
if (this.nowSel.index != -1) {
this.timer = null
this.nowSel.index = -1
this.nowSel.value = 0
}
});
},
},