<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="120">
|
<uni-forms-item :label="label"></uni-forms-item>
|
<uni-forms-item label="单据类型:生产领料单"></uni-forms-item>
|
<uni-forms-item label="料车编码">
|
<uni-easyinput type="text" :focus="!istrue" v-model="barcode" placeholder="请扫描料车编码"
|
ref='midInput' @input="inputChangebarcode()" />
|
</uni-forms-item>
|
<uni-forms-item label="物料编号">
|
<uni-combox :candidates="candidates" placeholder="请选择物料编号" v-model="matcode"></uni-combox>
|
</uni-forms-item>
|
<uni-forms-item label="物料数量">
|
<uni-easyinput type="number" v-model="quantity" placeholder="请输入数量" ref='midInput'
|
:focus="quantityFocus" />
|
</uni-forms-item>
|
<uni-forms-item>
|
<button @click="addItem" type="primary" style="margin-left: 50px;" size="mini">添加</button>
|
<button @click="submit" type="primary" style="margin-left: 100px;" size="mini">组盘</button>
|
</uni-forms-item>
|
</uni-forms>
|
<uni-list class="footer">
|
<uni-list-item direction="column" v-for="item in matInfos" :key="item.index">
|
<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.quantity}}</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="!barcodefocus" v-model="locationNo" placeholder="请输入货位编号"
|
ref='midInput' @input="locationNoinputChange" />
|
</uni-forms-item>
|
<uni-forms-item label="托盘条码">
|
<uni-easyinput type="text" :focus="barcodefocus" v-model="barcode2" placeholder="请扫描托盘条码"
|
ref='midInput' />
|
</uni-forms-item>
|
<uni-forms-item>
|
<button @click="bindStock" type="primary" size="default"
|
style="margin-top: 2%;">手动绑定</button>
|
</uni-forms-item>
|
</uni-forms>
|
</view>
|
</view>
|
|
</view>
|
<u-toast ref="uToast" />
|
</view>
|
</template>
|
|
<script>
|
// const SixUniTts = uni.requireNativePlugin("SmallSix-SixUniTts")
|
export default {
|
data() {
|
return {
|
items: ['半成品组盘', '库存绑定'],
|
current: 0,
|
istrue: false,
|
barcode: '',
|
matInfos: [],
|
barcodefocus: true,
|
quantity: 0,
|
quantityFocus: false,
|
matcode: "",
|
index: 0,
|
locationNo: "",
|
barcode2: '',
|
barcodefocus: false,
|
label: "",
|
orderNo: "",
|
candidates: []
|
}
|
},
|
onLoad(res) {
|
this.barcodefocus = false;
|
this.istrue = false;
|
this.orderNo = res.orderNo;
|
this.label = "单据编号:" + this.orderNo;
|
this.getData();
|
},
|
methods: {
|
getData() {
|
var postData = {
|
MainData: {
|
orderNo: this.orderNo
|
},
|
}
|
this.$u.post('/api/ErpOrder/GetReceiveOrderInfoByCode', postData).then((res) => {
|
if (res.status) {
|
// this.orderInfo = res.data.receiving_Dtls;
|
this.candidates = res.data.matCodes;
|
// if (this.orderInfo.length > 3) {
|
// this.loadVisible = true;
|
// }
|
}
|
})
|
},
|
onClickItem(e) {
|
this.barcodeFo = true;
|
this.focus = false;
|
this.addressFocus = false;
|
if (this.current !== e.currentIndex) {
|
this.current = e.currentIndex;
|
}
|
},
|
bindStock() {
|
if (this.locationNo == "") {
|
this.$refs.uToast.show({
|
title: "货位号不能为空",
|
type: "error"
|
});
|
return;
|
}
|
if (this.barcode2 == "") {
|
this.$refs.uToast.show({
|
title: "托盘号不能为空",
|
type: "error"
|
});
|
return;
|
}
|
var postData = {
|
MainData: {
|
"locationNo": this.locationNo,
|
"barcode": this.barcode2
|
},
|
}
|
this.$u.post('/api/StockOperate/BindStock', postData).then((res) => {
|
if (res.status) {
|
this.items = [];
|
this.$refs.uToast.show({
|
title: res.message,
|
type: "success"
|
});
|
this.locationNo = "";
|
this.barcode2 = "";
|
this.barcodefocus = false;
|
} else {
|
this.$refs.uToast.show({
|
title: res.message,
|
type: "error"
|
});
|
}
|
})
|
},
|
|
locationNoinputChange() {
|
this.barcodefocus = false;
|
this.$nextTick(function(x) {
|
if (this.locationNo != '') {
|
this.barcodefocus = true;
|
}
|
})
|
},
|
submit() {
|
if (this.barcode == "") {
|
this.$refs.uToast.show({
|
title: "请扫描料车编码",
|
type: "error"
|
})
|
return;
|
}
|
if (this.matInfos.length == 0) {
|
this.$refs.uToast.show({
|
title: "请录入物料信息",
|
type: "error"
|
})
|
return;
|
}
|
var params = {
|
MainData: {
|
"barcode": this.barcode,
|
"orderNo": this.orderNo
|
},
|
DetailData: this.matInfos
|
};
|
this.$u.post('/api/StockOperate/BCPBoxing', params).then(resdt => {
|
if (resdt.status) {
|
uni.$showMsg('组盘成功!')
|
this.matInfos = [];
|
this.barcode = "";
|
this.matcode = "";
|
this.quantity = 0;
|
this.quantityFocus = true;
|
this.istrue = false;
|
this.index = 0;
|
} else {
|
this.$refs.uToast.show({
|
title: resdt.message,
|
type: "error"
|
})
|
}
|
}).catch(err => {
|
this.$refs.uToast.show({
|
title: err.message,
|
type: "error"
|
})
|
})
|
},
|
addItem() {
|
this.$nextTick(() => {
|
if (this.matcode != "" && this.quantity > 0) {
|
this.matInfos.push({
|
matcode: this.matcode,
|
quantity: parseInt(this.quantity),
|
index: this.index++
|
});
|
this.$refs.uToast.show({
|
title: "添加成功",
|
type: "success"
|
})
|
this.matcode = "";
|
this.quantity = 0;
|
this.quantityFocus = false;
|
this.istrue = true;
|
} else {
|
this.$refs.uToast.show({
|
title: "数据输入错误",
|
type: "error"
|
})
|
}
|
})
|
},
|
inputChange(e) {
|
this.$nextTick(() => {
|
this.istrue = false;
|
this.quantityFocus = true;
|
})
|
},
|
updateFocus() {
|
this.materialsns = '';
|
if (!this.istrue) {
|
this.istrue = true;
|
}
|
},
|
inputChangebarcode() {
|
this.istrue = false;
|
this.$nextTick(function(x) {
|
if (this.barcode != '') {
|
this.istrue = true;
|
}
|
})
|
},
|
deleteList(res) {
|
this.matInfos.map((item, index) => {
|
if (item.matcode == res) {
|
this.matInfos.splice(index, 1);
|
}
|
})
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss">
|
@import '@/common/uni-ui.scss';
|
|
.content {
|
display: flex;
|
height: 150px;
|
}
|
|
.content-text {
|
font-size: 14px;
|
color: #666;
|
}
|
|
.itemstyle {
|
margin-top: 20px;
|
margin-left: 5%;
|
}
|
|
.headerstyle {
|
width: 90%;
|
}
|
</style>
|