From 3834d30a6d56ad7c4d4f5fe630af649ab6826428 Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期日, 28 八月 2022 22:25:58 +0800
Subject: [PATCH] 修复管理中心首页分析项

---
 src/views/manageCenter/index.vue |   73 +++++++++++++++++++++---------------
 1 files changed, 43 insertions(+), 30 deletions(-)

diff --git a/src/views/manageCenter/index.vue b/src/views/manageCenter/index.vue
index f72fe0a..c8914db 100644
--- a/src/views/manageCenter/index.vue
+++ b/src/views/manageCenter/index.vue
@@ -15,7 +15,7 @@
       <div class="products">
         <div class="title">鍏ㄩ儴浜у搧</div>
         <div class="productList">
-          <div class="productItem" v-for="(item, index) in productList" :key="index" @click="jump(item)">
+          <div class="productItem" v-for="(item, index) in permissionMenuList" :key="index" @click="jump(item)">
             <img :src="item.icon" alt="" />
             <div class="name">{{ item.name }}</div>
           </div>
@@ -251,6 +251,16 @@
         return 0
       }
       return parseInt((this.warningChecked / this.warningTotal) * 100) + "%"
+    },
+    permissionMenuList() {
+      let user = JSON.parse(sessionStorage.getItem("userInfo"))
+      if (user.username == "Administrator") {
+        return this.productList
+      }
+
+      return this.productList.filter((item) => {
+        return user.permissions.indexOf(item.permission) >= 0
+      })
     }
   },
   data() {
@@ -297,26 +307,26 @@
         },
         {
           name: "缁熻鍒嗘瀽",
-          icon: "/images/manageCenter/search.png",
+          icon: "/images/manageCenter/datav.png",
           openPath: "/dataView",
           path: "/dataView",
-          permission: "statisticMng"
+          permission: "dataViewMng"
         },
 
         {
           name: "鎺ㄩ�佺鐞�",
-          icon: "/images/manageCenter/manage2.png",
+          icon: "/images/manageCenter/push.png",
           openPath: "/report",
           path: "/report",
-          permission: "statisticMng"
+          permission: "dataPushMng"
         },
 
         {
           name: "瀹炴椂鐩戞帶",
-          icon: "/images/manageCenter/manage2.png",
+          icon: "/images/manageCenter/video.png",
           openPath: "/video",
           path: "/video",
-          permission: "statisticMng"
+          permission: "videoMng"
         }
       ],
       cameraTree: [],
@@ -483,23 +493,21 @@
       if (camereReq && camereReq.success) {
         this.cameraTree = camereReq.data.treeMenu
 
-        // 娓呯悊娌℃湁鏉冮檺绠$悊鐨勬憚鍍忔満, 鍚庣淇鍚庡垹闄�
         let userInfo = JSON.parse(sessionStorage.getItem("userInfo"))
-
         // 绠$悊鍛樻潈闄�
-        if (userInfo.username == "Administrator") {
-          return
-        }
+        if (userInfo.username != "Administrator") {
+          // 娓呯悊娌℃湁鏉冮檺绠$悊鐨勬憚鍍忔満, 鍚庣淇鍚庡垹闄�
+          let checkedCameras = userInfo.email
 
-        let checkedCameras = userInfo.email
-
-        // basic 涓哄瓙璐︽埛榛樿鐨勭┖瀛楁,琛ㄧず鍙鐞嗙殑鎽勫儚鏈虹洰褰曚负绌�
-        if (checkedCameras == "basic") {
-          this.cameraTree = []
-        } else {
-          let cameraIds = checkedCameras.split(",")
-          this.authorizedCameras = cameraIds
-          this.TreeDataPool.removeNoAuthorizedNode(this.cameraTree, cameraIds)
+          // basic 涓哄瓙璐︽埛榛樿鐨勭┖瀛楁,琛ㄧず鍙鐞嗙殑鎽勫儚鏈虹洰褰曚负绌�
+          if (checkedCameras == "basic") {
+            this.cameraTree = ["basic"]
+            this.authorizedCameras = ["basic"]
+          } else {
+            let cameraIds = checkedCameras.split(",")
+            this.authorizedCameras = cameraIds
+            this.TreeDataPool.removeNoAuthorizedNode(this.cameraTree, cameraIds)
+          }
         }
 
         let tmpTree = JSON.parse(JSON.stringify(this.cameraTree))
@@ -507,7 +515,7 @@
         for (let i = 0; i < tmpTree.length; i++) this.clearNode(tmpTree[i])
         this.menuTree = tmpTree
 
-        console.log(this.cameraTree)
+        // console.log(this.cameraTree)
       }
     },
     clearNode(tree) {
@@ -527,14 +535,13 @@
       let selectedNode = {}
       let orgNodeIds = []
 
-      if (this.selectedOrg == "") {
+      if (this.selectedOrg == "" || this.selectedOrg == null) {
         return this.authorizedCameras
       }
 
       function findNode(node) {
         if (node.id == selectedNodeId) {
           selectedNode = node
-
           return
         }
 
@@ -577,21 +584,21 @@
         if (rsp && rsp.success) {
           this.decodeWarningRate(rsp.data.warningRate)
           this.decodeWarningChartRate(rsp.data.warningChartRate)
-          this.decodeWarningStatics(rsp.data.warningTable)
-          this.decodeWarningTable(rsp.data.warningStatics)
+          this.decodeWarningStatics(rsp.data.warningStatics)
+          this.decodeWarningTable(rsp.data.warningTable)
         }
       })
     },
-    decodeWarningTable(b64data) {
+    // 鏁存敼鍒楄〃
+    decodeWarningStatics(b64data) {
       this.solvedTotal = 0
       this.tableDataList = []
       if (b64data) {
         let decodeString = Base64.decode(b64data)
         if (decodeString != "") {
           let decodeResult = JSON.parse(decodeString)
-          decodeResult = []
           if (decodeResult) {
-            console.log("decodeResult", decodeResult)
+            console.log("warningStatics", decodeResult)
             decodeResult.forEach((element) => {
               this.solvedTotal = this.solvedTotal + element.doc_count
               this.tableDataList.push({ date: element.key_as_string, count: element.doc_count })
@@ -601,7 +608,7 @@
       }
     },
     // 鎶樼嚎鍥�
-    decodeWarningStatics(b64data) {
+    decodeWarningTable(b64data) {
       this.lineChart.clear()
       this.barOption.xAxis.data = []
       this.barOption.series[0].data = []
@@ -668,6 +675,12 @@
       }
     },
     handleTreeChange(value) {
+      // console.log("change:", value)
+      if (value == null) {
+        this.selectedOrg = ""
+
+        return
+      }
       this.selectedOrg = value[value.length - 1]
     },
     getInfo() {

--
Gitblit v1.8.0