Prechádzať zdrojové kódy

处理码单管理异常报错问题/解决表单组渲染异常问题

lph 1 rok pred
rodič
commit
6d949844e9

+ 40 - 35
zkqy-ui/src/components/FormGroup/formList.vue

@@ -7,7 +7,7 @@
     >
       <k-form-build
         :dynamicData="item.template.dfFormSql || {}"
-        :defaultValue="{}"
+        :defaultValue="item.template.defaultValue || {}"
         class="formBuild"
         :ref="item.tableName"
         :value="item.template.dfVueTemplate"
@@ -22,6 +22,7 @@
 import { camelCase, toUnderline } from "@/utils/index";
 import { disableFormItem } from "@/utils/kFormDesign";
 import { uuid as uuidv4 } from "uuid";
+
 export default {
   name: "Approve",
   props: {
@@ -102,11 +103,11 @@ export default {
   },
   watch: {
     myFormList: {
-      handler(val) {
+      async handler(val) {
         // this.$emit("update:formList", val);
         console.log(JSON.parse(JSON.stringify(val)));
         let temp = JSON.parse(JSON.stringify(val));
-        this.formArray = this.disableHandler(temp);
+        this.formArray = await this.disableHandler(temp);
         this.$nextTick(() => {
           console.log("表单组渲染");
           // setTimeout(() => {
@@ -138,7 +139,8 @@ export default {
         this.defaultValue[item.tableName] = item.template?.defaultValue || {};
       });
       for (const key in this.defaultValue) {
-        console.log(this.defaultValue);
+        console.log(JSON.parse(JSON.stringify(this.defaultValue)));
+        console.log(this.$refs[key]);
         this.$refs[key][0]?.setData(this.defaultValue[key]);
       }
     },
@@ -153,41 +155,44 @@ export default {
      */
     disableHandler(formList) {
       this.resetForm();
-      if (formList.length == 0) return [];
-      formList.forEach((item) => {
-        item.template.dfFormSql =
-          typeof item.template.dfFormSql == "object"
-            ? item.template.dfFormSql
-            : JSON.parse(item.template.dfFormSql);
-        // item.template.dfVueTemplate = disableFormItem(
-        //   typeof item.template.dfVueTemplate == "object"
-        //     ? item.template.dfVueTemplate
-        //     : JSON.parse(item.template.dfVueTemplate)
-        // );
-        item.template.dfVueTemplate =
-          typeof item.template.dfVueTemplate == "object"
-            ? item.template.dfVueTemplate
-            : JSON.parse(item.template.dfVueTemplate);
+      return new Promise((resolve, reject) => {
+        if (formList.length == 0) resolve([]);
 
-        if (item.template.resultMap) {
-          item.template.defaultValue = item.template.resultMap[0]
-            ? item.template.resultMap[0]
-            : {};
-        }
+        formList.forEach((item) => {
+          item.template.dfFormSql =
+            typeof item.template.dfFormSql == "object"
+              ? item.template.dfFormSql
+              : JSON.parse(item.template.dfFormSql);
+          // item.template.dfVueTemplate = disableFormItem(
+          //   typeof item.template.dfVueTemplate == "object"
+          //     ? item.template.dfVueTemplate
+          //     : JSON.parse(item.template.dfVueTemplate)
+          // );
+          item.template.dfVueTemplate =
+            typeof item.template.dfVueTemplate == "object"
+              ? item.template.dfVueTemplate
+              : JSON.parse(item.template.dfVueTemplate);
 
-        // for (const key of Object.keys(item.template?.defaultValue || {})) {
-        //   item.template.defaultValue[toUnderline(key)] =
-        //     item.template.defaultValue[key];
-        // }
-        // this.defaultValue[item.tableName] = item.template?.defaultValue || {};
+          if (item.template.resultMap) {
+            item.template.defaultValue = item.template.resultMap[0]
+              ? item.template.resultMap[0]
+              : {};
+          }
 
-        // this.$nextTick(() => {
-        //   Object.assign(this.defaultValue, item.template.defaultValue);
-        // });
-        // item.formInfo.jsonData = disableFormItem(item.formInfo.jsonData);
-      });
+          // for (const key of Object.keys(item.template?.defaultValue || {})) {
+          //   item.template.defaultValue[toUnderline(key)] =
+          //     item.template.defaultValue[key];
+          // }
+          // this.defaultValue[item.tableName] = item.template?.defaultValue || {};
 
-      return formList;
+          // this.$nextTick(() => {
+          //   Object.assign(this.defaultValue, item.template.defaultValue);
+          // });
+          // item.formInfo.jsonData = disableFormItem(item.formInfo.jsonData);
+        });
+
+        resolve(formList);
+      });
     },
     // 获取表单信息
     getformInfo() {

+ 9 - 8
zkqy-ui/src/views/orderMange/codeListManage/index.vue

@@ -478,7 +478,7 @@
                     >
                       <el-option
                         v-for="item in dict.type.packaging_type"
-                        :key="item.value"
+                        :key="item.raw.dictCode"
                         :label="item.label"
                         :value="item.value"
                       >
@@ -514,7 +514,7 @@
                     >
                       <el-option
                         v-for="item in dropDownData.work_shifts"
-                        :key="item.codeName"
+                        :key="item.id"
                         :label="item.codeName"
                         :value="item.codeName"
                       >
@@ -543,7 +543,7 @@
                     >
                       <el-option
                         v-for="item in dropDownData.level"
-                        :key="item.codeName"
+                        :key="item.id"
                         :label="item.codeName"
                         :value="item.codeName"
                       >
@@ -570,7 +570,7 @@
                     >
                       <el-option
                         v-for="item in dropDownData.drum_weight"
-                        :key="item.codeName"
+                        :key="item.id"
                         :label="item.codeName"
                         :value="item.codeName"
                       >
@@ -603,7 +603,7 @@
                     >
                       <el-option
                         v-for="item in dropDownData.box_weight"
-                        :key="item.codeName"
+                        :key="item.id"
                         :label="item.codeName"
                         :value="item.codeName"
                       >
@@ -621,7 +621,7 @@
                     >
                       <el-option
                         v-for="item in dropDownData.tube_color"
-                        :key="item.codeName"
+                        :key="item.id"
                         :label="item.codeName"
                         :value="item.codeName"
                       >
@@ -640,7 +640,7 @@
                     >
                       <el-option
                         v-for="item in dict.type.port"
-                        :key="item.value"
+                        :key="item.raw.dictCode"
                         :label="item.label"
                         :value="item.value"
                       >
@@ -658,7 +658,7 @@
                     >
                       <el-option
                         v-for="item in dict.type.coding_list_format"
-                        :key="item.value"
+                        :key="item.raw.dictCode"
                         :label="item.label"
                         :value="item.value"
                       >
@@ -935,6 +935,7 @@ export default {
     },
   },
   mounted() {
+    console.log(this.dict.type.packaging_type);
     // this.initWebSocket();
   },
   beforeDestroy() {

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

@@ -244,7 +244,7 @@
         :limit.sync="queryParams.pageSize"
         @pagination="pageList"
       />
-      <!-- 添加或修改销售出库单:- 过磅记录生成数据对话框 -->
+      <!-- 添加或修改 -->
       <el-dialog :title="title" :visible.sync="open" append-to-body>
         <!-- <iframe
         :src="iframeUrl"
@@ -255,12 +255,19 @@
       >
       </iframe> -->
         <!-- <template v-else> -->
+        <div
+          v-show="formType == 'dragFormGroup' && times"
+          class="dialog_loading"
+        >
+          <i class="el-icon-loading"></i>
+        </div>
         <template>
           <FormList
-            v-show="formType == 'dragFormGroup'"
+            v-show="formType == 'dragFormGroup' && !times"
             ref="formGroupRef"
             :formList="formList"
           ></FormList>
+
           <!-- <el-button @click="showValue">test</el-button> -->
         </template>
         <template>
@@ -380,12 +387,13 @@ import DialogTemplate from "@/views/dialogTemplate/components/index.vue";
 import FormList from "@/components/FormGroup/formList.vue";
 import { v4 as uuidv4 } from "uuid";
 import printHtml from "./print";
-
+// let times = 2; //请求次数
 export default {
   name: "listInfo",
   components: { Queryfrom, Menu, DialogTemplate, FormList, BtnMenuList },
   data() {
     return {
+      times: 2, //请求次数
       // 提示信息 start
       toastMsg: "",
       toastShow: false,
@@ -916,9 +924,27 @@ export default {
               }
               // console.log(this.formList);
               this.open = true;
+              if (btnData.btnFormType == "dragFormGroup") {
+                this.times--;
+                if (this.times) {
+                  this.$nextTick(() => {
+                    setTimeout(() => {
+                      this.handleUpdate(row, btnData);
+                    }, 1000);
+                  });
+                }
+              }
+
+              // this.$nextTick(() => {
+              //   this.open = false;
+              //   this.$nextTick(() => {
+              //     this.open = true;
+              //   });
+              // });
               // this.$nextTick(() => {
-              //   // this.sleep(1000);
-              //   this.$refs.formGroupRef.setDefaultValue();
+              //   if (res.data.mainForm) {
+              //     this.$refs.formGroupRef.setDefaultValue();
+              //   }
               // });
             } else {
               console.error(res);
@@ -1064,6 +1090,7 @@ export default {
       if (showValue) {
         for (const key of Object.keys(showValue)) {
           showValue[toUnderline(key)] = showValue[key];
+          delete showValue[key];
         }
         mainForm.showTemplate.resultMap = [showValue];
       }
@@ -1112,6 +1139,7 @@ export default {
               for (const key of Object.keys(item.showValue[0].resultMap)) {
                 item.showValue[0].resultMap[toUnderline(key)] =
                   item.showValue[0].resultMap[key];
+                delete item.showValue[0].resultMap[key];
               }
 
               item.showTemplate.resultMap = [item.showValue[0].resultMap];
@@ -2020,7 +2048,9 @@ export default {
         this.noNeedHandler(btnData, row);
         return;
       }
-
+      if (btnData.btnFormType == "dragFormGroup") {
+        this.times = 2; //重置请求次数
+      }
       switch (btnType) {
         case "INNERLINK": //内链
           this.routerHandler(btnData, btnType);
@@ -2205,6 +2235,12 @@ export default {
 </script>
 
 <style scoped lang="scss">
+.dialog_loading {
+  display: flex;
+  justify-content: center;
+  width: 100%;
+  font-size: 30px;
+}
 ::v-deep .el-dialog:not(.is-fullscreen) {
   min-width: 610px !important;
 }