Sfoglia il codice sorgente

提交首页异常滞留

wangming 1 mese fa
parent
commit
e4342a55bc
2 ha cambiato i file con 86 aggiunte e 77 eliminazioni
  1. 65 71
      src/pages/home/home.vue
  2. 21 6
      src/pagesA/abnormalInfo/abnormalInfo.vue

+ 65 - 71
src/pages/home/home.vue

@@ -15,17 +15,6 @@
                 />
             </view>
             <view class="right">
-                <!-- <view class="rightItem">
-                    <view class="rightTitle">今日天气</view>
-                    <view class="rightPng">
-                        <view
-                            class="rightContent"
-                            style="text-align: center; font-size: 40rpx"
-                            >{{ weatherText }}</view
-                        >
-                    </view>
-                </view> -->
-
                 <view
                     class="rightItem"
                     @click="gotoDevice('/pagesA/devices/devices')"
@@ -105,29 +94,38 @@
         <view
             class="warmInfo"
             @click="goAbnormalInfo()"
-            v-if="warmList.length > 0"
+            v-if="alarmRetentionLists.length > 0"
         >
             <image src="../../static/warmImage.png" class="shareImage"></image>
             <view class="shareTitleContainer">
-                <view class="shareTitleList" v-if="warmList.length > 1">
+                <view
+                    class="shareTitleList"
+                    v-if="alarmRetentionLists.length > 1"
+                >
                     <view
                         class="shareTitle"
-                        v-for="item in warmList"
-                        :key="item.devId"
+                        v-for="item in alarmRetentionLists"
+                        :key="item.clientId"
                     >
-                        {{ item.devName }}检测到有目标滞留
+                        {{ item.devName }}检测到有{{
+                            getEventTypeName(item.eventType)
+                        }}
                     </view>
                     <view
                         class="shareTitle"
-                        v-for="(item, index) in warmList"
-                        :key="index"
+                        v-for="item in alarmRetentionLists"
+                        :key="item.clientId"
                     >
-                        {{ item.devName }}检测到有目标滞留
+                        {{ item.devName }}检测到有{{
+                            getEventTypeName(item.eventType)
+                        }}
                     </view>
                 </view>
                 <view class="shareTitleTwo" v-else>
                     <view class="shareTitle">
-                        {{ warmList[0].devName }}检测到有目标滞留
+                        {{ alarmRetentionLists[0].devName }}检测到有{{
+                            getEventTypeName(item.eventType)
+                        }}
                     </view>
                 </view>
             </view>
@@ -151,8 +149,8 @@ export default {
             devDevice: "",
             warmNum: "",
             warmDetail: [],
-            warmList: [],
-            weatherText: "",
+            alarmRetentionLists: [],
+            warmTypeList: [],
             isInitAlarm: false,
             isIniTenMinutes: false,
         };
@@ -255,52 +253,48 @@ export default {
                     this.shareNum = res.data.data?.length || 0;
                 });
         },
