Kaynağa Gözat

库存并库init

zh 3 ay önce
ebeveyn
işleme
daca4f2c90
1 değiştirilmiş dosya ile 97 ekleme ve 36 silme
  1. 97 36
      src/views/robot/merge/index.vue

+ 97 - 36
src/views/robot/merge/index.vue

@@ -2,13 +2,15 @@
   <div class="merge-container">
     <!-- 扫描输入框区域 -->
     <div class="scan-section">
-      <van-field
+      <van-search
         ref="boxCodeInputRef"
-        v-model="boxCode"
+        v-model.lazy="boxCode"
         placeholder="请扫描料箱号"
-        clearable
-        @click="onBoxCodeClick"
-        @keyup.enter="onBoxCodeEnter"
+        left-icon=""
+        :class="['scan-input', scanType === 1 ? 'scan-input-active' : '']"
+        @search="onBoxCodeEnter"
+        @focus="onBoxCodeClick"
+        autocomplete="off"
       />
     </div>
 
@@ -17,13 +19,15 @@
       <div class="table-row">
         <div class="cell label">源库位</div>
         <div class="cell value input-cell">
-          <van-field
+          <van-search
             ref="sourceLocationInputRef"
-            v-model="sourceLocation"
+            v-model.lazy="sourceLocation"
             placeholder="请扫描源库位"
-            clearable
-            @click="onSourceLocationClick"
-            @keyup.enter="onSourceLocationEnter"
+            left-icon=""
+            class="table-search-input"
+            @search="onSourceLocationEnter"
+            @focus="onSourceLocationClick"
+            autocomplete="off"
           />
         </div>
         <div class="cell label">库存数量</div>
@@ -36,13 +40,15 @@
       <div class="table-row">
         <div class="cell label">商品条码</div>
         <div class="cell value span-2 input-cell">
-          <van-field
+          <van-search
             ref="barcodeInputRef"
-            v-model="scanBarcode"
+            v-model.lazy="scanBarcode"
             placeholder="请扫描商品条码"
-            clearable
-            @click="onBarcodeClick"
-            @keyup.enter="onBarcodeEnter"
+            left-icon=""
+            class="table-search-input"
+            @search="onBarcodeEnter"
+            @focus="onBarcodeClick"
+            autocomplete="off"
           />
         </div>
       </div>
@@ -63,13 +69,15 @@
       <div class="table-row">
         <div class="cell label">目标库位</div>
         <div class="cell value input-cell input-wide">
-          <van-field
+          <van-search
             ref="targetLocationInputRef"
-            v-model="productInfo.targetLocationNew"
+            v-model.lazy="productInfo.targetLocationNew"
             placeholder="请扫描目标库位"
-            clearable
-            @click="onTargetLocationClick"
-            @keyup.enter="onTargetLocationEnter"
+            left-icon=""
+            class="table-search-input"
+            @search="onTargetLocationEnter"
+            @focus="onTargetLocationClick"
+            autocomplete="off"
           />
         </div>
         <div class="cell label">移库数量</div>
@@ -245,13 +253,30 @@ onMounted(() => {
   nextTick(() => {
     focusBoxCodeInput()
   })
+  // 防止键盘弹出时底部按钮上移
+  if (window.visualViewport) {
+    window.visualViewport.addEventListener('resize', handleViewportResize)
+  }
 })
 
 onUnmounted(() => {
   closeListener()
   stopPolling()
+  // 移除viewport监听
+  if (window.visualViewport) {
+    window.visualViewport.removeEventListener('resize', handleViewportResize)
+  }
 })
 
