wenhongquan před 2 roky
rodič
revize
1de5f964b4

+ 7 - 0
src/api/gpsData/index.ts

@@ -74,3 +74,10 @@ export function playlist(): AxiosPromise<any> {
   });
 }
 
+export function offlinelist(): AxiosPromise<any> {
+  return request({
+    url: `/system/common/devicemsg`,
+    data: {},
+    method: 'post'
+  });
+}

+ 5 - 2
src/components/HomeComponents/stationPie.vue

@@ -118,8 +118,11 @@ const getdevices = () => {
     totaldevice.value = 0;
     onlinedevice.value = 0;
     for (let key in res) {
-      totaldevice.value += 1;
-      onlinedevice.value += res[key].offline =="1"?0:1;
+      if (res[key]["name"] == "快递柜") {
+         totaldevice.value += 1;
+         onlinedevice.value += res[key].offline =="1"?0:1;
+      }
+
     }
     drawEchart()
   });

+ 48 - 33
src/components/HomeComponents/warnTable.vue

@@ -1,46 +1,61 @@
 <template>
-    <div class="warnPageClass">
-        <div class="messagePageClass">
-            <div class="titleBg">
-                <div class="titleFont">设备告警</div>
-            </div>
-            <div class="divContent">
-                <div style="padding-left: 1vw;max-height: 30vh;overflow-y: scroll;" class="tableClass">
-                    <div v-for="(item, index) in messageList" style="margin-top:20px;">
-                        <div
-                            style="display: flex;flex-direction: row;justify-content: space-around;align-items: center;">
-                            <div>
-                                <img v-if="item.type == 1" src="@/assets/images/home/Rectangle8.png" />
-                                <img v-if="item.type == 2" src="@/assets/images/home/Rectangle8(1).png" />
-                            </div>
-                            <div class="contentClass">{{ item.content }}</div>
-                            <div class="timeClass">{{ item.time }}</div>
-                        </div>
-                        <el-divider />
-                    </div>
-                </div>
+  <div class="warnPageClass">
+    <div class="messagePageClass">
+      <div class="titleBg">
+        <div class="titleFont">设备告警</div>
+      </div>
+      <div class="divContent">
+        <div style="padding-left: 1vw;max-height: 30vh;overflow-y: scroll;" class="tableClass">
+          <div v-for="(item, index) in messageList" style="margin-top:20px;" :key="index">
+            <div style="display: flex;flex-direction: row;justify-content: space-around;align-items: center;">
+              <div>
+                <img v-if="item.type == 1" src="@/assets/images/home/Rectangle8.png" />
+                <img v-if="item.type == 2" src="@/assets/images/home/Rectangle8(1).png" />
+              </div>
+              <div class="contentClass">{{ item.content }}</div>
+              <div class="timeClass">{{moment(item.time).format("MM/DD HH:mm") }}</div>
             </div>
+            <el-divider />
+          </div>
         </div>
-        <!-- <div class="title">告警信息</div>-->
+      </div>
     </div>
+    <!-- <div class="title">告警信息</div>-->
+  </div>
 </template>
 
 <script setup name="CarInfo" lang="ts">
+import { offlinelist } from '@/api/gpsData';
+import moment from 'moment';
+
+const messageList = ref([]);
+
+const getList = () => {
+  offlinelist().then(res => {
+    let msg: any[] = [];
+    Object.keys(res).forEach(i => {
+      let d = res[i];
+      if (d["station"].indexOf("闽") != -1) {
+        d["type"] = 1;
+        d["content"] = d["station"] + "Gps离线,请及时处理!";
+      } else {
+        d["type"] = 2;
+         d["content"] = d["station"] + "快递柜离线,请及时处理!";
+      }
+      msg.push(res[i]);
+    })
+    //排序
+    msg = msg.sort((a, b) => {
+      return moment(a.time).unix() - moment(b.time).unix();
+    })
+    messageList.value = msg;
+
+  })
+};
 
