现场调试修改 入库 出库 放货重新分配货位

This commit is contained in:
liuhanqing
2025-12-26 13:23:28 +08:00
parent ced125c8e9
commit 6b56e5f2ad
53 changed files with 3397 additions and 1832 deletions

View File

@@ -3,7 +3,7 @@
<view class="input-group">
<uni-easyinput
v-model="trayCode"
:placeholder="$t('outbound.exception.trayCodePlaceholder')"
placeholder="请输入或扫码输入托盘条码"
:clearable="true"
@input="handleInput"
@clear="handleClear"
@@ -19,27 +19,27 @@
<uni-card v-for="(item, index) in materialList" :key="index" class="material-card">
<view class="card-content">
<view class="info-row">
<text class="label">{{ $t('outbound.exception.materialCode') }}:</text>
<text class="label">物资编码:</text>
<text class="value">{{ item.productId }}</text>
</view>
<view class="info-row">
<text class="label">{{ $t('outbound.exception.materialName') }}:</text>
<text class="label">物料名称:</text>
<text class="value">{{ item.extraField.materialDesc }}</text>
</view>
<view class="info-row">
<text class="label">{{ $t('outbound.exception.outQuantity') }}:</text>
<text class="label">出库数量:</text>
<text class="value">{{ item.outQuantity }}</text>
</view>
<view class="info-row">
<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>
<text class="label">拣选数量:</text>
<text class="value">{{ item.pickQuantity }}</text>
</view>
</view>
</uni-card>
</view>
<view class="button-group" v-if="materialList.length > 0">
<button class="submit-button" @click="handleSubmit">{{ $t('outbound.exception.submit') }}</button>
<button class="submit-button" @click="handleSubmit">提交</button>
</view>
</view>
</template>
@@ -68,25 +68,19 @@ export default {
try {
const response = await getTaskDetail({trayCode: value,inOut:'2'})
if (response.code === 200) {
// 设置materialList并初始化pickQuantity为outQuantity的值
this.materialList = (response.data || []).map(item => {
return {
...item,
pickQuantity: item.outQuantity
}
})
this.materialList = response.data || []
} else {
uni.showToast({
title: response.msg || this.$t('common.noData'),
title: response.msg || '暂无数据',
icon: 'none'
})
}
} catch (error) {
console.error(this.$t('outbound.exception.getTrayInfoFailed'), error)
uni.showToast({
title: this.$t('outbound.exception.getTrayInfoFailed'),
icon: 'none'
})
console.error('获取托盘信息失败', error)
uni.showToast({
title: '获取托盘信息失败',
icon: 'none'
})
}
}
},
@@ -94,37 +88,6 @@ 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({
@@ -138,71 +101,19 @@ export default {
async handleSubmit() {
if (!this.materialList.length) {
uni.showToast({
title: this.$t('outbound.exception.scanTrayFirst'),
title: '请先扫描托盘条码',
icon: 'none'
})
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,
materialDetails: materialDetails
trayCode: this.trayCode
})
if (response.code === 200) {
uni.showToast({
title: this.$t('outbound.exception.submitSuccess'),
title: '提交成功',
icon: 'success'
})
// 清空数据
@@ -210,16 +121,16 @@ export default {
this.materialList = []
} else {
uni.showToast({
title: response.msg || this.$t('outbound.exception.submitFailed'),
title: response.msg || '提交失败',
icon: 'none'
})
}
} catch (error) {
console.error(this.$t('outbound.exception.submitFailed'), error)
uni.showToast({
title: this.$t('outbound.exception.submitFailed'),
icon: 'none'
})
console.error('提交失败', error)
uni.showToast({
title: '提交失败',
icon: 'none'
})
}
}
}