-        // 获取天气接口
-        // getWeather() {
-        //     uni.request({
-        //         url: "https://kp36x7gr79.re.qweatherapi.com/v7/weather/now", // 使用官方域名
-        //         data: {
-        //             location: "101220101", // 城市ID
-        //             key: "72afe228cd7f436ebea7caa1345956f2", // 你的API Key
-        //         },
-        //         method: "GET",
-        //         success: (res) => {
-        //             if (res.statusCode === 200) {
-        //                 this.weatherText = res.data.now.text;
-        //             }
-        //         },
-        //         fail: (err) => {
-        //             console.error("网络错误:", err);
-        //         },
-        //     });
-        // },
-        // 需要跟车对接一下,换一个接口
-        // getWarmList() {
-        //     this.$http
-        //         .post(
-        //             "wap/stats/alarmRetentionQuery",
-        //             {
-        //                 pageNo: 1,
-        //                 pageSize: 20,
-        //             },
-        //             {
-        //                 header: {
-        //                     "Content-Type": "application/json;charset=UTF-8",
-        //                     token: uni.getStorageSync("tokenValue") || "",
-        //                 },
-        //             }
-        //         )
-        //         .then((res) => {
-        //             if (res.data.data) {
-        //                 // this.warmNum = res.data.data.total;
-        //                 if (res.data.data.rows.length > 0) {
-        //                     this.warmDetail = res.data.data.rows;
-        //                     this.warmList = res.data.data.rows;
-        //                 }
-        //             }
-        //         });
-        //     uni.hideLoading();
-        // },
+
+        // 异常信息处理
+        getWarnList() {
+            uni.showLoading({
+                title: "查询中...",
+            });
+            this.$http
+                .post(
+                    "wap/stats/alarmEventsQuery",
+                    {
+                        pageNo: 1,
+                        pageSize: 3,
+                    },
+                    {
+                        header: {
+                            "Content-Type": "application/json;charset=UTF-8",
+                            token: uni.getStorageSync("tokenValue") || "",
+                        },
+                    }
+                )
+                .then((res) => {
+                    if (res.data.data) {
+                        this.alarmRetentionLists = res.data.data.rows;
+                    }
+                    uni.hideLoading();
+                });
+        },
+        getwarmType() {
+            this.$http
+                .get("pub/dic/query", { dicType: "alarm_event_type" })
+                .then((res) => {
+                    if (res.data.data) {
+                        this.warmTypeList = res.data.data;
+                    }
+                });
+        },
+        getEventTypeName(eventType) {
+            return (
+                this.warmTypeList.find((item) => item.itemCode == eventType)
+                    ?.itemName || "未知"
+            );
+        },
     },
     onLoad() {},
     onShow() {
@@ -310,8 +304,8 @@ export default {
             });
             this.getperSonInfo();
             this.getShareNum();
-            // this.getWarmList();
-            // this.getWeather();
+            this.getwarmType();
+            this.getWarnList();
             this.isInitAlarm = true;
             this.isIniTenMinutes = true;
         }
@@ -602,7 +596,7 @@ export default {
 .shareTitleList {
     display: flex;
     flex-direction: column;
-    animation: scrollUp 10s linear infinite;
+    animation: scrollUp 7s linear infinite;
 }
 .shareTitleTwo {
     display: flex;

+ 21 - 6
src/pagesA/abnormalInfo/abnormalInfo.vue

@@ -1,6 +1,6 @@
 <template>
     <view class="box">
-        <view class="search-box">
+        <!-- <view class="search-box">
             <view class="search-input">
                 <input
                     type="text"
@@ -10,7 +10,7 @@
                 />
             </view>
             <view class="search-btn" @click="searchBox"> 搜索 </view>
-        </view>
+        </view> -->
 
         <template v-if="alarmRetentionLists.length > 0">
             <view
@@ -36,7 +36,7 @@
                 </view>
                 <view class="menu-item">
                     <view class="meanLeft">
-                        <text>告警类型</text>
+                        <text>事件类型</text>
                     </view>
                     <view class="meanRight">
                         <text
@@ -61,10 +61,18 @@
                         >
                     </view>
                 </view>
+                <view class="menu-item">
+                    <view class="meanLeft">
+                        <text>事件内容</text>
+                    </view>
+                    <view class="meanRight">
+                        <text>{{ item.info }}</text></view
+                    >
+                </view>
             </view>
         </template>
         <view style="height: 20rpx"></view>
-        <!-- <alarModel ref="alarModel" /> -->
+        <alarModel v-if="isInitAlarm" />
     </view>
 </template>
 
@@ -78,6 +86,7 @@ export default {
             alarmRetentionLists: [],
             onReachJudge: true,
             warmTypeList: [],
+            isInitAlarm: "",
         };
     },
     methods: {
@@ -93,7 +102,7 @@ export default {
             });
             this.$http
                 .post(
-                    "wap/stats/alarmRetentionQuery",
+                    "wap/stats/alarmEventsQuery",
                     {
                         pageNo: this.pageNo,
                         pageSize: this.pageSize,
@@ -160,7 +169,13 @@ export default {
         });
     },
     onLoad() {
-        // this.$refs.alarModel.connectMQTTwo();
+        this.isInitAlarm = true;
+    },
+    onHide() {
+        this.isInitAlarm = false;
+    },
+    onUnload() {
+        this.isInitAlarm = false;
     },
 };
 </script>