Просмотр исходного кода

Merge branch 'zhaohuanhuan_comboProduct' into testing

# Conflicts:
#	src/views/haikang/putaway/putaway/index.vue
zhaohuanhuan 1 месяц назад
Родитель
Сommit
2953c5eef4

+ 99 - 0
src/views/inbound/putaway/components/BarcodeCombine.vue

@@ -0,0 +1,99 @@
+<template>
+  <div class="goods">
+    <van-dialog v-model:show="goodsTrueFalseBy"
+                :beforeClose="beforeClose"
+                title="组合商品上架"
+                show-cancel-button>
+        <div style="width:100%;max-height:150px;overflow:auto">
+          <div v-for="(item,index) in matchedSkuList" :key="index">
+            <van-cell center :title="item.matchedJson.barcode" :label="item.matchedJson.skuName">
+              <template #value>
+                <div>{{ item.matchedJson.quantity }}件/套</div>
+                <div class="goods-tips">待上架:{{ (item.expectedQuantity || 0) - (item.receivedQuantity || 0) }}件</div>
+              </template>
+            </van-cell>
+          </div>
+        </div>
+        <div class="goods-number">可上架套数:{{ maxCount }}</div>
+        <van-field label="上架套数" type="number" class="code-input" v-model="count" ref="countRef" placeholder="上架套数" />
+    </van-dialog>
+  </div>
+</template>
+<script setup>
+/** 组合商品上架弹框 */
+import { computed, ref } from 'vue'
+import { showToast } from 'vant'
+const goodsTrueFalseBy = ref(false)
+const countRef = ref(null)
+const count = ref('')
+const props = defineProps({
+  matchedSku: { type: Array, default: () => [] },
+})
+const matchedSkuList = computed(() => props.matchedSku)
+const maxCount = computed(() => {
+  const min = Math.min(
+    ...props.matchedSku.map((item) => ((item.expectedQuantity || 0) - (item.receivedQuantity || 0)) / (item.matchedJson?.quantity || 1))
+  )
+  return Number.isFinite(min) ? Math.floor(min) : 0
+})
+const show = () => {
+  count.value = ''
+  goodsTrueFalseBy.value = true
+  setTimeout(() => {
+    countRef.value?.focus()
+  }, 200)
+}
+const dataResult = (data) =>
+  data.map((item) => {
+    const { matchedJson, ...rest } = item
+    return { ...rest, quantity: matchedJson.quantity * Number(count.value) }
+  })
+const emit = defineEmits(['setCombine', 'cancel'])
+const beforeClose = (action) =>
+  new Promise((resolve) => {
+    if (action === 'confirm') {
+      if (count.value == '') {
+        showToast('请输入上架套数')
+        return resolve(false)
+      }
+      if (Number(count.value) <= 0) {
+        showToast('请输入有效上架套数')
+        return resolve(false)
+      }
+      if (Number(count.value) > maxCount.value) {
+        showToast({ duration: 3000, message: '上架套数不能大于可上架套数' })
+        return resolve(false)
+      }
+      const dataList = dataResult(matchedSkuList.value)
+      emit('setCombine', { dataList, count: Number(count.value) })
+    } else {
+      emit('cancel')
+    }
+    resolve(true)
+  })
+defineExpose({ show })
+</script>
+<style scoped lang="sass">
+.goods
+  .code-input
+    font-size: 16px
+    font-weight: bold
+    border-bottom: 2px solid #0077ff
+  :deep(.van-cell--center)
+    padding: 5px 20px
+  :deep(.van-cell__title)
+    text-align: left !important
+  :deep(.van-cell__value)
+    width: 40% !important
+    flex: 0 0 40% !important
+    color: #000
+  .goods-number
+    text-align: left
+    font-size: 16px
+    padding-left: 20px
+    margin-top: 5px
+  .goods-tips
+    font-size: 12px
+    text-align: right
+    color: #333
+</style>

+ 84 - 4
src/views/inbound/putaway/task/index.vue

@@ -148,6 +148,8 @@
       <location-list :locationList="locationList" />
     </div>
   </van-action-sheet>
+  <!--  组合商品上架数量-->
+  <barcode-combine ref="barcodeCombineRef" @setCombine="setPutawayCombine" @cancel="onCombineCancel" :matched-sku="combineMatchedSku" />
 </template>
 
 <script setup>
@@ -155,6 +157,7 @@ import { onMounted, onUnmounted, ref, computed } from 'vue'
 import { androidFocus, getHeader, goBack, scanError, scanSuccess } from '@/utils/android'
 import InputBarcode from '@/views/outbound/picking/components/InputBarcode.vue'
 import LocationList from '@/views/inbound/putaway/components/LocationList.vue'
+import BarcodeCombine from '@/views/inbound/putaway/components/BarcodeCombine.vue'
 import { openListener,closeListener,scanInit } from '@/utils/keydownListener.js'
 import { useRouter } from 'vue-router'
 import { closeLoading, showLoading } from '@/utils/loading'
@@ -162,6 +165,7 @@ import { useStore } from '@/store/modules/user'
 import { showNotify, showToast } from 'vant'
 import { getCurrentTime } from '@/utils/date'
 import { getWaitPutawayListNew, setPutawayNew } from '@/api/putaway/index'
+import { getListCombineSku } from '@/api/picking'
 import { barcodeToUpperCase } from '@/utils/dataType.js'
 import { getRecommendedLocation } from '@/api/haikang/index'
 import { getOwnerList } from '@/hooks/basic/index'
