From b680585c3a6d43f0c72a83a115ea537ce8c91a07 Mon Sep 17 00:00:00 2001
From: 647556386 <647556386@qq.com>
Date: 星期六, 13 十二月 2025 17:44:10 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/ZhongRui/ALDbanyunxiangmu

---
 项目代码/WIDESEA_WMSClient/src/extension/inbound/extend/EmptyTrayInbound.vue |  154 +++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 131 insertions(+), 23 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/EmptyTrayInbound.vue" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/EmptyTrayInbound.vue"
index d80b08e..d1914ac 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/EmptyTrayInbound.vue"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/extend/EmptyTrayInbound.vue"
@@ -1,17 +1,17 @@
 <template>
     <vol-box v-model="show" title="绌烘墭鍏ュ簱" :width="800" :height="1200">
         <template #content>
-            <el-form ref="form" :model="form" label-width="90px">
-                <el-form-item label="鍏ュ簱鍖哄煙:">
+            <el-form ref="form" :model="form" :rules="rules" label-width="90px">
+                <el-form-item label="鍏ュ簱鍖哄煙:" prop="locationType">
                     <el-select v-model="form.locationType" placeholder="璇烽�夋嫨鍏ュ簱鍖哄煙">
                         <el-option v-for="item in locationTypes" :key="item.locationType" :label="item.locationTypeDesc"
                             :value="item.locationType" />
                     </el-select>
                 </el-form-item>
 
-                <el-form-item label="鎵樼洏鏉$爜:">
-                    <el-input v-model="form.palletCode" placeholder="璇锋壂鎻�/杈撳叆鎵樼洏鏉$爜" @keyup.enter="submit" @keyup.13="submit"
-                        clearable maxlength="50" @paste="handlePaste" @input="handleInput" />
+                <el-form-item label="鎵樼洏鏉$爜:" prop="palletCode">
+                    <el-input v-model="form.palletCode" placeholder="璇锋壂鎻�/杈撳叆鎵樼洏鏉$爜锛圓寮�澶达紝鍚庤窡鏁板瓧锛�" @keyup.enter="submit" clearable
+                        @paste="handlePaste" @input="handleInput" ref="boxCodeInput" />
                 </el-form-item>
             </el-form>
         </template>
