<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="!focus"
|
v-model="barcode" @confirm="barcodeInput" />
|
</uni-forms-item>
|
<uni-forms-item label="内箱标签:">
|
<uni-easyinput type="text" placeholder="请扫描内箱标签" ref='midInput' :focus="focus"
|
v-model="materSn" @confirm="snInput" />
|
</uni-forms-item>
|
<uni-forms-item :label="Testlabel" v-if="Test">
|
<uni-easyinput type="text" :placeholder="Testplaceholder" ref='midInput'
|
v-model="Initiallife" />
|
</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>
|
<uni-list-item direction="column" v-for="(item,index) in matInfos" :key="index">
|
<template v-slot:body>
|
<view class="uni-list-box">
|
<uni-icons type="trash" size="22" style="position: absolute;right: 5%;"
|
@click="deleteList(index)">
|
</uni-icons>
|
<view class="uni-content">
|
<view class="uni-title-sub uni-ellipsis-2">采购单号:{{item.purchaseOrderNo}}</view>
|
<view class="uni-note">物料编码:{{item.materielCode}}</view>
|
<view class="uni-note">批次号:{{item.lotNo}}</view>
|
<!-- 数量编辑框 -->
|
<view class="uni-note" style="display: flex; align-items: center; gap: 10rpx;">
|
数量:
|
<uni-easyinput
|
type="number"
|
min="1"
|
style="width: 150rpx; display: inline-block;"
|
v-model="item.editableQuantity"
|
@input="handleQuantityChange(item)"
|
/>
|
</view>
|
<view class="uni-note">生产日期:{{item.productionDate}}</view>
|
<view class="uni-note">有效期:{{item.effectiveDate}}</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' @confirm="inputChangebarcode" />
|
</uni-forms-item>
|
<uni-forms-item label="地址条码">
|
<uni-easyinput type="text" v-model="address" :disabled="addressdisabled"
|
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>
|
<uni-list>
|
<uni-list-item direction="column" v-if="inboundBarcode">
|
<template v-slot:body>
|
<view class="uni-list-box">
|
<view class="uni-content">
|
<view class="uni-title-sub uni-ellipsis-2">组盘总数量:{{Summmary}}</view>
|
</view>
|
</view>
|
</template>
|
</uni-list-item>
|
<uni-list-item direction="column" v-for="(item,index) in stockInfoDetail" :key="index">
|
<template v-slot:body>
|
<view class="uni-list-box">
|
<view class="uni-content">
|
<view class="uni-title-sub uni-ellipsis-2">物料编号:{{item.materielCode}}</view>
|
<view class="uni-note">物料名称:{{item.materielName}}</view>
|
<view class="uni-note">物料批次:{{item.batchNo}}</view>
|
<view class="uni-note">组盘数量:{{item.stockQuantity}}</view>
|
<view class="uni-note">生产日期:{{item.productionDate}}</view>
|
<view class="uni-note">有 效 期:{{item.effectiveDate}}</view>
|
</view>
|
</view>
|
</template>
|
</uni-list-item>
|
</uni-list>
|
</view>
|
</view>
|
<view v-if="current === 2" class="headerstyle">
|
<view class="itemstyle">
|
<uni-forms label-width="180">
|
<uni-forms-item label="内箱标签:">
|
<uni-easyinput type="text" placeholder="请扫描内箱标签" ref='midInput' :focus="pkfocus"
|
v-model="pkmaterSn" @confirm="pksnInput" />
|
</uni-forms-item>
|
<uni-forms-item>
|
<button @click="pksubmit" type="primary" size="default" style="margin-top: 2%;">入平库</button>
|
</uni-forms-item>
|
</uni-forms>
|
<uni-list>
|
<uni-list-item direction="column" v-for="(item,index) in pkmatInfos" :key="index">
|
<template v-slot:body>
|
<view class="uni-list-box">
|
<uni-icons type="trash" size="22" style="position: absolute;right: 5%;"
|
@click="pkdeleteList(index)">
|
</uni-icons>
|
<view class="uni-content">
|
<view class="uni-title-sub uni-ellipsis-2">采购单号:{{item.purchaseOrderNo}}</view>
|
<view class="uni-note">物料编码:{{item.materielCode}}</view>
|
<view class="uni-note">批次号:{{item.lotNo}}</view>
|
<!-- 数量编辑框 -->
|
<view class="uni-note" style="display: flex; align-items: center; gap: 10rpx;">
|
数量:
|
<uni-easyinput
|
type="number"
|
min="1"
|
style="width: 150rpx; display: inline-block;"
|
v-model="item.editableQuantity"
|
@input="handlePkQuantityChange(item)"
|
/>
|
</view>
|
<view class="uni-note">生产日期:{{item.productionDate}}</view>
|
<view class="uni-note">有效期:{{item.effectiveDate}}</view>
|
</view>
|
</view>
|
</template>
|
</uni-list-item>
|
</uni-list>
|
</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,
|
pkfocus: false,
|
barcode: "",
|
materSn: "",
|
Initiallife: 1000,
|
sns: [],
|
sn: "",
|
addressFocus: false,
|
inboundBarcode: "",
|
address: "",
|
check: true,
|
value: "",
|
matInfo: [],
|
value2: "",
|
matTotals: [],
|
warehouseId: "",
|
Test: false,
|
Testlabel: "",
|
Testplaceholder: "",
|
Testcheck: false,
|
Summmary: 0,
|
stockInfoDetail: [],
|
addressdisabled: false,
|
pksns: [],
|
pkmaterSn: "",
|
pkmatInfos: []
|
}
|
},
|
onShow() {},
|
onLoad(res) {
|
this.focus = false;
|
this.addressFocus = false;
|
this.orderNo = res.orderNo;
|
this.warehouseId = res.warehouseId;
|
if (this.warehouseId == 6) { //测试架仓库区ID
|
this.Test = true;
|
this.Testlabel = "初始寿命:";
|
this.Testplaceholder = "请输入初始寿命";
|
} else if (this.warehouseId == 2) { //油墨仓库区ID
|
this.Test = true;
|
this.Testlabel = "数量:";
|
this.Testplaceholder = "请输入数量";
|
this.Initiallife = 16;
|
} else if (this.warehouseId == 5) { //辅料仓库区ID
|
this.address = "8005";
|
this.items.push("入平库");
|
this.items[1] = "入立库";
|
this.address = "8005";
|
} else if (this.warehouseId == 3) { //辅料仓库区ID
|
this.address = "1011";
|
this.addressdisabled = true;
|
}
|
this.label = "单据编号:" + this.orderNo;
|
this.getData();
|
},
|
methods: {
|
// 组盘页数量变更校验
|
handleQuantityChange(item) {
|
// 确保数量为正整数
|
item.editableQuantity = item.editableQuantity ? Math.max(1, parseInt(item.editableQuantity)) : 1;
|
},
|
|
// 入平库页数量变更校验
|
handlePkQuantityChange(item) {
|
item.editableQuantity = item.editableQuantity ? Math.max(1, parseInt(item.editableQuantity)) : 1;
|
},
|
|
//wms入平库
|
pksubmit() {
|
if (this.pkmatInfos.length == 0) {
|
this.$refs.uToast.show({
|
title: "请扫描内箱标签",
|
type: 'error'
|
})
|
return;
|
}
|
|
// 准备提交数据,包含编辑后的数量
|
const submitData = this.pkmatInfos.map(item => ({
|
serialNumber: item.serialNumber,
|
quantity: item.editableQuantity
|
}));
|
|
this.$u.post('/api/InboundOrder/WMSInPinKu?warehouseId=' + this.warehouseId, submitData).then(res => {
|
if (res.status) {
|
this.$refs.uToast.show({
|
title: "入库成功",
|
type: "success"
|
})
|
this.focus = false;
|
this.pkmatInfos = [];
|
this.pksns = [];
|
} else {
|
this.$refs.uToast.show({
|
title: res.message,
|
type: "error"
|
})
|
}
|
})
|
},
|
|
pksnInput() {
|
this.$nextTick(() => {
|
if (!this.pkmaterSn) return;
|
|
// 延迟100ms确保扫码完成
|
setTimeout(() => {
|
this.focus = false;
|
|
// 校验内箱码完整性
|
const requiredFields = ['M:', 'BS:', 'DM:', 'DE:', 'Q:', 'PO:', 'DN:'];
|
const hasAllFields = requiredFields.every(field => this.pkmaterSn.includes(field));
|
if (!hasAllFields) {
|
this.$refs.uToast.show({
|
title: "内箱码不完整,请重新扫描",
|
type: "error"
|
});
|
this.pkmaterSn = "";
|
return;
|
}
|
|
const matSn = this.pkmaterSn;
|
this.pkmaterSn = "";
|
|
this.$u.post('/api/MaterielInfo/CodeAnalysis?serNum=' + matSn, {}).then((res) => {
|
if (res.status) {
|
// 新增可编辑数量字段
|
const tempData = res.data;
|
tempData.editableQuantity = tempData.quantity;
|
|
this.pksns.push(tempData.serialNumber);
|
this.pkmatInfos.push(tempData);
|
} else {
|
this.$refs.uToast.show({
|
title: res.message,
|
type: "error"
|
})
|
}
|
})
|
}, 100);
|
})
|
},
|
|
//解盘
|
releasebox() {
|
if (this.value.length == 0) {
|
this.$refs.uToast.show({
|
title: "请扫码",
|
type: "error"
|
})
|
return;
|
}
|
var param;
|
var matInfo = this.value.split('|');
|
if (matInfo.length == 7) {
|
param = {
|
MainData: {
|
"innerCode": this.value
|
}
|
}
|
} else {
|
param = {
|
MainData: {
|
"barcode": this.value
|
}
|
}
|
}
|
this.$u.post('/api/StockOperate/ReleaseAllBox', param).then(resdt => {
|
if (resdt.status) {
|
uni.$showMsg('解盘成功!')
|
this.value = "";
|
this.matInfo = [];
|
this.matTotals = [];
|
this.value2 = "";
|
} else {
|
this.$refs.uToast.show({
|
title: resdt.message,
|
type: "error"
|
})
|
}
|
})
|
},
|
|
releaseboxInput() {
|
this.$nextTick(() => {
|
if (this.value.length == 0) {
|
return;
|
}
|
var matInfo = this.value.split('|');
|
this.matInfo = [];
|
if (matInfo.length == 7) {
|
this.$u.post('/api/StockOperate/GetStockInfoByInnerCode', {
|
MainData: {
|
"innerCode": this.value
|
}
|
}).then(res => {
|
if (res.status) {
|
this.matInfo = res.data.stockInfo;
|
this.matTotals = res.data.stockTotal;
|
this.value2 = res.data.barcode;
|
} else {
|
this.$refs.uToast.show({
|
title: res.message,
|
type: "error"
|
})
|
}
|
})
|
} else {
|
this.$u.post('/api/StockOperate/GetStockInfoByBarcode', {
|
MainData: {
|
"barcode": this.value
|
}
|
}).then(res => {
|
if (res.status) {
|
this.matInfo = res.data.stockInfo;
|
this.matTotals = res.data.stockTotal;
|
this.value2 = res.data.barcode;
|
} else {
|
this.$refs.uToast.show({
|
title: res.message,
|
type: "error"
|
})
|
}
|
})
|
}
|
})
|
},
|
|
updateFocus() {
|
this.$nextTick(() => {
|
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/InboundOrderDetail/GetInboundOrderDetails', 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) {
|
this.focus = true;
|
}
|
})
|
},
|
|
snInput() {
|
this.$nextTick(() => {
|
if (!this.materSn) return;
|
|
// 延迟100ms确保扫码完成
|
setTimeout(() => {
|
this.focus = false;
|
|
// 仓库11的特殊处理
|
if(this.warehouseId==11){
|
this.materSn=this.materSn.replace(/,SC.*/, '');
|
}
|
|
// 校验内箱码完整性
|
const requiredFields = ['M:', 'BS:', 'DM:', 'DE:', 'Q:', 'PO:', 'DN:'];
|
const hasAllFields = requiredFields.every(field => this.materSn.includes(field));
|
if (!hasAllFields) {
|
this.$refs.uToast.show({
|
title: "内箱码不完整,请重新扫描",
|
type: "error"
|
});
|
this.materSn = "";
|
return;
|
}
|
|
// 仓库特定逻辑
|
if (this.warehouseId == 6 || this.warehouseId == 2 || this.warehouseId == 3) {
|
if (this.sns.length > 0) {
|
this.sns = [];
|
}
|
}
|
|
const matSn = this.materSn;
|
this.materSn = "";
|
|
this.$u.post('/api/MaterielInfo/CodeAnalysis?serNum=' + matSn, {}).then((res) => {
|
this.Testcheck = false;
|
if (res.status) {
|
// 新增可编辑数量字段
|
const tempData = res.data;
|
tempData.editableQuantity = tempData.quantity;
|
|
this.sns.push(tempData.serialNumber);
|
if (this.warehouseId == 6 || this.warehouseId == 2 || this.warehouseId == 3) {
|
if (this.matInfos.length > 0) {
|
this.matInfos = [];
|
}
|
}
|
this.matInfos.push(tempData);
|
} else {
|
this.$refs.uToast.show({
|
title: res.message,
|
type: "error"
|
})
|
}
|
})
|
}, 100);
|
})
|
},
|
|
inbound() {
|
if (this.inboundBarcode == "") {
|
this.$refs.uToast.show({
|
title: "请扫描托盘条码",
|
type: "error"
|
})
|
return;
|
}
|
if (this.address == "") {
|
this.$refs.uToast.show({
|
title: "请扫描地址条码",
|
type: "error"
|
})
|
return;
|
}
|
var postData = {
|
MainData: {
|
"barcode": this.inboundBarcode,
|
"startPoint": this.address,
|
"warehouseId": this.warehouseId
|
}
|
}
|
this.$u.post('/api/Task/RequestInboundTask', postData).then(res => {
|
if (res.status) {
|
this.inboundBarcode = "";
|
if (this.warehouseId != 5 && this.warehouseId != 3) this.address = "";
|
this.stockInfoDetail = [];
|
//获取总数量
|
this.Summmary = 0;
|
setTimeout(() => {
|
this.addressFocus = false;
|
this.$refs.uToast.show({
|
title: "成功",
|
type: "success"
|
})
|
}, 200);
|
} 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;
|
}
|
})
|
this.$nextTick(function(x) {
|
if (this.inboundBarcode != '') {
|
var postData = {
|
MainData: {
|
"barcode": this.inboundBarcode,
|
"warehouseId": this.warehouseId,
|
}
|
};
|
this.$u.post('/api/StockInfo/StockQueryData', postData).then(res => {
|
this.stockInfoDetail = [];
|
if (res.status) {
|
this.stockInfoDetail = res.data.details
|
//获取总数量
|
this.Summmary = 0;
|
this.stockInfoDetail.forEach(item => {
|
this.Summmary += item.stockQuantity;
|
});
|
} else {
|
this.$refs.uToast.show({
|
title: res.message,
|
type: "error"
|
})
|
}
|
})
|
}
|
})
|
},
|
|
deleteList(res) {
|
this.matInfos.splice(res, 1);
|
this.sns.splice(res, 1);
|
},
|
|
pkdeleteList(res) {
|
this.pkmatInfos.splice(res, 1);
|
this.pksns.splice(res, 1);
|
},
|
|
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;
|
}
|
if (this.Test) {
|
if (!this.Testcheck) {
|
this.Testcheck = true;
|
if (this.warehouseId == 2) {
|
this.$refs.uToast.show({
|
title: "请确认数量",
|
type: 'error'
|
})
|
} else if (this.warehouseId == 6) {
|
this.$refs.uToast.show({
|
title: "请确认初始寿命",
|
type: 'error'
|
})
|
}
|
return;
|
}
|
}
|
|
// 准备提交数据,包含编辑后的数量
|
const submitSns = this.matInfos.map(item => ({
|
serialNumber: item.serialNumber,
|
quantity: item.editableQuantity
|
}));
|
|
if (this.warehouseId == 2) { //油墨仓库区ID
|
// 特殊处理保持不变,但使用编辑后的数量
|
const firstItem = this.matInfos[0];
|
for (var i = 0; i < firstItem.editableQuantity - 1; i++) {
|
submitSns.push({
|
serialNumber: firstItem.serialNumber,
|
quantity: 1
|
});
|
}
|
}
|
|
let url = 'palletCode=' + this.barcode + '&initiallife=' + this.Initiallife + '&warehouseId=' + this.warehouseId;
|
|
this.$u.post('/api/InboundOrder/ManualMaterielGroup?' + url, submitSns).then(res => {
|
this.Testcheck = false;
|
if (res.status) {
|
this.$refs.uToast.show({
|
title: "组盘成功",
|
type: "success"
|
})
|
this.focus = false;
|
this.barcode = "";
|
this.matInfos = [];
|
this.sns = [];
|
this.matTotal = [];
|
} else {
|
this.$refs.uToast.show({
|
title: res.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>
|