220 lines
6.9 KiB
Vue
220 lines
6.9 KiB
Vue
<template>
|
|
<view class="wrap">
|
|
<view class="uni-padding-wrap uni-common-mt" style="padding: 10px;">
|
|
<view class="uni-form-item uni-column">
|
|
<view class="title">站点:</view>
|
|
<view class="inputBorder">
|
|
<u-input v-model="site" placeholder="" :disabled="true" class="disabledColor"></u-input>
|
|
</view>
|
|
</view>
|
|
<view class="uni-form-item uni-column">
|
|
<view class="title"><span class="inputRequired">*</span>条码:</view>
|
|
<view class="inputBorder">
|
|
<u-input ref = "code" v-model="formObj.code" placeholder="请扫描条码" @confirm="scanCode" :focus="focus.code"
|
|
:disabled="codeDisabled" :class="codeDisabled ? 'disabledColor':''"></u-input>
|
|
</view>
|
|
</view>
|
|
<view class="uni-form-item uni-column">
|
|
<view class="title"><span class="inputRequired">*</span>拆批数量:</view>
|
|
<view class="inputBorder">
|
|
<u-input ref = "splitQty" type="number" v-model="formObj.splitQty" @confirm="checkQty()" :focus="focus.splitQty"
|
|
:disabled="!codeDisabled && inventoryList.length === 0" :class="!codeDisabled && inventoryList.length === 0 ? 'disabledColor': ''"></u-input>
|
|
</view>
|
|
</view>
|
|
<view class="uni-form-item uni-column">
|
|
<view class="title"><span class="inputRequired">*</span>拆批条数:</view>
|
|
<view class="inputBorder">
|
|
<u-input ref = "splitNum" type="number" v-model="formObj.splitNum" @confirm="checkQty" :focus="focus.splitNum"
|
|
:disabled="!codeDisabled && inventoryList.length === 0" :class="!codeDisabled && inventoryList.length === 0 ? 'disabledColor': ''"></u-input>
|
|
</view>
|
|
</view>
|
|
<scroll-view class="scroll-list" scroll-y="true">
|
|
<u-cell-group class="list" :border="false">
|
|
<div v-for="(item, index) in inventoryList" :key="index" :index="index">
|
|
<u-card :data="inventoryList" :show-head="false">
|
|
<view slot="body">
|
|
<u-row>
|
|
<u-col span="12">
|
|
<u-row>
|
|
<u-col span="3">
|
|
<span class="span-lable">条码:</span>
|
|
</u-col>
|
|
<u-col span="9">
|
|
<span class="span-lable">{{item.inventoryId}}</span>
|
|
</u-col>
|
|
<u-col span="3">
|
|
<span class="span-lable">数量:</span>
|
|
</u-col>
|
|
<u-col span="9">
|
|
<span class="span-lable">{{item.qtyOnHand}}</span>
|
|
</u-col>
|
|
</u-row>
|
|
</u-col>
|
|
</u-row>
|
|
</view>
|
|
</u-card>
|
|
</div>
|
|
</u-cell-group>
|
|
</scroll-view>
|
|
</view>
|
|
<view class="placeholder-view"></view>
|
|
<view class="form-footer stay-below">
|
|
<u-button class="btn" type="warning" @click="doClear">清除</u-button>
|
|
<u-button class="btn" type="primary" @click="doSplit">拆批执行</u-button>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import {isBlank} from "utils/string";
|
|
import {inputFocus} from 'utils/common';
|
|
import {mul} from 'utils/number';
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
site: this.vuex_tenantId,
|
|
formObj: {},
|
|
codeDisabled: false,
|
|
initData: {},
|
|
inventoryList: [],
|
|
splitInventory: this.$u.api.wms.inventory_split.splitInventory,
|
|
selectForSplit: this.$u.api.wms.inventory_split.selectForSplit,
|
|
listByActivityId: this.$u.api.listByActivityId,
|
|
focus: {
|
|
code: false,
|
|
splitQty: false,
|
|
splitNum: false,
|
|
}
|
|
};
|
|
},
|
|
|
|
onLoad(options) {
|
|
this.site = this.vuex_tenantId;
|
|
this.doClear();
|
|
this.loadData(options);
|
|
},
|
|
|
|
methods: {
|
|
loadData(urlParam) {
|
|
let me = this;
|
|
//加载作业规则
|
|
let activityId = urlParam.ACTIVITY_ID;
|
|
this.listByActivityId(activityId).then(respData => {
|
|
if (respData.code != 0) {
|
|
return this.$u.toast(respData.msg);
|
|
}
|
|
let data = respData.data;
|
|
for (let object of data) {
|
|
if (object.optionName === "PRINTER_D") {
|
|
me.printer = object.optionValue;
|
|
}
|
|
}
|
|
}).catch(e => {
|
|
console.log(e);
|
|
});
|
|
},
|
|
|
|
doClear() {
|
|
this.formObj = Object.assign({}, this.initData);
|
|
this.inventoryList = [];
|
|
this.codeDisabled = false;
|
|
inputFocus(this, "code");
|
|
},
|
|
|
|
scanCode() {
|
|
let me = this;
|
|
let code = me.formObj.code;
|
|
if (isBlank(code)) {
|
|
me.$u.toast("不可扫描空条码");
|
|
} else {
|
|
uni.showLoading();
|
|
me.selectForSplit({
|
|
inventoryId: code
|
|
}).then(res => {
|
|
uni.hideLoading();
|
|
let data = res.data;
|
|
me.formObj.qtyOnHand = data.qtyOnHand;
|
|
me.codeDisabled = true;
|
|
inputFocus(me,"splitQty")
|
|
}).catch(e => hideLoading());
|
|
}
|
|
},
|
|
|
|
checkQty() {
|
|
let me = this;
|
|
if (me.formObj.splitQty > 0 && me.formObj.splitNum > 0) {
|
|
if (mul(me.formObj.splitQty, me.formObj.splitNum) > me.formObj.qtyOnHand) {
|
|
me.$u.toast("拆批总量超过条码数量,请确认");
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
} else if (isBlank(me.formObj.splitQty) || me.formObj.splitQty < 0) {
|
|
inputFocus(me,"splitQty")
|
|
} else if (isBlank(me.formObj.splitNum) || me.formObj.splitNum < 0) {
|
|
inputFocus(me,"splitNum")
|
|
} else {
|
|
me.$u.toast("数量和条数必须大于0");
|
|
return false;
|
|
}
|
|
},
|
|
|
|
doSplit() {
|
|
let me = this;
|
|
if (me.checkQty()) {
|
|
uni.showLoading();
|
|
me.splitInventory({
|
|
parentInventoryId: me.formObj.code,
|
|
splitQty: me.formObj.splitQty,
|
|
splitNum: me.formObj.splitNum,
|
|
printer:me.printer
|
|
}).then(res => {
|
|
uni.hideLoading();
|
|
let data = res.data;
|
|
me.inventoryList = data.map(o => {
|
|
return {
|
|
seq: me.inventoryList.length + 1,
|
|
inventoryId: o,
|
|
qtyOnHand: me.formObj.splitQty
|
|
};
|
|
});
|
|
me.$u.toast("拆批成功");
|
|
}).catch(e => hideLoading());
|
|
}
|
|
},
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<style scoped>
|
|
.uni-form-item .title {
|
|
padding: 10px;
|
|
padding-left: 0px;
|
|
}
|
|
|
|
.inputBorder {
|
|
display: flex;
|
|
justify-content: flex-end;
|
|
border: 1px solid #dcdfe6;
|
|
border-radius: 4px;
|
|
}
|
|
|
|
.inputRequired {
|
|
content: "*";
|
|
width: 10px;
|
|
height: 20px;
|
|
display: inline-block;
|
|
vertical-align: middle;
|
|
text-align: center;
|
|
line-height: 26px;
|
|
font-size: large;
|
|
color: #f00;
|
|
}
|
|
|
|
.disabledColor {
|
|
background: #EAECEF;
|
|
}
|
|
|
|
</style>
|