|
|
@ -19,11 +19,11 @@ |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="si-bottom" v-if="pageInfo.isOpen || pageInfo.isClose"> |
|
|
|
<view v-if="pageInfo.isOpen" @click="operateBtn({ info: e, status: 1 })"> |
|
|
|
<view v-if="pageInfo.isOpen" @click="operateBtn({ switchInfo: e, status: 1 })"> |
|
|
|
<image mode="aspectFit" :src="pageInfo.openIcon || ''"></image> |
|
|
|
<view>{{pageInfo.openName || '-'}}</view> |
|
|
|
</view> |
|
|
|
<view v-if="pageInfo.isClose" @click="operateBtn({ info: e, status: 0 })"> |
|
|
|
<view v-if="pageInfo.isClose" @click="operateBtn({ switchInfo: e, status: 0 })"> |
|
|
|
<image mode="aspectFit" :src="pageInfo.closeIcon || ''"></image> |
|
|
|
<view>{{pageInfo.closeName || '-'}}</view> |
|
|
|
</view> |
|
|
@ -155,28 +155,53 @@ export default { |
|
|
|
}, |
|
|
|
|
|
|
|
// 按钮操作, status 0 -> 关(左), 1 -> 开(右) |
|
|
|
operateBtn: util.debounce(function({ info, status }){ |
|
|
|
let { curStoreInfo, pageInfo } = this; |
|
|
|
let _query = curStoreInfo.hardware_type === 'GateControl' ? |
|
|
|
this.getGateQuery({switchInfo: info, status}) : |
|
|
|
this.getSwitchQuery({ switchInfo: info, status }); |
|
|
|
operateBtn: util.debounce(function({ switchInfo, status }){ |
|
|
|
|
|
|
|
util.showLoad(); |
|
|
|
deviceServer.post({ |
|
|
|
url: deviceApi.ouxuanac, |
|
|
|
data: { |
|
|
|
let _data = this.getOperateReqData({ switchInfo, status }) |
|
|
|
//针对门禁没有关按钮发两条命令->开&关 20201224 后端: 直接发两条 关的那条这里填5 然后你那边不用管返回 |
|
|
|
if(switchInfo.hardware_type === 'AccessControl'&&status == 1){ |
|
|
|
this.operateReq({data: this.getOperateReqData({ switchInfo, status: 0 }), isTip: false, isLoad: false}); |
|
|
|
} |
|
|
|
|
|
|
|
this.operateReq({ data: _data }); |
|
|
|
|
|
|
|
}, 300, 300), |
|
|
|
|
|
|
|
// 获取接口参数结构 |
|
|
|
getOperateReqData({ switchInfo, status }){ |
|
|
|
let { curStoreInfo } = this; |
|
|
|
let _query = switchInfo.hardware_type === 'GateControl' ? |
|
|
|
this.getGateQuery({ switchInfo, status}) : |
|
|
|
this.getSwitchQuery({ switchInfo, status }); |
|
|
|
|
|
|
|
let _data = { |
|
|
|
device: curStoreInfo.device_name, // 中控名, |
|
|
|
data: _query, // 后端数据结构, 参考src\subpackage\device\js\ouxuanac.md |
|
|
|
}, |
|
|
|
failMsg: '操作失败!', |
|
|
|
}; |
|
|
|
|
|
|
|
//针对门禁没有关按钮发两条命令->开&关 20201224 后端: 直接发两条 关的那条这里填5 然后你那边不用管返回 |
|
|
|
if(switchInfo.hardware_type === 'AccessControl'&&status == 0)_data['delay'] = '5'; |
|
|
|
|
|
|
|
return _data; |
|
|
|
}, |
|
|
|
// 操作接口请求 |
|
|
|
operateReq({data, isTip=true, isLoad=true}){ |
|
|
|
if(isLoad)util.showLoad(); |
|
|
|
deviceServer.post({ |
|
|
|
url: deviceApi.ouxuanac, |
|
|
|
data: data, |
|
|
|
isDefaultGet: false, |
|
|
|
}) |
|
|
|
.then(res=>{ |
|
|
|
util.hideLoad(); |
|
|
|
console.log(res); |
|
|
|
if(isLoad)util.hideLoad(); |
|
|
|
if(res.data.code == 0){ |
|
|
|
if(isTip)util.showNone(res.data.message || '操作成功!'); |
|
|
|
}else{ |
|
|
|
if(isTip)util.showNone(res.data.message || '操作失败!'); |
|
|
|
} |
|
|
|
}) |
|
|
|
.catch(util.hideLoad) |
|
|
|
}, 300, 300), |
|
|
|
|
|
|
|
.catch(err=>{if(isLoad)util.hideLoad()}) |
|
|
|
}, |
|
|
|
// 门闸数据结构 // 门闸数据结构不统一 |
|
|
|
getGateQuery({ switchInfo, status }){ |
|
|
|
let { enter_id, leave_id, hardware_net_addr } = switchInfo; |
|
|
@ -201,22 +226,22 @@ export default { |
|
|
|
let { |
|
|
|
hardware_connect_method, |
|
|
|
hardware_type, |
|
|
|
hardware_connect_id, |
|
|
|
hardware_id, |
|
|
|
node_id, |
|
|
|
hardware_net_addr |
|
|
|
} = switchInfo; |
|
|
|
|
|
|
|
const postData = { |
|
|
|
name: this.getQueryName(switchInfo), |
|
|
|
value: { id: hardware_connect_id + '', } // value 内值全为String |
|
|
|
value: { id: hardware_id + '', } // value 内值全为String |
|
|
|
}; |
|
|
|
|
|
|
|
if (hardware_connect_method === 'Gpio') postData.value['status'] = this.getRelayStatus(status); |
|
|
|
if (this.changeLowerCase(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 (this.changeLowerCase(hardware_connect_method) === 'tcp') postData.value['tcp'] = hardware_net_addr + ''; |
|
|
|
let _flag = this.changeLowerCase(hardware_connect_method) === 'serialport485' || this.changeLowerCase(hardware_connect_method) === 'tcp'; |
|
|
|
if (_flag){ |
|
|
|
if(hardware_type === 'Air'){ // 空调开关状态 key为 op |
|
|
|
postData.value['op'] = this.getAirRelayStatus(status); |
|
|
|
postData['name'] = this.getAirQueryName(switchInfo) |
|
|
@ -228,7 +253,9 @@ export default { |
|
|
|
} |
|
|
|
return postData; |
|
|
|
}, |
|
|
|
|
|
|
|
changeLowerCase(str){ |
|
|
|
return str.toString().toLocaleLowerCase(); |
|
|
|
}, |
|
|
|
// 常规开关状态 |
|
|
|
// Low = "low", // 低电位,为开启 |
|
|
|
// High = "high", // 高电位, 为关闭 |
|
|
@ -258,13 +285,14 @@ export default { |
|
|
|
// 空调name获取 |
|
|
|
getAirQueryName(switchInfo){ |
|
|
|
let { hardware_connect_method, hardware_model } = switchInfo; |
|
|
|
if(hardware_connect_method === 'Tcp'&&hardware_model === 'JianDa')return 'ray-air-rs-tcp'; |
|
|
|
let _flag = this.changeLowerCase(hardware_connect_method) === 'tcp'&&this.changeLowerCase(hardware_model) === 'jianda'; |
|
|
|
if(_flag)return 'ray-air-rs-tcp'; |
|
|
|
let _obj = { |
|
|
|
'Acmelec': 'acmelec', |
|
|
|
'ZhongNan': 'zhongnan', |
|
|
|
'JianDa': 'ray-air-rs' |
|
|
|
'acmelec': 'acmelec', |
|
|
|
'zhongnan': 'zhongnan', |
|
|
|
'jianda': 'ray-air-rs' |
|
|
|
}; |
|
|
|
return _obj[hardware_model] || ''; |
|
|
|
return _obj[this.changeLowerCase(hardware_model)] || ''; |
|
|
|
}, |
|
|
|
getIcon(){ |
|
|
|
let { pageInfo } = this; |
|
|
|