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

Merge branch 'zhaohuanhuan_asrs-v4' into testing

# Conflicts:
#	src/hooks/basic/menu.js
zhaohuanhuan 3 месяцев назад
Родитель
Сommit
9efa46f98e

+ 6 - 1
src/hooks/basic/menu.js

@@ -113,7 +113,12 @@ export default function() {
               title: '库位合并',
               icon: 'newspaper-o',
               path: 'robot-merge',
-            }
+            },
+            {
+              title: '立库快上',
+              icon: 'newspaper-o',
+              path:   'hik-putaway-allocation?type=asrs',
+            },
           ],
         },
         {

+ 1 - 1
src/static/setting.txt

@@ -1 +1 @@
-78
+80

+ 8 - 5
src/views/haikang/putaway/dispatch/index.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="container">
     <van-nav-bar
-      title="海康上架-调度" left-arrow fixed placeholder @click-left="goBack">
+      :title="mode?'立库快上':'海康快上'" left-arrow fixed placeholder @click-left="goBack">
       <template #left>
         <van-icon name="arrow-left" size="25" />
         <div style="color: #fff">返回</div>
@@ -116,10 +116,12 @@ import { androidFocus, getHeader, goBack, playVoiceBin, scanError, scanSuccess }
 import InputBarcode from '@/views/outbound/picking/components/InputBarcode.vue'
 import { closeListener, openListener, scanInit } from '@/utils/keydownListener'
 import { useStore } from '@/store/modules/user'
-import { finishTask, getRecommendedLocation, getWaitPutawayList, setBindAllocateWall } from '@/api/haikang'
+import { finishTask, getRecommendedLocation, setBindAllocateWall } from '@/api/haikang'
 import { barcodeToUpperCase } from '@/utils/dataType'
 import { closeLoading, showLoading } from '@/utils/loading'
 import { getWaitPutawayListNew } from '@/api/putaway'
+import {useRoute} from "vue-router";
+
 try {
   getHeader()
   androidFocus()
@@ -133,6 +135,8 @@ onMounted(() => {
 })
 const store = useStore()
 const warehouse = store.warehouse
+const route = useRoute()
+const mode=ref(route.query.type)
 //收货容器号
 const containerNo = ref('')
 //分拨墙号
@@ -276,7 +280,7 @@ const matchingBarcodeItem = (data, barcode) => {
 // 获取库存数据
 const _getRecommendedLocation = async (lotNum, owner) => {
   try {
-    const params = { warehouse, lotNum, owner,zoneGroup:'WH01-01' }
+    const params = { warehouse, lotNum, owner,zoneGroup:mode.value?'WH01-3':'WH01-01' }
     const res = await getRecommendedLocation(params)
     locationList.value = res.data
     //  'EA'数据
@@ -304,7 +308,6 @@ const _getRecommendedLocation = async (lotNum, owner) => {
 }
 // 设置库位
 const locationActive = ref([])
-const wallBinCounts = ref(new Map())
 const setLocation = (item) => {
     locationActive.value = item
     const data = {
@@ -317,6 +320,7 @@ const setLocation = (item) => {
       sku: barcodeActive.value.sku,
       location: locationActive.value[0].location,
       lotNum: barcodeActive.value.lotNumber,
+      type:mode.value?'ASRS':'HIK'
     }
     showLoading()
     setBindAllocateWall(data).then(res => {
@@ -366,7 +370,6 @@ const onClickRight = () => {
   showConfirmDialog({
     title: '温馨提示',
     message:'您正在进行释放分拨墙是否继续?',
-    keyboardEnabled:false
   }).then(() => {
     showLoading()
     const params={warehouse,container:containerNo.value}

+ 64 - 215
src/views/inbound/photoOCR/index.vue

@@ -37,47 +37,31 @@
               <span>请拍摄或选择面单图片进行识别</span>
             </div>
             
-            <div class="camera-section">
-              <div class="camera-button" @click="openCamera">
-                <van-icon name="photo" size="40" />
-                <div class="camera-text">点击拍照</div>
-              </div>
-              
-              <!-- 隐藏的上传组件,用于处理从相册选择 -->
-              <van-uploader
-                v-model="uploadImages"
-                :max-count="1"
-                :before-read="beforeReadImage"
-                :after-read="afterReadImage"
-                preview-full-image
-                accept="image/*"
-                :show-upload="false"
-                style="display: none;"
-                ref="uploaderRef"
-              />
-            </div>
-            
-            <!-- 图片预览 -->
-            <div v-if="uploadImages.length > 0" class="image-preview">
-              <img :src="uploadImages[0].content" class="preview-image" />
-              <van-button 
-                type="danger" 
-                size="small" 
-                @click="removeImage"
-                class="remove-btn"
-              >
-                重新拍摄
-              </van-button>
-            </div>
-
-            <div class="upload-footer" v-if="uploading">
+            <van-uploader
+              v-model="uploadImages"
+              :max-count="1"
+              :before-read="beforeReadImage"
+              :after-read="afterReadImage"
+              preview-full-image
+              capture="camera"
+              accept="image/*"
+            >
+              <template #preview-cover="{ file }">
+                <div class="preview-cover">
+                  <van-icon name="photo" />
+                </div>
+              </template>
+            </van-uploader>
+
+            <div class="upload-footer">
               <van-button
                 type="primary"
                 block
                 :loading="uploading"
-                disabled
+                @click="submitOCR"
+                :disabled="!uploadImages.length"
               >
-                自动上传中...
+                {{ uploading ? '上传中...' : '上传识别' }}
               </van-button>
             </div>
           </div>
@@ -106,138 +90,6 @@ const warehouse = store.warehouse
 
 const uploadImages = ref([])
 const uploading = ref(false)
-const uploaderRef = ref(null)
-
-// 打开相机
-const openCamera = () => {
-  // 检查是否在App环境中
-  if (window.android && window.android.openCamera) {
-    // 调用App原生相机
-    window.android.openCamera()
-    return
-  }
-  
-  // 检查是否在iOS环境中
-  if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.openCamera) {
-    // 调用iOS原生相机
-    window.webkit.messageHandlers.openCamera.postMessage({})
-    return
-  }
-  
-  // 移动端浏览器:使用兼容性最好的方法
-  if (/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)) {
-    // 移动设备:使用input file的capture属性
-    const input = document.createElement('input')
-    input.type = 'file'
-    input.accept = 'image/*'
-    input.capture = 'camera' // 强制使用相机
-    
-    input.onchange = (e) => {
-      const file = e.target.files[0]
-      if (file) {
-        handleCameraPhoto(file)
-      }
-    }
-    
-    // 触发点击
-    input.click()
-  } else {
-    // PC端:使用getUserMedia
-    openCameraForPC()
-  }
-}
-
-// PC端打开相机
-const openCameraForPC = async () => {
-  try {
-    if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
-      showFailToast('您的浏览器不支持相机功能')
-      return
-    }
-
-    const stream = await navigator.mediaDevices.getUserMedia({ 
-      video: { facingMode: 'environment' }
-    })
-    showCameraPreview(stream)
-  } catch (error) {
-    console.error('打开相机失败:', error)
-    showFailToast('打开相机失败,请检查权限设置')
-  }
-}
-
-// 显示相机预览界面(仅PC端使用)
-const showCameraPreview = (stream) => {
-  const previewDiv = document.createElement('div')
-  previewDiv.style.cssText = `
-    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
-    background: black; z-index: 9999; display: flex; flex-direction: column; 
-    align-items: center; justify-content: center;
-  `
-
-  const video = document.createElement('video')
-  video.style.cssText = `width: 100%; height: 80%; object-fit: cover;`
-  video.srcObject = stream
-  video.autoplay = true
-  video.playsInline = true
-
-  const captureBtn = document.createElement('button')
-  captureBtn.style.cssText = `
-    width: 80px; height: 80px; border-radius: 50%; background: #fff;
-    border: 4px solid #1989fa; margin-top: 20px; cursor: pointer;
-    font-size: 16px; color: #1989fa;
-  `
-  captureBtn.textContent = '拍照'
-
-  const closeBtn = document.createElement('button')
-  closeBtn.style.cssText = `
-    position: absolute; top: 20px; right: 20px; background: rgba(255,255,255,0.3);
-    border: none; color: white; font-size: 24px; width: 40px; height: 40px;
-    border-radius: 50%; cursor: pointer;
-  `
-  closeBtn.textContent = '×'
-
-  captureBtn.onclick = () => {
-    const canvas = document.createElement('canvas')
-    const context = canvas.getContext('2d')
-    canvas.width = video.videoWidth
-    canvas.height = video.videoHeight
-    context.drawImage(video, 0, 0)
-
-    canvas.toBlob(async (blob) => {
-      stream.getTracks().forEach(track => track.stop())
-      document.body.removeChild(previewDiv)
-      const file = new File([blob], 'camera-photo.jpg', { type: 'image/jpeg' })
-      handleCameraPhoto(file)
-    }, 'image/jpeg', 0.9)
-  }
-
-  closeBtn.onclick = () => {
-    stream.getTracks().forEach(track => track.stop())
-    document.body.removeChild(previewDiv)
-  }
-
-  previewDiv.appendChild(video)
-  previewDiv.appendChild(captureBtn)
-  previewDiv.appendChild(closeBtn)
-  document.body.appendChild(previewDiv)
-  video.play()
-}
-
-// 处理相机拍摄的照片
-const handleCameraPhoto = async (file) => {
-  const fileItem = {
-    file: file,
-    content: URL.createObjectURL(file),
-    status: 'uploading'
-  }
-  uploadImages.value = [fileItem]
-  await afterReadImage(fileItem)
-}
-
-// 移除图片
-const removeImage = () => {
-  uploadImages.value = []
-}
 
 // 自动上传图片
 const autoUploadImage = async (file) => {
@@ -357,7 +209,51 @@ const afterReadImage = async (file) => {
   }
 }
 
+// 提交OCR识别
+const submitOCR = async () => {
+  if (!uploadImages.value.length) {
+    showFailToast('请先选择图片')
+    return
+  }
+
+  if (!warehouse) {
+    showFailToast('未获取到仓库信息')
+    return
+  }
+
+  // 检查图片大小是否超过2MB
+  const image = uploadImages.value[0]
+  if (image.file.size > 2 * 1024 * 1024) {
+    showFailToast('图片大小不能超过2MB')
+    return
+  }
+
+  uploading.value = true
+  const toast = showLoadingToast('识别中...')
 
+  try {
+    const formData = new FormData()
+    formData.append('file', image.file)
+    formData.append('warehouse', warehouse)
+    
+    const response = await uploadOCRImage(image.file, warehouse)
+    
+    closeToast()
+    
+    if (response.code === 200) {
+      showNotify({ type: 'success', message: '面单上传成功' })
+      // 上传成功后重置表单
+      uploadImages.value = []
+    } else {
+      showNotify({ type: 'danger', message: response.message || '上传失败' })
+    }
+  } catch (err) {
+    closeToast()
+    showNotify({ type: 'danger', message: '识别过程发生异常: ' + (err.message || '未知错误') })
+  } finally {
+    uploading.value = false
+  }
+}
 
 
 
@@ -433,53 +329,6 @@ onMounted(() => {
   text-align: center
   background: rgba(0, 0, 0, 0.3)
 
-.camera-section
-  display: flex
-  flex-direction: column
-  align-items: center
-  margin-bottom: 20px
-
-.camera-button
-  width: 120px
-  height: 120px
-  border: 2px dashed #ccc
-  border-radius: 8px
-  display: flex
-  flex-direction: column
-  align-items: center
-  justify-content: center
-  cursor: pointer
-  transition: all 0.3s
-  background: #f8f8f8
-
-.camera-button:hover
-  border-color: #1989fa
-  background: #f0f8ff
-
-.camera-button:active
-  transform: scale(0.95)
-
-.camera-text
-  margin-top: 8px
-  font-size: 14px
-  color: #666
-
-.image-preview
-  display: flex
-  flex-direction: column
-  align-items: center
-  margin-bottom: 20px
-
-.preview-image
-  width: 200px
-  height: 200px
-  object-fit: cover
-  border-radius: 8px
-  margin-bottom: 10px
-
-.remove-btn
-  margin-top: 10px
-
 :deep(.van-uploader__upload)
   width: 100px
   height: 100px