zhangzengfei
2022-12-05 c746783c4f570f9bdbe2d62b22bda22308b0dfba
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>
@@ -26,7 +26,7 @@
        <div class="products">
          <div class="title">统计分析</div>
          <div class="productList">
            <p class="p-statis" style=" vertical-align: top">
            <p class="p-statis" style="vertical-align: top">
              <span>时间:</span>
              <el-date-picker
                size="mini"
@@ -64,7 +64,7 @@
              <span>部门:</span>
              <el-cascader
                size="mini"
                style="width:400px"
                style="width: 400px"
                v-model="searchTree"
                :options="menuTree"
                :props="{ value: 'id', label: 'name', checkStrictly: true }"
@@ -80,7 +80,7 @@
                clearable
                collapse-tags
                size="mini"
                style="width:140px"
                style="width: 140px"
                placeholder="请选择"
              >
                <el-option
@@ -162,7 +162,7 @@
        <div class="left">
          <div class="title">预警数据占比:</div>
          <div class="info">
            <div class="equipmentInfo" style="margin-top:25px">
            <div class="equipmentInfo" style="margin-top: 25px">
              <div class="equipmentCard">
                <div class="label">整改总量</div>
                <div class="number">
@@ -198,7 +198,7 @@
                <el-table-column prop="count" align="center" label="整改数量" show-overflow-tooltip></el-table-column>
              </el-table>
              <el-pagination
              <!-- <el-pagination
                @current-change="refrash"
                @size-change="handleSizeChange"
                :current-page="page"
@@ -207,7 +207,7 @@
                :page-sizes="[5, 10, 15, 20, 25]"
                :total="solvedTotal"
                background
              ></el-pagination>
              ></el-pagination> -->
            </div>
          </div>
        </div>
@@ -250,7 +250,17 @@
      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() {
@@ -297,26 +307,49 @@
        },
        {
          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",
          openPath: "/report",
          path: "/report",
          permission: "statisticMng"
          name: "用户管理",
          icon: "/images/manageCenter/push.png",
          openPath: "/subAccount",
          path: "/subAccount",
          permission: "accountMng"
        },
        {
          name: "数据上传",
          icon: "/images/manageCenter/push.png",
          openPath: "/dataPush",
          path: "/dataPush",
          permission: "reportMng"
        },
        {
          name: "数据报表",
          icon: "/images/manageCenter/push.png",
          openPath: "/dataReport",
          path: "/dataReport",
          permission: ""
        },
        {
          name: "实时监控",
          icon: "/images/manageCenter/manage2.png",
          icon: "/images/manageCenter/video.png",
          openPath: "/video",
          path: "/video",
          permission: "statisticMng"
          permission: "videoMng"
        },
        {
          name: "点位变更",
          icon: "/images/manageCenter/cam.png",
          openPath: "/invalidCamera",
          path: "/invalidCamera",
          permission: "positionMng"
        }
      ],
      cameraTree: [],
@@ -434,6 +467,10 @@
          "rgb(255, 124, 31)",
          "rgb(165, 96, 255)"
        ],
        tooltip: {
          trigger: "item",
          formatter: "{b} {d}%" //只要百分比
        },
        series: [
          {
            name: "Nightingale Chart",
@@ -446,7 +483,9 @@
            },
            label: {
              show: false
              //formatter: '{b} : {c} ({d}%)' //带当前图例名 + 百分比
            },
            data: []
          }
        ]
@@ -457,17 +496,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() {
@@ -481,9 +521,30 @@
      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"]
            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))
        for (let i = 0; i < tmpTree.length; i++) this.clearNode(tmpTree[i])
        this.menuTree = tmpTree
        // console.log(this.cameraTree)
      }
    },
    clearNode(tree) {
@@ -503,14 +564,13 @@
      let selectedNode = {}
      let orgNodeIds = []
      if (this.selectedOrg == "") {
        return orgNodeIds
      if (this.selectedOrg == "" || this.selectedOrg == null) {
        return this.authorizedCameras
      }
      function findNode(node) {
        if (node.id == selectedNodeId) {
          selectedNode = node
          return
        }
@@ -553,30 +613,34 @@
        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("warningStatics", decodeResult)
            decodeResult.forEach((element) => {
              this.solvedTotal = this.solvedTotal + element.doc_count
              this.tableDataList.push({ date: element.key_as_string, count: element.doc_count })
              this.tableDataList.push({
                date: element.key_as_string,
                count: element.doc_count
              })
            })
          }
        }
      }
    },
    // 折线图
    decodeWarningStatics(b64data) {
    decodeWarningTable(b64data) {
      this.lineChart.clear()
      this.barOption.xAxis.data = []
      this.barOption.series[0].data = []
@@ -605,7 +669,10 @@
          let decodeResult = JSON.parse(decodeString)
          if (decodeResult) {
            decodeResult.forEach((element) => {
              this.pieOption.series[0].data.push({ value: element.doc_count, name: element.key })
              this.pieOption.series[0].data.push({
                value: element.doc_count,
                name: element.key
              })
            })
          }
        }
@@ -643,6 +710,12 @@
      }
    },
    handleTreeChange(value) {
      // console.log("change:", value)
      if (value == null) {
        this.selectedOrg = ""
        return
      }
      this.selectedOrg = value[value.length - 1]
    },
    getInfo() {
@@ -701,23 +774,10 @@
      this.pieChart.setOption(this.pieOption)
    },
    jump(route) {
      const userInfo = JSON.parse(sessionStorage.getItem("userInfo"))
      const val = userInfo.permissions.find((item) => {
        return item == route.permission
      const { href } = this.$router.resolve({
        path: route.path
      })
      if (val) {
        if (route.path === "/search" || route.path === "/dataView") {
          const { href } = this.$router.resolve({
            path: route.path
          })
          window.open(href, "_blank")
          return
        }
        this.$router.push(route.path)
      } else if (!userInfo.parentId) {
        this.$router.push(route.openPath)
      }
      window.open(href, "_blank")
    },
    refrash() {},
    handleSizeChange() {},
@@ -811,7 +871,7 @@
      display: flex;
      .productItem {
        margin-right: 20px;
        margin: 0px 10px;
        width: 190px;
        height: 90px;
        display: flex;