@@ -376,6 +380,10 @@ const switchTask = () => {
 const lotBarcodeList = ref([])
 const lotBarcodeTrueFalseBy = ref(false)
 const barcodeActiveList = ref([])
+// 组合商品
+const barcodeCombineRef = ref(null)
+const putawayCombineData = ref(null)
+const combineMatchedSku = ref([])
 const reset = () => {
   searchCount.value = ''
   searchBarcode.value = ''
@@ -383,11 +391,43 @@ const reset = () => {
   oldSearchBarcode.value = ''
   locationList.value = []
   barcodeActiveList.value = []
+  putawayCombineData.value = null
+  combineMatchedSku.value = []
+}
+// 组合商品上架数量弹框
+const _showPutawayCombineDialog = (batchItem) => {
+  if (!putawayCombineData.value || !batchItem?.length) return
+  const total = batchItem.reduce((sum, i) => sum + Number(i.quantity || 0), 0)
+  combineMatchedSku.value = [{
+    matchedJson: putawayCombineData.value,
+    expectedQuantity: total,
+    receivedQuantity: 0,
+  }]
+  barcodeCombineRef.value?.show()
+}
+// 组合商品确认上架数量
+const setPutawayCombine = ({ dataList }) => {
+  if (dataList?.[0]?.quantity != null) {
+    searchCount.value = String(dataList[0].quantity)
+  }
+  showNotify({ type: 'success', duration: 2000, message: `已填入上架数量:${searchCount.value},请扫描库位并确认上架` })
+}
+// 组合商品取消
+const onCombineCancel = () => {
+  const qtyPerSet = putawayCombineData.value?.quantity ?? 1
+  const total = barcodeQuantity(barcodeActiveList.value)
+  searchCount.value = String(total < qtyPerSet ? 1 : qtyPerSet)
 }
 // 选择单据
 const onDetailActive = (item) => {
   barcodeActiveList.value = item
   lotBarcodeTrueFalseBy.value = false
+  if (putawayCombineData.value) {
+    _showPutawayCombineDialog(item)
+    _getRecommendedLocation(item[0].lotNumber, item[0].owner)
+    scanType.value = 3
+    return
+  }
   searchCount.value = 1
   scanType.value = 3
   _getRecommendedLocation(item[0].lotNumber, item[0].owner)
@@ -400,6 +440,46 @@ const onAsnCancel = () => {
     locationList.value = []
   }
 }
+// 商品条码不匹配时,查询组合条码
+const _handlePutawayCombineProduct = (code) => {
+  showLoading()
+  getListCombineSku({ combineSku: barcodeToUpperCase(code), workEnvironment: 'inbound' })
+    .then((res) => {
+      const _err = (msg) => {
+        closeLoading()
+        scanError()
+        showNotify({ type: 'danger', duration: 3000, message: msg })
+        reset()
+      }
+      if (!res.data?.length) return _err(`${code}-商品条码不匹配,请重新扫描`)
+      if (res.data.length > 1) return _err('不支持多商品组合商品')
+      const combineBarcode = res.data[0].barcode
+      lotBarcodeList.value = matchingBarcodeItem(dataMap.value, combineBarcode)
+      if (lotBarcodeList.value.length === 0) return _err('组合商品与待上架数据不匹配,请检查组合商品配置!')
+      putawayCombineData.value = res.data[0]
+      closeLoading()
+      scanSuccess()
+      if (lotBarcodeList.value.length === 1) {
+        barcodeActiveList.value = lotBarcodeList.value[0]
+        _showPutawayCombineDialog(lotBarcodeList.value[0])
+        _getRecommendedLocation(barcodeActiveList.value[0].lotNumber, barcodeActiveList.value[0].owner)
+        scanType.value = 3
+      } else {
+        locationList.value = []
+        barcodeActiveList.value = []
+        searchCount.value = ''
+        searchLocation.value = ''
+        lotBarcodeTrueFalseBy.value = true
+      }
+    })
+    .catch(() => {
+      closeLoading()
+      scanError()
+      showNotify({ type: 'danger', duration: 3000, message: `${code}-商品条码不匹配,请重新扫描` })
+      reset()
+    })
+}
+
 // 扫描条码监听
 const _handlerScan = (code) => {
   if (scanType.value == 2) {
@@ -407,6 +487,8 @@ const _handlerScan = (code) => {
     oldSearchBarcode.value = code
     lotBarcodeList.value = matchingBarcodeItem(dataMap.value, code)
     if (lotBarcodeList.value.length > 0) {
+      putawayCombineData.value = null
+      combineMatchedSku.value = []
       if (lotBarcodeList.value.length == 1) {
         barcodeActiveList.value = lotBarcodeList.value[0]
         _getRecommendedLocation(barcodeActiveList.value[0].lotNumber, barcodeActiveList.value[0].owner)
@@ -420,14 +502,12 @@ const _handlerScan = (code) => {
         lotBarcodeTrueFalseBy.value = true
       }
     } else {
-      scanError()
-      showNotify({ type: 'danger', duration: 3000, message: `${code}-商品条码不匹配,请重新扫描` })
-      reset()
+      _handlePutawayCombineProduct(code)
     }
   } else if (scanType.value == 3) {
     searchLocation.value = barcodeToUpperCase(code)
     scanType.value = 4
-    searchCount.value = 1
+    if (!searchCount.value) searchCount.value = 1
     scanSuccess()
   }
 }

+ 100 - 0
src/views/inbound/takeDelivery/components/BarcodeCombine.vue

@@ -0,0 +1,100 @@
+<template>
+  <div class="goods">
+    <van-dialog v-model:show="goodsTrueFalseBy"
+                :beforeClose="beforeClose"
+                title="组合商品收货"
+                show-cancel-button>
+        <div style="width:100%;max-height:150px;overflow:auto">
+          <div v-for="(item,index) in matchedSkuList" :key="index">
+            <van-cell center :title="item.matchedJson.barcode" :label="item.matchedJson.skuName">
+              <template #value>
+                <div>{{ item.matchedJson.quantity }}件/套</div>
+                <div class="goods-tips">待收货:{{ (item.expectedQuantity || 0) - (item.receivedQuantity || 0) }}件</div>
+              </template>
+            </van-cell>
+          </div>
+        </div>
+        <div class="goods-number">可收货套数:{{ maxCount }}</div>
+        <van-field label="收货套数" type="number" class="code-input" v-model="count" ref="countRef" placeholder="收货套数" />
+    </van-dialog>
+  </div>
+</template>
+<script setup>
+/** 组合商品弹框 */
+import { computed, ref } from 'vue'
+import { showToast } from 'vant'
+const goodsTrueFalseBy = ref(false)
+const countRef = ref(null)
+const count = ref('')
+const props = defineProps({
+  matchedSku: { type: Array, default: () => [] },
+  container: { type: String, default: '' }
+})
+const matchedSkuList = computed(() => props.matchedSku)
+const maxCount = computed(() => {
+  const min = Math.min(
+    ...props.matchedSku.map((item) => ((item.expectedQuantity || 0) - (item.receivedQuantity || 0)) / (item.matchedJson?.quantity || 1))
+  )
+  return Number.isFinite(min) ? Math.floor(min) : 0
+})
+const show = () => {
+  count.value = ''
+  goodsTrueFalseBy.value = true
+  setTimeout(() => {
+    countRef.value?.focus()
+  }, 200)
+}
+const dataResult = (data) =>
+  data.map((item) => {
+    const { matchedJson, ...rest } = item
+    return { ...rest, quantity: matchedJson.quantity * Number(count.value), containerId: props.container }
+  })
+const emit = defineEmits(['setCombine', 'cancel'])
+const beforeClose = (action) =>
+  new Promise((resolve) => {
+    if (action === 'confirm') {
+      if (count.value == '') {
+        showToast('请输入收货数量')
+        return resolve(false)
+      }
+      if (Number(count.value) <= 0) {
+        showToast('请输入标准收货数量')
+        return resolve(false)
+      }
+      if (Number(count.value) > maxCount.value) {
+        showToast({ duration: 3000, message: '收货数量不能大于应收数量' })
+        return resolve(false)
+      }
+      const dataList = dataResult(matchedSkuList.value)
+      emit('setCombine', { dataList, count: Number(count.value) })
+    } else {
+      emit('cancel')
+    }
+    resolve(true)
+  })
+defineExpose({ show })
+</script>
+<style scoped lang="sass">
+.goods
+  .code-input
+    font-size: 16px
+    font-weight: bold
+    border-bottom: 2px solid #0077ff
+  :deep(.van-cell--center)
+    padding: 5px 20px
+  :deep(.van-cell__title)
+    text-align: left !important
+  :deep(.van-cell__value)
+    width: 40% !important
+    flex: 0 0 40% !important
+    color: #000
+  .goods-number
+    text-align: left
+    font-size: 16px
+    padding-left: 20px
+    margin-top: 5px
+  .goods-tips
+    font-size: 12px
+    text-align: right
+    color: #333
+</style>

+ 19 - 0
src/views/inbound/takeDelivery/task/hooks/barcodeCombine.js

@@ -0,0 +1,19 @@
+import { barcodeToUpperCase } from '@/utils/dataType'
+
+/** 组合商品:匹配ASN明细中条码,附加 matchedJson */
+export function receivingBarcodeCombine(asnDetailList, combineSkuMap) {
+  if (!combineSkuMap || !Array.isArray(asnDetailList) || !asnDetailList.length) return []
+  const mapUpper = Object.fromEntries(
+    Object.entries(combineSkuMap).filter(([barcode]) => barcode).map(([barcode, config]) => [barcodeToUpperCase(barcode), config])
+  )
+  return asnDetailList
+    .map((item) => {
+      const barcodes = [item.barcode, item.barcode2, item.sku].filter(Boolean)
+      const matchedBar = barcodes.find((bar) => mapUpper[barcodeToUpperCase(bar)])
+      if (!matchedBar) return null
+      const matched = mapUpper[barcodeToUpperCase(matchedBar)]
+      const remaining = (item.expectedQuantity || 0) - (item.receivedQuantity || 0)
+      return remaining >= matched.quantity ? { ...item, matchedJson: matched } : null
+    })
+    .filter(Boolean)
+}

+ 117 - 56
src/views/inbound/takeDelivery/task/index.vue

@@ -129,6 +129,8 @@
   <attribute ref="attributeRef" @set-attribute="setAttribute" />
   <!--  商品批次属性-->
   <lot-date ref="lotDateRef" @select-lot-date="selectLotDate" />
+  <!--  组合商品-->
+  <barcode-combine ref="barcodeCombineRef" @setCombine="setCombineReceiving" @cancel="onCombineCancel" :container="containerNo" :matched-sku="combineMatchedSku" />
   <!--  唯一码-->
   <unique-code-input ref="uniqueCodeRef"
                      v-model:uniqueCodeList="uniqueCodeList"
@@ -168,6 +170,7 @@ import {
   getReceivingAsnDetails,
   setProductAttribute, setReceiving,
 } from '@/api/takeDelivery/index'
+import { getListCombineSku } from '@/api/picking'
 import { closeLoading, showLoading } from '@/utils/loading'
 import { useStore } from '@/store/modules/user'
 import { showNotify, showToast } from 'vant'
@@ -175,7 +178,9 @@ import { isAttribute } from '@/views/inbound/takeDelivery/task/hooks/attribute'
 import Attribute from '@/views/inbound/takeDelivery/components/Attribute.vue'
 import LotDate from '@/views/inbound/takeDelivery/components/LotDate.vue'
 import UniqueCodeInput from '@/views/inbound/takeDelivery/components/UniqueCodeInput.vue'
-import { barcodeToUpperCase, toMap } from '@/utils/dataType.js'
+import BarcodeCombine from '@/views/inbound/takeDelivery/components/BarcodeCombine.vue'
+import { receivingBarcodeCombine } from '@/views/inbound/takeDelivery/task/hooks/barcodeCombine'
+import { barcodeToUpperCase, toMap } from '@/utils/dataType'
 import { getCurrentTime } from '@/utils/date'
 
 const router = useRouter()
@@ -201,6 +206,8 @@ const taskInfo = ref({ receivedQty: 0, expectedQty: 0 })
 const currentTime = ref('--')
 const scanType = ref(2)
 
+//任务号下所有asn单数据
+const allAsnDetailList=ref([])
 const type=localStorage.getItem('checkAllType')?JSON.parse(localStorage.getItem('checkAllType')):true
 const checkAllType=ref(type)
 // 页面初始化
@@ -244,10 +251,9 @@ const stopTimer = () => {
 
 const back = ref(true)
 const inputBarcodeType = ref('task')
-//输入框组件
 const inputBarcodeRef = ref(null)
 const oldSearchBarcode = ref('')
-// 设置容器号
+// 任务号/容器号:code 为任务号时拉取任务及ASN明细
 const setBarcode = (code, type) => {
   if (inputBarcodeType.value === 'lot') {
     lotData.value.forEach((lot) => {
@@ -271,9 +277,6 @@ const setBarcode = (code, type) => {
         taskNo.value=''
         taskInfo.value={}
         switchTask()
-      }else {
-        taskInfo.value=res.data
-        taskNo.value=code
       }
       containerNo.value=''
       stopTimer()
@@ -284,11 +287,15 @@ const setBarcode = (code, type) => {
         startTimer()
         containerNo.value=''
       }
-      taskInfo.value=res.data
-      taskNo.value=code
     }
+    taskInfo.value=res.data
+    taskNo.value=code
     scanType.value=2
     uniqueCodeList.value=[]
+    const params = { warehouse, asnNos: taskInfo.value?.asnNos.join(',') }
+    getReceivingAsnDetails(params).then(res => {
+      allAsnDetailList.value = res.data
+    })
     scanSuccess()
   }).catch(err=>{
     inputBarcodeRef.value?.show('', '请扫描开单任务号',err.message)
@@ -298,9 +305,8 @@ const setBarcode = (code, type) => {
     closeLoading()
   })
 }
-// setBarcode('BSSH20250605000006')
+// setBarcode('BSSH20260318000003')
 
-//切换任务
 const switchTask = () => {
   inputBarcodeType.value = 'switchTask'
   back.value = false
@@ -318,13 +324,19 @@ const reset = () => {
   searchBarcode.value = ''
   oldSearchBarcode.value = ''
   uniqueCodeList.value = []
+  combineMatchedSku.value = []
+  combineAsnSelectList.value = []
+  isCombineSelectMode.value = false
+  combineReceivingData.value = []
 }
-// 选择单据
 const onDetailActive = (item) => {
+  if (isCombineSelectMode.value) {
+    _onCombineAsnSelected(item)
+    return
+  }
   asnInfo.value = item
   asnDetailsTrueFalseBy.value = false
   searchCount.value=1
-  // searchCount.value = asnInfo.value.expectedQuantity - asnInfo.value.receivedQuantity
   _getProductAttribute(item)
   _getProductLot(item)
   _getCommodityRule(item)
@@ -338,29 +350,104 @@ const onAsnCancel = () => {
 }
 const uniqueCodeList = ref([])
 
-// 扫描条码监听
+// 组合商品
+const barcodeCombineRef = ref(null)
+const combineMatchedSku = ref([])
+const combineAsnSelectList = ref([])
+const isCombineSelectMode = ref(false)
+const combineReceivingData = ref([]) // 确认实收数后暂存,完成收货时提交
+
+// 组合商品只支持1个
+const _handleCombineProduct = (code) => {
+  showLoading()
+  getListCombineSku({ combineSku: barcodeToUpperCase(code), workEnvironment: 'receiving' }).then((res) => {
+    const _err = (msg) => { closeLoading(); scanError(); showNotify({ type: 'danger', duration: 3000, message: msg }); reset() }
+    if (!res.data?.length) return _err(`${code}-商品条码不匹配,请重新扫描`)
+    if (res.data.length > 1) return _err('不支持多商品组合商品')
+    const combineData = res.data
+    const matchedList = receivingBarcodeCombine(allAsnDetailList.value, toMap(combineData, 'barcode'))
+    if (!matchedList.length) return _err('组合商品与待收货数据不匹配,请检查组合商品配置!')
+    const asnGroupMap = matchedList.reduce((acc, detail) => {
+      const key = detail.asnNo
+      if (!acc[key]) acc[key] = { asnNo: detail.asnNo, customerId: detail.customerId, expectedQuantity: 0, list: [] }
+      acc[key].list.push(detail)
+      acc[key].expectedQuantity += (detail.expectedQuantity || 0) - (detail.receivedQuantity || 0)
+      return acc
+    }, {})
+    const asnOptions = Object.values(asnGroupMap)
+    if (asnOptions.length > 1) {
+      isCombineSelectMode.value = true
+      combineAsnSelectList.value = asnOptions
+      combineMatchedSku.value = matchedList
+      asnDetailsList.value = asnOptions.map((opt) => ({ asnNo: opt.asnNo, customerId: opt.customerId, expectedQuantity: opt.expectedQuantity }))
+      asnDetailsTrueFalseBy.value = true
+    } else {
+      _showCombineDialog(matchedList)
+    }
+    closeLoading()
+    scanSuccess()
+  }).catch(() => { closeLoading(); scanError() })
+}
+
+const _showCombineDialog = (matchedList) => {
+  combineMatchedSku.value = matchedList
+  asnInfo.value = matchedList[0]
+  _getProductAttribute(matchedList[0])
+  _getProductLot(matchedList[0])
+  _getCommodityRule(matchedList[0])
+  barcodeCombineRef.value?.show()
+}
+
+// 组合商品取消:收货数量=1套总件数
+const onCombineCancel = () => {
+  const total = combineMatchedSku.value.reduce((sum, row) => sum + (row.matchedJson?.quantity || 0), 0)
+  searchCount.value = total ? String(total) : '1'
+  combineReceivingData.value = []
+}
+
+const _onCombineAsnSelected = (item) => {
+  const selected = combineAsnSelectList.value.find((opt) => opt.asnNo === item.asnNo)
+  if (selected?.list) _showCombineDialog(selected.list)
+  asnDetailsTrueFalseBy.value = isCombineSelectMode.value = false
+  combineAsnSelectList.value = []
+}
+
+// 组合商品确认实收数
+const setCombineReceiving = ({ dataList }) => {
+  if (!dataList?.length) return
+  const total = dataList.reduce((sum, row) => sum + (row.quantity || 0), 0)
+  searchCount.value = String(total)
+  combineReceivingData.value = dataList
+  showNotify({ type: 'success', duration: 2000, message: `已填入收货数量:${total},请点击完成收货提交` })
+}
+
+// 条码扫描:scanType 2商品/4数量/3唯一码/5容器
 const _handlerScan = (code) => {
   if (scanType.value == 2) {
     searchBarcode.value = code
     oldSearchBarcode.value = code
-    const params = { warehouse, barcode: code, asnNos: taskInfo.value?.asnNos.join(',') }
-    showLoading()
-    getReceivingAsnDetails(params).then(res => {
+      if ( allAsnDetailList.value.length > 0) {
+        const upperCode = barcodeToUpperCase(code) || ''
+        const clientMatched = allAsnDetailList.value.filter((detail) => {
+          const bars = [detail.barcode, detail.barcode2, detail.sku].filter(Boolean)
+          return bars.some((bar) => bar && barcodeToUpperCase(bar) === upperCode)
+        })
+        asnDetailsList.value = clientMatched
+      }
       uniqueCodeList.value=[]
-      asnDetailsList.value = res.data
-      if (res.data.length > 0) {
+
+      if (asnDetailsList.value.length > 0) {
         scanSuccess()
         closeLoading()
-        if (res.data.length == 1) {
-          const item = res.data[0]
+        if (asnDetailsList.value.length == 1) {
+          const item = asnDetailsList.value[0]
           asnInfo.value = item
-          // searchCount.value = item.expectedQuantity - item.receivedQuantity
-          searchCount.value=1
+          searchCount.value = 1
           _getProductAttribute(item)
           _getProductLot(item)
           _getCommodityRule(item)
         }
-        if (res.data.length > 1) {
+        if (asnDetailsList.value.length > 1) {
           asnInfo.value = {}
           lotData.value = []
           searchCount.value = ''
@@ -368,21 +455,14 @@ const _handlerScan = (code) => {
           asnDetailsTrueFalseBy.value = true
         }
       } else {
-        scanError()
-        showNotify({ type: 'danger', duration: 3000, message: `暂未查询到条码《${code}》信息请重试` })
-        reset()
-        closeLoading()
+        _handleCombineProduct(code)
       }
-    }).catch(() => {
-      scanError()
-      closeLoading()
-    })
   } else if (scanType.value == 3) {
     if (code) {
       const uniqueCodeScanType = uniqueCodeRef.value?.uniqueCodeScanType
       if (checkAllType.value && uniqueCodeScanType === 'barcode') {
         const barcode = Array.from(new Set([asnInfo.value.barcode, asnInfo.value.barcode2, asnInfo.value.sku].filter(Boolean)));
-        if (barcode.some(item => barcodeToUpperCase(item) === barcodeToUpperCase(code))) {
+        if (barcode.some((bar) => barcodeToUpperCase(bar) === barcodeToUpperCase(code))) {
           scanSuccess();
           uniqueCodeRef.value.uniqueCodeScanType = 'unique'
           uniqueCodeRef.value.uniqueBarcode = code
@@ -428,9 +508,7 @@ const _handlerScan = (code) => {
     scanType.value=2
   }
 }
-/**
- * 物理属性
- */
+// 物理属性
 const attributeRef = ref(null)
 const attributeMap = ref({})
 const attributeTrueFalseBy = ref(true)
@@ -461,14 +539,8 @@ const setAttribute = (data) => {
     scanError()
   })
 }
-/**
- * 物理属性 end
- */
 
-/**
- * 商品批次属性
- */
-// 获取商品批次属性
+// 批次属性
 const lotData = ref([])
 const _getProductLot = (item) => {
   const params = { warehouse: item.warehouse, owner: item.customerId, barcode: item.sku }
@@ -579,12 +651,7 @@ const selectLotDate = (date) => {
   inputBarcodeType.value = 'task'
 }
 
-/**
- * 商品批次属性end
- */
-/**
- * 唯一码
- */
+// 唯一码
 const uniqueCodeRef = ref(null)
 //规则列表
 const uniqueRuleList = ref([])
@@ -604,12 +671,9 @@ const _getCommodityRule = (item) => {
     uniqueRuleMap.value = toMap(res.data, 'type', 'uniqueRegExp')
   })
 }
-/**
- * 唯一码end
- */
 const containerNoRef = ref(null)
 const numberRef = ref(null)
-// 完成收货校验
+// 完成收货前校验
 const isCheck = () => {
   if (!asnInfo.value.asnNo) {
     scanError()
@@ -685,7 +749,7 @@ const isCheck = () => {
   }
   return true
 }
-// 收货
+// 完成收货
 const onConfirm = () => {
   if(isCheck()){
     const lotMap = toMap(lotData.value, 'field', 'mapping')
@@ -728,9 +792,6 @@ const loadData = () => {
   if (!taskNo.value) {
     inputBarcodeRef.value?.show('', '请扫描开单任务号','')
     return
-  } else {
-    // currentTime.value=getCurrentTime()
-    // startTimer()
   }
 }
 onUnmounted(() => {

+ 105 - 0
src/views/outbound/check/moveStock/components/MoveStockCombine.vue

@@ -0,0 +1,105 @@
+<template>
+  <div class="goods">
+    <van-dialog v-model:show="goodsTrueFalseBy"
+                :beforeClose="beforeClose"
+                title="组合商品还库"
+                show-cancel-button>
+      <div style="width:100%;max-height:150px;overflow:auto">
+        <div v-for="(item,index) in matchedSkuList" :key="index">
+          <van-cell center :title="item.matchedJson.barcode" :label="item.matchedJson.skuName">
+            <template #value>
+              <div>{{ item.matchedJson.quantity }}件/套</div>
+              <div class="goods-tips">可还:{{ item.expectedQuantity || 0 }}件 </div>
+            </template>
+          </van-cell>
+          <div class="goods-lot">生产:{{ item.productionDate || '--' }}, 失效:{{ item.expirationDate || '--' }}</div>
+        </div>
+      </div>
+      <div class="goods-number">可还套数:{{ maxCount }}</div>
+      <van-field label="还库套数" type="number" class="code-input" v-model="count" ref="countRef" placeholder="还库套数" autocomplete="off" />
+    </van-dialog>
+  </div>
+</template>
+<script setup>
+/** 还库-组合商品弹框 */
+import { computed, ref } from 'vue'
+import { showToast } from 'vant'
+const goodsTrueFalseBy = ref(false)
+const countRef = ref(null)
+const count = ref('')
+const props = defineProps({
+  matchedSku: { type: Array, default: () => [] }
+})
+const matchedSkuList = computed(() => props.matchedSku)
+const maxCount = computed(() => {
+  const min = Math.min(
+    ...props.matchedSku.map((item) => (item.expectedQuantity || 0) / (item.matchedJson?.quantity || 1))
+  )
+  return Number.isFinite(min) ? Math.floor(min) : 0
+})
+const show = () => {
+  count.value = ''
+  goodsTrueFalseBy.value = true
+  setTimeout(() => {
+    countRef.value?.focus()
+  }, 200)
+}
+const dataResult = (data) =>
+  data.map((item) => {
+    const { matchedJson, ...rest } = item
+    return { ...rest, quantity: matchedJson.quantity * Number(count.value) }
+  })
+const emit = defineEmits(['setCombine', 'cancel'])
+const beforeClose = (action) =>
+  new Promise((resolve) => {
+    if (action === 'confirm') {
+      if (count.value == '') {
+        showToast('请输入还库套数')
+        return resolve(false)
+      }
+      if (Number(count.value) <= 0) {
+        showToast('请输入正确还库套数')
+        return resolve(false)
+      }
+      if (Number(count.value) > maxCount.value) {
+        showToast({ duration: 3000, message: '还库套数不能大于可还套数' })
+        return resolve(false)
+      }
+      const dataList = dataResult(matchedSkuList.value)
+      emit('setCombine', { dataList, count: Number(count.value) })
+    } else {
+      emit('cancel')
+    }
+    resolve(true)
+  })
+defineExpose({ show })
+</script>
+<style scoped lang="sass">
+.goods
+  .code-input
+    font-size: 16px
+    font-weight: bold
+    border-bottom: 2px solid #0077ff
+  :deep(.van-cell--center)
+    padding: 5px 20px
+  :deep(.van-cell__title)
+    text-align: left !important
+  :deep(.van-cell__value)
+    width: 40% !important
+    flex: 0 0 40% !important
+    color: #000
+  .goods-number
+    text-align: left
+    font-size: 16px
+    padding-left: 20px
+    margin-top: 5px
+  .goods-tips
+    font-size: 12px
+    text-align: right
+    color: #333
+  .goods-lot
+    font-size: 12px
+    color: #666
+    margin-left: 20px
+    text-align: left
+</style>

+ 125 - 32
src/views/outbound/check/moveStock/index.vue

@@ -6,16 +6,15 @@
       fixed
       placeholder
       @click-left="goBack"
+      @click-right="refresh"
     >
       <template #left>
         <van-icon name="arrow-left" size="25" />
         <div  style="color: #fff">返回</div>
       </template>
-<!--      <template #right>-->
-<!--        <div class="nav-right" @click="onClickRight">-->
-<!--          <van-icon name="list-switch" size="25" />-->
-<!--        </div>-->
-<!--      </template>-->
+      <template #right>
+        <div style="color: #fff">刷新<van-icon name="replay" /></div>
+      </template>
     </van-nav-bar>
     <div class="move-stock">
       <div class="code">
@@ -32,6 +31,8 @@
             v-model="searchBarcode"
             placeholder="请扫描商品条码"
             @search="_handlerScan(searchBarcode)"
+            @input="onBarcodeChange"
+            @clear="onBarcodeClear"
             label="商品条码:"
             left-icon=""
             :class="[scanType===2?'search-input-barcode':'','van-hairline--bottom']"
@@ -124,6 +125,8 @@
     />
     <!-- 条码输入组件 -->
     <input-barcode :back="back" @setBarcode="setBarcode" ref="inputBarcodeRef" />
+    <!-- 组合商品还库 -->
+    <move-stock-combine ref="moveStockCombineRef" :matched-sku="combineMatchedSku" @set-combine="setCombineMoveStock" @cancel="onCombineCancel" />
     <van-dialog v-model:show="moveStockTrueFalseBy"
                 :beforeClose="beforeClose"
                 :title="'商品条码:'+ model.sku +',还库:'+location" show-cancel-button  >
@@ -171,17 +174,20 @@
 </template>
 
 <script setup>
-import { onMounted, onUnmounted, ref, computed } from 'vue'
-import { useRouter } from 'vue-router'
-import { useStore } from '@/store/modules/user'
-import { androidFocus, getHeader, goBack, scanError, scanSuccess } from '@/utils/android'
-import { closeListener, openListener, scanInit } from '@/utils/keydownListener'
-import { getInventory, getInventoryList, movementReturn } from '@/api/check/index'
+import {computed, onMounted, onUnmounted, ref} from 'vue'
+import {useRouter} from 'vue-router'
+import {useStore} from '@/store/modules/user'
+import {androidFocus, getHeader, goBack, scanError, scanSuccess} from '@/utils/android'
+import {closeListener, openListener, scanInit} from '@/utils/keydownListener'
+import {getInventory, getInventoryList, movementReturn} from '@/api/check/index'
 import InputBarcode from '@/views/outbound/picking/components/InputBarcode.vue'
-import { closeLoading, showLoading } from '@/utils/loading'
+import {closeLoading, showLoading} from '@/utils/loading'
 import nodataUrl from '@/assets/nodata.png'
-import { showNotify, showToast } from 'vant'
-import { barcodeToUpperCase } from '@/utils/dataType.js'
+import {showNotify, showToast} from 'vant'
+import {barcodeToUpperCase} from '@/utils/dataType.js'
+import {getListCombineSku} from '@/api/picking'
+import MoveStockCombine from './components/MoveStockCombine.vue'
+
 const router = useRouter()
 const store = useStore()
 try {
@@ -193,7 +199,7 @@ try {
 const warehouse = store.warehouse
 const pattern=/^[1-9]\d*$/
 // 容器号和扫描类型的状态
-const containerNo = ref('')
+const containerNo = ref('FJ-WH01-1')
 //输入框组件类型
 const inputBarcodeType = ref('')
 //扫描类型
@@ -207,12 +213,17 @@ const totalList=ref([])
 const searchRef=ref(null)
 //扫描条码
 const searchBarcode=ref('')
+const oldSearchBarcode=ref('')
 //扫描库位
 const location=ref('')
 //
 const model=ref({})
 const countRef=ref(null)
 const back=ref(true)
+// 组合商品还库
+const moveStockCombineRef = ref(null)
+const combineData = ref(null)
+const combineMatchedSku = ref([])
 // 页面初始化
 onMounted(() => {
   openListener()
@@ -238,7 +249,8 @@ const setBarcode = (code) => {
   scanType.value = 2
   containerNo.value = code
   searchBarcode.value=''
-  moveList.value=''
+  moveList.value=[]
+  combineData.value=null
   location.value=''
   // if(searchBarcode.value){
   //   _getInventoryList(searchBarcode.value)
@@ -251,6 +263,23 @@ const _setContainerNo=()=>{
   inputBarcodeRef.value?.show('', '请扫描反拣容器')
 }
 
+// 商品条码调整时,清空还库推荐、库存列表、还库库位
+const onBarcodeChange = () => {
+  if (searchBarcode.value === '' || (oldSearchBarcode.value && oldSearchBarcode.value.length !== searchBarcode.value.length)) {
+    moveList.value = []
+    totalList.value = []
+    location.value = ''
+    combineData.value = null
+  }
+}
+const onBarcodeClear = () => {
+  moveList.value = []
+  totalList.value = []
+  location.value = ''
+  combineData.value = null
+  oldSearchBarcode.value = ''
+}
+
 // 扫描条码监听
 const _handlerScan = (code) => {
   console.log(code)
@@ -266,8 +295,35 @@ const _handlerScan = (code) => {
   }
 }
 
+// 商品条码查询为空时,查询组合商品列表
+const _handleCombineProduct = async (code) => {
+  try {
+    showLoading()
+    const res = await getListCombineSku({ combineSku: barcodeToUpperCase(code), workEnvironment: 'movement' })
+    closeLoading()
+    const _err = (msg) => {
+      scanError()
+      searchBarcode.value = ''
+      showNotify({ type: 'danger', duration: 5000, message: msg })
+    }
+    if (!res.data?.length) return _err(`条码:${code},未找到可还库库存,请检查条码!`)
+    if (res.data.length > 1) return _err('组合商品不支持多商品')
+    const innerBarcode = res.data[0].barcode
+    combineData.value = res.data[0]
+    searchBarcode.value = code
+    oldSearchBarcode.value = code
+    _getInventoryList(innerBarcode, true)
+    scanSuccess()
+  } catch (err) {
+    closeLoading()
+    scanError()
+    searchBarcode.value = ''
+    showNotify({ type: 'danger', duration: 5000, message: `条码查询失败,请检查条码!` })
+  }
+}
+
 // 获取库存数据
-const _getInventoryList = async (barcode) => {
+const _getInventoryList = async (barcode, fromCombineQuery = false) => {
   const data = { warehouse, location: containerNo.value, barcode }
   try {
     showLoading()
@@ -275,25 +331,43 @@ const _getInventoryList = async (barcode) => {
     closeLoading()
     moveList.value = res.data
     if (res.data.length === 0) {
-      scanError()
-      searchBarcode.value = ''
-      showNotify({ duration: 5000, message: `条码:${barcode},未找到可还库库存,请检查条码!` })
+      _handleCombineProduct(barcode)
       return
     }
+    // 仅当直接扫描普通条码命中时清除组合标记;从组合商品内件查询来时保留
+    if (!fromCombineQuery) combineData.value = null
     scanSuccess()
-    searchBarcode.value= res.data[0].sku
-    const params={ warehouse, barcode,locationRegexp:'^(?!STAGE_|SORTATION_|REVERSEPICK_|FJ-|TRANSFER_).*$',queryLocationInfo:true }
-    if(barcode==='') return
-    getInventory(params).then(res=>{
-      totalList.value=res.data
+    if (!fromCombineQuery) {
+      searchBarcode.value = res.data[0].sku
+      oldSearchBarcode.value = res.data[0].sku
+    }
+    const params = { warehouse, barcode, locationRegexp: '^(?!STAGE_|SORTATION_|REVERSEPICK_|FJ-|TRANSFER_).*$', queryLocationInfo: true }
+    if (barcode === '') return
+    getInventory(params).then(res => {
+      totalList.value = res.data
     })
-    scanType.value=3
+    scanType.value = 3
   } catch (err) {
     closeLoading()
     console.error(err)
   }
 }
 
+// 刷新
+const refresh = () => {
+  moveList.value = []
+  totalList.value = []
+  location.value = ''
+  combineData.value = null
+  scanType.value = 2
+  if (containerNo.value && searchBarcode.value) {
+    oldSearchBarcode.value = ''
+    _getInventoryList(searchBarcode.value)
+  } else {
+    loadData()
+  }
+}
+
 //移动数量
 const moveCount=ref('')
 //移动弹框
@@ -311,11 +385,30 @@ const onMove=(item)=>{
     return
   }
   model.value=item
-  moveCount.value=''
-  moveStockTrueFalseBy.value=true
-  setTimeout(()=>{
-    countRef.value?.focus()
-  },300)
+  if (combineData.value) {
+    combineMatchedSku.value = [{ ...item, matchedJson: combineData.value, expectedQuantity: item.availableQty }]
+    moveStockCombineRef.value?.show()
+  } else {
+    moveCount.value=''
+    moveStockTrueFalseBy.value=true
+    setTimeout(()=>{
+      countRef.value?.focus()
+    },300)
+  }
+}
+
+// 组合商品还库确认
+const setCombineMoveStock = ({ dataList }) => {
+  if (!dataList?.[0]) return
+  const row = dataList[0]
+  moveCount.value = String(row.quantity)
+  model.value = { ...model.value, ...row }
+  createMoveStock()
+}
+
+// 组合商品还库取消
+const onCombineCancel = () => {
+  moveCount.value = ''
 }
 /**
  * 确认还库
@@ -373,6 +466,7 @@ const  createMoveStock=()=>{
       location.value=''
       moveList.value=[]
       totalList.value=[]
+      combineData.value=null
     }else {
       location.value=''
       _getInventoryList(searchBarcode.value)
@@ -434,7 +528,6 @@ const onSelectMode = async (value) => {
     inputBarcodeRef.value?.show()
   }
 }
-
 // 数据刷新
 const loadData = () => {
   if(searchBarcode.value){