+// 处理viewport变化(键盘弹出/收起)
+const handleViewportResize = () => {
+  // 保持页面滚动位置,防止键盘弹出时页面跳动
+  const scrollTop = document.documentElement.scrollTop || document.body.scrollTop
+  requestAnimationFrame(() => {
+    window.scrollTo(0, scrollTop)
+  })
+}
+
 // 设置料箱号输入框焦点
 const focusBoxCodeInput = () => {
   nextTick(() => {
@@ -305,11 +330,12 @@ const _handlerScan = (code: string) => {
 
 // 料箱号输入框点击 - 重置所有数据
 const onBoxCodeClick = () => {
-  resetAllData()
+  scanType.value = 1
 }
 
 // 料箱号回车
 const onBoxCodeEnter = () => {
+  scanType.value = 1
   if (boxCode.value && boxCode.value.length > 5) {
     loadBoxData(boxCode.value)
   }
@@ -317,7 +343,7 @@ const onBoxCodeEnter = () => {
 
 // 源库位输入框点击 - 重置除料箱号外的数据
 const onSourceLocationClick = () => {
-  resetExceptBoxCode()
+  scanType.value = 2
 }
 
 // 源库位回车
@@ -334,7 +360,7 @@ const onSourceLocationEnter = () => {
 
 // 商品条码输入框点击 - 只重置商品信息
 const onBarcodeClick = () => {
-  resetProductInfo()
+  scanType.value = 3
 }
 
 // 目标库位输入框点击
@@ -944,9 +970,20 @@ const selectSubLocation = (station: StationItem, sub: SubLocation) => {
 
 // 确认选择库位
 const confirmSelectLocation = () => {
-  productInfo.targetLocationNew = currentLocation.id
-  showLocationPopup.value = false
-  showToast(`已选择库位: ${currentLocation.id}`)
+  if (currentLocation.recommendType === 'clear') {
+    // 推荐清空库位,填入源库位
+    sourceLocation.value = currentLocation.id
+    showLocationPopup.value = false
+    showToast(`已选择源库位: ${currentLocation.id}`)
+    // 切换到扫描商品条码
+    scanType.value = 3
+    focusBarcodeInput()
+  } else {
+    // 推荐保留库位,填入目标库位
+    productInfo.targetLocationNew = currentLocation.id
+    showLocationPopup.value = false
+    showToast(`已选择目标库位: ${currentLocation.id}`)
+  }
 }
 
 // 呼唤机器人
@@ -1050,8 +1087,25 @@ const submitMove = () => {
 .scan-section {
   margin-bottom: 12px;
 
-  :deep(.van-field) {
+  .scan-input {
+    padding: 0;
+    background: #fff;
     border-radius: 4px;
+
+    :deep(.van-search__content) {
+      background: #fff;
+      padding-left: 12px;
+    }
+
+    :deep(.van-field__control) {
+      font-size: 14px;
+    }
+
+    &.scan-input-active {
+      :deep(.van-search__content) {
+        border-bottom: 2px solid #1989fa;
+      }
+    }
   }
 }
 
@@ -1101,15 +1155,17 @@ const submitMove = () => {
     
       &.input-cell {
         padding: 0;
-    
-        :deep(.van-field) {
-          padding: 4px 6px;
-    
-          .van-field__body {
-            height: 24px;
+
+        .table-search-input {
+          padding: 0;
+          background: transparent;
+
+          :deep(.van-search__content) {
+            background: transparent;
+            padding-left: 6px;
           }
-    
-          .van-field__control {
+
+          :deep(.van-field__control) {
             font-size: 13px;
           }
         }
@@ -1288,18 +1344,23 @@ const submitMove = () => {
   justify-content: space-between;
   align-items: center;
   padding: 10px 12px;
+  padding-bottom: calc(10px + env(safe-area-inset-bottom));
   background: #fff;
   box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
+  z-index: 100;
+  /* 防止键盘弹出时上移 */
+  transform: translateZ(0);
 
   .btn-right {
     display: flex;
-    gap: 8px;
+    gap: 12px; /* 增加按钮间距 */
   }
 
   .van-button {
     height: 32px;
     font-size: 13px;
     padding: 0 12px;
+    min-width: 70px; /* 确保按钮最小宽度 */
   }
 
   .btn-robot {