Browse Source

开关控制

voice
刘嘉炜 4 years ago
parent
commit
e6612b9cf3
  1. 2
      src/js/server.js
  2. 4
      src/subpackage/device/js/device_api.js
  3. 6
      src/subpackage/device/js/ouxuanac.md
  4. 38
      src/subpackage/device/pages/device_manage/device_manage.vue
  5. 9
      src/subpackage/device/pages/index/index.vue
  6. 37
      src/subpackage/device/pages/sell_box_manage/sell_box_manage.vue
  7. 118
      src/subpackage/device/pages/sell_box_test/sell_box_test.vue
  8. 57
      src/subpackage/device/pages/switch_manage/switch_manage.vue

2
src/js/server.js

@ -1,6 +1,6 @@
import util from '../utils/util';
// import { app as vm } from '../main';
const islog = false;
const islog = true;
export class Server {
request(url,data,method,header,isDefaultGet,failMsg){

4
src/subpackage/device/js/device_api.js

@ -5,6 +5,10 @@ export const DEVICE_API = {
vendingGoodsList:`${ORIGIN}/stadium/vending/goods/list`, // 售货柜-商品列表
vendingGoodsRestock:`${ORIGIN}/admin/stadium/vending/goods/restock`, // 售货柜-库存修改保存
vendingTestAll:`${ORIGIN}/admin/stadium/vending/path/test/all`, // 售货柜-全部货道测试
vendingTestOne:`${ORIGIN}/admin/stadium/vending/path/test/one`, // 售货柜-单货道测试
hardwareSave:`${ORIGIN}/admin/stadium/hardware/save`, // 设备开启/关闭
hardwareList:`${ORIGIN}/admin/stadium/hardware/list`, // 设备列表
ouxuanac:`${ORIGIN}/ouxuanac/sendPacket`, // 中控控制

6
src/subpackage/device/js/ouxuanac.md

@ -56,9 +56,9 @@ function relay485Packet(id: string, p: string, o: RelayOP) {
return {
"name": "zzio404d-gpio",
"value": {
"id": id,
"p": p,
"o": o,
"id": id, // 主键id
"p": p, // 子id, 对应 node_id
"o": o, // 设备状态
}
}
}

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

@ -7,7 +7,7 @@
<view class="di-header">
<image mode="aspectFit" :src="getIcon()"></image>
<view class="dh-name">{{e.hardware_type_name || '-'}}</view>
<view class="dh-test-btn" v-if="pageInfo.isTestBtn" @click="testBtn">
<view class="dh-test-btn" v-if="pageInfo.isTestBtn" @click="testBtn(e)">
<image mode="aspectFit" :src="pageInfo.testBtnIcon || ''"></image>
<view>{{pageInfo.testBtnName || '-'}}</view>
</view>
@ -22,15 +22,14 @@
设备<text class="active">离线</text>
</view>
<view hover-class="hover-active">更新</view>
<view v-if="isStart" hover-class="hover-active" @click="isStart = !isStart">
<view 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 class="active" v-else hover-class="hover-active" @click="isStart = !isStart">
<view v-else-if="e.enable_status == 1" class="active" 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>
</view>
</view>
</view>
@ -115,8 +114,29 @@ export default {
this.getDeviceList(_pageInfo)
},
methods: {
changeDeviceStatus({info, status}){
let { pageInfo } = this;
util.showLoad();
deviceServer.get({
url: deviceApi.hardwareSave,
data: {
id: info.id,
enable_status:status,
},
isDefaultGet: false
})
.then(res=>{
if(res.data.code == 0){
util.showNone(res.data.message || '操作成功!')
setTimeout(_=>this.getDeviceList(pageInfo),1200);
}else{
util.showNone(res.data.message || '操作失败!');
}
})
},
getDeviceList(pageInfo){
let { curStoreInfo } = this;
util.showLoad();
deviceServer.get({
url: deviceApi.hardwareList,
data: {
@ -126,10 +146,12 @@ export default {
failMsg: '加载设备失败!'
})
.then(res=>{
util.hideLoad();
let _list = res.list || [];
this.deviceList = _list;
console.log(res);
})
.catch(util.hideLoad)
},
getIcon(){
let { pageInfo } = this;
@ -147,9 +169,13 @@ export default {
// if(pageInfo.id == 9)return util.routeTo(`/subpackage/device/pages/locker_manage/locker_manage`, 'nT');
if(pageInfo.id == 10)return util.routeTo(`/subpackage/device/pages/coffee_manage/coffee_manage`, 'nT');
},
testBtn(){
testBtn(e){
let { pageInfo } = this;
if(pageInfo.id == 7)return util.routeTo(`/subpackage/device/pages/sell_box_test/sell_box_test`, 'nT');
let _query = {
id: e.id,
name: e.hardware_type_name
}
if(pageInfo.id == 7)return util.routeTo(`/subpackage/device/pages/sell_box_test/sell_box_test?query=${util.jsonStr(_query)}`, 'nT');
// if(pageInfo.id == 8)return util.routeTo(`/subpackage/device/pages/locker_manage/locker_manage`, 'nT');
if(pageInfo.id == 9)return util.routeTo(`/subpackage/device/pages/locker_manage/locker_manage?type=9`, 'nT');
if(pageInfo.id == 10)return util.routeTo(`/subpackage/device/pages/coffee_test/coffee_test`, 'nT');

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

@ -63,7 +63,14 @@ export default {
},
routeTo(e){
if(e.path == '')return util.showNone('暂未开放!');
if(e.id == 5 || e.id == 7)return util.routeTo(`${rootPage}${e.path}?sid=${e.id}`, 'nT');
if(
e.id == 1 || //
e.id == 3 || //
e.id == 4 || //
e.id == 5 ||  //
e.id == 11 ||  //
e.id == 7   //
)return util.routeTo(`${rootPage}${e.path}?sid=${e.id}`, 'nT');
util.showNone(`开发中!`);
}
}

37
src/subpackage/device/pages/sell_box_manage/sell_box_manage.vue

@ -12,7 +12,7 @@
<view class="sgl-item" v-for="(k,j) in e.vending_goods" :key="j">
<view class="si-img">
<image mode="aspectFit" :src="k.image || ''"></image>
<view class="si-tag"><view>101</view></view>
<view class="si-tag" v-if="k.grid_id"><view>{{k.grid_id || ''}}</view></view>
</view>
<view class="si-name">
<view>{{k.goods_name || '-'}}</view>
@ -80,13 +80,42 @@ export default {
let _goodsArr = [];
_list.forEach((el,idx)=>{
if(el.vending_goods.length)el.vending_goods.forEach((e,i)=>{
// depth
_goodsArr.push({ id: e.id, stock: isFillAll? e.depth : e.stock });
})
})
util.showModal({
title: '是否确认补货?',
content: isFillAll? '请确认全部货道是否铺满':'',
showCancel: true,
success: res=>{
if(res.confirm)this.replenishmentREQ({
goodsArr: _goodsArr,
optionsQuery
})
}
})
// deviceServer.post({
// url: deviceApi.vendingGoodsRestock,
// data: _goodsArr,
// isDefaultGet: false
// })
// .then(res=>{
// if(res.data.code == 0){
// util.showNone(res.data.message || '');
// setTimeout(_=>this.getGoodsList(optionsQuery.id), 1200);
// }else{
// util.showNone(res.data.message || '');
// }
// })
}, 300, 300),
replenishmentREQ({goodsArr, optionsQuery}){
util.showLoad();
deviceServer.post({
url: deviceApi.vendingGoodsRestock,
data: _goodsArr,
data: goodsArr,
isDefaultGet: false
})
.then(res=>{
@ -97,9 +126,7 @@ export default {
util.showNone(res.data.message || '操作失败!');
}
})
console.log(_goodsArr)
}, 300, 300),
},
addGoods({group, index}){
let _list = this.goodsList.slice();
if(_list[group].vending_goods[index].depth<= _list[group].vending_goods[index].stock)return util.showNone('超出上限');

118
src/subpackage/device/pages/sell_box_test/sell_box_test.vue

@ -1,19 +1,21 @@
<template>
<view class="sell-box-test">
<device-name></device-name>
<device-name :name="optionsQuery.name"></device-name>
<view class="sbt-tit">测试货道</view>
<view class="sbt-tip">您可自定义测试某个货道也可以批量测试所有货道</view>
<view class="sbt-section">
<view class="ss-item">
<!-- <view class="ss-item">
<view class="si-tit">批量测试货道</view>
<view class="si-ipt"><input placeholder="请输入运行圈数" /></view>
<view class="si-btn" hover-class="hover-active">执行</view>
</view>
<view class="si-btn" hover-class="hover-active" @click="testAllBtn">执行</view>
</view> -->
<view class="ss-item">
<view class="si-tit">自定义测试</view>
<picker><view class="si-ipt"><input placeholder="请选择货道编号" disabled/><image></image></view></picker>
<view class="si-ipt"><input placeholder="请输入运行圈数" /></view>
<view class="si-btn" hover-class="hover-active">执行</view>
<picker :range="goodsList" range-key="grid_id" @change="pickerChange">
<view class="si-ipt"><input placeholder="请选择货道编号" disabled :value="curTestCargoLane.grid_id"/><view></view></view>
</picker>
<view class="si-ipt"><input placeholder="请输入运行圈数" v-model="testOneNum" /></view>
<view class="si-btn" hover-class="hover-active" @click="testOneBtn">执行</view>
</view>
</view>
</view>
@ -21,9 +23,101 @@
<script>
import device_name from '../../components/device_name/device_name';
import deviceServer from '../../js/device_server';
import deviceApi from '../../js/device_api';
import util from '../../../../utils/util';
import { mapState } from 'vuex';
export default {
components: {
'device-name': device_name
},
computed: {
...mapState({
curStoreInfo: state => state.device.curStoreInfo,
})
},
data(){
return {
curTestCargoLane: {},
goodsList: [],
optionsQuery: {},
testOneNum: 1
}
},
onLoad(options){
let _query = util.jsonPar(options.query);
this.optionsQuery = _query || {};
this.getGoodsList(_query.id)
},
methods: {
// testAllBtn: util.debounce(function(){
// let { curStoreInfo, optionsQuery } = this;
// console.log(optionsQuery)
// util.showLoad();
// deviceServer.get({
// url: deviceApi.vendingTestAll,
// data: {
// stadium_id: curStoreInfo.id,
// stadium_hardware_id: optionsQuery.id
// },
// 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)
// }, 300, 300),
testOneBtn: util.debounce(function(){
let { curStoreInfo, optionsQuery, curTestCargoLane,testOneNum } = this;
util.showLoad();
deviceServer.get({
url: deviceApi.vendingTestOne,
data: {
id: curTestCargoLane.id,
stadium_id: curStoreInfo.id,
stadium_hardware_id: optionsQuery.id,
number: testOneNum,
},
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)
}, 300, 300),
pickerChange(e){
let { goodsList } = this;
this.curTestCargoLane = goodsList[e.detail.value];
console.log(e)
},
getGoodsList(hardware_id){
util.showLoad();
deviceServer.get({
url: deviceApi.vendingGoodsList,
data: { hardware_id },
failMsg: '加载失败!'
})
.then(res=>{
util.hideLoad();
let _list = res.list || [];
let _goodsArr = [];
_list.forEach(e=>{if(e.vending_goods.length)_goodsArr.push(...e.vending_goods)});
this.goodsList = _goodsArr;
})
.catch(util.hideLoad);
},
}
}
</script>
@ -72,12 +166,14 @@ export default {
font-size: 28upx;
color: #333;
}
>image{
>view{
flex-shrink: 0;
margin-left: 20upx;
width: 40upx;
height: 40upx;
background-color: #333;
width: 0upx;
height: 0upx;
border-left: 12upx solid transparent;
border-right: 12upx solid transparent;
border-top: 16upx solid #333;
}
}
.si-btn{

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

@ -9,13 +9,13 @@
<view class="st-right">
<view class="sr-name">{{e.hardware_name || '-'}}</view>
<!-- 门闸没有状态查询 -->
<view class="sr-bot" v-if="pageInfo.id !=5">
<!-- 请求接口自定义字段设备状态 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>
<image mode="aspectFit" src="/subpackage/device/static/images/refresh.png"></image>
</view>
</view> -->
</view>
</view>
<view class="si-bottom" v-if="pageInfo.isOpen || pageInfo.isClose">
@ -154,11 +154,11 @@ export default {
.catch(util.hideLoad)
},
// status 0 -> 1 ->
// status 0 -> 1 ->
operateBtn({ info, status }){
let { curStoreInfo } = this;
let { curStoreInfo, pageInfo } = this;
let _cid = status === 1? info.enter_id + '':status === 0?info.leave_id:''; // ID |-> enter_id -> leave_id|
let _query = {
let _query = pageInfo.id == 5 ? {
name: 'gate',
value: {
tcp: info.hardware_net_addr + '',
@ -166,7 +166,10 @@ export default {
},
is_delay: true,
queue_group: 'gate'
}
} : this.getSwitchQueryData({
switchInfo: info,
status: status,
})
util.showLoad();
deviceServer.post({
url: deviceApi.ouxuanac,
@ -182,6 +185,48 @@ export default {
})
.catch(util.hideLoad)
},
// Low = "low", //
// High = "high", //
getRelayStatus(status){
return [ 'high', 'low' ][status] || ''
},
// status = "status",
// on = "on",
// off = "off",
getAirRelayStatus(status){
return [ 'off', 'on' ][status] || ''
},
// name
getQueryName(switchInfo){
let _obj = {
'Gpio': 'set-rpio',
'SerialPort485': 'zzio404d-gpio',
'Tcp': 'zzio404d-gpio-tcp',
};
return _obj[switchInfo.hardware_connect_method] || ''
},
// switchInfo ->
// status -> 0 -> 1 ->
// src\subpackage\device\js\ouxuanac.md
getSwitchQueryData({ switchInfo, status }){
const postData = {
name: this.getQueryName(switchInfo),
value: { id: switchInfo.hardware_connect_id, }
};
if (switchInfo.hardware_connect_method === 'Gpio') postData.value['status'] = this.getRelayStatus(status);
if (switchInfo.hardware_connect_method === 'Tcp') postData.value['tcp'] = switchInfo.hardware_net_addr;
if (switchInfo.hardware_connect_method === 'SerialPort485' || switchInfo.hardware_connect_method === 'Tcp') {
//
postData.value['p'] = switchInfo.node_id; // id
postData.value['o'] = this.getRelayStatus(status); //
}
return postData;
},
getIcon(){
let { pageInfo } = this;
if(!pageInfo.id)return '';

Loading…
Cancel
Save