From 281e26622642a4f8cd1ece302ade524ae9c23a3f Mon Sep 17 00:00:00 2001 From: "liujw155@outlook.com" Date: Fri, 25 Dec 2020 18:05:53 +0800 Subject: [PATCH] fix bug && add device status --- src/subpackage/device/js/ouxuanac.md | 5 ++ .../device/pages/coffee_manage/coffee_manage.vue | 7 +- .../device/pages/coffee_test/coffee_test.vue | 2 +- .../device/pages/device_manage/device_manage.vue | 7 ++ .../device/pages/locker_manage/locker_manage.vue | 19 ++++- .../device/pages/switch_manage/switch_manage.vue | 95 ++++++++++++++++++++-- 6 files changed, 122 insertions(+), 13 deletions(-) diff --git a/src/subpackage/device/js/ouxuanac.md b/src/subpackage/device/js/ouxuanac.md index b35051d..72b9907 100644 --- a/src/subpackage/device/js/ouxuanac.md +++ b/src/subpackage/device/js/ouxuanac.md @@ -24,6 +24,10 @@ enum RelayOP { High = "high", // 高电位, 为关闭 } + +// 咖啡机和门闸暂时没有状态 + + //--------------------------if 通讯方式为开关量时使用----------------------------- //原生继电器 // 全设备通用 @@ -168,6 +172,7 @@ enum LockerOP { //--------------------------if 通讯方式485, 设备类型为储物柜时使用----------------------------- +// 开格子的时候你要同时打开多个 所以传多一个"is_delay": true, //485 储物柜 //tcp 储物柜 cid为硬件地址id id为具体箱子的id function Locker485Packet(id: string, cid: string, op: LockerOP) { diff --git a/src/subpackage/device/pages/coffee_manage/coffee_manage.vue b/src/subpackage/device/pages/coffee_manage/coffee_manage.vue index f4838cf..b00c603 100644 --- a/src/subpackage/device/pages/coffee_manage/coffee_manage.vue +++ b/src/subpackage/device/pages/coffee_manage/coffee_manage.vue @@ -8,7 +8,7 @@ {{e.name || '-'}} - - + + ¥{{e.price || 0}} @@ -59,7 +59,7 @@ export default { success: res=>{ if(res.confirm){ this.confirmReq( - typeList.map(e=>({id: e.id, stock: isFillAll? e.limit || 38 : e.stock})) + typeList.map(e=>({id: e.id, stock: isFillAll? e.depth || 38 : e.stock})) ); } } @@ -154,6 +154,9 @@ export default { font-size: 32upx; line-height: 44upx; color: #333; + &.active{ + color: #FF4F00; + } } >view{ width: 36upx; diff --git a/src/subpackage/device/pages/coffee_test/coffee_test.vue b/src/subpackage/device/pages/coffee_test/coffee_test.vue index 4739599..856be62 100644 --- a/src/subpackage/device/pages/coffee_test/coffee_test.vue +++ b/src/subpackage/device/pages/coffee_test/coffee_test.vue @@ -84,7 +84,7 @@ export default { let { curTestInfo, temperatureType, curStoreInfo } = this; util.showLoad(); let deviceInfo = await deviceServer.get({ - url: deviceApi.hardwareInfo + curTestInfo.stadium_hardware_id, + url: deviceApi.hardwareInfo + curTestInfo.outlet, data: {}, failMsg: '获取设备信息失败!' }) diff --git a/src/subpackage/device/pages/device_manage/device_manage.vue b/src/subpackage/device/pages/device_manage/device_manage.vue index 2d63f68..f104636 100644 --- a/src/subpackage/device/pages/device_manage/device_manage.vue +++ b/src/subpackage/device/pages/device_manage/device_manage.vue @@ -100,6 +100,13 @@ export default { curStoreInfo: state => state.device.curStoreInfo, }) }, + watch: { + curStoreInfo(newVal, oldVal){ + let { pageInfo } = this; + this.deviceList = []; + this.getDeviceList(pageInfo) + } + }, components: { 'store-name': store_name }, diff --git a/src/subpackage/device/pages/locker_manage/locker_manage.vue b/src/subpackage/device/pages/locker_manage/locker_manage.vue index 954bc26..8aab606 100644 --- a/src/subpackage/device/pages/locker_manage/locker_manage.vue +++ b/src/subpackage/device/pages/locker_manage/locker_manage.vue @@ -14,8 +14,15 @@ - - + + + {{e.cabinet_name || '-'}} + + {{e.price || 0}}{{e.dimensions[0] || '-'}} + + + + {{isRent(e)?e.cabinet_name || '-':e.goods_name || '-'}} {{e.price || '0'}}{{e.unit || '-'}} @@ -105,10 +112,11 @@ export default { return info.cabinet_type === 'rent' }, getleaseBoxType(info){ + let { optionsQuery } = this; let _rentArr = ['未租', '已租']; let _sellArr = ['未卖', '已卖']; if(!info)return ''; - if(info.cabinet_type == 'rent')return _rentArr[info. usage_status] || ''; + if(info.cabinet_type == 'rent' || optionsQuery.page_id == 9)return _rentArr[info. usage_status] || ''; if(info.cabinet_type == 'sell')return _sellArr[info. usage_status] || ''; }, getBoxList(){ @@ -130,7 +138,10 @@ export default { }, openLocker(){ let { optionsQuery } = this; - if(optionsQuery.page_id == 9)return util.showModal({ + let { boxList } = this; + let selectedList = boxList.filter(ele=>ele._isSelected); + console.log(selectedList) + if(optionsQuery.page_id == 8)return util.showModal({ title: '提示', content: '是否补货', showCancel: true, diff --git a/src/subpackage/device/pages/switch_manage/switch_manage.vue b/src/subpackage/device/pages/switch_manage/switch_manage.vue index 258e02f..066dc0c 100644 --- a/src/subpackage/device/pages/switch_manage/switch_manage.vue +++ b/src/subpackage/device/pages/switch_manage/switch_manage.vue @@ -10,12 +10,12 @@ {{e.hardware_name || '-'}} - + + @@ -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