Browse Source

gx coffee air...

voice
刘嘉炜 4 years ago
parent
commit
aa672480a8
  1. 3
      src/subpackage/device/js/device_api.js
  2. 2
      src/subpackage/device/js/ouxuanac.md
  3. 104
      src/subpackage/device/pages/coffee_manage/coffee_manage.vue
  4. 7
      src/subpackage/device/pages/device_manage/device_manage.vue
  5. 2
      src/subpackage/device/pages/index/index.vue
  6. 107
      src/subpackage/device/pages/switch_manage/switch_manage.vue

3
src/subpackage/device/js/device_api.js

@ -9,6 +9,9 @@ export const DEVICE_API = {
vendingTestOne:`${ORIGIN}/admin/stadium/vending/path/test/one`, // 售货柜-单货道测试
hardwareSave:`${ORIGIN}/admin/stadium/hardware/save`, // 设备开启/关闭
drinkList:`${ORIGIN}/admin/stadium/coffee/drink/list`, // 咖啡机口味列表
drinkRestock:`${ORIGIN}/admin/stadium/coffee/drink/restock`, // 咖啡机口味列表
hardwareList:`${ORIGIN}/admin/stadium/hardware/list`, // 设备列表
ouxuanac:`${ORIGIN}/ouxuanac/sendPacket`, // 中控控制

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

@ -26,7 +26,7 @@ enum RelayOP {
//--------------------------if 通讯方式为开关量时使用-----------------------------
//原生继电器
//原生继电器 // 全设备通用
function relayPacket(id: string, op: RelayOP) {
return {
"name": "set-rpio",

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

@ -1,37 +1,115 @@
<template>
<view class="coffee-manage">
<device-name></device-name>
<device-name :name="optionsQuery.name"></device-name>
<view class="cm-list">
<view class="cl-item" v-for="i in 10" :key="i">
<image></image>
<view class="cl-item" v-for="(e,i) in typeList" :key="i">
<image mode="aspectFit" :src="e.image || ''"></image>
<view class="ci-content">
<view class="cc-name">咖啡</view>
<view class="cc-name">{{e.name || '-'}}</view>
<view class="cc-num">
<view hover-class="hover-active">-</view>
<input value="32" disabled />
<view hover-class="hover-active" class="active">+</view>
<view hover-class="hover-active" @click="reduceStock(i)">-</view>
<input :value="e.stock" disabled />
<view hover-class="hover-active" class="active" @click="addStock(i)">+</view>
</view>
<view class="cc-price"><text>¥</text>2</view>
<view class="cc-price"><text>¥</text>{{e.price || 0}}</view>
</view>
</view>
</view>
<view class="cm-tip">Tips:一包标准粉如若大概能冲40杯左右建议一包填38杯库存</view>
<view class="cm-fixed-bar">
<view class="cfb-select-all">
<image class="active" mode="aspectFit" src="/subpackage/device/static/images/selected_987.png"></image>
<view class="cfb-select-all" @click="isFillAll = !isFillAll">
<image v-if="isFillAll" class="active" mode="aspectFit" src="/subpackage/device/static/images/selected_987.png"></image>
<image v-else></image>
<text>全部饮品补满</text>
</view>
<view class="cfb-confirm" hover-class="hover-active">确认补粉</view>
<view class="cfb-confirm" hover-class="hover-active" @click="confirmSave">确认补粉</view>
</view>
</view>
</template>
<script>
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';
export default {
components: {
'device-name': device_name
},
data(){
return {
isFillAll: false,
optionsQuery: {},
typeList: [],
}
},
onLoad(options){
let _query = util.jsonPar(options.query);
this.optionsQuery = _query;
console.log(_query);
this.coffeeList(_query.id);
},
methods:{
confirmSave: util.debounce(function(){
let { typeList, isFillAll } = this;
util.showModal({
title: '是否确认补分?',
content: isFillAll?'请确认全部补满':'',
showCancel: true,
success: res=>{
if(res.confirm){
this.confirmReq(
typeList.map(e=>({id: e.id, stock: isFillAll? e.limit || 38 : e.stock}))
);
}
}
})
}, 300, 300),
confirmReq(list){
let { optionsQuery } = this;
util.showLoad();
deviceServer.post({
url: deviceApi.drinkRestock,
data: list,
isDefaultGet: false,
})
.then(res=>{
util.hideLoad()
if(res.data.code == 0){
util.showNone(res.data.message || '操作成功!');
setTimeout(_=>this.coffeeList(optionsQuery.id),1200);
}else{
util.showNone(res.data.message || '操作失败!');
}
})
},
reduceStock(index){
let _typeList = this.typeList.slice();
if(_typeList[index].stock<=0)return;
_typeList[index].stock--;
this.typeList = _typeList;
},
addStock(index){
let _typeList = this.typeList.slice();
_typeList[index].stock++;
this.typeList = _typeList;
},
coffeeList(hardware_id){
deviceServer.get({
url: deviceApi.drinkList,
data: {
'filter[stadium_hardware_id]': hardware_id
},
failMsg: '加载失败!'
})
.then(res=>{
this.typeList = res.list || [];
console.log(res);
})
}
}
}
</script>
@ -55,7 +133,6 @@ export default {
margin-right: 20upx;
width: 160upx;
height: 160upx;
background-color: skyblue;
}
.ci-content{
flex-grow: 1;
@ -110,7 +187,6 @@ export default {
}
.cm-tip{
margin-bottom: 20upx;
margin-top: 178upx;
padding: 0 24upx;
font-size: 28upx;
line-height: 40upx;
@ -139,7 +215,7 @@ export default {
border: 2upx solid #d8d8d8;
border-radius: 50%;
&.active{
border-width: 0;
border-color: transparent;
}
}
}

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

@ -6,7 +6,7 @@
<view class="dl-item" v-for="(e, i) in deviceList" :key="i">
<view class="di-header">
<image mode="aspectFit" :src="getIcon()"></image>
<view class="dh-name">{{e.hardware_type_name || '-'}}</view>
<view class="dh-name">{{e.hardware_name || '-'}}</view>
<view class="dh-test-btn" v-if="pageInfo.isTestBtn" @click="testBtn(e)">
<image mode="aspectFit" :src="pageInfo.testBtnIcon || ''"></image>
<view>{{pageInfo.testBtnName || '-'}}</view>
@ -89,6 +89,7 @@ const dmObj = {
stockBtnName: '补货',
deviceBtnOpenName: '开启售货',
deviceBtnStopName: '停止售货',
deviceType: 'CoffeeMachine', //
},
}
export default {
@ -167,7 +168,7 @@ export default {
if(pageInfo.id == 7)return util.routeTo(`/subpackage/device/pages/sell_box_manage/sell_box_manage?query=${util.jsonStr(_query)}`, 'nT');
if(pageInfo.id == 8)return util.routeTo(`/subpackage/device/pages/locker_manage/locker_manage?type=8`, 'nT');
// 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');
if(pageInfo.id == 10)return util.routeTo(`/subpackage/device/pages/coffee_manage/coffee_manage?query=${util.jsonStr(_query)}`, 'nT');
},
testBtn(e){
let { pageInfo } = this;
@ -178,7 +179,7 @@ export default {
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');
if(pageInfo.id == 10)return util.routeTo(`/subpackage/device/pages/coffee_test/coffee_test?query=${util.jsonStr(_query)}`, 'nT');
}
}
}

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

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

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

@ -155,21 +155,12 @@ export default {
},
// status 0 -> 1 ->
operateBtn({ info, status }){
operateBtn: util.debounce(function({ info, status }){
let { curStoreInfo, pageInfo } = this;
let _cid = status === 1? info.enter_id + '':status === 0?info.leave_id:''; // ID |-> enter_id -> leave_id|
let _query = pageInfo.id == 5 ? {
name: 'gate',
value: {
tcp: info.hardware_net_addr + '',
cid: _cid
},
is_delay: true,
queue_group: 'gate'
} : this.getSwitchQueryData({
switchInfo: info,
status: status,
})
let _query = curStoreInfo.hardware_type === 'GateControl' ?
this.getGateQuery({switchInfo: info, status}) :
this.getSwitchQuery({ switchInfo: info, status });
util.showLoad();
deviceServer.post({
url: deviceApi.ouxuanac,
@ -184,13 +175,68 @@ export default {
console.log(res);
})
.catch(util.hideLoad)
}, 300, 300),
// //
getGateQuery({ switchInfo, status }){
let { enter_id, leave_id, hardware_net_addr } = switchInfo;
// ID |-> enter_id -> leave_id|
let _cid = status === 1 ? enter_id :
status === 0 ? leave_id : '';
return {
name: 'gate',
value: {
tcp: hardware_net_addr + '',
cid: _cid + ''
},
is_delay: true,
queue_group: 'gate'
}
},
// switchInfo ->
// status -> 0 -> 1 ->
// src\subpackage\device\js\ouxuanac.md
// hardware_type === 'Air'
getSwitchQuery({ switchInfo, status }){
let {
hardware_connect_method,
hardware_type,
hardware_connect_id,
node_id,
hardware_net_addr
} = switchInfo;
const postData = {
name: this.getQueryName(switchInfo),
value: { id: hardware_connect_id + '', } // value String
};
if (hardware_connect_method === 'Gpio') postData.value['status'] = this.getRelayStatus(status);
// tcp hardware_net_addr
if (hardware_connect_method === 'Tcp') postData.value['tcp'] = hardware_net_addr + '';
if (hardware_connect_method === 'SerialPort485' || hardware_connect_method === 'Tcp'){
if(hardware_type === 'Air'){ // key op
postData.value['op'] = this.getAirRelayStatus(status);
postData['name'] = this.getAirQueryName(switchInfo)
}else{
//
postData.value['p'] = node_id + ''; // id
postData.value['o'] = this.getRelayStatus(status); //
}
}
return postData;
},
//
// Low = "low", //
// High = "high", //
getRelayStatus(status){
return [ 'high', 'low' ][status] || ''
},
//
// status = "status",
// on = "on",
// off = "off",
@ -200,32 +246,25 @@ export default {
// name
getQueryName(switchInfo){
let { hardware_connect_method } = switchInfo;
let _obj = {
'Gpio': 'set-rpio',
'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, }
return _obj[hardware_connect_method] || ''
},
// name
getAirQueryName(switchInfo){
let { hardware_connect_method, hardware_model } = switchInfo;
if(hardware_connect_method === 'Tcp'&&hardware_model === 'JianDa')return 'ray-air-rs-tcp';
let _obj = {
'Acmelec': 'acmelec',
'ZhongNan': 'zhongnan',
'JianDa': 'ray-air-rs'
};
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;
return _obj[hardware_model] || '';
},
getIcon(){
let { pageInfo } = this;

Loading…
Cancel
Save