Browse Source

add all

voice
刘嘉炜 4 years ago
parent
commit
76a4458cf6
  1. 2
      src/subpackage/device/js/device_api.js
  2. 172
      src/subpackage/device/pages/device_manage/device_manage.vue
  3. 2
      src/subpackage/device/pages/index/index.vue
  4. 103
      src/subpackage/device/pages/locker_manage/locker_manage.vue
  5. 8
      src/utils/util.js

2
src/subpackage/device/js/device_api.js

@ -14,6 +14,8 @@ export const DEVICE_API = {
leaseList:`${ORIGIN}/admin/stadium/lease/cabinet/list`, // 租售柜列表
lockerList:`${ORIGIN}/admin/stadium/locker/cabinet/list`, // 储物柜列表
leaseTest:`${ORIGIN}/admin/stadium/lease/cabinet/test`, // 储物柜列表
leaseReset:`${ORIGIN}/admin/stadium/lease/cabinet/reset`, // 储物柜列表

172
src/subpackage/device/pages/device_manage/device_manage.vue

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

2
src/subpackage/device/pages/index/index.vue

@ -62,7 +62,7 @@ export default {
return `/subpackage/device/static/images/devices/${id || 14}.png`
},
routeTo(e){
if(e.path == '')return util.showNone('暂未开放!');
if(e.path == '')return util.showNone('开发中!');
if(
e.id == 1 || //
e.id == 2 || //

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

@ -59,6 +59,7 @@ import util from '../../../../utils/util';
import device_name from '../../components/device_name/device_name';
import deviceServer from '../../js/device_server';
import deviceApi from '../../js/device_api';
import { mapState } from 'vuex';
// e.page_id == 8 ||  //
// e.page_id == 9 ||  //
export default {
@ -79,7 +80,10 @@ export default {
if(!el._isSelected)_is = false;
})
return _is
}
},
...mapState({
curStoreInfo: state => state.device.curStoreInfo,
})
},
data(){
return{
@ -117,12 +121,16 @@ export default {
let _sellArr = ['未卖', '已卖'];
if(!info)return '';
if(info.cabinet_type == 'rent' || optionsQuery.page_id == 9)return _rentArr[info. usage_status] || '';
if(info.cabinet_type == 'sell')return _sellArr[info. usage_status] || '';
if(info.cabinet_type == 'sell')return _sellArr[info.usage_status] || '';
},
getBoxList(){
let { optionsQuery, curStoreInfo } = this;
deviceServer.get({
url: this.getListApi(),
data: {},
data: {
cabine_ids: optionsQuery.id,
brand_id: curStoreInfo.brand_id
},
failMsg: '加载失败!'
})
.then(res=>{
@ -136,18 +144,87 @@ export default {
if(optionsQuery.page_id == 8)return deviceApi.leaseList;
if(optionsQuery.page_id == 9)return deviceApi.lockerList;
},
openLocker(){
let { optionsQuery } = this;
// e.page_id == 8 ||  //
// e.page_id == 9 ||  //
openLocker: util.debounce(async function(){
let { optionsQuery, curStoreInfo } = this;
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,
success: modalRes=>{
console.log(modalRes)
let _selectedList = boxList.filter(ele=>ele._isSelected);
let _selledList = _selectedList.filter(ele=>ele.cabinet_type === 'sell'&&ele.usage_status == 1);
try{
let _openStatus = await this.openLockerReq(_selectedList.map(el=>el.id).join(','));
if(_selledList.length){
let _tipStr = '';
_selledList.forEach((ele,idx)=>{
_tipStr += _selledList.length-1>idx?`${ele.id}号柜、`:`${ele.id}号柜`;
})
_tipStr+= `商品已被售`
if(_openStatus){
uni.hideToast();
util.showModal({
title: '请问您是否已经补货?',
content: _tipStr,
showCancel: true,
success: async modalRes=>{
if(modalRes.confirm)this.leaseReset(_selledList.map(el=>el.id).join(','));
}
})
}
}
}catch(err){
console.log('open err', err);
util.hideLoad();
}
}, 300, 300),
leaseReset(ids){
let { curStoreInfo } = this;
util.showLoad();
deviceServer.get({
url: deviceApi.leaseReset,
data: {
brand_id: curStoreInfo.brand_id,
lease_cabinet_id: ids,
},
isDefaultGet: false
})
.then(res=>{
util.hideLoad();
if(res.data.code == 0){
util.showNone(res.data.message || '操作成功!');
}else{
util.showNone(res.data.message || '操作失败!');
}
})
.catch(util.hideLoad)
},
openLockerReq(cabinet_ids){
let { curStoreInfo } = this;
util.showLoad();
return deviceServer.get({
url: deviceApi.leaseTest,
data: {
brand_id: curStoreInfo.brand_id,
cabinet_ids: cabinet_ids,
},
isDefaultGet: false
})
.then(res=>{
util.hideLoad();
if(res.data.code == 0){
util.showNone(res.data.message || '操作成功!');
return true
}else{
util.showNone(res.data.message || '操作失败!');
return false
}
})
}
}

8
src/utils/util.js

@ -329,6 +329,11 @@ function formatScene(sceneStr = ''){
return obj;
},{}) || {};
}
function changeLowerCase(str){
return str.toString().toLocaleLowerCase();
}
export default {
formatTime,
formatNumber,
@ -355,5 +360,6 @@ export default {
substrDate,
requestPayment,
getQueryStr,
formatScene
formatScene,
changeLowerCase
}
Loading…
Cancel
Save