Browse Source

修改高级查询2

zhaoke 1 year ago
parent
commit
cafd05023b
2 changed files with 50 additions and 12 deletions
  1. 1 1
      src/getMenu.js
  2. 49 11
      src/views/newQuery/index.vue

+ 1 - 1
src/getMenu.js

@@ -120,7 +120,7 @@ function parseMenuItem (data) {
           qid: item.queryTemplateID,
           auth_id: item.auth_id,
           up_auth_id: item.up_auth_id,
-          keepAlive: true
+          keepAlive: item.auth_ident == 'search_page' ? true : false
         },
         component: resolve => require(['@/views' + item.file_link], resolve),
         // component: () => import('./views/table/index.vue'),

+ 49 - 11
src/views/newQuery/index.vue

@@ -113,6 +113,7 @@ export default {
         ],
       },
       nums: 1,
+      queryClicks: sessionStorage.getItem('queryClicks') || 0,
       searchItems: []
     }
   },
@@ -128,7 +129,7 @@ export default {
   mounted () {
     const { query } = this.$route
     if (query && Object.keys(query).length) {
-      const queryData = query
+      const queryData = _.cloneDeep(query)
       const datas = []
       for (const key in queryData) {
         if (Object.hasOwnProperty.call(queryData, key)) {
@@ -147,12 +148,7 @@ export default {
         }
       }
       this.flag = true
-      setTimeout(() => {
-        this.dataQuery = datas
-        this.tableTag = {
-          filter: datas
-        }
-      }, 50);
+      this.setFormatQuery(datas)
     }
   },
   methods: {
@@ -250,24 +246,66 @@ export default {
           this.queryArrs.push(arrs)
         }
       } else {
+        this.setFormatQuery(arrs)
+      }
+    },
+    setFormatQuery (arrs) {
+      const ndatas = _.cloneDeep(arrs)
+      const narrs = []
+      const nss1 = [], nss2 = []
+      ndatas.map((citem) => {
+        const { column, value } = citem
+        if (column == 'luggageNum') {
+          const nval = this.baggageFormat(value)
+          const ndata = nval.split(',')
+          if (ndata.length > 1) {
+            ndata.map((item, index) => {
+              const r = {
+                left: index == 0 ? '(' : '',
+                column,
+                comparator: '=',
+                value: item,
+                right: ndata.length - 1 == index ? ')' : '',
+                connector: ndata.length - 1 == index ? 'and' : 'or'
+              }
+              narrs.push(r)
+            })
+          } else {
+            narrs.push(citem)
+          }
+        } else {
+          narrs.push(citem)
+        }
+      })
+      narrs.map((citem) => {
+        const { column } = citem
+        if (column == 'luggageNum') {
+          nss1.push(citem)
+        } else {
+          nss2.push(citem)
+        }
+      })
+      setTimeout(() => {
+        this.dataQuery = narrs
         this.tableTag = {
-          filter: arrs
+          filter: [...nss1, ...nss2]
         }
-      }
+      }, 50);
     },
     formatQuery (key, val) {
+      this.queryClicks++
       if (key == 'luggageNum') {
         const nval = this.baggageFormat(val)
         const ndata = nval.split(',')
         if (ndata.length > 1) {
-          ndata.map(item => {
+          ndata.map((item, index) => {
             const r = {
               left: '(',
               column: key,
               comparator: '=',
               value: item,
               right: ')',
-              connector: 'or'
+              connector: ndata.length - 1 == index ? 'and' : 'or'
             }
             this.searchItems.push(r)
           })