|
|
@@ -6,9 +6,13 @@
|
|
|
<van-icon name="arrow-left" size="25" />
|
|
|
<div style="color: #fff">返回</div>
|
|
|
</template>
|
|
|
+ <!-- <template #right>-->
|
|
|
+ <!-- <div class="nav-right" @click="onClickRight">提交任务</div>-->
|
|
|
+ <!-- </template>-->
|
|
|
</van-nav-bar>
|
|
|
<div class="large">
|
|
|
<div class="large-title">
|
|
|
+ <!-- <div><span style="font-size: 12px">订单号:</span>{{ orderNo || '--' }}</div>-->
|
|
|
<div class="large-tips">
|
|
|
<van-notice-bar :background="'none'" :speed="50" :text="tips" />
|
|
|
</div>
|
|
|
@@ -122,6 +126,7 @@
|
|
|
import { onMounted, onUnmounted, computed, ref } from 'vue'
|
|
|
import { androidFocus, getHeader, goBack, scanError, scanSuccess } from '@/utils/android'
|
|
|
import { closeListener, openListener, scanInit } from '@/utils/keydownListener'
|
|
|
+import InputBarcode from '@/views/outbound/picking/components/InputBarcode.vue'
|
|
|
import { useStore } from '@/store/modules/user'
|
|
|
import { closeLoading, showLoading } from '@/utils/loading'
|
|
|
import { getOrderPacking, getPendingReviewTask, listEnableCheckDocumentPrint, reversePicking } from '@/api/check'
|
|
|
@@ -129,7 +134,6 @@ import { barcodeToUpperCase } from '@/utils/dataType'
|
|
|
import { showConfirmDialog, showDialog, showNotify, showToast } from 'vant'
|
|
|
import { fluxPrint } from '@/api/picking'
|
|
|
import Printer from '@/components/Printer.vue'
|
|
|
-import InputBarcode from '@/views/outbound/picking/components/InputBarcode.vue'
|
|
|
import CheckPacking from '@/views/outbound/check/components/CheckPacking.vue'
|
|
|
import BatchPacking from '@/views/outbound/check/components/BatchPacking.vue'
|
|
|
import PackingList from '@/views/outbound/check/components/PackingList.vue'
|
|
|
@@ -139,7 +143,6 @@ try {
|
|
|
getHeader()
|
|
|
androidFocus()
|
|
|
} catch (error) {
|
|
|
- router.push('/login')
|
|
|
}
|
|
|
// 页面初始化
|
|
|
onMounted(() => {
|
|
|
@@ -207,6 +210,7 @@ const packingCount = computed(() => {
|
|
|
return packingList.value.reduce((sum, item) => sum + (+item.qty || 0), 0);
|
|
|
})
|
|
|
|
|
|
+//
|
|
|
//扫描订单产品总数
|
|
|
const scanOrderBarcodeCount = computed(() => {
|
|
|
return dataList.value.reduce((sum, item) => {
|
|
|
@@ -249,52 +253,42 @@ const matchBarcodeList = ref([])
|
|
|
const barcodeNumberTrueFalseBy = ref(false)
|
|
|
const barcodeNumberRef = ref(null)
|
|
|
const barcodeNumber=ref('')
|
|
|
+const pattern=/^[0-9]\d*$/
|
|
|
const _handlerScan = async (code) => {
|
|
|
- if (code) {
|
|
|
- // 含唯一码/IMEI 的订单仅允许 PC 端复核
|
|
|
- if (isUniqueCode.value) {
|
|
|
+ if (code) {
|
|
|
+ if (isUniqueCode.value) {
|
|
|
scanError()
|
|
|
scanBarcode.value = ''
|
|
|
showNotify({ type: 'warning', duration: 3000, message: `此单包含唯一码/IMEI码,请到PC复核` })
|
|
|
return
|
|
|
}
|
|
|
- // 待复核(60)/部分复核(600) 行:主副条码、SKU、69 码去重,作合法扫描集合
|
|
|
- const barcode = [...new Set(
|
|
|
+ const barcode = [...new Set(
|
|
|
orderList.value
|
|
|
.filter(item => (item.status == '60' || item.status == '600'))
|
|
|
.flatMap(item => [item.barcode, item.barcode2, item.sku, item.universalCode])
|
|
|
.filter(value => value !== null && value !== '' && value !== undefined),
|
|
|
)]
|
|
|
- // 与大写后的集合元素比对,忽略大小写
|
|
|
- const checkBarcode = barcodeToUpperCase(code)
|
|
|
- // 扫描条码匹配
|
|
|
- if (barcode.some(item => barcodeToUpperCase(item) === checkBarcode)) {
|
|
|
- // 将命中行排到列表前,其余保持顺序在后
|
|
|
- dataList.value = await barcodeMatching(checkBarcode)
|
|
|
- // 当前码对应且仍有待扫数量
|
|
|
- matchBarcodeList.value = dataList.value.filter(item => (item.barcode === checkBarcode || item.sku === checkBarcode || item.barcode2 === checkBarcode || item.universalCode == checkBarcode)
|
|
|
- && (item.status == '60' || item.status == '600') && item.qty > 0)
|
|
|
- // 有匹配行则继续处理
|
|
|
+ const checkBarcode = barcodeToUpperCase(code)
|
|
|
+ if (barcode.some(item => barcodeToUpperCase(item) === checkBarcode)) {
|
|
|
+ dataList.value = await barcodeMatching(checkBarcode)
|
|
|
+ matchBarcodeList.value = dataList.value.filter(item => (item.barcode === checkBarcode || item.sku === checkBarcode || item.barcode2 === checkBarcode || item.universalCode == checkBarcode) && (item.status == '60' || item.status == '600') && item.qty > 0)
|
|
|
if (matchBarcodeList.value.length > 0) {
|
|
|
- scanBarcode.value = code
|
|
|
- // 匹配行 qty 求和
|
|
|
- const allCount = matchBarcodeList.value.reduce((sum, item) => sum + Number(item.qty), 0)
|
|
|
- // 弹出数量录入
|
|
|
- if (allCount > 1) {
|
|
|
+ scanBarcode.value = code
|
|
|
+ const allCount = matchBarcodeList.value.reduce((sum, item) => sum + Number(item.qty), 0)
|
|
|
+ if (allCount > 1) {
|
|
|
barcodeNumberTrueFalseBy.value = true
|
|
|
setTimeout(() => {
|
|
|
barcodeNumber.value=''
|
|
|
- barcodeNumberRef.value?.focus() // 延迟聚焦,避免与扫描框抢焦点
|
|
|
+ barcodeNumberRef.value?.focus()
|
|
|
},300)
|
|
|
return
|
|
|
}
|
|
|
- // 仅一件则直接按 1 扣减
|
|
|
- cutBarcode([matchBarcodeList.value[0]], 1)
|
|
|
+ cutBarcode([matchBarcodeList.value[0]], 1)
|
|
|
} else {
|
|
|
scanBarcode.value = ''
|
|
|
scanError()
|
|
|
tips.value = `商品条码${code},已全部扫描完成`
|
|
|
- showNotify({ type: 'warning', duration: 3000, message: `商品条码${code},已全部扫描完成` })
|
|
|
+ showNotify({ type: 'warning', duration: 3000, message: `商品条码${code},已全部扫描完成` })
|
|
|
}
|
|
|
} else {
|
|
|
scanBarcode.value = ''
|
|
|
@@ -350,15 +344,12 @@ const cutBarcode = (list, count) => { //扣减数量
|
|
|
// 更新扫描数据的逻辑
|
|
|
const updateData = (item) => {
|
|
|
const itemIndex = dataList.value.findIndex(data => data.lotNum === item.lotNum)
|
|
|
- // 扣减的数量
|
|
|
- const deductedAmount = item.originalDetailAmount - item.qty
|
|
|
+ const deductedAmount = item.originalDetailAmount - item.qty // 扣减的数量
|
|
|
if (itemIndex !== -1) {
|
|
|
dataList.value[itemIndex] = {
|
|
|
...dataList.value[itemIndex],
|
|
|
- // 更新实际扣减的数量
|
|
|
- quantity: dataList.value[itemIndex].quantity + deductedAmount,
|
|
|
- // 更新原始数量
|
|
|
- oldQuantity:dataList.value[itemIndex].oldQuantity + deductedAmount,
|
|
|
+ quantity: dataList.value[itemIndex].quantity + deductedAmount, // 更新实际扣减的数量
|
|
|
+ oldQuantity:dataList.value[itemIndex].oldQuantity + deductedAmount, // 更新实际扣减的数量
|
|
|
}
|
|
|
} else {
|
|
|
item.quantity = deductedAmount
|
|
|
@@ -367,22 +358,21 @@ const cutBarcode = (list, count) => { //扣减数量
|
|
|
}
|
|
|
}
|
|
|
list.forEach(item => {
|
|
|
- // 如果剩余数量为0,停止扣减
|
|
|
- if (remainingCount <= 0) return
|
|
|
- // 保存原始数量
|
|
|
- item.originalDetailAmount = item.qty
|
|
|
+ if (remainingCount <= 0) return // 如果剩余数量为0,停止扣减
|
|
|
+ item.originalDetailAmount = item.qty // 保存原始数量
|
|
|
if (item.qty > 0) {
|
|
|
- // 剩余数量大于当前商品的数量,则直接扣除当前商品的数量
|
|
|
+ // 如果剩余数量大于当前商品的数量,则直接扣除当前商品的数量
|
|
|
if (remainingCount >= item.qty) {
|
|
|
remainingCount -= item.qty
|
|
|
item.qty = 0
|
|
|
- } else {
|
|
|
- item.qty -= remainingCount
|
|
|
+ } else {
|
|
|
+ item.qty -= remainingCount // 扣减剩余数量
|
|
|
remainingCount = 0
|
|
|
}
|
|
|
+ item.isPacking=true
|
|
|
}
|
|
|
if (item.qty !== item.originalDetailAmount) {
|
|
|
- updateData(item)
|
|
|
+ updateData(item) // 更新扫描数据
|
|
|
scanBarcode.value = ''
|
|
|
tips.value = '请继续扫描商品'
|
|
|
scanSuccess()
|
|
|
@@ -391,16 +381,14 @@ const cutBarcode = (list, count) => { //扣减数量
|
|
|
const materiaList=orderList.value.filter(item=>item.status=='600' && item.qty>0)
|
|
|
const endOrder=orderList.value.filter(item=>item.status=='60' && item.qty>0)
|
|
|
if(materiaList.length ==0 &&endOrder.length==0){
|
|
|
- // 进行装箱
|
|
|
setPacking('single')
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+// 进行装箱
|
|
|
const checkPackingRef=ref(null)
|
|
|
const currPackingList=ref([])
|
|
|
const batchPackingRef=ref(null)
|
|
|
-// 装箱
|
|
|
const setPacking=(type)=>{
|
|
|
if(!printer.value){
|
|
|
scanError()
|
|
|
@@ -426,11 +414,9 @@ const setPacking=(type)=>{
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
- // 普通装箱
|
|
|
- if (type === 'single') {
|
|
|
+ if (type === 'single') { // 普通装箱
|
|
|
checkPackingRef.value?.show(currPackingList.value, orderDetail.value)
|
|
|
- } else {
|
|
|
- // 批量装箱
|
|
|
+ } else { // 批量装箱
|
|
|
const list =orderList.value.filter(item => item.isPacking && item.status=='60')
|
|
|
if (list.length > 1) {
|
|
|
scanError()
|
|
|
@@ -547,6 +533,9 @@ const printPickingList=(deliveryNo,curPackingList)=> {
|
|
|
}
|
|
|
const printRequests = async(index, dataList)=> {
|
|
|
if (index >= dataList.length) {
|
|
|
+ // if (this.orderList.length == 0) {
|
|
|
+ // this.getOrderList();
|
|
|
+ // }
|
|
|
return;
|
|
|
}
|
|
|
try {
|
|
|
@@ -608,7 +597,7 @@ const setBarcode = (code) => {
|
|
|
tips.value = '请扫描商品条码'
|
|
|
_getOrderPacking(res.data.orderNo)
|
|
|
scanSuccess()
|
|
|
- // 处理详情
|
|
|
+ // 处理每个详情项
|
|
|
res.data.details.forEach((item) => {
|
|
|
item.quantity = 0
|
|
|
item.oldQuantity = 0
|
|
|
@@ -685,14 +674,11 @@ const _reversePicking = () => {
|
|
|
closeLoading()
|
|
|
})
|
|
|
}
|
|
|
-// 订单装箱明细原始列表(接口返回,未合并)
|
|
|
const packingList=ref([])
|
|
|
-// 拉取订单装箱数据:按 sku+traceId 合并数量,再按 traceId 分组;type===1 时弹出装箱清单
|
|
|
const _getOrderPacking=(orderNo,type)=>{
|
|
|
showLoading()
|
|
|
getOrderPacking({ warehouse, code:orderNo }).then(res => {
|
|
|
packingList.value=res.data
|
|
|
- // 相同 sku + 追溯码合并为一条,数量累加
|
|
|
const mergedList = Object.values(
|
|
|
res.data.reduce((acc, item) => {
|
|
|
const { sku, traceId, qty } = item
|
|
|
@@ -705,7 +691,6 @@ const _getOrderPacking=(orderNo,type)=>{
|
|
|
return acc;
|
|
|
}, {})
|
|
|
)
|
|
|
- // 装箱行列表
|
|
|
packingDetailMap.value = mergedList.reduce((acc, item) => {
|
|
|
const { traceId } = item
|
|
|
acc[traceId] = acc[traceId] || []
|
|
|
@@ -716,7 +701,6 @@ const _getOrderPacking=(orderNo,type)=>{
|
|
|
packingListRef.value?.show(packingDetailMap.value,orderDetail.value)
|
|
|
}
|
|
|
}).catch(err => {
|
|
|
- // 请求失败时清空分组,避免沿用旧数据
|
|
|
packingDetailMap.value = {}
|
|
|
}).finally(f=>{
|
|
|
closeLoading()
|