Browse Source

处理条件查询按钮传参修改逻辑

lph 1 year ago
parent
commit
6c5fe1a973

+ 50 - 55
zkqy-ui/src/views/tablelist/commonTable/listInfo.vue

@@ -41,7 +41,7 @@
             :underline="false"
             style="font-size: 12px; vertical-align: baseline"
             @click="importTemplate"
-          >下载模板
+            >下载模板
           </el-link>
         </div>
       </el-upload>
@@ -66,7 +66,7 @@
           icon="el-icon-plus"
           size="mini"
           @click="handleAdd"
-        >新增
+          >新增
         </el-button>
       </el-col>
       <el-col :span="1.5" v-if="false">
@@ -77,7 +77,7 @@
           size="mini"
           :disabled="single"
           @click="handleUpdate"
-        >修改
+          >修改
         </el-button>
       </el-col>
       <el-col :span="1.5">
@@ -88,7 +88,7 @@
           size="mini"
           :disabled="multiple"
           @click="handleBatchDelete"
-        >删除
+          >删除
         </el-button>
       </el-col>
       <el-col :span="1.5">
@@ -97,7 +97,7 @@
           icon="el-icon-upload2"
           size="mini"
           @click="upload.open = true"
-        >导入
+          >导入
         </el-button>
       </el-col>
       <el-col :span="1.5">
@@ -107,7 +107,7 @@
           icon="el-icon-download"
           size="mini"
           @click="handleExport"
-        >导出
+          >导出
         </el-button>
       </el-col>
       <right-toolbar