-const messageList = ref([{ carNum: '闽JY3013', content: '闽J-Y3013GPS已离线,请及时处理。', station: '铁湖站', time: '5/10 17:26', type: 1 },
-{ carNum: '闽JY3013', content: '闽J-Y3013GPS已离线,请及时处理。', station: '铁湖站', time: '5/10 17:26', type: 2 },
-{ carNum: '闽JY3013', content: '闽J-Y3013GPS已离线,请及时处理。', station: '铁湖站', time: '5/10 17:26', type: 1 },
-{ carNum: '闽JY3013', content: '闽J-Y3013GPS已离线,请及时处理。', station: '铁湖站', time: '5/10 17:26', type: 1 },
-{ carNum: '闽JY3013', content: '闽J-Y3013GPS已离线,请及时处理。', station: '铁湖站', time: '5/10 17:26', type: 2 },
-{ carNum: '闽JY3013', content: '闽J-Y3013GPS已离线,请及时处理。', station: '铁湖站', time: '5/10 17:26', type: 1 },
-{ carNum: '闽JY3013', content: '闽J-Y3013GPS已离线,请及时处理。', station: '铁湖站', time: '5/10 17:26', type: 1 },
-{ carNum: '闽JY3013', content: '闽J-Y3013GPS已离线,请及时处理。', station: '铁湖站', time: '5/10 17:26', type: 2 },
-{ carNum: '闽JY3013', content: '闽J-Y3013GPS已离线,请及时处理。', station: '铁湖站', time: '5/10 17:26', type: 1 },
-{ carNum: '闽JY3013', content: '闽J-Y3013GPS已离线,请及时处理。', station: '铁湖站', time: '5/10 17:26', type: 1 }
-]);
 
 onMounted(() => {
-    // getList();
+    getList();
 });
 </script>
 <style scoped lang="scss">

+ 4 - 2
src/components/HomeStatics/stationPie.vue

@@ -61,8 +61,10 @@ const getdevices = () => {
     totaldevice.value = 0;
     onlinedevice.value = 0;
     for (let key in res) {
-      totaldevice.value += 1;
-      onlinedevice.value += res[key].offline =="1"?0:1;
+      if (res[key]["name"] == "快递柜") {
+         totaldevice.value += 1;
+         onlinedevice.value += res[key].offline =="1"?0:1;
+      }
     }
     drawEchart()
   });

+ 29 - 7
src/components/HomeStatics/warnTable.vue

@@ -9,7 +9,7 @@
             <img v-if="item.type == 2" src="@/assets/images/home/Rectangle8(1).png" />
           </div>
           <div class="contentClass">{{ item.content }}</div>
-          <div class="timeClass">{{ item.time }}</div>
+          <div class="timeClass">{{moment(item.time).format("MM/DD HH:mm") }}</div>
         </div>
         <el-divider />
       </div>
@@ -18,15 +18,37 @@
 </template>
 
 <script setup name="CarInfo" lang="ts">
+import { offlinelist} from '@/api/gpsData';
+import moment from 'moment';
+
+const messageList = ref([]);
+
+const getList = () => {
+  offlinelist().then(res => {
+    let msg: any[] = [];
+    Object.keys(res).forEach(i => {
+      let d = res[i];
+      if (d["station"].indexOf("闽") != -1) {
+        d["type"] = 1;
+        d["content"] = d["station"] + "Gps离线,请及时处理!";
+      } else {
+        d["type"] = 2;
+         d["content"] = d["station"] + "快递柜离线,请及时处理!";
+      }
+      msg.push(res[i]);
+    })
+    //排序
+    msg = msg.sort((a, b) => {
+      return moment(a.time).unix() - moment(b.time).unix();
+    })
+    messageList.value = msg;
+
+  })
+};
 
-const messageList = ref([{ carNum: '闽JY3013', content: '闽J-Y3013车辆GPS离线,请及时处理。', station: '铁湖站', time: '5/10 17:26', type: 1 },
-{ carNum: '闽JY3013', content: '铁湖站点的快递柜已离线,请及时处理。', station: '铁湖站', time: '5/10 17:26', type: 2 },
-{ carNum: '闽JY3013', content: '闽J-Y3013车辆GPS离线,请及时处理。', station: '铁湖站', time: '5/10 17:26', type: 1 },
-{ carNum: '闽JY3013', content: '铁湖站点的LED已离线,请及时处理。', station: '铁湖站', time: '5/10 17:26', type: 1 }
-]);
 
 onMounted(() => {
-    // getList();
+    getList();
 });
 </script>
 <style scoped lang="scss">