bulusiLuo 1 year ago
parent
commit
eae597f9f7
1 changed files with 92 additions and 7 deletions
  1. 92 7
      src/layout/components/AppMain.vue

+ 92 - 7
src/layout/components/AppMain.vue

@@ -23,13 +23,18 @@
             layout="prev, pager, next"
             pager-count="3"
             :total="total"
+            small
           >
           </el-pagination>
+          <el-button
+            type="primary"
+            size="small"
+            class="btn"
+            @click="handleClick(data)"
+            >标 记</el-button
+          >
         </div>
       </div>
-      <el-button type="primary" size="small" class="btn" @click="shuo = false"
-        >确 定</el-button
-      >
     </el-card>
   </section>
 </template>
@@ -37,7 +42,7 @@
 <script>
 // import { asyncRoutes } from '@/router/router.config'
 import { uploadRoute } from "@/api/user";
-import { getNotifications } from "@/api/dashboard";
+import { getNotifications, markAsRead } from "@/api/dashboard";
 
 export default {
   name: "AppMain",
@@ -63,16 +68,82 @@ export default {
         current: 1,
         type: 8,
         tableName: "SCADA_HISTORY",
+        flag: 0,
       },
       total: 0,
       topic: "",
       message: "",
+      data: null,
     };
   },
   mounted() {
     this.getNotificationList();
   },
   methods: {
+    // 列表行点击操作
+    handleClick(data) {
+      const setRoute = (row) => {
+        // console.log(row.routeIp, "row.routeIp");
+        row.routeIp && this.$router.push({ path: row.routeIp });
+        const splitRoute = row.routeIp.split("/");
+        const target = splitRoute[splitRoute.length - 1];
+        // const target = splitRoute[1]
+        const origin = JSON.parse(
+          JSON.stringify(this.$store.state.routeSetting.dynamicRoutes)
+        );
+        delete origin.dashboard;
+        for (const key in origin) {
+          for (const item of origin[key]) {
+            if (!this.arrayIsNull(item.children)) {
+              let result = item.children.find((route) => {
+                if (route.name === target || route.path === target) {
+                  return route;
+                }
+              });
+              if (!this.arrayIsNull(result)) {
+                result = key;
+                return result;
+              }
+            }
+          }
+        }
+        return result;
+      };
+
+      const setMapParent = (target) => {
+        const origin = JSON.parse(
+          JSON.stringify(this.$store.state.routeSetting.dynamicRoutes)
+        );
+        for (const key in origin) {
+          for (const item of origin[key]) {
+            if (!this.arrayIsNull(item.children)) {
+              let result = item.children.find((route) => {
+                if (route.name === target || route.path === target) {
+                  return route;
+                }
+              });
+              if (!this.strIsNull(result)) {
+                result = key;
+                return result;
+              }
+            }
+          }
+        }
+        return result;
+      };
+
+      // const { row } = data
+      const row = data;
+      //  console.log("类型:",type,JSON.stringify(row))
+
+      const param = {
+        messageIds: row.id.toString(),
+      };
+      markAsRead(param).then(() => {
+        // this.$emit("reget-noti");
+        this.handleCurrentChange();
+      });
+    },
     handleCurrentChange(value) {
       console.log("2333", value);
       this.pagination.current = value;
@@ -86,10 +157,13 @@ export default {
       getNotifications(data).then((res) => {
         if (res.code == 1) {
           if (res.result.records.length > 0) {
+            this.data = res.result.records[0];
             this.topic = res.result.records[0].topic;
             this.message = res.result.records[0].message;
             this.total = res.result.total;
             this.mainShow = true;
+          } else {
+            this.shuo = false;
           }
         }
       });
@@ -101,6 +175,7 @@ export default {
       getNotifications(data).then((res) => {
         if (res.code == 1) {
           if (res.result.records.length > 0) {
+            this.data = res.result.records[0];
             this.topic = res.result.records[0].topic;
             this.message = res.result.records[0].message;
             this.total = res.result.total;
@@ -109,6 +184,13 @@ export default {
         }
       });
     },
+    /**
+     * @description 判断字符串是否为空
+     */
+    strIsNull(strVal) {
+      strVal = strVal || "";
+      return typeof strVal === "undefined" || strVal == null || strVal == "";
+    },
     uploadRouteTable() {
       const data = {
         1: JSON.stringify({
@@ -144,8 +226,8 @@ export default {
 }
 .btn {
   position: absolute;
-  bottom: 10px;
   right: 10px;
+  bottom: 0;
 }
 .title {
   height: 40px;
@@ -156,7 +238,7 @@ export default {
   cursor: pointer;
 }
 .text {
-  height: 160px;
+  height: 190px;
 }
 .p {
   margin: 0;
@@ -169,7 +251,10 @@ export default {
   -webkit-box-orient: vertical;
 }
 .block {
-  width: 150px;
+  width: 280px;
+  display: flex;
+  justify-content: space-between;
+  position: relative;
 }
 .fixed-header + .app-main {
   padding-top: 43px;