Sfoglia il codice sorgente

高级查询修改

zhongxiaoyu 1 anno fa
parent
commit
b6c50295be
2 ha cambiato i file con 48 aggiunte e 5 eliminazioni
  1. 47 4
      src/views/newQuery/components/search.vue
  2. 1 1
      src/views/newQuery/index.vue

+ 47 - 4
src/views/newQuery/components/search.vue

@@ -114,13 +114,23 @@
                   @click="deleteParam(rowIndex)"
                 />
               </template>
-              <template v-else-if="col.inputType === 'toggle'">
+              <template v-else-if="col.inputType === 'connector'">
                 <div
+                  v-if="row.connector"
                   class="clickable-toggle"
                   @click="toggle(rowIndex)"
                 >
                   {{ row.connector === 'and' ? '并且' : '或者' }}
                 </div>
+                <div
+                  v-else
+                  class="clickable-add"
+                  @click="addParamsHandler"
+                >
+                  <div class="clickable-wrapper">
+                    <i class="el-icon-plus" />
+                  </div>
+                </div>
               </template>
             </el-form-item>
           </el-col>
@@ -238,7 +248,7 @@ export default {
         {
           prop: 'connector',
           // label: '连接',
-          inputType: 'toggle',
+          inputType: 'connector',
         },
       ],
       columnSet: {},
@@ -289,6 +299,15 @@ export default {
       deep: true,
       immediate: true,
     },
+    'paramsForm.params': {
+      handler(params) {
+        const { length } = params
+        params[length - 1].connector = ''
+        if (params[length - 2] && !params[length - 2].connector) {
+          params[length - 2].connector = 'and'
+        }
+      },
+    },
   },
   mounted() {
     this.queryHandler()
@@ -297,10 +316,13 @@ export default {
     queryHandler() {
       const colDatas = this.authMsg
       if (colDatas && colDatas.length) {
-        const columns = colDatas.filter(item => item.is_search == 1)
+        const columns = colDatas.filter(item => String(item.is_search) === '1')
         const datas = formatOrder(columns)
         this.getColumnSet(datas)
       }
+      if (!this.paramsForm.params.length) {
+        this.addParamsHandler()
+      }
     },
     sendColData() {
       this.$emit('getColData', this.queryContent)
@@ -311,7 +333,7 @@ export default {
         paramKey: '',
         comparisonOperator: '',
         paramValue: '',
-        connector: 'and',
+        connector: '',
       })
     },
     selectChangeHandler(value, rowIndex, colIndex) {
@@ -552,6 +574,27 @@ export default {
       color: #409eff;
       cursor: pointer;
     }
+    .clickable-add {
+      height: 48px;
+      text-align: center;
+      font-size: 20px;
+      cursor: pointer;
+      display: flex;
+      justify-content: center;
+      align-items: center;
+      .clickable-wrapper {
+        width: 30px;
+        height: 30px;
+        line-height: 28px;
+        border-radius: 50%;
+        border: 1px solid #409eff;
+        color: #409eff;
+      }
+      &:hover .clickable-wrapper {
+        background-color: #409eff;
+        color: #fff;
+      }
+    }
   }
 }
 </style>

+ 1 - 1
src/views/newQuery/index.vue

@@ -15,7 +15,7 @@
         </div>
         <div class="newQuery-head-right flex-wrap">
           <template v-if="flag">
-            <el-button @click="handleAdd" size="mini" plain type="primary">新增</el-button>
+            <!-- <el-button @click="handleAdd" size="mini" plain type="primary">新增</el-button> -->
             <el-button @click="saveItem" size="mini" plain type="primary">保存条件</el-button>
           </template>
           <el-button @click="handleSearch" size="mini" class="r10" plain type="primary">查询</el-button>