<div class="smart-info">
<div class="smart-left">
<p class="title-p"><span>机器设备1号</span><i-switch v-model="switchParams.switch" true-value="0" false-value="1" @on-change="switchChangebox"></i-switch></span></p>
<div class="two-info">
<p>
<span>当前模式 </span>
<span v-for="(item, index) in smartTag" :key="index" :class="switchParams.switch == item.switchTap ? 'is-active' : ''">{{ item.name}}</span>
</p>
<p>机器人已开启{{switchParams.switch == '1' ? '手动' : '自动'}}模式</p>
</div>
<p class="nomal-ps">
<span class="nomal-span">名称</span>
<span class="nomal-span">状态</span>
<span class="nomal-span">调控</span>
</p>
<p class="nomal-p" v-for="(item, index) in smartItems" :key="index">
<span class="nomal-span">
{{item.name}}
</span>
<span v-if="device">{{ item.deviceName }}</span>
<span class="nomal-span">{{item.startupstatus == '0' ? '未工作' : '工作中'}}</span>
<span class="nomal-span">
<i-switch v-model="item.startupstatus" true-value="1" false-value="0" v-show="modelview" @on-change="switchChange(item,item.startupstatus)"></i-switch>
</span>
</p>
<p v-if="!smartLeftItems || smartLeftItems.length === 0" style="text-align:center;padding-top:28%">暂无数据信息</p>
</div>
// switch开关控制
switchChange(item, type) {
if(this.switchParams.switch == '1') {
if(this.swichchange == '333' && (item.deviceName == '666' && type == '1') ) {
this.$Message.info('“第一指令正在执行前进,请关闭后再执行第二指令”')
setTimeout(()=>{
item.startupstatus = '0'
},0)
}else if(this.swichchange == '666' && (item.deviceName == '333' && type == '1') ) {
this.$Message.info('“第二指令正在执行前进,请关闭后再执行第一指令”')
setTimeout(()=>{
item.startupstatus = '0'
},0)
}else if((item.deviceName == '666' && type == '0') || (item.deviceName == '333' && type == '0')){
this.swichchange = null
setTimeout(()=>{
this.initSwitchRobot(item, type)
},5)
}else{
if((item.deviceName == '666' && type == '1') || (item.deviceName == '333' && type == '1') ){
this.swichchange = item.deviceName
}
setTimeout(()=>{
this.initSwitchRobot(item, type)
},5)
}
}else{
if(type == '1' && this.swichchangeAuto) {
this.$Message.info('“全部状态已执行一条指令,请关闭后再执行新指令”')
setTimeout(()=>{
item.startupstatus = '0'
},0)
}else{
if(type=='0'&& this.swichchangeAuto==item.deviceName){
this.swichchangeAuto = null
}
if(type=='1'){
this.swichchangeAuto = item.deviceName
}
setTimeout(()=>{
this.initSwitchRobot(item, type)
},5)
}
}
},
// 初始化已开启的状态判断,如果开启一种,另一种不可开启
if((item.deviceName == '333' && item.startupstatus == '1') || (item.deviceName == '666' && item.startupstatus == '1')){
this.swichchange = item.deviceName // 变量存储状态
}
// 如果全部设备开启一个了,其他不可开启
if(item.startupstatus == '1'){
this.swichchangeAuto = item.deviceName // 变量存储状态
}
data
{
swichchange:null,
swichchangeAuto:null,
smartTag: [
{
id: '1',
name: '手动',
switchTap:'1',
isActive: false
},
{
id: '2',
name: '自动',
switchTap:'0',
isActive: true
}
],
}