Ver Fonte

处理待办审批动态表格数据回显问题/解决新的顶部按钮新增时表单残留数据问题

lph há 1 ano atrás
pai
commit
954f218897

+ 8 - 3
zkqy-ui/src/components/FormGroup/Approve.vue

@@ -183,6 +183,7 @@ export default {
       return "";
     },
     setDefaultValue() {
+      console.log("this.defaultValueObj", this.defaultValueObj);
       for (const key in this.defaultValueObj) {
         // console.log(this.$refs[key], key);
         this.$refs[key][0]?.setData(this.defaultValueObj[key]);
@@ -213,9 +214,13 @@ export default {
             : JSON.parse(item.template.dfVueTemplate)
         );
         if (item.template.resultMap) {
-          item.template.defaultValue = item.template.resultMap[0]?.resultMap
-            ? item.template.resultMap[0].resultMap
-            : {};
+          if (item.template.resultMap[0]?.batch) {
+            item.template.defaultValue = item.template.resultMap[0];
+          } else {
+            item.template.defaultValue = item.template.resultMap[0]?.resultMap
+              ? item.template.resultMap[0].resultMap
+              : {};
+          }
         }
 
         for (const key of Object.keys(item.template?.defaultValue || {})) {

+ 53 - 2
zkqy-ui/src/views/bussiness/OAMange.vue

@@ -212,6 +212,7 @@ import receiptDocuments from "@/utils/print/receiptDocuments";
 import qrCodeList from "@/utils/print/qrCodeList.js";
 import { xmlStr2XmlObj } from "@/utils/bpmn/tool";
 import { submitNodeForm } from "@/api/bpmprocess/runDialogApi/index";
+import { camelCase, toUnderline } from "@/utils";
 
 export default {
   name: "processMange",
@@ -394,15 +395,65 @@ export default {
       });
       if (subFormList && subFormList.length > 0) {
         subFormList.forEach((item) => {
-          let showValue = item.showValue[0];
+          let showValue = null;
+          if (item.showValue) {
+            showValue = item.showValue[0];
+          }
+          let defaultValue = {};
           if (showValue) {
-            item.showTemplate.resultMap = mainForm.showValue;
+            if (item.showTemplate.spare == "2") {
+              //动态表格表单
+              let batch = {},
+                tableName = item.formItem?.split(".")?.[0];
+              batch[tableName] = item.showValue.map((item) => item.resultMap);
+              defaultValue = JSON.parse(JSON.stringify(batch));
+              console.log(JSON.parse(JSON.stringify(batch)));
+              // 所有字段驼峰转下划线
+              batch[tableName].forEach((i) => {
+                for (const key of Object.keys(i)) {
+                  i[toUnderline(key)] = i[key];
+                  if (toUnderline(key) != key) {
+                    delete i[key];
+                  }
+                }
+              });
+              item.showTemplate.resultMap = [
+                {
+                  batch,
+                },
+              ];
+            } else {
+              for (const key of Object.keys(item.showValue[0].resultMap)) {
+                item.showValue[0].resultMap[toUnderline(key)] =
+                  item.showValue[0].resultMap[key];
+              }
+
+              item.showTemplate.resultMap = [item.showValue[0].resultMap];
+            }
           }
           this.formList.push({
             template: item.showTemplate,
             tableName: item.formItem?.split(".")?.[0],
           });
+          // this.FormNameList.push({
+          //   tableName: item.formItem?.split(".")?.[0],
+          //   formItem: item.formItem,
+          //   relateFormItem: item.relateMainItem,
+          //   formType: item.showTemplate.spare == "2" ? "batch" : "normal",
+          //   defaultValue,
+          //   insertMap: item.insertMap,
+          // });
         });
+        // subFormList.forEach((item) => {
+        //   let showValue = item.showValue[0];
+        //   if (showValue) {
+        //     item.showTemplate.resultMap = mainForm.showValue;
+        //   }
+        //   this.formList.push({
+        //     template: item.showTemplate,
+        //     tableName: item.formItem?.split(".")?.[0],
+        //   });
+        // });
       }
     },
     toDetail(row) {

+ 6 - 0
zkqy-ui/src/views/tablelist/commonTable/listInfo.vue

@@ -920,6 +920,12 @@ export default {
             this.jsonData = JSON.parse(templateData);
             this.open = true;
             this.title = btnGroupType == "top" ? "新增信息" : "修改信息";
+            if (btnGroupType == "top") {
+              //新增  重置表单
+              this.$nextTick(() => {
+                this.$refs.addFromRef.reset();
+              });
+            }
             this.form.password = this.initPassword;
             if (btnGroupType == "right") {
               this.$nextTick(() => {