Эх сурвалжийг харах

修改按钮绑定参数格式及渲染逻辑

lph 1 жил өмнө
parent
commit
290845b9a0

+ 8 - 6
zkqy-ui/src/views/tablelist/commonTable/BtnMenu.vue

@@ -48,6 +48,7 @@
 </template>
 
 <script>
+import { camelCase, toUnderline } from "@/utils";
 export default {
   name: "Menu",
   components: {},
@@ -78,19 +79,20 @@ export default {
     },
     judgeBtnHandler(row, con) {
       let { fieldName, refValue, mark } = con;
+      let realyFieldName = camelCase(fieldName.replace(".", "_"));
       switch (mark) {
         case "1":
-          return row[fieldName] > refValue;
+          return row[realyFieldName] > refValue;
         case "2":
-          return row[fieldName] < refValue;
+          return row[realyFieldName] < refValue;
         case "3":
-          return row[fieldName] == refValue;
+          return row[realyFieldName] == refValue;
         case "4":
-          return row[fieldName] >= refValue;
+          return row[realyFieldName] >= refValue;
         case "5":
-          return row[fieldName] <= refValue;
+          return row[realyFieldName] <= refValue;
         case "6":
-          return row[fieldName] != refValue;
+          return row[realyFieldName] != refValue;
         default:
           return true;
       }

+ 64 - 15
zkqy-ui/src/views/tablelist/commonTable/listInfo.vue

@@ -892,11 +892,9 @@ export default {
       if (this.currentBtnData.btnParams) {
         let btnParams = JSON.parse(this.currentBtnData.btnParams);
         btnParams.forEach((item) => {
-          data.btnParametersMap[
-            this.formatField(item.fieldName, camelCase(this.tableName))
-          ] = item.fieldValue
+          data.btnParametersMap[item.fieldName.split(".")[1]] = item.fieldValue
             ? item.fieldValue
-            : this.currentRow[item.fieldName];
+            : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
         });
       }
       data.conditionMap[this.templateInfo.template?.primaryKey] = delIds;
@@ -1075,11 +1073,12 @@ export default {
             if (this.currentBtnData.btnParams) {
               let btnParams = JSON.parse(this.currentBtnData.btnParams);
               btnParams.forEach((item) => {
-                data.btnParametersMap[
-                  this.formatField(item.fieldName, camelCase(this.tableName))
-                ] = item.fieldValue
-                  ? item.fieldValue
-                  : this.currentRow[item.fieldName];
+                data.btnParametersMap[item.fieldName.split(".")[1]] =
+                  item.fieldValue
+                    ? item.fieldValue
+                    : this.currentRow[
+                        camelCase(item.fieldName.replace(".", "_"))
+                      ];
               });
             }
             if (Object.keys(this.defaultValue).length) {
@@ -1131,11 +1130,10 @@ export default {
         if (this.currentBtnData.btnParams) {
           let btnParams = JSON.parse(this.currentBtnData.btnParams);
           btnParams.forEach((item) => {
-            data.btnParametersMap[
-              this.formatField(item.fieldName, camelCase(this.tableName))
-            ] = item.fieldValue
-              ? item.fieldValue
-              : this.currentRow[item.fieldName];
+            data.btnParametersMap[item.fieldName.split(".")[1]] =
+              item.fieldValue
+                ? item.fieldValue
+                : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
           });
         }
         // data.basicMap.btnType = this.currentBtnData.btnType;
@@ -1316,9 +1314,15 @@ export default {
 
     // 操作列回调
     excuteHandler(btnData, row) {
-      let { btnType, btnParams } = btnData;
+      console.log("btnData", btnData, row);
+      let { btnType, btnParams, btnFormType } = btnData;
       this.currentBtnData = btnData;
       this.currentRow = JSON.parse(JSON.stringify(row));
+      // 无表单
+      if (btnFormType == "noNeed") {
+        this.noNeedHandler(btnData, row);
+        return;
+      }
       switch (btnType) {
         case "INNERLINK":
           this.routerHandler(btnData, btnType);
@@ -1342,6 +1346,51 @@ export default {
           break;
       }
     },
+    noNeedHandler(btnData, row) {
+      this.$modal
+        .confirm("是否确认执行该操作?")
+        .then(async () => {
+          // 获取默认参数
+          let data = {
+            basicMap: {
+              tableName: this.tableName,
+              // btnKey: btnData.btnKey,
+              btnKey: this.currentBtnData.btnKey,
+            },
+            conditionMap: {},
+            commMap: {},
+            btnParametersMap: {},
+          };
+          console.log(this.currentBtnData, this.currentRow);
+          if (this.currentBtnData.btnParams) {
+            let btnParams = JSON.parse(this.currentBtnData.btnParams);
+            btnParams.forEach((item) => {
+              data.conditionMap[item.fieldName.split(".")[1]] = item.fieldValue
+                ? item.fieldValue
+                : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
+            });
+          }
+          data.basicMap.btnType = this.currentBtnData.btnType;
+          data.basicMap.visible = true;
+          try {
+            let res = await btnCommonApi(data);
+            if (res.code == 200) {
+              this.$message.success("操作成功");
+            } else {
+              this.$message.error("网络异常,请稍后再试");
+            }
+          } catch (error) {
+            console.log(error);
+            this.$message.error("网络异常,请稍后再试");
+          }
+        })
+        .then(() => {
+          // 调用子组件查询方法 目的是携带上子组件中的查询参数
+          this.$refs.mychild.pageList();
+          this.$modal.msgSuccess("操作成功");
+        })
+        .catch(() => {});
+    },
 
     // k-form-build表单变化回调
     formChangeHandler(value, label) {