Forráskód Böngészése

对车辆管理页面代码进行小改进

East 3 éve
szülő
commit
f6458cc9dc
2 módosított fájl, 55 hozzáadás és 82 törlés
  1. 1 1
      src/components/newTable/NewTable.vue
  2. 54 81
      src/views/BioSafety/CarAdmin.vue

+ 1 - 1
src/components/newTable/NewTable.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2021-09-18 16:30:17
- * @LastEditTime: 2021-12-21 16:56:35
+ * @LastEditTime: 2021-12-29 09:08:42
  * @LastEditors: Please set LastEditors
  * @Description: 表格的封装
  * @FilePath: \hyyfClient\src\components\NewTable.vue

+ 54 - 81
src/views/BioSafety/CarAdmin.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2021-09-13 17:52:31
- * @LastEditTime: 2021-12-27 18:18:52
+ * @LastEditTime: 2021-12-29 09:26:11
  * @LastEditors: Please set LastEditors
  * @Description: 生物安全 - 车辆管理
  * @FilePath: \hyyfClient\src\views\BioSafety\CarAdmin.vue
@@ -364,7 +364,7 @@ export default {
   },
   watch: {
     btnSelected: {
-      async handler(newVal) {
+      handler(newVal) {
         const loading = this.$loading({
           lock: true,
           text: "加载中...",
@@ -382,25 +382,28 @@ export default {
         }
         this.title = titles[this.btnSelected - 1];
         this.tableItems = tableItems[this.btnSelected - 1];
-        if (newVal === 1) {
-          // 档案
-          await this.getCarList();
-        } else if (newVal === 2) {
-          // 车辆通行
-          await this.carPassage();
-        } else if (newVal === 3) {
-          // 车辆洗消
-          await this.carWash();
-        } else if (newVal === 4) {
-          // 车辆烘干
-          await this.carDrying();
-        } else if (newVal === 5) {
-          // 白名单
-          await this.ShowCarWhite();
-        } else {
-          // 黑名单
-          await this.ShowCarBlack();
-        }
+        this.getPageFn(newVal).forEach(async (fn) => {
+          await fn();
+        });
+        // if (newVal === 1) {
+        //   // 档案
+        //   await this.getCarList();
+        // } else if (newVal === 2) {
+        //   // 车辆通行
+        //   await this.carPassage();
+        // } else if (newVal === 3) {
+        //   // 车辆洗消
+        //   await this.carWash();
+        // } else if (newVal === 4) {
+        //   // 车辆烘干
+        //   await this.carDrying();
+        // } else if (newVal === 5) {
+        //   // 白名单
+        //   await this.ShowCarWhite();
+        // } else {
+        //   // 黑名单
+        //   await this.ShowCarBlack();
+        // }
         loading.close();
       },
     },
@@ -418,79 +421,50 @@ export default {
     getBtnSelected(id) {
       this.btnSelected = id;
     },
+    // 获取当前操作对应的页面请求
+    getPageFn(newVal) {
+      const fns = {
+        1: [this.getCarList], // 档案
+        2: [this.carPassage], // 车辆通行
+        3: [this.carWash, this.carWashTotal], // 车辆洗消
+        4: [this.carDrying], // 车辆烘干
+        5: [this.ShowCarWhite], // 白名单
+        6: [this.ShowCarBlack], // 黑名单
+      };
+      return fns[newVal];
+    },
     // 获取查询条件
     handleQuery(params) {
       this.pageNum = 1;
       this.params = params;
 
       this.listData = [];
-      if (this.btnSelected === 1) {
-        // 档案
-        this.getCarList();
-      } else if (this.btnSelected === 2) {
-        // 车辆通行
-        this.carPassage();
-      } else if (this.btnSelected === 3) {
-        // 车辆洗消
-        this.carWash();
-      } else if (this.btnSelected === 4) {
-        // 车辆烘干
-        this.carDrying();
-      } else if (this.btnSelected === 5) {
-        // 白名单
-        this.ShowCarWhite();
-      } else {
-        // 黑名单
-        this.ShowCarBlack();
-      }
     },
     // 修改size
-    sizeChange(val) {
+    async sizeChange(val) {
       this.size = val;
       this.pageNum = 1;
       this.listData = [];
-      if (this.btnSelected === 1) {
-        // 档案
-        this.getCarList();
-      } else if (this.btnSelected === 2) {
-        // 车辆通行
-        this.carPassage();
-      } else if (this.btnSelected === 3) {
-        // 车辆洗消
-        this.carWash();
-      } else if (this.btnSelected === 4) {
-        // 车辆烘干
-        this.carDrying();
-      } else if (this.btnSelected === 5) {
-        // 白名单
-        this.ShowCarWhite();
-      } else {
-        // 黑名单
-        this.ShowCarBlack();
-      }
+      const loading = this.$loading({
+        lock: true,
+        text: "加载中...",
+        spinner: "el-icon-loading",
+        background: "rgba(0, 0, 0, 0.7)",
+      });
+      await this.getPageFn(this.btnSelected)[0]();
+      loading.close();
     },
     // 修改页数
-    pageChange(val) {
+    async pageChange(val) {
       this.pageNum = val;
-      if (this.btnSelected === 1) {
-        // 档案
-        this.getCarList();
-      } else if (this.btnSelected === 2) {
-        // 车辆通行
-        this.carPassage();
-      } else if (this.btnSelected === 3) {
-        // 车辆洗消
-        this.carWash();
-      } else if (this.btnSelected === 4) {
-        // 车辆烘干
-        this.carDrying();
-      } else if (this.btnSelected === 5) {
-        // 白名单
-        this.ShowCarWhite();
-      } else {
-        // 黑名单
-        this.ShowCarBlack();
-      }
+      const loading = this.$loading({
+        lock: true,
+        text: "加载中...",
+        spinner: "el-icon-loading",
+        background: "rgba(0, 0, 0, 0.7)",
+      });
+      await this.getPageFn(this.btnSelected)[0]();
+      loading.close();
     },
     // 车辆通行 查询
     carPassage() {
@@ -719,7 +693,6 @@ export default {
         });
       }
     },
-
     // 车辆通行添加到车辆档案
     addBase(id) {
       let params = {