From cb897aaeed0f3a24f91dc4265b8ff0d2b31284c6 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期日, 23 四月 2023 17:35:00 +0800
Subject: [PATCH] Merge pull request #829 from kairlec/wvp-28181-2.0

---
 web_src/src/components/dialog/catalogEdit.vue |   72 +++++++++++++++++++++++++++---------
 1 files changed, 54 insertions(+), 18 deletions(-)

diff --git a/web_src/src/components/dialog/catalogEdit.vue b/web_src/src/components/dialog/catalogEdit.vue
index 93d8f8d..e1cd8d2 100644
--- a/web_src/src/components/dialog/catalogEdit.vue
+++ b/web_src/src/components/dialog/catalogEdit.vue
@@ -12,24 +12,21 @@
     >
       <div id="shared" style="margin-top: 1rem;margin-right: 100px;">
         <el-form ref="form" :rules="rules" :model="form" label-width="140px" >
+<!--          <el-form-item >-->
+<!--            寤鸿鐨勭被鍨嬶細-->
+<!--            <br/>-->
+<!--            &emsp;&emsp;琛屾斂鍖哄垝锛堝彲閫�2浣�/4浣�/6浣�/8浣�/10浣嶆暟瀛楋紝渚嬪锛�130432锛岃〃绀烘渤鍖楃渷閭兏甯傚箍骞冲幙锛�-->
+<!--            <br/>-->
+<!--            &emsp;&emsp;涓氬姟鍒嗙粍锛堢11銆�12銆�13浣�215锛屼緥濡傦細34020000002150000001锛�-->
+<!--            <br/>-->
+<!--            &emsp;&emsp;铏氭嫙缁勭粐锛堢11銆�12銆�13浣�216锛屼緥濡傦細34020000002160000001锛�-->
+<!--          </el-form-item>-->
           <el-form-item label="鑺傜偣缂栧彿" prop="id" >
-            <el-tooltip class="item" effect="dark" content="" placement="top-start">
-              <div slot="content">
-                寤鸿鐨勭被鍨嬶細
-                <br/>
-                &emsp;&emsp;琛屾斂鍖哄垝锛堝彲閫�2浣�/4浣�/6浣�/8浣�/10浣嶆暟瀛楋紝渚嬪锛�130432锛岃〃绀烘渤鍖楃渷閭兏甯傚箍骞冲幙锛�
-                <br/>
-                &emsp;&emsp;涓氬姟鍒嗙粍锛堢11銆�12銆�13浣�215锛屼緥濡傦細34020000002150000001锛�
-                <br/>
-                &emsp;&emsp;铏氭嫙缁勭粐锛堢11銆�12銆�13浣�216锛屼緥濡傦細34020000002160000001锛�
-              </div>
-              <el-input v-model="form.id" :disabled="isEdit"></el-input>
-            </el-tooltip>
+            <el-input v-model="form.id" :disabled="isEdit" clearable></el-input>
           </el-form-item>
           <el-form-item label="鑺傜偣鍚嶇О" prop="name">
             <el-input v-model="form.name" clearable></el-input>
           </el-form-item>
-
 
           <el-form-item>
             <div style="float: right;">
@@ -52,11 +49,42 @@
   props: ['platformId'],
   created() {},
   data() {
+    let checkId = (rule, value, callback) => {
+      console.log("checkId")
+      console.log(this.treeType)
+      console.log(rule)
+      console.log(value)
+      console.log(value.length)
+      console.log(this.level)
+      if (!value) {
+        return callback(new Error('缂栧彿涓嶈兘涓虹┖'));
+      }
+      if (this.treeType === "BusinessGroup" && value.length !== 20) {
+        return callback(new Error('缂栧彿蹇呴』鐢�20浣嶆暟瀛楃粍鎴�'));
+      }
+      if (this.treeType === "CivilCode" && value.length <= 8 && value.length%2 !== 0) {
+        return callback(new Error('琛屾斂鍖哄垝蹇呴』鏄叓浣嶄互涓嬬殑鍋舵暟涓暟瀛楃粍鎴�'));
+      }
+      if (this.treeType === "BusinessGroup") {
+        let catalogType = value.substring(10, 13);
+        console.log(catalogType)
+        // 216 涓鸿櫄鎷熺粍缁� 215 涓轰笟鍔″垎缁勶紱鐩綍绗竴绾у繀椤讳负涓氬姟鍒嗙粍锛� 涓氬姟鍒嗙粍涓嬩负铏氭嫙缁勭粐锛岃櫄鎷熺粍缁囦笅鍙互鏈夊叾浠栬櫄鎷熺粍缁�
+        if (this.level === 1 && catalogType !== "215") {
+          return callback(new Error('涓氬姟鍒嗙粍妯″紡涓嬬涓�灞傜洰褰曠殑缂栧彿11鍒�13浣嶅繀椤讳负215'));
+        }
+        if (this.level > 1 && catalogType !== "216") {
+          return callback(new Error('涓氬姟鍒嗙粍妯″紡涓嬬涓�灞備互涓嬬洰褰曠殑缂栧彿11鍒�13浣嶅繀椤讳负216'));
+        }
+      }
+      callback();
+    }
     return {
       submitCallback: null,
       showDialog: false,
       isLoging: false,
       isEdit: false,
+      treeType: null,
+      level: 0,
       form: {
         id: null,
         name: null,
@@ -65,13 +93,14 @@
       },
       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, treeType, level, callback) {
       console.log("parentId: " + parentId)
+      console.log(this.form)
       this.isEdit = isEdit;
       this.form.id = id;
       this.form.name = name;
@@ -79,6 +108,8 @@
       this.form.parentId = parentId;
       this.showDialog = true;
       this.submitCallback = callback;
+      this.treeType = treeType;
+      this.level = level;
     },
     onSubmit: function () {
       console.log("onSubmit");
@@ -87,8 +118,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 {
@@ -105,8 +135,14 @@
         });
     },
     close: function () {
+      this.isEdit = false;
+      this.form.id = null;
+      this.form.name = null;
+      this.form.platformId = null;
+      this.form.parentId = null;
+      this.callback = null;
       this.showDialog = false;
-      this.$refs.form.resetFields();
+      console.log(this.form)
     },
   },
 };

--
Gitblit v1.8.0