From 4619d729fbf0f3a6971fbb236e40187454a9c6cf Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期六, 13 十二月 2025 09:47:29 +0800
Subject: [PATCH] 1

---
 项目代码/WIDESEA_WMSClient/src/extension/inbound/extend/EmptyTrayInbound.vue |   96 +++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 74 insertions(+), 22 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 7105202..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" ref="boxCodeInput" />
+                <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,13 +34,37 @@
         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: {
@@ -62,15 +86,13 @@
         },
 
         async submit() {
-            if (!this.form.palletCode) {
-                this.$message.warning('璇疯緭鍏ユ墭鐩樻潯鐮�')
-                this.focusInput()
-                return
-            }
-
-            if (!this.form.locationType) {
-                this.$message.warning('璇烽�夋嫨鍏ュ簱鍖哄煙')
-                return
+            // 琛ㄥ崟楠岃瘉
+            try {
+                await this.$refs.form.validate();
+            } catch (error) {
+                // 楠岃瘉澶辫触锛岃仛鐒﹁緭鍏ユ
+                this.focusAndSelectInput();
+                return;
             }
 
             try {
@@ -88,6 +110,8 @@
                     this.$message.success("缁勭洏鎴愬姛");
                     // 娓呯┖杈撳叆妗嗘暟鎹�
                     this.form.palletCode = '';
+                    // 閲嶇疆楠岃瘉鐘舵��
+                    this.$refs.form.clearValidate('palletCode');
                     // 鑱氱劍骞堕�変腑杈撳叆妗�
                     this.focusAndSelectInput();
                 } else {
@@ -104,15 +128,39 @@
 
         // 鎵弿鏋紭鍖栧鐞�
         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(() => {
@@ -129,7 +177,7 @@
                 }, 100);
             });
         },
-        
+
         // 鍙仛鐒﹁緭鍏ユ锛堜笉娓呯┖鏁版嵁锛�
         focusInput() {
             this.$nextTick(() => {
@@ -140,10 +188,14 @@
                 }
             });
         },
-        
+
         // 娓呯┖琛ㄥ崟鏁版嵁
         clearForm() {
             this.form.palletCode = '';
+            // 閲嶇疆楠岃瘉鐘舵��
+            if (this.$refs.form) {
+                this.$refs.form.clearValidate();
+            }
             // 涓嶆竻绌� locationType锛屼繚鎸佸尯鍩熼�夋嫨
         }
     },

--
Gitblit v1.9.3