@@ -161,7 +161,7 @@
                   :style="`color:${
                     scope.row.styleFieldObj[item.key].fontColor
                   }`"
-                >{{ scope.row[item.key] }}</span
+                  >{{ scope.row[item.key] }}</span
                 >
               </template>
               <!-- 标签字体样式 -->
@@ -191,7 +191,7 @@
                   scope.row.styleFieldObj[item.key].listClass == '' ||
                   scope.row.styleFieldObj[item.key].listClass == 'default'
                 "
-              >{{ scope.row.styleFieldObj[item.key].dictLabel }}</span
+                >{{ scope.row.styleFieldObj[item.key].dictLabel }}</span
               >
               <el-tag
                 v-else
@@ -200,9 +200,8 @@
                     ? ''
                     : scope.row.styleFieldObj[item.key].listClass
                 "
-              >{{ scope.row.styleFieldObj[item.key].dictLabel }}
-              </el-tag
-              >
+                >{{ scope.row.styleFieldObj[item.key].dictLabel }}
+              </el-tag>
             </template>
           </template>
           <!-- 显示默认值 -->
@@ -330,20 +329,20 @@ import {
   batchEdit,
   getStatisticList,
 } from "@/api/tablelist/commonTable";
-import {listData} from "@/api/system/tenant/data";
-import {getToken} from "@/utils/auth";
+import { listData } from "@/api/system/tenant/data";
+import { getToken } from "@/utils/auth";
 import Queryfrom from "@/views/tablelist/commonTable/queryfrom.vue";
-import {camelCase, toUnderline} from "@/utils";
-import {inputDisableComplete} from "@/utils/other";
+import { camelCase, toUnderline } from "@/utils";
+import { inputDisableComplete } from "@/utils/other";
 import Menu from "./BtnMenu.vue";
-import {checkRole} from "@/utils/permission";
+import { checkRole } from "@/utils/permission";
 import DialogTemplate from "@/views/dialogTemplate/components/index.vue";
 import FormList from "@/components/FormGroup/formList.vue";
-import {v4 as uuidv4} from "uuid";
+import { v4 as uuidv4 } from "uuid";
 
 export default {
   name: "listInfo",
-  components: {Queryfrom, Menu, DialogTemplate, FormList},
+  components: { Queryfrom, Menu, DialogTemplate, FormList },
   data() {
     return {
       // 绑定按钮dialog
@@ -386,7 +385,7 @@ export default {
         // 是否更新已经存在的数据
         updateSupport: 0,
         // 设置上传的请求头部
-        headers: {Authorization: "Bearer " + getToken()},
+        headers: { Authorization: "Bearer " + getToken() },
         // 上传的地址
         url: process.env.VUE_APP_BASE_API1 + "common/uploadData",
       },
@@ -499,7 +498,7 @@ export default {
     getRowKey(row) {
       return row[
         camelCase(this.tableName + "_" + this.templateInfo.template?.primaryKey)
-        ];
+      ];
     },
     /** 查询列表 */
     getList(queryParams) {
@@ -507,7 +506,7 @@ export default {
       // 序列化当前查询参数列表
       queryParams && (this.queryParams.queryMap = queryParams.queryMap);
       // 获取当前表单结构信息
-      dragTableInfo({"queryMap": {"tableKey": this.tableKey}})
+      dragTableInfo({ queryMap: { tableKey: this.tableKey } })
         .then((res) => {
           console.log(res);
           // 得到当前模版信息 --- sql columns queryWhere
@@ -642,9 +641,9 @@ export default {
       this.$refs.mychild.pageList(
         row == undefined
           ? {
-            limit: this.queryParams.pageSize,
-            page: this.queryParams.pageNum,
-          }
+              limit: this.queryParams.pageSize,
+              page: this.queryParams.pageNum,
+            }
           : row
       );
     },
@@ -656,7 +655,7 @@ export default {
             camelCase(
               this.tableName + "_" + this.templateInfo.template?.primaryKey
             )
-            ]
+          ]
       );
       this.single = selection.length != 1;
       this.multiple = !selection.length;
@@ -680,7 +679,7 @@ export default {
       // this.reset();
       this.defaultValue = {};
       this.formType = "dragForm";
-      getInfoBySqlKey(this.templateInfo.template.sqlKey).then(({data}) => {
+      getInfoBySqlKey(this.templateInfo.template.sqlKey).then(({ data }) => {
         if (!data || !data.dfVueTemplate) {
           this.jsonData = false;
           this.$message.error("当前表格未绑定表单!");
@@ -732,8 +731,7 @@ export default {
     // 延迟
     sleep(ms) {
       var unixtime_ms = new Date().getTime();
-      while (new Date().getTime() < unixtime_ms + ms) {
-      }
+      while (new Date().getTime() < unixtime_ms + ms) {}
       return "";
     },
     /** 修改按钮操作 */
@@ -761,7 +759,7 @@ export default {
       // 新的修改请求
       try {
         // console.log("btnData", btnData);
-        let {btnFormType} = btnData;
+        let { btnFormType } = btnData;
         this.formType = btnFormType;
         let payLoad = {};
         let primary = camelCase(
@@ -827,7 +825,7 @@ export default {
           } else {
             //单个表单
             res.data.template.dfFormSql &&
-            (this.dynamicData = JSON.parse(res.data.template.dfFormSql));
+              (this.dynamicData = JSON.parse(res.data.template.dfFormSql));
             this.addRealFieldName(res.data.result.resultMap);
             let resultMap = res.data.result.resultMap;
 
@@ -936,7 +934,7 @@ export default {
     // 将表单组数据转换成符合单个表单的数据格式
     transformDataFormat(data) {
       this.FormNameList = [];
-      let {mainForm, subFormList} = data;
+      let { mainForm, subFormList } = data;
       this.formList = [];
       let showValue = mainForm.showValue[0];
       if (showValue) {
@@ -1054,8 +1052,7 @@ export default {
           this.$refs.mychild.pageList();
           this.$modal.msgSuccess("删除成功");
         })
-        .catch(() => {
-        });
+        .catch(() => {});
     },
     // 批量删除接口
     handleBatchDelete() {
@@ -1095,8 +1092,7 @@ export default {
           this.$refs.mychild.pageList();
           this.$modal.msgSuccess("删除成功");
         })
-        .catch(() => {
-        });
+        .catch(() => {});
     },
     /** 导出按钮操作 */
     handleExport() {
@@ -1133,7 +1129,7 @@ export default {
     importTemplate() {
       this.download(
         process.env.VUE_APP_BASE_API1 +
-        `common/exportTemplate?tableName=${this.tableName}&sqlkey=${this.templateInfo.template.sqlKey}`,
+          `common/exportTemplate?tableName=${this.tableName}&sqlkey=${this.templateInfo.template.sqlKey}`,
         {},
         `下载模版名称${new Date().getTime()}.xlsx`
       );
@@ -1149,10 +1145,10 @@ export default {
       this.$refs.upload.clearFiles();
       this.$alert(
         "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
-        response.msg +
-        "</div>",
+          response.msg +
+          "</div>",
         "导入结果",
-        {dangerouslyUseHTMLString: true}
+        { dangerouslyUseHTMLString: true }
       );
       this.$refs.mychild.pageList({
         limit: this.queryParams.pageSize,
@@ -1229,7 +1225,7 @@ export default {
                   item.fieldValue
                     ? item.fieldValue
                     : this.currentRow[
-                      camelCase(item.fieldName.replace(".", "_"))
+                        camelCase(item.fieldName.replace(".", "_"))
                       ];
               });
               conditionData.forEach((item) => {
@@ -1237,7 +1233,7 @@ export default {
                   item.fieldValue
                     ? item.fieldValue
                     : this.currentRow[
-                      camelCase(item.fieldName.replace(".", "_"))
+                        camelCase(item.fieldName.replace(".", "_"))
                       ];
               });
             }
@@ -1308,7 +1304,7 @@ export default {
                 item.fieldValue
                   ? item.fieldValue
                   : this.currentRow[
-                    camelCase(item.fieldName.replace(".", "_"))
+                      camelCase(item.fieldName.replace(".", "_"))
                     ];
             });
             conditionData.forEach((item) => {
@@ -1346,17 +1342,17 @@ export default {
                       item.fieldValue
                         ? item.fieldValue
                         : this.currentRow[
-                          camelCase(item.fieldName.replace(".", "_"))
+                            camelCase(item.fieldName.replace(".", "_"))
                           ];
                   });
                 } else {
                   // 从表条件
-                  let {formItem, relateFormItem} = item;
+                  let { formItem, relateFormItem } = item;
                   let fieldName = formItem.split(".")[1];
                   let value =
                     this.currentRow[
                       camelCase(relateFormItem.replace(".", "_"))
-                      ];
+                    ];
                   result.conditionMap[fieldName] = value;
                 }
                 return result;
@@ -1378,7 +1374,7 @@ export default {
                 };
 
                 // 添加新增数据的关联条件
-                let {formItem, relateFormItem} = item;
+                let { formItem, relateFormItem } = item;
                 // console.log(formItem);
                 result.addListMap[0][formItem.split(".")[1]] = uuid;
                 return result;
@@ -1454,17 +1450,17 @@ export default {
                       item.fieldValue
                         ? item.fieldValue
                         : this.currentRow[
-                          camelCase(item.fieldName.replace(".", "_"))
+                            camelCase(item.fieldName.replace(".", "_"))
                           ];
                   });
                 } else {
                   // 从表条件
-                  let {formItem, relateFormItem} = item;
+                  let { formItem, relateFormItem } = item;
                   let fieldName = formItem.split(".")[1];
                   let value =
                     this.currentRow[
                       camelCase(relateFormItem.replace(".", "_"))
-                      ];
+                    ];
                   result.conditionMap[fieldName] = value;
                 }
                 return result;
@@ -1552,7 +1548,7 @@ export default {
         });
     },
     // 判断是否生效行样式
-    cellStyle({row, column, rowIndex, columnIndex}) {
+    cellStyle({ row, column, rowIndex, columnIndex }) {
       let rowStyleList = this.styleList.filter((item) => item.styleType == 0);
       if (!rowStyleList.length) return "";
       let mainTableName = this.templateInfo.querySql.tableAlias; //主表名
@@ -1675,7 +1671,7 @@ export default {
 
     // 内链页面跳转
     routerHandler(btnData, type) {
-      let {url, commonFieldData} = JSON.parse(btnData.btnParams);
+      let { url, commonFieldData } = JSON.parse(btnData.btnParams);
       let tempArr = [];
       if (commonFieldData) {
         let queryArr = JSON.parse(commonFieldData);
@@ -1702,7 +1698,7 @@ export default {
     // 操作列回调
     excuteHandler(btnData, row) {
       // console.log("btnData", btnData, row);
-      let {btnType, btnParams, btnFormType} = btnData;
+      let { btnType, btnParams, btnFormType } = btnData;
       this.currentBtnData = btnData;
       this.currentRow = JSON.parse(JSON.stringify(row));
       // 无表单
@@ -1769,7 +1765,7 @@ export default {
                 item.fieldValue
                   ? item.fieldValue
                   : this.currentRow[
-                    camelCase(item.fieldName.replace(".", "_"))
+                      camelCase(item.fieldName.replace(".", "_"))
                     ];
             });
           }
@@ -1792,8 +1788,7 @@ export default {
           this.$refs.mychild.pageList();
           // this.$modal.msgSuccess("操作成功");
         })
-        .catch(() => {
-        });
+        .catch(() => {});
     },
 
     // k-form-build表单变化回调

+ 113 - 46
zkqy-ui/src/views/tablelist/commonTable/queryfrom.vue

@@ -1,57 +1,104 @@
 <template>
   <div>
-    <cardcountpanel :showCount="showCount" :statisticList="statisticList"/>
-    <el-form :model="queryParams.queryMap" ref="queryForm" size="small" :inline="true" label-width="68px"
-             @submit.native.prevent v-show="showSearch"  class="demo-form-inline">
+    <cardcountpanel :showCount="showCount" :statisticList="statisticList" />
+    <el-form
+      :model="queryParams.queryMap"
+      ref="queryForm"
+      size="small"
+      :inline="true"
+      label-width="68px"
+      @submit.native.prevent
+      v-show="showSearch"
+      class="demo-form-inline"
+    >
       <el-form-item label="超级查询">
-        <el-input v-model="queryParams.queryMap.queryCriteriaValue" placeholder="请输入"
-                  @keyup.enter.native="handleQuery" clearable/>
+        <el-input
+          v-model="queryParams.queryMap.queryCriteriaValue"
+          placeholder="请输入"
+          @keyup.enter.native="handleQuery"
+          clearable
+        />
       </el-form-item>
       <el-form-item>
-        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
-        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
+        <el-button
+          type="primary"
+          icon="el-icon-search"
+          size="mini"
+          @click="handleQuery"
+          >搜索</el-button
+        >
+        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
+          >重置</el-button
+        >
       </el-form-item>
 
       <!--   不加载初始数据   -->
       <div v-if="true" class="btn-wrap">
         <!--      条件循环-->
-        <span v-for="(item, index) in formVals" :key="index" >
+        <span v-for="(item, index) in formVals" :key="index">
           <!--      input框循环-->
           <span
             v-if="item.conditionType == 'input'"
-            style="width: 500px; height: 500px">
-            <el-form-item :label="item.conditionName"
-                          :prop="item.conditionField">
-              <el-input v-model="queryParams.queryMap[item.conditionField]"
-                        :placeholder="item.conditionNotes == null ? '请输入' : item.conditionNotes"
-                        @keyup.enter.native="handleQuery" clearable/>
+            style="width: 500px; height: 500px"
+          >
+            <el-form-item
+              :label="item.conditionName"
+              :prop="item.conditionField"
+            >
+              <el-input
+                v-model="queryParams.queryMap[item.conditionField]"
+                :placeholder="
+                  item.conditionNotes == null ? '请输入' : item.conditionNotes
+                "
+                @keyup.enter.native="handleQuery"
+                clearable
+              />
             </el-form-item>
           </span>
 
           <!--      button按钮循环-->
-          <span v-if="item.conditionType == 'button'" >
+          <span v-if="item.conditionType == 'button'">
             <el-form-item :label="item.conditionName">
               <!--              {{-->
               <!--                (queryParams.queryMap[item.conditionField] =-->
               <!--                  item.conditionDefaultValue)-->
               <!--              }}-->
-              <el-button @keyup.enter.native="btnClick"
-                         @click="btnClick(item.conditionField ,item.conditionDefaultValue)">
+              <el-button
+                @keyup.enter.native="btnClick"
+                @click="
+                  btnClick(item.conditionField, item.conditionDefaultValue)
+                "
+              >
                 {{ item.conditionNotes == null ? "按钮" : item.conditionNotes }}
               </el-button>
             </el-form-item>
-            <div style="clear: both;"/>
+            <div style="clear: both" />
           </span>
-          <div style="clear: both;"/>
+          <div style="clear: both" />
 
           <!--      select下拉框循环-->
-          <span v-if="item.conditionType == 'select'" style="width: 500px; height: 500px">
-            <el-form-item :label="item.conditionName" :prop="item.conditionField">
-              <el-select v-model="queryParams.queryMap[item.conditionField]"
-                         :placeholder="item.conditionNotes == null ? '请选择' : item.conditionNotes" clearable
-                         filterable>
-                <el-option v-for="(i, index) in item.dropDownList" :key="index" :label="i.fieldName"
-                           :value="i.fieldKey"></el-option>
+          <span
+            v-if="item.conditionType == 'select'"
+            style="width: 500px; height: 500px"
+          >
+            <el-form-item
+              :label="item.conditionName"
+              :prop="item.conditionField"
+            >
+              <el-select
+                v-model="queryParams.queryMap[item.conditionField]"
+                :placeholder="
+                  item.conditionNotes == null ? '请选择' : item.conditionNotes
+                "
+                clearable
+                filterable
+              >
+                <el-option
+                  v-for="(i, index) in item.dropDownList"
+                  :key="index"
+                  :label="i.fieldName"
+                  :value="i.fieldKey"
+                ></el-option>
               </el-select>
 
               <!-- <el-option
@@ -63,21 +110,41 @@
             </el-form-item>
           </span>
           <!--      radio单选框循环-->
-          <span v-if="item.conditionType == 'radio'" style="width: 500px; height: 500px">
+          <span
+            v-if="item.conditionType == 'radio'"
+            style="width: 500px; height: 500px"
+          >
             <el-form-item :prop="item.conditionField">
-              <el-button :type="item.componentType" :icon="item.componentIcon" :size="item.componentSize"
-                         @click="buttonClick(item)">
-                {{ item.conditionName }}</el-button>
+              <el-button
+                :type="item.componentType"
+                :icon="item.componentIcon"
+                :size="item.componentSize"
+                @click="buttonClick(item)"
+              >
+                {{ item.conditionName }}</el-button
+              >
             </el-form-item>
           </span>
           <!--      time时间范围  -->
-          <span v-if="item.conditionType == 'between'" style="width: 500px; height: 500px">
-            <el-form-item :label="item.conditionName" :prop="item.conditionField">
+          <span
+            v-if="item.conditionType == 'between'"
+            style="width: 500px; height: 500px"
+          >
+            <el-form-item
+              :label="item.conditionName"
+              :prop="item.conditionField"
+            >
               <!--  item.componentType 使用某种组件
         year/month/date/dates/months/years week/datetime/datetimerange/ daterange/monthrange-->
-              <el-date-picker v-model="queryParams.queryMap[item.conditionField]" :type="item.componentType"
-                              range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"
-                              value-format="yyyy-MM-DD HH:mm:ss" :default-time="['12:00:00']">
+              <el-date-picker
+                v-model="queryParams.queryMap[item.conditionField]"
+                :type="item.componentType"
+                range-separator="至"
+                start-placeholder="开始日期"
+                end-placeholder="结束日期"
+                value-format="yyyy-MM-DD HH:mm:ss"
+                :default-time="['12:00:00']"
+              >
               </el-date-picker>
             </el-form-item>
           </span>
@@ -107,7 +174,7 @@ export default {
       type: Array,
     },
   },
-  components: {cardcountpanel},
+  components: { cardcountpanel },
   data() {
     return {
       // 时间范围临时存储
@@ -165,7 +232,7 @@ export default {
     },
   },
   created() {
-    console.log("formVals", this.queryParams)
+    console.log("formVals", this.queryParams);
     this.$emit("getList", this.queryParams);
     // console.log("showCount", this.showCount)
     // console.log("showSearch", this.showSearch)
@@ -187,15 +254,16 @@ export default {
       this.queryParams.pageNum = 1;
       console.log(this.queryParams);
       // 调用父组件中的查询函数
-      return new Promise((resolve) => {
-        this.$emit("getList", this.queryParams);
-        resolve();
-      })
+      let tempQueryParams = JSON.parse(JSON.stringify(this.queryParams));
+      console.log(tempQueryParams);
+      this.$emit("getList", tempQueryParams);
     },
-    async btnClick(field, val) {
+    btnClick(field, val) {
       this.queryParams.queryMap[field] = val;
-      await this.handleQuery();
-      delete this.queryParams.queryMap[field];
+      this.handleQuery();
+      this.$nextTick(() => {
+        delete this.queryParams.queryMap[field];
+      });
     },
     /**分页查询操作*/
     pageList(row) {
@@ -262,9 +330,8 @@ export default {
   .count {
     font-size: 30px;
   }
-
 }
-.btn-wrap{
+.btn-wrap {
   display: flex;
   flex-direction: row-reverse;
 }