YangJian0701 11 сар өмнө
parent
commit
fa35af17ce

BIN
ERP.rar


+ 22 - 11
src/views/storehouse/inventory/InStorageSn.vue

@@ -4,7 +4,7 @@ import { Delete } from '@element-plus/icons-vue'
 import Drawer from '@/components/Drawer/index.vue'
 import type { FormInstance, FormRules } from 'element-plus'
 import { Storehouse_Device_Check } from '@/api/storehouse/index'
-
+import { ElMessage } from 'element-plus'
 type Fn = () => void
 interface FormSnType {
   Id?: number
@@ -36,16 +36,27 @@ const addSn = (formEl: FormInstance | undefined) => {
   if (!formEl) return
   formEl.validate(async valid => {
     if (valid) {
-      const res: any = await Storehouse_Device_Check({ T_sn: formSn.sn, T_type: formSn.type })
-      if (res.Code === 200) {
-        tableSnData.value.push({ sn: formSn.sn })
-        tableSnData.value = tableSnData.value.filter((value, index, self) => {  //去重
-            return self.findIndex(t => (t.sn === value.sn)) === index;  
-        });  
-        nextTick(() => {
-          resetSnForm(ruleSnFormRef.value)
-        })
-      }
+        if (formSn.sn.length === 16 || formSn.sn.length === 24) {  
+            if(formSn.sn.length==24){
+                formSn.sn = formSn.sn.substring(2, formSn.sn.length - 6)
+            }  
+            const res: any = await Storehouse_Device_Check({ T_sn: formSn.sn, T_type: formSn.type })
+            if (res.Code === 200) {
+                tableSnData.value.unshift({ sn: formSn.sn })
+                tableSnData.value = tableSnData.value.filter((value, index, self) => {  //去重
+                    return self.findIndex(t => (t.sn === value.sn)) === index;  
+                });  
+                nextTick(() => {
+                    resetSnForm(ruleSnFormRef.value)
+                })
+            }
+        } else {  
+            ElMessage.error('扫描设备异常')
+            nextTick(() => {
+                resetSnForm(ruleSnFormRef.value)
+            })
+            return 
+        }  
     }
   })
 }