@@ -34,19 +34,46 @@
         value: { type: Boolean, default: false }
     },
     data() {
+        // 鑷畾涔夋潯鐮侀獙璇佽鍒�
+        const validatePalletCode = (rule, value, callback) => {
+            if (!value) {
+                return callback(new Error('璇疯緭鍏ユ墭鐩樻潯鐮�'));
+            }
+
+            // 楠岃瘉鏉$爜鏍煎紡锛欰寮�澶达紝鍚庨潰鑷冲皯1浣嶆暟瀛楋紙涓嶉檺鍒跺叿浣撻暱搴︼級
+            const codePattern = /^A\d+$/;
+            if (!codePattern.test(value)) {
+                return callback(new Error('鏉$爜鏍煎紡涓嶆纭紒姝g‘鏍煎紡锛欰寮�澶达紝鍚庤窡鏁板瓧锛屽锛欰000008080'));
+            }
+
+            callback();
+        };
+
         return {
             show: false,
             form: {
                 palletCode: '',
                 locationType: ''
             },
-            locationTypes: []
+            locationTypes: [],
+            // 琛ㄥ崟楠岃瘉瑙勫垯
+            rules: {
+                locationType: [
+                    { required: true, message: '璇烽�夋嫨鍏ュ簱鍖哄煙', trigger: 'change' }
+                ],
+                palletCode: [
+                    { validator: validatePalletCode, trigger: ['blur', 'change'] }
+                ]
+            }
         }
     },
     methods: {
         open() {
             this.show = true
             this.getData();
+            this.$nextTick(() => {
+                this.focusInput()
+            })
         },
 
         async getData() {
@@ -59,14 +86,13 @@
         },
 
         async submit() {
-            if (!this.form.palletCode) {
-                this.$message.warning('璇疯緭鍏ユ墭鐩樻潯鐮�')
-                return
-            }
-
-            if (!this.form.locationType) {
-                this.$message.warning('璇烽�夋嫨鍏ュ簱鍖哄煙')
-                return
+            // 琛ㄥ崟楠岃瘉
+            try {
+                await this.$refs.form.validate();
+            } catch (error) {
+                // 楠岃瘉澶辫触锛岃仛鐒﹁緭鍏ユ
+                this.focusAndSelectInput();
+                return;
             }
 
             try {
@@ -81,26 +107,108 @@
                 )
 
                 if (status) {
-                    this.$message.success("缁勭洏鎴愬姛")
-                    this.show = false
-                    this.$emit('refresh')
+                    this.$message.success("缁勭洏鎴愬姛");
+                    // 娓呯┖杈撳叆妗嗘暟鎹�
+                    this.form.palletCode = '';
+                    // 閲嶇疆楠岃瘉鐘舵��
+                    this.$refs.form.clearValidate('palletCode');
+                    // 鑱氱劍骞堕�変腑杈撳叆妗�
+                    this.focusAndSelectInput();
                 } else {
-                    this.$message.error(message || '鎿嶄綔澶辫触')
+                    this.$message.error(message || '鎿嶄綔澶辫触');
+                    // 澶辫触鏃朵笉娓呯悊鏁版嵁锛屼絾鑱氱劍骞堕�変腑杈撳叆妗嗭紝鏂逛究淇敼
+                    this.focusAndSelectInput();
                 }
             } catch (error) {
-                this.$message.error('璇锋眰寮傚父')
+                this.$message.error('璇锋眰寮傚父');
+                // 寮傚父鏃朵篃涓嶆竻鐞嗘暟鎹�
+                this.focusAndSelectInput();
             }
         },
 
         // 鎵弿鏋紭鍖栧鐞�
         handleInput(value) {
-            // 杩囨护闈炴暟瀛楀拰鏉$爜甯哥敤瀛楃
-            this.form.palletCode = value.replace(/[^a-zA-Z0-9\-]/g, '')
+            // 杩囨护闈炴暟瀛楀拰鏉$爜甯哥敤瀛楃锛屽厑璁窤寮�澶�
+            this.form.palletCode = value.replace(/[^a-zA-Z0-9]/g, '')
+
+            // 鑷姩杞崲涓哄ぇ鍐欙紙鏉$爜閫氬父涓哄ぇ鍐欙級
+            this.form.palletCode = this.form.palletCode.toUpperCase();
+
+            // 鑷姩瑙﹀彂楠岃瘉
+            this.$nextTick(() => {
+                this.$refs.form.validateField('palletCode');
+            });
         },
 
         handlePaste(e) {
-            // 绮樿创鏃惰嚜鍔ㄦ彁浜�
-            setTimeout(this.submit, 100)
+            // 鑾峰彇绮樿创鐨勫唴瀹�
+            const clipboardData = e.clipboardData || window.clipboardData;
+            const pastedText = clipboardData.getData('text');
+
+            // 澶勭悊绮樿创鍐呭
+            const cleanedText = pastedText.replace(/[^a-zA-Z0-9]/g, '').toUpperCase();
+
+            // 濡傛灉绮樿创鍐呭绗﹀悎鏉$爜鏍煎紡锛岃嚜鍔ㄥ~鍏呭苟鎻愪氦
+            if (cleanedText.startsWith('A')) {
+                this.form.palletCode = cleanedText;
+                // 寤惰繜鎻愪氦锛岀‘淇濊〃鍗曞凡鏇存柊
+                setTimeout(() => {
+                    this.submit();
+                }, 50);
+            }
+
+            // 闃绘榛樿绮樿创琛屼负锛屼娇鐢ㄦ垜浠鐞嗗悗鐨勫��
+            e.preventDefault();
+        },
+
+        // 鑱氱劍骞堕�変腑杈撳叆妗�
+        focusAndSelectInput() {
+            this.$nextTick(() => {
+                setTimeout(() => {
+                    const inputRef = this.$refs.boxCodeInput;
+                    if (inputRef) {
+                        // Element Plus/Element UI 鐨勫鐞嗘柟寮�
+                        const inputEl = inputRef.$el ? inputRef.$el.querySelector('input') : inputRef;
+                        if (inputEl) {
+                            inputEl.focus();
+                            inputEl.select();
+                        }
+                    }
+                }, 100);
+            });
+        },
+
+        // 鍙仛鐒﹁緭鍏ユ锛堜笉娓呯┖鏁版嵁锛�
+        focusInput() {
+            this.$nextTick(() => {
+                const inputRef = this.$refs.boxCodeInput;
+                if (inputRef) {
+                    const inputEl = inputRef.$el ? inputRef.$el.querySelector('input') : inputRef;
+                    inputEl?.focus();
+                }
+            });
+        },
+
+        // 娓呯┖琛ㄥ崟鏁版嵁
+        clearForm() {
+            this.form.palletCode = '';
+            // 閲嶇疆楠岃瘉鐘舵��
+            if (this.$refs.form) {
+                this.$refs.form.clearValidate();
+            }
+            // 涓嶆竻绌� locationType锛屼繚鎸佸尯鍩熼�夋嫨
+        }
+    },
+    watch: {
+        show(val) {
+            if (val) {
+                this.$nextTick(() => {
+                    this.focusInput()
+                })
+            } else {
+                // 鍏抽棴寮圭獥鏃舵竻绌鸿〃鍗�
+                this.clearForm();
+            }
         }
     }
 }

--
Gitblit v1.9.3