From bc90fb7e0c6c8313e7d5fcf3aba57e3a1f975c93 Mon Sep 17 00:00:00 2001
From: 田源 <lastanimals@163.com>
Date: 星期四, 15 八月 2024 17:39:45 +0800
Subject: [PATCH] 对象建模模块,保存统一先进行正则校验(之间是失焦才进行校验)

---
 Source/plt-web/plt-web-ui/src/views/modelingMenu/modeling/enumType/index.vue |  122 ++++++++++++++++++++++------------------
 1 files changed, 66 insertions(+), 56 deletions(-)

diff --git a/Source/plt-web/plt-web-ui/src/views/modelingMenu/modeling/enumType/index.vue b/Source/plt-web/plt-web-ui/src/views/modelingMenu/modeling/enumType/index.vue
index 1fb7931..8ef3a18 100644
--- a/Source/plt-web/plt-web-ui/src/views/modelingMenu/modeling/enumType/index.vue
+++ b/Source/plt-web/plt-web-ui/src/views/modelingMenu/modeling/enumType/index.vue
@@ -84,9 +84,9 @@
           </el-form>
 
           <span slot="footer" class="dialog-footer">
-        <el-button type="primary" @click="rowSaveHandler">纭� 瀹�</el-button>
-        <el-button @click="dialogVisible = false">鍙� 娑�</el-button>
-      </span>
+            <el-button @click="dialogVisible = false">鍙� 娑�</el-button>
+            <el-button type="primary" @click="rowSaveHandler">纭� 瀹�</el-button>
+          </span>
         </el-dialog>
 
         <!-- 鏌ョ湅浣跨敤鑼冨洿    -->
@@ -243,7 +243,7 @@
       dialogData: [],
       dialogOption: {
         ...basicOption,
-        calcHeight:50,
+        calcHeight: 50,
         refreshBtn: false,
         selection: false,
         column: [
@@ -377,8 +377,12 @@
         row,
         this.$refs.userCrud,
         this.lastIndex,
-        (newIndex) => { this.lastIndex = newIndex; },
-        () => { this.selectList = []; }
+        (newIndex) => {
+          this.lastIndex = newIndex;
+        },
+        () => {
+          this.selectList = [];
+        }
       );
     },
 
@@ -473,61 +477,67 @@
 
     // 瀵硅瘽妗嗘灇涓句繚瀛�
     rowSaveHandler() {
-      const lengthStatus = this.dialogData.some(item => item.value.length > this.form.length)
-      if (lengthStatus) {
-        this.$message.error('璇锋鏌ユ灇涓惧�兼槸鍚﹁秴杩囨渶澶ч暱搴︼紒')
-        return;
-      }
-
-      if (this.form.enumValueDataType === "Integer") {
-        // 鍒ゆ柇鏄惁鍖呭惈闈炴暟瀛楀瓧绗�
-        const integerStatus = this.dialogData.some(item => {
-          if (!/^\-?\d+$/.test(item.value)) {
-            return true;
+      const lengthStatus = this.dialogData.some(item => item.value.length > this.form.length);
+      this.$refs.form.validate((valid) => {
+        if (valid) {
+          if (lengthStatus) {
+            this.$message.error('璇锋鏌ユ灇涓惧�兼槸鍚﹁秴杩囨渶澶ч暱搴︼紒')
+            return;
           }
-        })
 
-        // 鍒ゆ柇鏄惁鏄痠nteger鏍煎紡
-        const integerNumStatus = this.dialogData.some(item => {
-          let numValue = parseInt(item.value);
-          if (isNaN(numValue) || !Number.isInteger(numValue)) {
-            return true;
+          if (this.form.enumValueDataType === "Integer") {
+            // 鍒ゆ柇鏄惁鍖呭惈闈炴暟瀛楀瓧绗�
+            const integerStatus = this.dialogData.some(item => {
+              if (!/^\-?\d+$/.test(item.value)) {
+                return true;
+              }
+            })
+
+            // 鍒ゆ柇鏄惁鏄痠nteger鏍煎紡
+            const integerNumStatus = this.dialogData.some(item => {
+              let numValue = parseInt(item.value);
+              if (isNaN(numValue) || !Number.isInteger(numValue)) {
+                return true;
+              }
+            })
+
+            if (integerStatus || integerNumStatus) {
+              this.$message.error('鏋氫妇鍊煎繀椤绘槸Integer绫诲瀷');
+              return;
+            }
           }
-        })
 
-        if (integerStatus || integerNumStatus) {
-          this.$message.error('鏋氫妇鍊煎繀椤绘槸Integer绫诲瀷');
-          return;
+          if (this.dialogType === 'add') {
+            let params = {
+              ...this.form,
+              items: this.dialogData
+            }
+            addEnumType(params).then(res => {
+              if (res.data.code === 200) {
+                this.$message.success(res.data.obj);
+                this.dialogVisible = false;
+                this.getTableList();
+              }
+            })
+          } else if (this.dialogType === 'edit') {
+            let params = {
+              ...this.form,
+              items: this.dialogData,
+              oid: this.editRow.oid,
+              ts: this.editRow.ts
+            }
+            updateEnumType(params).then(res => {
+              if (res.data.code === 200) {
+                this.$message.success(res.data.obj);
+                this.dialogVisible = false;
+                this.getTableList();
+              }
+            })
+          }
+        } else {
+          return false;
         }
-      }
-
-      if (this.dialogType === 'add') {
-        let params = {
-          ...this.form,
-          items: this.dialogData
-        }
-        addEnumType(params).then(res => {
-          if (res.data.code === 200) {
-            this.$message.success(res.data.obj);
-            this.dialogVisible = false;
-            this.getTableList();
-          }
-        })
-      } else if (this.dialogType === 'edit') {
-        let params = {
-          ...this.form,
-          items: this.dialogData,
-          oid: this.editRow.oid,
-          ts: this.editRow.ts
-        }
-        updateEnumType(params).then(res => {
-          if (res.data.code === 200) {
-            this.$message.success(res.data.obj);
-            this.dialogVisible = false;
-            this.getTableList();
-          }
-        })
-      }
+      });
     },
 
     // 鏋氫妇椤规柊澧�

--
Gitblit v1.9.3