zhangzengfei
2022-08-23 e37e45cfe1123928dba5d9c5a427b0ee497b7ad6
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>
@@ -250,7 +250,18 @@
      if (this.warningChecked == 0 || this.warningTotal == 0) {
        return 0
      }
      return parseInt(this.warningChecked / this.warningTotal) * 100 + "%"
      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() {
@@ -295,13 +306,28 @@
          path: "/search",
          permission: "statisticMng"
        },
        {
          name: "统计分析",
          icon: "/images/manageCenter/search.png",
          openPath: "/dataView",
          path: "/dataView",
          permission: "dataViewMng"
        },
        {
          name: "推送管理",
          icon: "/images/manageCenter/manage2.png",
          openPath: "/report",
          path: "/report",
          permission: "statisticMng"
          permission: "dataPushMng"
        },
        {
          name: "实时监控",
          icon: "/images/manageCenter/manage2.png",
          openPath: "/video",
          path: "/video",
          permission: "videoMng"
        }
      ],
      cameraTree: [],
@@ -442,17 +468,18 @@
      solvedTotal: 0,
      warningTotal: 0,
      warningChecked: 0,
      warningSolved: 0
      warningSolved: 0,
      authorizedCameras: []
    }
  },
  created() {
    this.getInfo()
  },
  mounted() {
  async mounted() {
    await this.getCameras()
    this.searchHandler()
    this.initBar()
    this.initPie()
    this.getCameras()
  },
  methods: {
    async getCameras() {
@@ -466,9 +493,29 @@
      let camereReq = await getLocalCameraTree({ clusterId: clusterId })
      if (camereReq && camereReq.success) {
        this.cameraTree = camereReq.data.treeMenu
        let tmpTree = JSON.parse(JSON.stringify(camereReq.data.treeMenu))
        let userInfo = JSON.parse(sessionStorage.getItem("userInfo"))
        // 管理员权限
        if (userInfo.username != "Administrator") {
          // 清理没有权限管理的摄像机, 后端修复后删除
          let checkedCameras = userInfo.email
          // basic 为子账户默认的空字段,表示可管理的摄像机目录为空
          if (checkedCameras == "basic") {
            this.cameraTree = ["basic"]
          } else {
            let cameraIds = checkedCameras.split(",")
            this.authorizedCameras = cameraIds
            this.TreeDataPool.removeNoAuthorizedNode(this.cameraTree, cameraIds)
          }
        }
        let tmpTree = JSON.parse(JSON.stringify(this.cameraTree))
        for (let i = 0; i < tmpTree.length; i++) this.clearNode(tmpTree[i])
        this.menuTree = tmpTree
        console.log(this.cameraTree)
      }
    },
    clearNode(tree) {
@@ -489,7 +536,7 @@
      let orgNodeIds = []
      if (this.selectedOrg == "") {
        return orgNodeIds
        return this.authorizedCameras
      }
      function findNode(node) {
@@ -552,6 +599,7 @@
          let decodeResult = JSON.parse(decodeString)
          decodeResult = []
          if (decodeResult) {
            console.log("decodeResult", decodeResult)
            decodeResult.forEach((element) => {
              this.solvedTotal = this.solvedTotal + element.doc_count
              this.tableDataList.push({ date: element.key_as_string, count: element.doc_count })
@@ -692,9 +740,9 @@
        return item == route.permission
      })
      if (val) {
        if (route.path === "/search") {
        if (route.path === "/search" || route.path === "/dataView") {
          const { href } = this.$router.resolve({
            path: "/search"
            path: route.path
          })
          window.open(href, "_blank")
          return