浏览代码

处理模板页面顶部新增按钮表单调用失败问题

lph 1 年之前
父节点
当前提交
257ca4ae53
共有 1 个文件被更改,包括 35 次插入13 次删除
  1. 35 13
      zkqy-ui/src/views/tablelist/commonTable/listInfo.vue

+ 35 - 13
zkqy-ui/src/views/tablelist/commonTable/listInfo.vue

@@ -821,7 +821,7 @@ export default {
       // 新的修改请求
       try {
         // console.log("btnData", btnData);
-        let { btnFormType } = btnData;
+        let { btnFormType, btnGroupType } = btnData;
         this.formType = btnFormType;
         let payLoad = {};
         let primary = camelCase(
@@ -859,7 +859,17 @@ export default {
         let res = await btnCommonApi(payLoad);
         // 判断是否绑定dialog弹窗
         if (!this.currentBtnData.btnTableFormGroupKey) {
-          if ((!res.data || !res.data.template) && !res.data?.mainForm) {
+          if (
+            btnGroupType == "right" &&
+            (!res.data || !res.data.template) &&
+            !res.data?.mainForm
+          ) {
+            //右侧判定逻辑
+            this.$message.error("当前按钮未绑定表单!");
+            return;
+          }
+          if (btnGroupType == "top" && !res.data.dfVueTemplate) {
+            //顶部判定逻辑
             this.$message.error("当前按钮未绑定表单!");
             return;
           }
@@ -886,20 +896,32 @@ export default {
               this.$message.error("网络异常,请稍后再试");
             }
           } else {
-            //单个表单
-            res.data.template.dfFormSql &&
-              (this.dynamicData = JSON.parse(res.data.template.dfFormSql));
-            this.addRealFieldName(res.data.result.resultMap);
-            let resultMap = res.data.result.resultMap;
+            let optionsData = "",
+              templateData = "";
+            if (btnGroupType == "top") {
+              optionsData = res.data.dfFormSql;
+              templateData = res.data.dfVueTemplate;
+            } else {
+              //修改
+              optionsData = res.data.template.dfFormSql;
+              templateData = res.data.template.dfVueTemplate;
 
-            Object.assign(this.defaultValue, resultMap);
-            this.jsonData = JSON.parse(res.data.template.dfVueTemplate);
+              this.addRealFieldName(res.data.result.resultMap);
+              let resultMap = res.data.result.resultMap;
+
+              Object.assign(this.defaultValue, resultMap);
+            }
+            //单个表单
+            optionsData && (this.dynamicData = JSON.parse(optionsData));
+            this.jsonData = JSON.parse(templateData);
             this.open = true;
-            this.title = "修改信息";
+            this.title = btnGroupType == "top" ? "新增信息" : "修改信息";
             this.form.password = this.initPassword;
-            this.$nextTick(() => {
-              this.$refs.addFromRef.setData(res.data.result.resultMap);
-            });
+            if (btnGroupType == "right") {
+              this.$nextTick(() => {
+                this.$refs.addFromRef.setData(res.data.result.resultMap);
+              });
+            }
           }
         } else {
           this.subTableName = res.data.result.dragTables[1].dtTableName;