|
|
@ -10,12 +10,12 @@ |
|
|
|
<view class="sr-name">{{e.hardware_name || '-'}}</view> |
|
|
|
<!-- 门闸没有状态查询 --> |
|
|
|
<!-- 请求接口自定义字段设备状态 1->在线,0->离线 --> |
|
|
|
<!-- <view class="sr-bot" v-if="pageInfo.id !=5"> |
|
|
|
<view :class="[e.defineStatus == 1?'active':'']"> |
|
|
|
<text>{{ e.defineStatus == 1 ? '设备在线' : e.defineStatus == 0?'设备离线' : '-' }}</text> |
|
|
|
<view class="sr-bot" v-if="pageInfo.id !=5"> |
|
|
|
<view :class="[e.defineStatusCode == 1?'active':'']"> |
|
|
|
<text>{{ e.defineStatusCode == 1 ? '设备在线' : e.defineStatusCode == 0?'设备离线' : '-' }}</text> |
|
|
|
</view> |
|
|
|
<image mode="aspectFit" src="/subpackage/device/static/images/refresh.png"></image> |
|
|
|
</view> --> |
|
|
|
<image mode="aspectFit" src="/subpackage/device/static/images/refresh.png" @click="refreshStatusBtn({switchInfo:e, index:i})"></image> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="si-bottom" v-if="pageInfo.isOpen || pageInfo.isClose"> |
|
|
@ -105,6 +105,7 @@ export default { |
|
|
|
}, |
|
|
|
watch: { |
|
|
|
curStoreInfo(newVal, oldVal){ |
|
|
|
this.deviceList = []; |
|
|
|
this.getDeviceList({ |
|
|
|
stadium_id: newVal.id, |
|
|
|
hardware_type: this.pageInfo.hardware_type |
|
|
@ -128,6 +129,7 @@ export default { |
|
|
|
}) |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
|
|
|
|
getDeviceList({ |
|
|
|
stadium_id, |
|
|
|
hardware_type, |
|
|
@ -166,7 +168,7 @@ export default { |
|
|
|
this.operateReq({ data: _data }); |
|
|
|
|
|
|
|
}, 300, 300), |
|
|
|
|
|
|
|
|
|
|
|
// 获取接口参数结构 |
|
|
|
getOperateReqData({ switchInfo, status }){ |
|
|
|
let { curStoreInfo } = this; |
|
|
@ -218,6 +220,87 @@ export default { |
|
|
|
queue_group: 'gate' |
|
|
|
} |
|
|
|
}, |
|
|
|
// |
|
|
|
refreshStatusBtn: util.debounce(function({switchInfo, index}){ |
|
|
|
this.getStatusReq({ |
|
|
|
data: this.getSwitchStatusQuery(switchInfo), |
|
|
|
index, |
|
|
|
}) |
|
|
|
},300,300), |
|
|
|
// 获取设备状态 |
|
|
|
getStatusReq({data, index}){ |
|
|
|
let _deviceList = this.deviceList.slice(); |
|
|
|
util.showLoad(); |
|
|
|
deviceServer.post({ |
|
|
|
url: deviceApi.ouxuanac, |
|
|
|
data: data, |
|
|
|
isDefaultGet: false, |
|
|
|
}) |
|
|
|
.then(res=>{ |
|
|
|
util.hideLoad(); |
|
|
|
let _data = res.data || {}; |
|
|
|
console.log(this.changeLowerCase(_data.data)) |
|
|
|
if(_data.code == 504 || this.changeLowerCase(_data.data).indexOf('timeout')!=-1){ |
|
|
|
_deviceList[index]['defineStatusCode'] = 0; |
|
|
|
|
|
|
|
}else if(_data.code == 0&&this.changeLowerCase(_data.data).indexOf('timeout')==-1){ |
|
|
|
_deviceList[index]['defineStatusCode'] = 1; |
|
|
|
}else{ |
|
|
|
util.showNone(_data.message || '操作失败!'); |
|
|
|
} |
|
|
|
this.deviceList = _deviceList; |
|
|
|
// if(res.data.code == 0){ |
|
|
|
// if(isTip)util.showNone(res.data.message || '操作成功!'); |
|
|
|
// }else{ |
|
|
|
// if(isTip)util.showNone(res.data.message || '操作失败!'); |
|
|
|
// } |
|
|
|
}) |
|
|
|
.catch(util.hideLoad) |
|
|
|
}, |
|
|
|
|
|
|
|
// 咖啡机和门闸暂时没有状态 |
|
|
|
// 设备状态请求参数数据结构 |
|
|
|
getSwitchStatusQuery(switchInfo){ |
|
|
|
let { curStoreInfo } = this; |
|
|
|
let { |
|
|
|
hardware_connect_method, |
|
|
|
hardware_type, |
|
|
|
hardware_id, |
|
|
|
node_id, |
|
|
|
hardware_net_addr |
|
|
|
} = switchInfo; |
|
|
|
|
|
|
|
|
|
|
|
const _query = { |
|
|
|
name: this.getQueryName(switchInfo), |
|
|
|
value: { id: hardware_id + '', } // value 内值全为String |
|
|
|
}; |
|
|
|
|
|
|
|
if (this.changeLowerCase(hardware_connect_method) === 'tcp') _query.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 |
|
|
|
_query.value['op'] = 'status' |
|
|
|
_query['name'] = this.getAirQueryName(switchInfo) |
|
|
|
}else{ |
|
|
|
_query.value['p'] = node_id + ''; // 硬件子id |
|
|
|
// postData.value['o'] = this.getRelayStatus(status); // 开关状态 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return { |
|
|
|
device: curStoreInfo.device_name, // 中控名, |
|
|
|
data: _query, // 后端数据结构, 参考src\subpackage\device\js\ouxuanac.md |
|
|
|
} |
|
|
|
|
|
|
|
// this.getStatusReq({ |
|
|
|
// index, |
|
|
|
// data: { |
|
|
|
// device: curStoreInfo.device_name, // 中控名, |
|
|
|
// data: _query, // 后端数据结构, 参考src\subpackage\device\js\ouxuanac.md |
|
|
|
// } |
|
|
|
// }) |
|
|
|
}, |
|
|
|
// switchInfo -> 当前开关信息 |
|
|
|
// status -> 开关状态 0 -> 关(右), 1 -> 开(左) |
|
|
|
// 数据结构参考 src\subpackage\device\js\ouxuanac.md |
|
|
|