|
|
@ -155,21 +155,12 @@ export default { |
|
|
|
}, |
|
|
|
|
|
|
|
// 按钮操作, status 0 -> 关(左), 1 -> 开(右) |
|
|
|
operateBtn({ info, status }){ |
|
|
|
operateBtn: util.debounce(function({ info, status }){ |
|
|
|
let { curStoreInfo, pageInfo } = this; |
|
|
|
let _cid = status === 1? info.enter_id + '':status === 0?info.leave_id:''; // 进出控制ID |进入-> enter_id 离开-> leave_id| |
|
|
|
let _query = pageInfo.id == 5 ? { |
|
|
|
name: 'gate', |
|
|
|
value: { |
|
|
|
tcp: info.hardware_net_addr + '', |
|
|
|
cid: _cid |
|
|
|
}, |
|
|
|
is_delay: true, |
|
|
|
queue_group: 'gate' |
|
|
|
} : this.getSwitchQueryData({ |
|
|
|
switchInfo: info, |
|
|
|
status: status, |
|
|
|
}) |
|
|
|
let _query = curStoreInfo.hardware_type === 'GateControl' ? |
|
|
|
this.getGateQuery({switchInfo: info, status}) : |
|
|
|
this.getSwitchQuery({ switchInfo: info, status }); |
|
|
|
|
|
|
|
util.showLoad(); |
|
|
|
deviceServer.post({ |
|
|
|
url: deviceApi.ouxuanac, |
|
|
@ -184,13 +175,68 @@ export default { |
|
|
|
console.log(res); |
|
|
|
}) |
|
|
|
.catch(util.hideLoad) |
|
|
|
}, 300, 300), |
|
|
|
|
|
|
|
// 门闸数据结构 // 门闸数据结构不统一 |
|
|
|
getGateQuery({ switchInfo, status }){ |
|
|
|
let { enter_id, leave_id, hardware_net_addr } = switchInfo; |
|
|
|
// 进出控制ID |进入-> enter_id 离开-> leave_id| |
|
|
|
let _cid = status === 1 ? enter_id : |
|
|
|
status === 0 ? leave_id : ''; |
|
|
|
return { |
|
|
|
name: 'gate', |
|
|
|
value: { |
|
|
|
tcp: hardware_net_addr + '', |
|
|
|
cid: _cid + '' |
|
|
|
}, |
|
|
|
is_delay: true, |
|
|
|
queue_group: 'gate' |
|
|
|
} |
|
|
|
}, |
|
|
|
// switchInfo -> 当前开关信息 |
|
|
|
// status -> 开关状态 0 -> 关(右), 1 -> 开(左) |
|
|
|
// 数据结构参考 src\subpackage\device\js\ouxuanac.md |
|
|
|
// 空调开关数据结构独立判断处理 hardware_type === 'Air' |
|
|
|
getSwitchQuery({ switchInfo, status }){ |
|
|
|
let { |
|
|
|
hardware_connect_method, |
|
|
|
hardware_type, |
|
|
|
hardware_connect_id, |
|
|
|
node_id, |
|
|
|
hardware_net_addr |
|
|
|
} = switchInfo; |
|
|
|
|
|
|
|
const postData = { |
|
|
|
name: this.getQueryName(switchInfo), |
|
|
|
value: { id: hardware_connect_id + '', } // value 内值全为String |
|
|
|
}; |
|
|
|
|
|
|
|
if (hardware_connect_method === 'Gpio') postData.value['status'] = this.getRelayStatus(status); |
|
|
|
|
|
|
|
// tcp 连接需要 hardware_net_addr |
|
|
|
if (hardware_connect_method === 'Tcp') postData.value['tcp'] = hardware_net_addr + ''; |
|
|
|
|
|
|
|
if (hardware_connect_method === 'SerialPort485' || hardware_connect_method === 'Tcp'){ |
|
|
|
if(hardware_type === 'Air'){ // 空调开关状态 key为 op |
|
|
|
postData.value['op'] = this.getAirRelayStatus(status); |
|
|
|
postData['name'] = this.getAirQueryName(switchInfo) |
|
|
|
}else{ |
|
|
|
// 空调设备不需要以下两个字段 |
|
|
|
postData.value['p'] = node_id + ''; // 硬件子id |
|
|
|
postData.value['o'] = this.getRelayStatus(status); // 开关状态 |
|
|
|
} |
|
|
|
} |
|
|
|
return postData; |
|
|
|
}, |
|
|
|
|
|
|
|
// 常规开关状态 |
|
|
|
// Low = "low", // 低电位,为开启 |
|
|
|
// High = "high", // 高电位, 为关闭 |
|
|
|
getRelayStatus(status){ |
|
|
|
return [ 'high', 'low' ][status] || '' |
|
|
|
}, |
|
|
|
|
|
|
|
// 空调状态 |
|
|
|
// status = "status", |
|
|
|
// on = "on", |
|
|
|
// off = "off", |
|
|
@ -200,32 +246,25 @@ export default { |
|
|
|
|
|
|
|
// 非空调获取name |
|
|
|
getQueryName(switchInfo){ |
|
|
|
let { hardware_connect_method } = switchInfo; |
|
|
|
let _obj = { |
|
|
|
'Gpio': 'set-rpio', |
|
|
|
'Gpio': 'set-rpio', // 全设备 |
|
|
|
'SerialPort485': 'zzio404d-gpio', |
|
|
|
'Tcp': 'zzio404d-gpio-tcp', |
|
|
|
'Tcp': 'zzio404d-gpio-tcp', |
|
|
|
}; |
|
|
|
return _obj[switchInfo.hardware_connect_method] || '' |
|
|
|
}, |
|
|
|
|
|
|
|
// switchInfo -> 当前开关信息 |
|
|
|
// status -> 开关状态 0 -> 关(左), 1 -> 开(右) |
|
|
|
// 数据结构参考 src\subpackage\device\js\ouxuanac.md |
|
|
|
getSwitchQueryData({ switchInfo, status }){ |
|
|
|
const postData = { |
|
|
|
name: this.getQueryName(switchInfo), |
|
|
|
value: { id: switchInfo.hardware_connect_id, } |
|
|
|
return _obj[hardware_connect_method] || '' |
|
|
|
}, |
|
|
|
// 空调name获取 |
|
|
|
getAirQueryName(switchInfo){ |
|
|
|
let { hardware_connect_method, hardware_model } = switchInfo; |
|
|
|
if(hardware_connect_method === 'Tcp'&&hardware_model === 'JianDa')return 'ray-air-rs-tcp'; |
|
|
|
let _obj = { |
|
|
|
'Acmelec': 'acmelec', |
|
|
|
'ZhongNan': 'zhongnan', |
|
|
|
'JianDa': 'ray-air-rs' |
|
|
|
}; |
|
|
|
if (switchInfo.hardware_connect_method === 'Gpio') postData.value['status'] = this.getRelayStatus(status); |
|
|
|
|
|
|
|
if (switchInfo.hardware_connect_method === 'Tcp') postData.value['tcp'] = switchInfo.hardware_net_addr; |
|
|
|
|
|
|
|
if (switchInfo.hardware_connect_method === 'SerialPort485' || switchInfo.hardware_connect_method === 'Tcp') { |
|
|
|
// 空调设备不需要以下两个字段 |
|
|
|
postData.value['p'] = switchInfo.node_id; // 硬件子id |
|
|
|
postData.value['o'] = this.getRelayStatus(status); // 开关状态 |
|
|
|
} |
|
|
|
return postData; |
|
|
|
return _obj[hardware_model] || ''; |
|
|
|
}, |
|
|
|
getIcon(){ |
|
|
|
let { pageInfo } = this; |
|
|
|