手持机
This commit is contained in:
@@ -88,6 +88,7 @@
|
||||
<view v-for="(item, index) in shelfInfo" :key="index" class="shelf-item">
|
||||
<text class="shelf-name">{{ item.productName || $t('outbound.bindShelf.unknownMaterial') }}</text>
|
||||
<text class="shelf-code">{{ item.productId || $t('outbound.bindShelf.noCode') }}</text>
|
||||
<text class="shelf-quantity">{{ item.quantity || $t('outbound.bindShelf.noQuantity') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -244,7 +245,7 @@ export default {
|
||||
this.materialList = (response.rows || []).map(item => ({
|
||||
...item,
|
||||
selected: false,
|
||||
bindQuantity: item.quantit
|
||||
bindQuantity: item.quantity
|
||||
}))
|
||||
} else {
|
||||
uni.showToast({
|
||||
@@ -299,6 +300,19 @@ export default {
|
||||
return
|
||||
}
|
||||
|
||||
// 检查绑定数量是否为0或空
|
||||
const invalidQuantityItem = selectedItems.find(item => {
|
||||
return !item.bindQuantity || item.bindQuantity === 0
|
||||
})
|
||||
|
||||
if (invalidQuantityItem) {
|
||||
uni.showToast({
|
||||
title: '绑定数量不能为0或空',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
this.$refs.bindShelfPopup.open()
|
||||
},
|
||||
// 关闭绑定料架弹窗
|
||||
@@ -375,6 +389,19 @@ export default {
|
||||
return
|
||||
}
|
||||
|
||||
// 检查绑定数量是否为0或空
|
||||
const invalidQuantityItem = selectedItems.find(item => {
|
||||
return !item.bindQuantity || item.bindQuantity === 0
|
||||
})
|
||||
|
||||
if (invalidQuantityItem) {
|
||||
uni.showToast({
|
||||
title: '绑定数量不能为0或空',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 这里可以根据实际需求调用相应的API进行提交
|
||||
// 示例:构建提交数据
|
||||
const submitData = {
|
||||
|
||||
@@ -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