手持机
This commit is contained in:
@@ -31,9 +31,9 @@
|
||||
<text class="value">{{ item.outQuantity }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="label">{{ $t('outbound.exception.pickQuantity') }}:</text>
|
||||
<text class="value">{{ item.pickQuantity }}</text>
|
||||
</view>
|
||||
<text class="label">{{ $t('outbound.exception.pickQuantity') }}:</text>
|
||||
<uni-easyinput v-model="item.pickQuantity" type="number" :placeholder="$t('outbound.exception.enterPickQuantity')" style="flex: 1;" @input="validatePickQuantity(item)"></uni-easyinput>
|
||||
</view>
|
||||
</view>
|
||||
</uni-card>
|
||||
</view>
|
||||
@@ -68,7 +68,13 @@ export default {
|
||||
try {
|
||||
const response = await getTaskDetail({trayCode: value,inOut:'2'})
|
||||
if (response.code === 200) {
|
||||
this.materialList = response.data || []
|
||||
// 设置materialList并初始化pickQuantity为outQuantity的值
|
||||
this.materialList = (response.data || []).map(item => {
|
||||
return {
|
||||
...item,
|
||||
pickQuantity: item.outQuantity
|
||||
}
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: response.msg || this.$t('common.noData'),
|
||||
@@ -88,6 +94,37 @@ export default {
|
||||
handleClear() {
|
||||
this.materialList = []
|
||||
},
|
||||
// 验证拣货数量不超过出库数量且不为负数
|
||||
validatePickQuantity(item) {
|
||||
// 转换为数字
|
||||
let pickQty = Number(item.pickQuantity)
|
||||
let outQty = Number(item.outQuantity)
|
||||
|
||||
// 检查是否为有效数字
|
||||
if (isNaN(pickQty) || pickQty === '') {
|
||||
item.pickQuantity = outQty
|
||||
return
|
||||
}
|
||||
|
||||
// 检查是否为负数
|
||||
if (pickQty < 0) {
|
||||
uni.showToast({
|
||||
title: this.$t('outbound.exception.pickQuantityNegative'),
|
||||
icon: 'none'
|
||||
})
|
||||
item.pickQuantity = 0
|
||||
return
|
||||
}
|
||||
|
||||
// 检查是否超过出库数量
|
||||
if (pickQty > outQty) {
|
||||
uni.showToast({
|
||||
title: this.$t('outbound.exception.pickQuantityExceed'),
|
||||
icon: 'none'
|
||||
})
|
||||
item.pickQuantity = outQty
|
||||
}
|
||||
},
|
||||
// 处理扫码事件
|
||||
handleScan() {
|
||||
uni.scanCode({
|
||||
@@ -106,10 +143,62 @@ export default {
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 提交前再次验证所有物料的pickQuantity
|
||||
let isValid = true
|
||||
this.materialList.forEach(item => {
|
||||
// 转换为数字
|
||||
let pickQty = Number(item.pickQuantity)
|
||||
let outQty = Number(item.outQuantity)
|
||||
|
||||
// 检查是否为有效数字
|
||||
if (isNaN(pickQty) || pickQty === '') {
|
||||
isValid = false
|
||||
uni.showToast({
|
||||
title: this.$t('outbound.exception.invalidPickQuantity'),
|
||||
icon: 'none'
|
||||
})
|
||||
item.pickQuantity = outQty
|
||||
return
|
||||
}
|
||||
|
||||
// 检查是否为负数
|
||||
if (pickQty < 0) {
|
||||
isValid = false
|
||||
uni.showToast({
|
||||
title: this.$t('outbound.exception.pickQuantityNegative'),
|
||||
icon: 'none'
|
||||
})
|
||||
item.pickQuantity = 0
|
||||
return
|
||||
}
|
||||
|
||||
// 检查是否超过出库数量
|
||||
if (pickQty > outQty) {
|
||||
isValid = false
|
||||
uni.showToast({
|
||||
title: this.$t('outbound.exception.pickQuantityExceed'),
|
||||
icon: 'none'
|
||||
})
|
||||
item.pickQuantity = outQty
|
||||
}
|
||||
})
|
||||
|
||||
if (!isValid) return
|
||||
|
||||
// 准备提交数据,包含所有物料编码和pickQuantity
|
||||
const materialDetails = this.materialList.map(item => {
|
||||
return {
|
||||
jobDetailId: item.jobDetailId,
|
||||
productId: item.productId,
|
||||
pickQuantity: item.pickQuantity
|
||||
}
|
||||
})
|
||||
|
||||
try {
|
||||
const response = await submitError({
|
||||
trayCode: this.trayCode
|
||||
|
||||
trayCode: this.trayCode,
|
||||
materialDetails: materialDetails
|
||||
})
|
||||
if (response.code === 200) {
|
||||
uni.showToast({
|
||||
|
||||
Reference in New Issue
Block a user