yusheng 10 mesi fa
parent
commit
d281641766

+ 20 - 8
src/components/common/seekPage.vue

@@ -14,7 +14,7 @@
                 clearable
                 v-model="defaultWhere[item.value]"
                 :placeholder="item.placeholder || '请输入内容'"
-                :style="{ width: item.width ? item.width + 'px' : '220px' }"
+                :style="{ width: item.width ? item.width + 'px' : '230px' }"
               />
             </div>
             <div v-if="item.type == 'select'">
@@ -24,7 +24,7 @@
                 :multiple="item.multiple ? item.multiple : false"
                 :filterable="item.filterable ? item.filterable : true"
                 :placeholder="item.placeholder || '请选择'"
-                :style="{ width: item.width ? item.width + 'px' : '220px' }"
+                :style="{ width: item.width ? item.width + 'px' : '230px' }"
               >
                 <el-option
                   v-for="(op, i) in item.planList"
@@ -46,7 +46,7 @@
                 labelKey="name"
                 :placeholder="item.placeholder || '请选择'"
                 default-expand-all
-                :style="{ width: item.width ? item.width + 'px' : '220px' }"
+                :style="{ width: item.width ? item.width + 'px' : '230px' }"
               />
             </div>
             <div v-if="item.type == 'date'">
@@ -58,7 +58,7 @@
                 start-placeholder="开始日期"
                 end-placeholder="结束日期"
                 value-format="yyyy-MM-dd HH:mm:ss"
-                :style="{ width: item.width ? item.width + 'px' : '220px' }"
+                :style="{ width: item.width ? item.width + 'px' : '380px' }"
               >
               </el-date-picker>
             </div>
@@ -99,7 +99,7 @@
                           v-model="defaultWhere[item.value]"
                           :placeholder="item.placeholder || '请输入内容'"
                           :style="{
-                            width: item.width ? item.width + 'px' : '220px'
+                            width: item.width ? item.width + 'px' : '230px'
                           }"
                         />
                       </div>
@@ -111,7 +111,7 @@
                           :filterable="item.filterable ? item.filterable : true"
                           :placeholder="item.placeholder || '请选择'"
                           :style="{
-                            width: item.width ? item.width + 'px' : '220px'
+                            width: item.width ? item.width + 'px' : '230px'
                           }"
                           @visible-change="change"
                           @change="handerChange"
@@ -137,7 +137,7 @@
                           :placeholder="item.placeholder || '请选择'"
                           default-expand-all
                           :style="{
-                            width: item.width ? item.width + 'px' : '220px'
+                            width: item.width ? item.width + 'px' : '230px'
                           }"
                         />
                       </div>
@@ -151,7 +151,7 @@
                           end-placeholder="结束日期"
                           value-format="yyyy-MM-dd HH:mm:ss"
                           :style="{
-                            width: item.width ? item.width + 'px' : '220px'
+                            width: item.width ? item.width + 'px' : '230px'
                           }"
                         >
                         </el-date-picker>
@@ -257,6 +257,18 @@
       },
 
       search() {
+        let valueAr = this.seekList.filter((item) => item.valueAr);
+        valueAr.forEach((item) => {
+          let data = this.defaultWhere[item.value];
+          if (data) {
+            this.defaultWhere[item.valueAr[0]] = data[0];
+            this.defaultWhere[item.valueAr[1]] = data[1];
+          } else {
+            delete this.defaultWhere[item.valueAr[0]];
+            delete this.defaultWhere[item.valueAr[1]];
+          }
+          delete this.defaultWhere[item.value];
+        });
         this.$emit('search', this.defaultWhere);
       },
       // 重置

+ 23 - 71
src/views/system/operationLog/components/search.vue

@@ -1,87 +1,39 @@
 <!-- 搜索表单 -->
 <template>
-  <el-form
-    label-width="100px"
-    class="ele-form-search"
-    @keyup.enter.native="search"
-    @submit.native.prevent
-  >
-    <el-row :gutter="15">
-      <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
-        <el-form-item label="操作描述:">
-          <el-input
-            clearable
-            v-model.trim="where.description"
-            placeholder="请输入"
-          />
-        </el-form-item>
-      </el-col>
-      <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
-        <el-form-item label="操作时间:" prop="createTime">
-          <el-date-picker
-            v-model="createTime"
-            type="datetimerange"
-            style="width: 100%"
-            value-format="yyyy-MM-dd HH:mm:ss"
-            start-placeholder="开始时间"
-            end-placeholder="结束时间"
-          
-          >
-          </el-date-picker>
-        </el-form-item>
-      </el-col>
-      <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
-        <div class="ele-form-actions">
-          <el-button
-            type="primary"
-            icon="el-icon-search"
-            class="ele-btn-icon"
-            @click="search"
-          >
-            查询
-          </el-button>
-          <el-button @click="reset">重置</el-button>
-        </div>
-      </el-col>
-    </el-row>
-  </el-form>
+  <seekPage :seekList="seekList" :formLength="3" @search="search"></seekPage>
 </template>
 
 <script>
   export default {
     data() {
-      // 默认表单数据
-      const defaultWhere = {
-        description: '',
-        beginTime: '',
-        endTime: ''
-      };
-      return {
-        createTime: [],
-        // 表单数据
-        where: { ...defaultWhere }
-      };
+      return {};
     },
     computed: {
-      // 是否开启响应式布局
-      styleResponsive() {
-        return this.$store.state.theme.styleResponsive;
+      // 表格列配置
+      seekList() {
+        return [
+          {
+            label: '操作描述:',
+            value: 'description',
+            type: 'input'
+          },
+          {
+            label: '操作时间:',
+            value: 'createTime',
+            type: 'date',
+            dateType: 'datetimerange',
+            placeholder: '',
+            valueAr: ['beginTime', 'endTime']
+          }
+        ];
       }
     },
     methods: {
       /* 搜索 */
-      search() {
-        if(this.createTime.length){
-          this.where.beginTime=this.createTime?.[0]
-          this.where.endTime=this.createTime?.[1]
-        }  
-        this.$emit('search', this.where);
-      },
-      /*  重置 */
-      reset() {
-        this.createTime=[]
-        this.where = { ...this.defaultWhere };
-        this.search();
+      search(e) {
+        this.$emit('search', {
+          ...e
+        });
       }
     }
   };