|
|
@ -1,27 +1,27 @@ |
|
|
|
<template> |
|
|
|
<view class="sell-box-manage"> |
|
|
|
<device-name id="devicename"></device-name> |
|
|
|
<device-name id="devicename" :name="optionsQuery.name"></device-name> |
|
|
|
<view class="sbm-section" :style="'height:'+ sectionHeight +'px;'"> |
|
|
|
<scroll-view class="ss-tabs" scroll-y> |
|
|
|
<view :class="['st-item', i == 2?'active':'']" v-for="(e,i) in 20" :key="i">第一层</view> |
|
|
|
<view :class="['st-item', e.row == scrollIntoViewID?'active':'']" v-for="(e,i) in goodsList" :key="i" @click="tabChange(e.row)">第{{e.row || ''}}层</view> |
|
|
|
</scroll-view> |
|
|
|
<scroll-view class="ss-list" scroll-y> |
|
|
|
<view class="sl-section" v-for="k in 5" :key="k"> |
|
|
|
<view class="ss-tit">第一层<text>售货机第一行的商品</text></view> |
|
|
|
<scroll-view class="ss-list" scroll-y :scroll-into-view="'ss'+scrollIntoViewID" scroll-with-animation> |
|
|
|
<view class="sl-section" v-for="(e,i) in goodsList" :key="i" :id="'ss' + e.row"> |
|
|
|
<view class="ss-tit">第{{e.row || ''}}层<text>售货机第{{e.row || ''}}行的商品</text></view> |
|
|
|
<view class="ss-goods-list"> |
|
|
|
<view class="sgl-item" v-for="i in 5" :key="i"> |
|
|
|
<view class="sgl-item" v-for="(k,j) in e.vending_goods" :key="j"> |
|
|
|
<view class="si-img"> |
|
|
|
<image></image> |
|
|
|
<image mode="aspectFit" :src="k.image || ''"></image> |
|
|
|
<view class="si-tag"><view>101</view></view> |
|
|
|
</view> |
|
|
|
<view class="si-name"> |
|
|
|
<view>维他奶原味豆奶</view> |
|
|
|
<view>{{k.goods_name || '-'}}</view> |
|
|
|
</view> |
|
|
|
<view class="si-price">¥3.5</view> |
|
|
|
<view class="si-price">¥{{k.price || '-'}}</view> |
|
|
|
<view class="si-contral"> |
|
|
|
<view hover-class="hover-active">-</view> |
|
|
|
<input disabled value="200"/> |
|
|
|
<view hover-class="hover-active">+</view> |
|
|
|
<view hover-class="hover-active" @click="reduceGoods({group: i, index: j})">-</view> |
|
|
|
<input disabled :value="k.stock || 0"/> |
|
|
|
<view hover-class="hover-active" @click="addGoods({group: i, index: j})">+</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
@ -30,28 +30,38 @@ |
|
|
|
</scroll-view> |
|
|
|
</view> |
|
|
|
<view class="sbm-fixed-bar"> |
|
|
|
<view> |
|
|
|
<image class="active" mode="aspectFit" src="/subpackage/device/static/images/selected_987.png"></image> |
|
|
|
<text>确认补货</text> |
|
|
|
<view @click="fillAll"> |
|
|
|
<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>确认补货</view> |
|
|
|
<view @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 { |
|
|
|
sectionHeight: 0 |
|
|
|
sectionHeight: 0, |
|
|
|
optionsQuery: {}, |
|
|
|
goodsList: [], |
|
|
|
scrollIntoViewID: '', |
|
|
|
isFillAll: false |
|
|
|
} |
|
|
|
}, |
|
|
|
async onLoad(){ |
|
|
|
|
|
|
|
async onLoad(options){ |
|
|
|
let _query = util.jsonPar(options.query); |
|
|
|
this.optionsQuery = _query || {}; |
|
|
|
this.getGoodsList(_query.id) |
|
|
|
// this.getGoodsList(12) |
|
|
|
}, |
|
|
|
async onReady(){ |
|
|
|
let _topBar = await util.getNodeMes(`#devicename`); |
|
|
@ -59,8 +69,68 @@ export default { |
|
|
|
let _sysMes = uni.getSystemInfoSync(); |
|
|
|
|
|
|
|
this.sectionHeight = _sysMes.windowHeight - (_botBar.height + _topBar.height); |
|
|
|
console.log(_topBar, _botBar, _sysMes, this.sectionHeight) |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
fillAll(){ |
|
|
|
this.isFillAll = !this.isFillAll; |
|
|
|
}, |
|
|
|
confirmSave: util.debounce(function(){ |
|
|
|
let { isFillAll, optionsQuery } = this; |
|
|
|
let _list = this.goodsList.slice(); |
|
|
|
let _goodsArr = []; |
|
|
|
_list.forEach((el,idx)=>{ |
|
|
|
if(el.vending_goods.length)el.vending_goods.forEach((e,i)=>{ |
|
|
|
_goodsArr.push({ id: e.id, stock: isFillAll? e.depth : e.stock }); |
|
|
|
}) |
|
|
|
}) |
|
|
|
util.showLoad(); |
|
|
|
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 || '操作失败!'); |
|
|
|
} |
|
|
|
}) |
|
|
|
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('超出上限'); |
|
|
|
_list[group].vending_goods[index].stock++; |
|
|
|
this.goodsList = _list; |
|
|
|
}, |
|
|
|
reduceGoods({group, index}){ |
|
|
|
let _list = this.goodsList.slice(); |
|
|
|
if(_list[group].vending_goods[index].stock<=0)return; |
|
|
|
_list[group].vending_goods[index].stock--; |
|
|
|
this.goodsList = _list; |
|
|
|
}, |
|
|
|
getGoodsList(hardware_id){ |
|
|
|
util.showLoad(); |
|
|
|
deviceServer.get({ |
|
|
|
url: deviceApi.vendingGoodsList, |
|
|
|
data: { hardware_id }, |
|
|
|
failMsg: '加载失败!' |
|
|
|
}) |
|
|
|
.then(res=>{ |
|
|
|
util.hideLoad() |
|
|
|
let _list = res.list || []; |
|
|
|
this.goodsList = _list; |
|
|
|
if(_list.length>0)this.scrollIntoViewID = _list[0].row; |
|
|
|
}) |
|
|
|
.catch(util.hideLoad) |
|
|
|
}, |
|
|
|
tabChange(row){ |
|
|
|
this.scrollIntoViewID = row; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|
|
|
|
@ -134,11 +204,10 @@ export default { |
|
|
|
margin-bottom: 10upx; |
|
|
|
width: 148upx; |
|
|
|
height: 148upx; |
|
|
|
background-color: skyblue; |
|
|
|
>image{ |
|
|
|
width: 100%; |
|
|
|
height: 100%; |
|
|
|
background-color: turquoise; |
|
|
|
background-color: #faf7fa; |
|
|
|
} |
|
|
|
.si-tag{ |
|
|
|
position: absolute; |
|
|
@ -251,7 +320,6 @@ export default { |
|
|
|
border-radius: 50%; |
|
|
|
border: 2upx solid #DDD; |
|
|
|
&.active{ |
|
|
|
border-width: 0; |
|
|
|
border-color: transparent; |
|
|
|
} |
|
|
|
} |
|
|
|