From 9e28923b8c1c333df8ce3caf741b0e16da2ed48a Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期二, 20 六月 2023 14:15:27 +0800
Subject: [PATCH] Merge branch 'wvp-28181-2.0' into wvp-28181-2.0

---
 web_src/src/components/dialog/catalogEdit.vue |   52 +++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 47 insertions(+), 5 deletions(-)

diff --git a/web_src/src/components/dialog/catalogEdit.vue b/web_src/src/components/dialog/catalogEdit.vue
index 13cabfb..e2fe59b 100644
--- a/web_src/src/components/dialog/catalogEdit.vue
+++ b/web_src/src/components/dialog/catalogEdit.vue
@@ -46,14 +46,56 @@
 export default {
   name: "catalogEdit",
   computed: {},
-  props: ['platformId'],
+  props: ['platformId', 'platformDeviceId'],
   created() {},
   data() {
+    let checkId = (rule, value, callback) => {
+      console.log("checkId")
+      console.log(rule)
+      console.log(value)
+      console.log(value.length)
+      console.log(this.level)
+      if (!value) {
+        return callback(new Error('缂栧彿涓嶈兘涓虹┖'));
+      }
+      if (value.trim().length <= 8) {
+        if (value.trim().length%2 !== 0) {
+          return callback(new Error('琛屾斂鍖哄垝缂栧彿蹇呴』涓�2/4/6/8浣�'));
+        }
+        if (this.form.parentId !== this.platformDeviceId && this.form.parentId.length >= value.trim().length) {
+          return callback(new Error('琛屾斂鍖哄垝缂栧彿闀垮害搴旇姣忔涓や綅閫掑'));
+        }
+      }else {
+        if (value.trim().length !== 20) {
+          return callback(new Error('缂栧彿蹇呴』涓�2/4/6/8浣嶇殑琛屾斂鍖哄垝鎴�20浣嶇殑铏氭嫙缁勭粐/涓氬姟鍒嗙粍'));
+        }
+        let catalogType = value.substring(10, 13);
+        console.log(catalogType)
+        if (catalogType !== "215" && catalogType !== "216") {
+          return callback(new Error('缂栧彿閿欒锛屼笟鍔″垎缁�11-13浣嶄负215锛岃櫄鎷熺粍缁�11-13浣嶄负216'));
+        }
+        if (catalogType === "216") {
+
+          if (this.form.parentId !== this.platformDeviceId){
+            if (this.form.parentId.length <= 8) {
+              return callback(new Error('缂栧彿閿欒锛屽缓绔嬭櫄鎷熺粍缁囧墠蹇呴』鍏堝缓绔嬩笟鍔″垎缁勶紙11-13浣嶄负215锛�'));
+            }
+          }
+        }
+        if (catalogType === "215") {
+          if (this.form.parentId.length === "215") {
+            return callback(new Error('缂栧彿閿欒锛屼笟鍔″垎缁勪笅鍙兘寤虹珛铏氭嫙缁勭粐锛�11-13浣嶄负216锛�'));
+          }
+        }
+      }
+      callback();
+    }
     return {
       submitCallback: null,
       showDialog: false,
       isLoging: false,
       isEdit: false,
+      level: 0,
       form: {
         id: null,
         name: null,
@@ -62,12 +104,12 @@
       },
       rules: {
         name: [{ required: true, message: "璇疯緭鍏ュ悕绉�", trigger: "blur" }],
-        id: [{ required: true, message: "璇疯緭鍏D", trigger: "blur" }]
+        id: [{ required: true, trigger: "blur",validator: checkId  }]
       },
     };
   },
   methods: {
-    openDialog: function (isEdit, id, name, parentId, callback) {
+    openDialog: function (isEdit, id, name, parentId, level, callback) {
       console.log("parentId: " + parentId)
       console.log(this.form)
       this.isEdit = isEdit;
@@ -77,6 +119,7 @@
       this.form.parentId = parentId;
       this.showDialog = true;
       this.submitCallback = callback;
+      this.level = level;
     },
     onSubmit: function () {
       console.log("onSubmit");
@@ -85,8 +128,7 @@
         method:"post",
         url:`/api/platform/catalog/${!this.isEdit? "add":"edit"}`,
         data: this.form
-      })
-        .then((res)=> {
+      }).then((res)=> {
           if (res.data.code === 0) {
             if (this.submitCallback)this.submitCallback(this.form)
           }else {

--
Gitblit v1.8.0