pc-master #23
@ -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#平均湿度',
 | 
			
		||||
@ -45,7 +49,7 @@ export default {
 | 
			
		||||
                '水温',
 | 
			
		||||
            ],
 | 
			
		||||
            rightList: ['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'],
 | 
			
		||||
           
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    mounted() {
 | 
			
		||||
@ -53,20 +57,20 @@ export default {
 | 
			
		||||
    },
 | 
			
		||||
    methods: {
 | 
			
		||||
        checkTime(i) {
 | 
			
		||||
    if (i < 10) {
 | 
			
		||||
        i = "0" + i;
 | 
			
		||||
    }
 | 
			
		||||
            if (i < 10) {
 | 
			
		||||
                i = "0" + i;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
    return i;
 | 
			
		||||
},
 | 
			
		||||
            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.rightList[index]=this.getList(this.inputData['212'+this.checkTime(index)])
 | 
			
		||||
                    this.leftList.forEach((el, index) => {
 | 
			
		||||
 | 
			
		||||
                        this.rightList[index] = this.getList(this.inputData['212' + this.checkTime(index)])
 | 
			
		||||
                    })
 | 
			
		||||
                    this.$forceUpdate();
 | 
			
		||||
                } else {
 | 
			
		||||
@ -89,22 +93,48 @@ 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'
 | 
			
		||||
            return [...arr].reverse()
 | 
			
		||||
        },
 | 
			
		||||
        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("请求出错");
 | 
			
		||||
                }
 | 
			
		||||
                this.timer = null
 | 
			
		||||
                if (this.nowSel.index != -1) {
 | 
			
		||||
                    this.timer = null
 | 
			
		||||
                    this.nowSel.index = -1
 | 
			
		||||
                    this.nowSel.value = 0
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
        },
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user