From ee07d050ac5e52ded8f0de0872085ef9b00790ee Mon Sep 17 00:00:00 2001
From: fujunling <2984387807@qq.com>
Date: 星期一, 05 六月 2023 18:09:21 +0800
Subject: [PATCH] 动态表单

---
 Source/UBCS-WEB/src/components/FormTemplate/index.vue |   57 +++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 39 insertions(+), 18 deletions(-)

diff --git a/Source/UBCS-WEB/src/components/FormTemplate/index.vue b/Source/UBCS-WEB/src/components/FormTemplate/index.vue
index d04ed50..f99d7b4 100644
--- a/Source/UBCS-WEB/src/components/FormTemplate/index.vue
+++ b/Source/UBCS-WEB/src/components/FormTemplate/index.vue
@@ -13,14 +13,22 @@
       v-bind="$attrs"
       :visible="visible"
       :type="type"
+      :rowOid="rowOid"
       v-if="dialogVisible"
       ref="FormTempalte"
       @getFormTemplateEnd="getFormTemplate"
       @getFormData="getFormData"
     ></FormTempalte>
 
-    <div class="tab_box" v-if="type !== 'detail' && dialogVisible && (showCodeApply || showResembleQuery)">
-      <el-tabs v-model="activeName" type="border-card">
+    <div
+      class="tab_box"
+      v-if="
+        type !== 'detail' &&
+        dialogVisible &&
+        (showCodeApply || showResembleQuery)
+      "
+    >
+      <el-tabs v-model="activeName" type="border-card" @tab-click="handleClick">
         <el-tab-pane label="鐮佸�肩敵璇�" name="codeApply" v-if="showCodeApply">
           <CodeApply
             ref="CodeApply"
@@ -48,7 +56,10 @@
       <el-button @click="submit()" type="primary" :loading="submitBtnLoading"
         >纭� 瀹�</el-button
       >
-      <el-button @click="resembleQuerySubmit" type="primary" v-if="showResembleQuery"
+      <el-button
+        @click="resembleQuerySubmit"
+        type="primary"
+        v-if="showResembleQuery"
         >鐩镐技鍍忔煡璇�</el-button
       >
     </div>
@@ -79,6 +90,7 @@
       type: String,
       default: "80%",
     },
+    rowOid: ''
   },
   data() {
     return {
@@ -88,6 +100,7 @@
       resembleTableColumn: [],
       secVOList: [],
       form: {},
+      activeName: "",
     };
   },
   created() {},
@@ -101,29 +114,25 @@
       },
     },
     showCodeApply() {
-      if (this.type === "add") {
-        if (this.hasResemble && this.secVOList.length === 0) {
-          return false;
-        }
-      } else {
-        return false;
-      }
+      // 娴嬭瘯鏁版嵁灞曠ず
+      // if (this.type === "add") {
+      //   if (this.hasResemble && this.secVOList.length === 0) {
+      //     return false;
+      //   }
+      // } else {
+      //   return false;
+      // }
       return true;
     },
     showResembleQuery() {
       return this.hasResemble;
-    },
-    activeName() {
-      return (
-        (this.showCodeApply && "codeApply") ||
-        (this.showResembleQuery && "resembleQuery")
-      );
     },
   },
   methods: {
     openDialog() {
       this.$nextTick(() => {
         this.$refs.FormTempalte.init();
+        this.$refs.CodeApply.getCodeRule();
       });
     },
     close() {
@@ -138,6 +147,9 @@
         data.resembleTableVO.cols &&
         data.resembleTableVO.cols.length > 0;
       this.resembleTableColumn = data.resembleTableVO.cols || [];
+      this.activeName =
+        (this.showCodeApply && "codeApply") ||
+        (this.showResembleQuery && "resembleQuery");
     },
     getFormData(form) {
       this.form = form;
@@ -145,12 +157,21 @@
     resembleQuerySubmit() {
       this.$refs.resembleQueryRef.resembleQuery(this.form);
     },
+    handleClick() {
+      if (this.activeName === 'resembleQuery') {
+        this.resembleQuerySubmit()
+      }
+    },
     async submit() {
       const formValidate = await this.$refs.FormTempalte.validate();
+      let codeValidate = true;
       if (this.showCodeApply) {
-        const codeValidate = this.$refs.CodeApply.validate();
-        console.log(formValidate, codeValidate);
+        codeValidate = await this.$refs.CodeApply.validate();
       }
+      this.$emit("submit", {
+        form: this.form,
+        flag: formValidate && codeValidate,
+      });
     },
   },
 };

--
Gitblit v1.9.3