Jelajahi Sumber

手持-拣货-增加波次打印

zhaohuanhuan 9 bulan lalu
induk
melakukan
b57ec9812e

+ 12 - 0
src/api/picking/index.ts

@@ -96,6 +96,18 @@ export function setPickingDetail(data: any[]) {
   })
 }
 
+/**
+ * 打印面单
+ * @param data
+ */
+export function printExpressNo(params: any[]) {
+  return request({
+    url: 'api/wms/order/express-print',
+    method: 'post',
+    params
+  })
+}
+
 
 /**
  * 大件拣货

+ 100 - 0
src/views/outbound/picking/components/expressPrint.vue

@@ -0,0 +1,100 @@
+<template>
+  <div class="express-print">
+    <van-dialog v-model:show="expressPrintTrueFalseBy"
+                :close-on-click-overlay="false"
+                :beforeClose="beforeClose"
+                title="打印面单"
+                show-cancel-button>
+      <van-cell title="打印机" is-link :value="printer" @click="selectPrinter" />
+      <van-cell title="打印波次">
+        <template #value>
+          <van-checkbox-group v-model="waveNo" shape="square">
+            <van-checkbox :name="item" v-for="item in waveList" size="16px" style="margin-bottom: 10px">{{ item }}</van-checkbox>
+          </van-checkbox-group>
+        </template>
+      </van-cell>
+    </van-dialog>
+    <printer ref="printerRef" @onPrint="onPrint" />
+  </div>
+</template>
+<script setup lang="ts">
+import { ref } from 'vue'
+import { showNotify, showToast } from 'vant'
+import Printer from '@/components/Printer.vue'
+import { closeLoading, showLoading } from '@/utils/loading'
+import { printExpressNo } from '@/api/picking'
+const props = defineProps({
+  warehouse:String
+});
+const waveNo = ref([])
+const waveList = ref([])
+const expressPrintTrueFalseBy = ref(false)
+const printerRef = ref(null)
+const printer = ref('请选择打印机')
+const server = ref('')
+const show = async (code) => {
+  expressPrintTrueFalseBy.value = true
+  waveList.value = code
+  waveNo.value=code
+  printer.value='请选择打印机'
+  server.value=''
+}
+//选择打印机
+const selectPrinter = () => {
+  printerRef.value?.show(props.warehouse)
+}
+//设置打印机
+const onPrint = (code) => {
+  printer.value = code.printer
+  server.value = code.server
+}
+const beforeClose = (action) =>
+  new Promise(async (resolve) => {
+    if (action === 'confirm') {
+      if (!server.value) {
+        showToast('请先选择打印机')
+        return resolve(false)
+      }
+      if(waveNo.value.length==0){
+        showToast('请先选择打印波次')
+        return resolve(false)
+      }
+      printRequests(0, waveNo.value.length)
+    }
+    resolve(true)
+  })
+//打印
+const printRequests = async (startIndex = 0, printNum) => {
+  try {
+    if (startIndex < printNum) {
+      const wave = waveNo.value[startIndex]
+      const res = await _printMode(wave)
+      if (res) {
+        showNotify({ message:`波次${wave}打印成功`, duration: 5000, type:'success' })
+        // 递归调用,继续打印下一个
+        await printRequests(startIndex + 1, printNum)
+      } else {
+        showNotify({ message:`波次${wave}打印失败`, duration: 5000, type:'danger' })
+      }
+    }
+  } catch (error) {
+    console.error('请求过程中发生错误', error)
+  } finally {
+    closeLoading()
+  }
+}
+const _printMode = (code) => {
+  return new Promise((resolve, reject) => {
+    const params = { warehouse:props.warehouse,code, server: server.value, printer: printer.value }
+    showLoading()
+    printExpressNo(params)
+      .then(res => resolve(res))
+      .catch(err => reject('打印失败', err))
+  })
+}
+defineExpose({ show })
+</script>
+<style scoped lang="sass">
+.express-print
+  text-align: left
+</style>

+ 8 - 1
src/views/outbound/picking/list/index.vue

@@ -105,6 +105,7 @@
     <input-barcode ref="inputBarcodeRef" @setBarcode="_handlerScan" />
 <!--    <van-floating-bubble v-if="locationList.length>0"  :gap="50" axis="xy" magnetic="x"  @click="onContainerNo(containerNo===''?2:scanType)">容器</van-floating-bubble>-->
     <lot-att ref="lotAttRef" />
+    <express-print ref="expressPrintRef" :warehouse="warehouse" />
     <barcode-combine ref="barcodeCombineRef" @setCombine="setCombine" :container="containerNo" :matched-sku="matchedSku" />
     <printer ref="printerRef" @onPrint="onPrint"/>
     <van-dialog v-model:show="countTrueFalseBy" title="拣货数量" show-cancel-button  :beforeClose="beforeClose" :keyboardEnabled="false"  >
@@ -125,7 +126,7 @@ import { showConfirmDialog, showDialog, showFailToast, showNotify, showToast } f
 import { fetchPickingData, getPickingTask } from '@/views/outbound/picking/list/hooks/list'
 import { getOwnerList } from '@/hooks/basic'
 import { useRouter,useRoute } from 'vue-router'
-import { getListCombineSku, printerByPick, removePickingTask, setPickingDetail } from '@/api/picking'
+import { getListCombineSku, getPickingWaveNo, printerByPick, removePickingTask, setPickingDetail } from '@/api/picking'
 const router = useRouter()
 const route = useRoute()
 const store = useStore()
@@ -148,6 +149,7 @@ import { basicStore } from '@/store/modules/basic'
 import { closeLoading, showLoading } from '@/utils/loading'
 import WaveInfo from '@/views/outbound/picking/components/WaveInfo.vue'
 import Printer from '@/components/Printer.vue'
+import ExpressPrint from '@/views/outbound/picking/components/expressPrint.vue'
 onUnmounted(() => {
   closeListener()
 })
@@ -734,6 +736,7 @@ const actions = [
   { name: '反转库位顺序' ,key:'reversal'},
   { name: '获取任务',key:'task' },
   { name: '波次号打印' ,key:'wave'},
+  { name: '面单打印' ,key:'express'},
   { name: '检索条码' ,key:'inputBarcode'},
 
 ];
@@ -750,6 +753,7 @@ const onClickRight = () => {
 const pickingNoInputRef=ref(null)
 const inputBarcodeRef=ref(null)
 const printerRef=ref(null)
+const expressPrintRef=ref(null)
 const onSelectMode= async (value) => {
   if(value.key=='task'){
     if(route.query.aisle){
@@ -767,6 +771,9 @@ const onSelectMode= async (value) => {
     }else {
       showToast('当前没有任务不支持打印')
     }
+  }else if(value.key=='express'){
+    const waveList=Object.keys(getWaveOne())
+    expressPrintRef.value.show(waveList)
   }else if(value.key=='removeTask'){
     if(pickingNo.value){
       if(selectTask.value.length>0){