|
|
@ -14,19 +14,24 @@ |
|
|
|
</view> |
|
|
|
<view class="di-section"> |
|
|
|
<view class="ds-stock" v-if="pageInfo.isShowStock"> |
|
|
|
<view>库存:<text class="active">充足</text></view> |
|
|
|
<view>库存:<text :class="e.is_enough?'active':''">{{is_enough?'充足':'缺货'}}</text></view> |
|
|
|
<view hover-class="hover-active" @click="stockBtn(e)">{{pageInfo.stockBtnName || '-'}}</view> |
|
|
|
</view> |
|
|
|
<view class="ds-contral"> |
|
|
|
<view> |
|
|
|
设备:<text class="active">离线</text> |
|
|
|
<!-- // 咖啡机和门闸暂时没有状态 --> |
|
|
|
<view class="dc-status"> |
|
|
|
设备:<text :class="[e.defineStatusCode == 1?'active':'']">{{ |
|
|
|
pageInfo.id ==10?'-': |
|
|
|
e.defineStatusCode == 1? '在线': |
|
|
|
e.defineStatusCode == 0? '离线':'-' |
|
|
|
}}</text> |
|
|
|
</view> |
|
|
|
<view hover-class="hover-active">更新</view> |
|
|
|
<view v-if="e.enable_status == 0" hover-class="hover-active" @click="changeDeviceStatus({info: e, status: 1})"> |
|
|
|
<view v-if="pageInfo.id !=10" class="dc-refresh-btn" hover-class="hover-active" @click="refreshBtn({deviceInfo: e, index: i})">更新</view> |
|
|
|
<view class="dc-status-btn" v-if="e.enable_status == 0" hover-class="hover-active" @click="changeDeviceStatus({info: e, status: 1})"> |
|
|
|
<text>{{ pageInfo.deviceBtnOpenName || '-' }}</text> |
|
|
|
<image mode="aspectFit" src="/subpackage/device/static/images/start.png"></image> |
|
|
|
</view> |
|
|
|
<view v-else-if="e.enable_status == 1" class="active" hover-class="hover-active" @click="changeDeviceStatus({info: e, status: 0})"> |
|
|
|
<view class="dc-status-btn active" v-else-if="e.enable_status == 1" hover-class="hover-active" @click="changeDeviceStatus({info: e, status: 0})"> |
|
|
|
<text>{{ pageInfo.deviceBtnStopName || '-' }}</text> |
|
|
|
<image mode="aspectFit" src="/subpackage/device/static/images/stop.png"></image> |
|
|
|
</view> |
|
|
@ -124,6 +129,85 @@ export default { |
|
|
|
this.getDeviceList(_pageInfo) |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
refreshBtn: util.debounce(function({deviceInfo, index}){ |
|
|
|
if(this.getQueryData(deviceInfo) === 'configError')return; |
|
|
|
this.getDeviceOnlineStatus({ |
|
|
|
data: this.getQueryData(deviceInfo), |
|
|
|
index |
|
|
|
}); |
|
|
|
}, 300, 300), |
|
|
|
// 获取设备在线状态参数结构 |
|
|
|
getQueryData(deviceInfo){ |
|
|
|
let { |
|
|
|
hardware_connect_method, |
|
|
|
hardware_type, |
|
|
|
hardware_id, |
|
|
|
hardware_net_addr |
|
|
|
} = deviceInfo; |
|
|
|
|
|
|
|
let _query = {}; |
|
|
|
// 储物柜、租售柜 |
|
|
|
if (util.changeLowerCase(hardware_type) === 'locker'){ |
|
|
|
_query = { |
|
|
|
"name": "lock-b", |
|
|
|
"value": { |
|
|
|
"id": hardware_id + '', |
|
|
|
"cid": '1', |
|
|
|
"op": 'status', |
|
|
|
} |
|
|
|
}; |
|
|
|
if(util.changeLowerCase(hardware_connect_method) === 'tcp'){ |
|
|
|
_query['name'] = 'lock-b-tcp'; |
|
|
|
_query['value']['tcp'] = hardware_net_addr + ''; |
|
|
|
} |
|
|
|
}else if(util.changeLowerCase(hardware_type) === 'vendingmachine'){ |
|
|
|
// 售货机 |
|
|
|
_query = [{ |
|
|
|
"name": "yunyin-mac", |
|
|
|
"value": { |
|
|
|
"tcp": hardware_net_addr + '', |
|
|
|
} |
|
|
|
}] |
|
|
|
}else{ |
|
|
|
util.showNone(`config error -> type:${hardware_type || '-'} / connect method:${hardware_connect_method || '-'}`) |
|
|
|
return 'configError'; |
|
|
|
} |
|
|
|
return _query; |
|
|
|
}, |
|
|
|
// 获取设备在线状态 |
|
|
|
getDeviceOnlineStatus({ data, index }){ |
|
|
|
let _deviceList = this.deviceList.slice(); |
|
|
|
let { curStoreInfo } = this; |
|
|
|
util.showLoad(); |
|
|
|
deviceServer.post({ |
|
|
|
url: deviceApi.ouxuanac, |
|
|
|
data: { |
|
|
|
device: curStoreInfo.device_name, |
|
|
|
data, |
|
|
|
}, |
|
|
|
isDefaultGet: false, |
|
|
|
}) |
|
|
|
.then(res=>{ |
|
|
|
util.hideLoad(); |
|
|
|
let _data = res.data || {}; |
|
|
|
if(_data.code == 504 || util.changeLowerCase(_data.data).indexOf('timeout')!=-1){ |
|
|
|
_deviceList[index]['defineStatusCode'] = 0; |
|
|
|
|
|
|
|
}else if(_data.code == 0&&util.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) |
|
|
|
}, |
|
|
|
|
|
|
|
changeDeviceStatus({info, status}){ |
|
|
|
let { pageInfo } = this; |
|
|
|
util.showLoad(); |
|
|
@ -281,48 +365,46 @@ export default { |
|
|
|
} |
|
|
|
.ds-contral{ |
|
|
|
@include centerFlex(space-between); |
|
|
|
>view{ |
|
|
|
&:first-child{ |
|
|
|
font-size: 26upx; |
|
|
|
line-height: 36upx; |
|
|
|
color: #9A9A9D; |
|
|
|
>text{ |
|
|
|
color: #333333; |
|
|
|
&.active{ |
|
|
|
color: $themeColor; |
|
|
|
} |
|
|
|
.dc-status{ |
|
|
|
font-size: 26upx; |
|
|
|
line-height: 36upx; |
|
|
|
color: #9A9A9D; |
|
|
|
>text{ |
|
|
|
color: #333333; |
|
|
|
&.active{ |
|
|
|
color: $themeColor; |
|
|
|
} |
|
|
|
} |
|
|
|
&:nth-child(2){ |
|
|
|
margin-left: 28upx; |
|
|
|
width: 116upx; |
|
|
|
height: 46upx; |
|
|
|
line-height: 42upx; |
|
|
|
text-align: center; |
|
|
|
border: 2upx solid $themeColor; |
|
|
|
border-radius: 25upx; |
|
|
|
font-size: 24upx; |
|
|
|
color: $themeColor; |
|
|
|
} |
|
|
|
.dc-refresh-btn{ |
|
|
|
margin-left: 28upx; |
|
|
|
width: 116upx; |
|
|
|
height: 46upx; |
|
|
|
line-height: 42upx; |
|
|
|
text-align: center; |
|
|
|
border: 2upx solid $themeColor; |
|
|
|
border-radius: 25upx; |
|
|
|
font-size: 24upx; |
|
|
|
color: $themeColor; |
|
|
|
} |
|
|
|
.dc-status-btn{ |
|
|
|
padding: 0 18upx; |
|
|
|
height: 56upx; |
|
|
|
line-height: 52upx; |
|
|
|
text-align: center; |
|
|
|
font-size: 28upx; |
|
|
|
color: $themeColor; |
|
|
|
border: 2upx solid $themeColor; |
|
|
|
border-radius: 10upx; |
|
|
|
>image{ |
|
|
|
margin-left: 6upx; |
|
|
|
vertical-align: middle; |
|
|
|
width: 32upx; |
|
|
|
height: 32upx; |
|
|
|
} |
|
|
|
&:nth-child(3){ |
|
|
|
padding: 0 18upx; |
|
|
|
height: 56upx; |
|
|
|
line-height: 52upx; |
|
|
|
text-align: center; |
|
|
|
font-size: 28upx; |
|
|
|
color: $themeColor; |
|
|
|
border: 2upx solid $themeColor; |
|
|
|
border-radius: 10upx; |
|
|
|
>image{ |
|
|
|
margin-left: 6upx; |
|
|
|
vertical-align: middle; |
|
|
|
width: 32upx; |
|
|
|
height: 32upx; |
|
|
|
} |
|
|
|
&.active{ |
|
|
|
border-color: #EA5061; |
|
|
|
color: #EA5061; |
|
|
|
} |
|
|
|
&.active{ |
|
|
|
border-color: #EA5061; |
|
|
|
color: #EA5061; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|