Browse Source

fix bug && add device status

voice
刘嘉炜 5 years ago
parent
commit
281e266226
  1. 5
      src/subpackage/device/js/ouxuanac.md
  2. 7
      src/subpackage/device/pages/coffee_manage/coffee_manage.vue
  3. 2
      src/subpackage/device/pages/coffee_test/coffee_test.vue
  4. 7
      src/subpackage/device/pages/device_manage/device_manage.vue
  5. 19
      src/subpackage/device/pages/locker_manage/locker_manage.vue
  6. 95
      src/subpackage/device/pages/switch_manage/switch_manage.vue

5
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) {

7
src/subpackage/device/pages/coffee_manage/coffee_manage.vue

@ -8,7 +8,7 @@
<view class="cc-name">{{e.name || '-'}}</view>
<view class="cc-num">
<view hover-class="hover-active" @click="reduceStock(i)">-</view>
<input :value="e.stock" disabled />
<input :class="[e.stock<=e.limit?'active':'']" :value="e.stock" disabled />
<view hover-class="hover-active" class="active" @click="addStock(i)">+</view>
</view>
<view class="cc-price"><text>¥</text>{{e.price || 0}}</view>
@ -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;

2
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: '获取设备信息失败!'
})

7
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
},

19
src/subpackage/device/pages/locker_manage/locker_manage.vue

@ -14,8 +14,15 @@
</view>
<view class="li-content">
<view>
<!-- 储物柜 -->
<view v-if="optionsQuery.page_id == 9">
<view class="lc-name">{{e.cabinet_name || '-'}}</view>
<view class="lc-price">
<view>{{e.price || 0}}<text>{{e.dimensions[0] || '-'}}</text></view>
</view>
</view>
<!-- 租售柜 -->
<view v-if="optionsQuery.page_id == 8">
<view class="lc-name">{{isRent(e)?e.cabinet_name || '-':e.goods_name || '-'}}</view>
<view class="lc-price">
<view>{{e.price || '0'}}<text>{{e.unit || '-'}}</text></view>
@ -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,

95
src/subpackage/device/pages/switch_manage/switch_manage.vue

@ -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

Loading…
Cancel
Save