From 6f58ac928c7b9d9ef463dcd6d01826626b4e6d6e Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Fri, 09 Apr 2021 09:04:28 +0800
Subject: [PATCH] 卡片模式的相关调整

---
 src/api/supervisory/card.js           |    4 +-
 src/views/supervisoryConsole/card.vue |   88 +++++++++++++++++++++++++++++---------------
 2 files changed, 60 insertions(+), 32 deletions(-)

diff --git a/src/api/supervisory/card.js b/src/api/supervisory/card.js
index 4460ec2..b446c34 100644
--- a/src/api/supervisory/card.js
+++ b/src/api/supervisory/card.js
@@ -1,9 +1,9 @@
 import request from '@/router/axios';
 
-export const getList = () => {
+export const getList = (res) => {
   return request({
     url: '/api/blade-jfpts/equipment/equipment/listAll',
     method: 'get',
-    params: {}
+    params: {...res}
   })
 }
\ No newline at end of file
diff --git a/src/views/supervisoryConsole/card.vue b/src/views/supervisoryConsole/card.vue
index 8cf99b5..9d0bbe1 100644
--- a/src/views/supervisoryConsole/card.vue
+++ b/src/views/supervisoryConsole/card.vue
@@ -7,12 +7,17 @@
           v-model="inputSearchValue"
           class="input-with-select"
         >
-          <el-button slot="append" icon="el-icon-search"></el-button>
+          <el-button
+            slot="append"
+            icon="el-icon-search"
+            @click.stop="inputSearchBtn"
+          ></el-button>
         </el-input>
       </div>
       <div class="radio">
         <el-radio-group v-model="radio" @change="siteStatus">
-          <el-radio label="仅显示设备在线">仅显示设备在线</el-radio>
+          <el-radio label="全部">全部</el-radio>
+          <el-radio label="仅显示预警设备">仅显示预警设备</el-radio>
           <el-radio label="仅显示设备掉线">仅显示设备掉线</el-radio>
           <el-radio label="仅显示设备故障">仅显示设备故障</el-radio>
         </el-radio-group>
@@ -29,7 +34,7 @@
         v-for="(item, index) in option"
         :key="index"
       >
-       <!-- @click.stop="goToDetails(item.deviceNumber)" -->
+        <!-- @click.stop="goToDetails(item.deviceNumber)" -->
         <a :href="'/#/dataL/index?deviceNumber=' + item.deviceNumber">
           <el-card
             :style="
@@ -86,7 +91,7 @@
       option: [],
       count: [],
       loading: false,
-      radio: "仅显示设备在线",
+      radio: "全部",
       inputSearchValue: "",
     };
   },
@@ -99,30 +104,7 @@
     },
   },
   created() {
-    getList().then((res) => {
-      var a = [],
-        b = [],
-        c = [];
-
-      res.data.data.forEach((item) => {
-        if (item.state != "") a.push(item);
-        if (item.state == "" && item.onlineStatus != 1) b.push(item);
-        if (item.state == "" && item.onlineStatus == 1) c.push(item);
-      });
-
-      var d = a.concat(c.concat(b));
-
-      d.forEach((item) => {
-        this.count.push(item);
-      });
-      this.option = [];
-      for (var i = 0; i <= 24; i++) {
-        if (this.count.length > 0) {
-          this.option.push(this.count[0]);
-          this.count.shift();
-        }
-      }
-    });
+    this.getEquipmentLists();
   },
 
   methods: {
@@ -142,8 +124,54 @@
     siteStatus(value, e) {
       console.log(this.radio, value);
     },
-    goToDetails(data) {
-      this.$router.push({ path: "/dataL ", query: data });
+    inputSearchBtn() {
+      this.getEquipmentLists();
+    },
+
+    siteStatus() {
+      this.inputSearchValue = "";
+      this.getEquipmentLists();
+    },
+
+    getEquipmentLists() {
+      getList({ deviceName: this.inputSearchValue }).then((res) => {
+        var a = [],
+          b = [],
+          c = [];
+        if (this.radio == "全部") {
+          res.data.data.forEach((item) => {
+            if (item.state != "") a.push(item);
+            if (item.state == "" && item.onlineStatus == 1) c.push(item);
+            if (item.state == "" && item.onlineStatus != 1) b.push(item);
+          });
+        } else if (this.radio == "仅显示预警设备") {
+          res.data.data.forEach((item) => {
+            if (item.state == "" && item.onlineStatus == 1) c.push(item);
+          });
+        } else if (this.radio == "仅显示设备掉线") {
+          res.data.data.forEach((item) => {
+            if (item.state == "" && item.onlineStatus != 1) b.push(item);
+          });
+        } else if (this.radio == "仅显示设备故障") {
+          res.data.data.forEach((item) => {
+            if (item.state != "") a.push(item);
+          });
+        }
+
+        var d = a.concat(c.concat(b));
+
+        d.forEach((item) => {
+          this.count.push(item);
+        });
+        this.option = [];
+        for (var i = 0; i <= 24; i++) {
+          if (this.count.length > 0) {
+            this.option.push(this.count[0]);
+            this.count.shift();
+          }
+        }
+        this.inputSearchValue = "";
+      });
     },
   },
 };

--
Gitblit v1.9.3