<template>
|
<view>
|
<uni-segmented-control :current="current" :values="items" @clickItem="onClickItem">
|
</uni-segmented-control>
|
<view class="content">
|
<view v-if="current === 0" class="headerstyle">
|
<view class="itemstyle">
|
<uni-forms label-width="180">
|
<uni-forms-item label="托盘条码:">
|
<uni-easyinput type="text" placeholder="请扫描托盘条码" ref='midInput' :focus="true"
|
v-model="barcode" @input="barcodeInput" />
|
</uni-forms-item>
|
<uni-forms-item label="产品条码:">
|
<uni-easyinput type="text" placeholder="请扫描产品条码" ref='midInput' :focus="focus"
|
v-model="materSn" @input="snInput" />
|
</uni-forms-item>
|
<uni-forms-item>
|
<button @click="submit" type="primary" size="default" style="margin-top: 2%;">组盘</button>
|
</uni-forms-item>
|
</uni-forms>
|
<uni-list class="footer">
|
<uni-list-item direction="column" v-for="item in matInfos" :key="item.matCode">
|
<template v-slot:body>
|
<view class="uni-list-box">
|
<view class="uni-content">
|
<view class="uni-title-sub uni-ellipsis-2">物料编码:{{item.matCode}}</view>
|
<view class="uni-title-sub uni-ellipsis-2">安规:{{item.safety}}</view>
|
<view class="uni-title-sub uni-ellipsis-2">数量:{{item.qty}}</view>
|
</view>
|
</view>
|
</template>
|
</uni-list-item>
|
<uni-list-item direction="column" v-for="(item,index) in sns" :key="item">
|
<template v-slot:body>
|
<view class="uni-list-box">
|
<view class="uni-content">
|
<view class="uni-title-sub uni-ellipsis-2">产品条码:{{item}}</view>
|
</view>
|
</view>
|
</template>
|
</uni-list-item>
|
</uni-list>
|
</view>
|
</view>
|
<view v-if="current === 1" class="headerstyle">
|
<view class="itemstyle">
|
<uni-forms label-width="120">
|
<uni-forms-item label="托盘条码">
|
<uni-easyinput type="text" :focus="!addressFocus" v-model="inboundBarcode"
|
placeholder="请扫描托盘条码" ref='midInput' @input="inputChangebarcode" />
|
</uni-forms-item>
|
<uni-forms-item label="地址条码">
|
<uni-easyinput type="text" v-model="address" placeholder="请扫描地址条码" ref='midInput'
|
:focus="addressFocus" />
|
</uni-forms-item>
|
<uni-forms-item>
|
<button @click="inbound" type="primary" size="default" style="margin-top: 2%;">入库确认</button>
|
</uni-forms-item>
|
</uni-forms>
|
</view>
|
</view>
|
<view v-if="current === 2" class="headerstyle">
|
<view class="itemstyle">
|
|
</view>
|
</view>
|
</view>
|
<u-toast ref="uToast" />
|
</view>
|
</template>
|
|
<script>
|
const innerAudioContext = uni.createInnerAudioContext();
|
export default {
|
data() {
|
return {
|
items: ['成品组盘', '成品入库'],
|
current: 0,
|
matTotal: [],
|
matInfos: [],
|
orderNo: "",
|
label: "",
|
orderInfo: [],
|
focus: false,
|
barcode: "",
|
materSn: "",
|
sns: [],
|
addressFocus: false,
|
inboundBarcode: "",
|
address: "",
|
check: true
|
}
|
},
|
onShow() {},
|
onLoad(res) {
|
this.focus = false;
|
this.addressFocus = false;
|
},
|
methods: {
|
voiceSpeech(src) {
|
innerAudioContext.src = src; // '../../static/success.mp3';
|
innerAudioContext.play();
|
},
|
updateFocus() {
|
this.$nextTick(() => {
|
console.log(1);
|
this.materSn = '';
|
if (!this.focus) {
|
this.focus = true;
|
}
|
});
|
},
|
barcodeFocus() {
|
this.barcode = '';
|
if (this.focus) {
|
this.focus = false;
|
}
|
},
|
getData() {
|
var postData = {
|
MainData: {
|
orderNo: this.orderNo
|
},
|
}
|
this.$u.post('/api/ErpOrder/GetReceivingOrderInfo', postData).then((res) => {
|
if (res.status) {
|
this.orderInfo = res.data;
|
if (this.orderInfo.length > 3) {
|
this.loadVisible = true;
|
}
|
}
|
})
|
},
|
onClickItem(e) {
|
this.focus = false;
|
this.addressFocus = false;
|
if (this.current !== e.currentIndex) {
|
this.current = e.currentIndex;
|
if (this.current == 2) {
|
this.getData();
|
}
|
}
|
},
|
barcodeInput() {
|
this.$nextTick(function(x) {
|
if (this.barcode.length > 0) {
|
var param = {
|
MainData: {
|
"barcode": this.barcode,
|
}
|
}
|
this.$u.post('/api/StockOperate/GetProductByBarcode', param).then(res => {
|
if (res.status) {
|
this.matInfos = res.data.matTotal;
|
this.sns.push(res.data.matInfo);
|
}
|
this.focus = true;
|
})
|
} else {
|
this.matInfos = [];
|
this.sns = [];
|
}
|
})
|
},
|
snInput() {
|
this.$nextTick(() => {
|
if (this.materSn != "") {
|
this.focus = false;
|
var code = this.materSn;
|
var param = {
|
MainData: {
|
"sn": code,
|
}
|
}
|
this.$u.post('/api/Bill_group_stock_product/GetProductInfoBySn', param).then(res => {
|
if (res.status) {
|
if (res.data) {
|
var tmp = this.sns.find(x => x == code);
|
if (!tmp) {
|
var matInfo = this.matInfos.find(x => x.matCode == res.data
|
.mater_code && x
|
.safety == res.data.safety_regulations);
|
if (matInfo) {
|
matInfo.qty += 1;
|
} else {
|
this.matInfos.push({
|
matCode: res.data.mater_code,
|
safety: res.data.safety_regulations,
|
qty: 1
|
});
|
}
|
this.sns.push(code);
|
this.voiceSpeech('../../static/success.mp3');
|
setTimeout(this.updateFocus, 200);
|
} else {
|
this.$refs.uToast.show({
|
title: "扫码重复",
|
type: "error"
|
})
|
this.voiceSpeech('../../static/fail.mp3');
|
setTimeout(this.updateFocus, 200);
|
}
|
} else {
|
this.$refs.uToast.show({
|
title: "扫码错误" + res.message,
|
type: "error"
|
})
|
this.voiceSpeech('../../static/fail.mp3');
|
setTimeout(this.updateFocus, 200);
|
}
|
} else {
|
this.$refs.uToast.show({
|
title: "扫码错误" + res.message,
|
type: "error"
|
})
|
this.voiceSpeech('../../static/fail.mp3');
|
setTimeout(this.updateFocus, 200);
|
}
|
})
|
}
|
})
|
},
|
inbound() {
|
var postData = {
|
MainData: {
|
"barcode": this.inboundBarcode,
|
"startPoint": this.address
|
}
|
}
|
this.$u.post('/api/Inbound/ProductRequestInbound', postData).then(res => {
|
if (res.status) {
|
uni.$showMsg(res.message);
|
this.inboundBarcode = "";
|
this.address = "";
|
} else {
|
this.$refs.uToast.show({
|
title: res.message,
|
type: "error"
|
})
|
}
|
}).catch(err => {
|
this.$refs.uToast.show({
|
title: err.message,
|
type: "error"
|
})
|
})
|
},
|
inputChangebarcode() {
|
this.addressFocus = false;
|
this.$nextTick(function(x) {
|
if (this.inboundBarcode != '') {
|
this.addressFocus = true;
|
}
|
})
|
},
|
deleteList(res) {
|
var sn = '';
|
this.matInfos.map((item, index) => {
|
if (item.innerCode == res) {
|
this.matInfos.splice(index, 1);
|
sn = item.sn;
|
var tmp = this.matTotal.find(x => x.matCode == item.matCode);
|
if (tmp) {
|
tmp.matQuantity -= parseInt(item.matQty);
|
} else {
|
|
}
|
}
|
})
|
this.sns.map((item, index) => {
|
if (item == res) {
|
this.sns.splice(index, 1);
|
}
|
})
|
},
|
submit() {
|
if (this.barcode == "") {
|
this.$refs.uToast.show({
|
title: "请扫描托盘条码",
|
type: 'error'
|
})
|
return;
|
}
|
if (this.sns.length == 0) {
|
this.$refs.uToast.show({
|
title: "请扫描产品条码",
|
type: 'error'
|
})
|
return;
|
}
|
this.$u.post('/api/Bill_group_stock_product/ProductBoxing', {
|
MainData: {
|
"barcode": this.barcode,
|
"orderNo": this.orderNo,
|
"isFull": this.check
|
},
|
DetailData: this.matInfos,
|
DelKeys: this.sns
|
}).then(res => {
|
if (res.status) {
|
uni.$showMsg('组盘成功!')
|
this.barcode = "";
|
this.matInfos = [];
|
this.sns = [];
|
this.matTotal = [];
|
} else {
|
this.$refs.uToast.show({
|
title: res.message,
|
type: "error"
|
})
|
}
|
}).catch(err => {
|
uni.showToast.show({
|
title: err.message,
|
type: 'error'
|
})
|
})
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss">
|
@import '@/common/uni-ui.scss';
|
|
.content {
|
display: flex;
|
height: 150px;
|
}
|
|
.content-text {
|
font-size: 14px;
|
color: #666;
|
}
|
|
.itemstyle {
|
margin-top: 30px;
|
margin-left: 5%;
|
}
|
|
.headerstyle {
|
width: 90%;
|
}
|
</style>
|