index.vue 21.1 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659
<template>
  <div class="home_page">

    <!-- 区域查车按钮 开始 -->
    <div class="area_car" @click="openAreaCar()" v-if="hasPermission('INDEX_AREA_SEARCH_CAR')">
      <img src="https://img01.glsx.com.cn/weapp/resource/e-shield/car.png" alt="" class="img" />
    </div>
    <!-- 区域查车按钮 end -->

    <!-- 数据列表 开始 -->
    <div class="static_list_box">
     <div class="mask" v-show="maskFlag"><i class="el-icon-loading" style="font-size: 20px;"></i>loading...</div>
      <!-- 总绑定数 开始 -->
      <div class="cell_box">
        <!-- 表头 开始 -->
        <div class="head">
          <span>总绑定数</span>
          <el-tooltip class="item" effect="dark" placement="right-start">
            <div slot="content">
              <p>总绑定数:统计该账号权限下,车辆绑定总数</p>
              <p>趋势图:统计该账号权限下,最近30天的日车辆绑定数趋势</p>
              <p>今日绑定数:统计该账号权限下,今日车辆绑定数</p>
            </div>
            <i class="el-icon-question"></i>
          </el-tooltip>
        </div>
        <!-- 表头 end -->
        <!-- 数据 开始 -->
        <div class="info_box">
          <div class="title">{{staticInfo.allBindNumber}}</div>
          <div id="bindChart" class="c_canvas"></div>
          <div class="footer">
            今日绑定数:{{staticInfo.bindNumForToday}}
          </div>
        </div>
        <!-- 数据 end -->
      </div>
      <!-- 总绑定数 end -->

      <!-- 总激活数 开始 -->
      <div class="cell_box">
        <!-- 表头 开始 -->
        <div class="head">
          <span>总激活数</span>
          <el-tooltip class="item" effect="dark" placement="right-start">
            <div slot="content">
              <p>总激活数:统计该账号权限下,有线设备和无线设备的激活数之和;</p>
              <p>趋势图:统计该账号权限下,最近30天的日激活数趋势;</p>
              <p>今日激活数:统计该账号权限下,今日有线设备和无线设备的激活数之和;</p>
            </div>
            <i class="el-icon-question"></i>
          </el-tooltip>
        </div>
        <!-- 表头 end -->
        <!-- 数据 开始 -->
        <div class="info_box">
          <div class="title">{{staticInfo.allActiveNumber}}</div>
          <div id="activedChart" class="c_canvas"></div>
          <div class="footer">
            今日激活数:{{staticInfo.activeNumForToday}}
          </div>
        </div>
        <!-- 数据 end -->
      </div>
      <!-- 总激活数 end -->

      <!-- 设备数 开始 -->
      <div class="cell_box" style="flex: 2;">
        <!-- 表头 开始 -->
        <div class="head">
          <span>设备数</span>
        </div>
        <!-- 表头 end -->
        <!-- 数据 开始 -->
        <div class="info_box">
         <div class="equipment_box">
          <!-- 设备在线数 -->
          <div class="equipment_boxs">
           <div>
            <span>设备在线数</span>
            <el-tooltip class="item" effect="dark" placement="right-start">
              <div slot="content">
                <p>{{hasPermission('data_doard_offLine') ? '在线数 = 总在线数 + 假性离线数' : '在线数 = 有线设备在线数 + 无线设备在线数'}}</p>
                <p>{{hasPermission('data_doard_offLine') ? '总在线数:' : '有线设备在线数:'}}</p>
                <p>
                  统计该账号权限下,在统计当日所有设备在线率情况,
                  <span>3天内(72小时内)</span>连接服务器即认为在线;
                </p>
                <p v-show="!hasPermission('data_doard_offLine')">无线设备在线数:</p>
                <p v-show="!hasPermission('data_doard_offLine')">
                  统计该账号权限下,在统计当日所有设备在线率情况,
                  <span>3天内(72小时内)</span>连接服务器即认为在线;
                </p>
                <p v-show="hasPermission('data_doard_offLine')">假性离线数:</p>
                <p v-show="hasPermission('data_doard_offLine')">
                  统计该账号权限下,在统计当日所有设备假性离线情况,
                  <span>若满足对应条件则判定为假性离线,即在线;</span>
                </p>
                <p>{{hasPermission('data_doard_offLine') ? '总在线率 = (设备在线数 + 假性离线数)/ 总激活数;' : '在线率 = 在线数 / 总激活数;'}}</p>
                <p>{{hasPermission('data_doard_offLine') ? '总在线率保留百分位,四舍五入' : '在线率保留百分位,四舍五入'}}</p>
              </div>
              <i class="el-icon-question"></i>
            </el-tooltip>
            <div class="title" style="margin-top: 10px;">{{staticInfo.onlineNumber}}</div>
            </div>
            <div id="onlineChart" class="c_canvass"></div>
           </div>
           <!-- 假性离线数 -->
          <div class="equipment_boxs" v-show="hasPermission('data_doard_offLine')">
            <div>
             <span>假性离线数</span>
             <div class="title" style="margin-top: 10px;">{{staticInfo.fakeOfflineNumber}}</div>
            </div>
            <div id="fakeOfflineChart" class="c_canvass"></div>
           </div>
           <!-- 设备离线数 -->
          <div class="equipment_boxs">
            <div>
             <span>设备离线数</span>
             <el-tooltip class="item" effect="dark" placement="right-start">
               <div slot="content">
                 <p>{{hasPermission('data_doard_offLine') ? '离线数 = 总离线数 - 假性离线数' : '离线数 = 有线设备离线数 + 无线设备离线数'}}</p>
                 <p>{{hasPermission('data_doard_offLine') ? '总离线数:' : '有线设备离线数:'}}</p>
                 <p>
                   统计该账号权限下,在统计当日所有设备在线率情况,
                   <span>3天内(72小时内)</span>
                   无连接服务器即认为离线;
                 </p>
                 <p v-show="!hasPermission('data_doard_offLine')">无线设备离线数:</p>
                 <p v-show="!hasPermission('data_doard_offLine')">
                   统计该账号权限下,在统计当日所有设备在线率情况,
                   <span>3天内(72小时内)</span>
                   无连接服务器即认为离线;
                 </p>
                 <p v-show="hasPermission('data_doard_offLine')">假性离线数:</p>
                 <p v-show="hasPermission('data_doard_offLine')">
                  统计该账号权限下,在统计当日所有设备假性离线情况,若满足对应条件则判定为假性离线,即在线,并从离线率中剔除;
                 </p>
                 <p>{{hasPermission('data_doard_offLine') ? '离线率 = (总离线数 - 假性离线数)/ 总激活数;' : '离线率 = 离线数 / 总激活数;'}}</p>
                 <p>离线率保留百分位,四舍五入</p>
                 <p v-if="isZhongli && staticInfo.offlineSnNum>0">确认{{staticInfo.offlineSnNum}}台设备加入白名单,不予统计</p>
               </div>
               <i class="el-icon-question"></i>
             </el-tooltip>
             <div class="title" style="margin-top: 10px;" v-show="staticInfo.offlineNumber != undefined">{{hasPermission('data_doard_offLine') ?  staticInfo.offlineNumber - staticInfo.fakeOfflineNumber : staticInfo.offlineNumber}}</div>
            </div>
            <div id="offlineChart" class="c_canvass"></div>
           </div>
           
          </div>
          <div class="footer">
            <div class="footer-box">
             <span style="color: #0196FA;">{{hasPermission('data_doard_offLine') ? '设备总在线率:' : '设备在线率:'}}</span>
             <span style="color: #0196FA;" v-show="staticInfo.onlineRate != undefined">{{hasPermission('data_doard_offLine') ? addSub(staticInfo.onlineRate, staticInfo.fakeOfflineRate) : staticInfo.onlineRate}}%</span>
            </div>
            <div class="footer-box" v-show="hasPermission('data_doard_offLine')"></div>
            <div class="footer-box">
             <span style="color: #F47F13;">设备离线率:</span>
             <span style="color: #F47F13;" v-show="staticInfo.offlineRate != undefined">{{hasPermission('data_doard_offLine') ? accSub(staticInfo.offlineRate, staticInfo.fakeOfflineRate) : staticInfo.offlineRate}}%</span>
            </div>
          </div>
        </div>
        <!-- 数据 end -->
      </div>
      <!-- 设备数 end -->

    </div>
    <!-- 数据列表 end -->

    <!-- 常规报警 开始 -->
    <div class="alarm_box">
      <div class="head">常规报警</div>
      <div class="alarm_list">

        <!-- 防拆报警 开始 -->
        <div class="cell" @click="linkToPage('/trialRun#/alarmCenter/fence')">
          <div class="title">
            <img src="@/assets/images/enclosureicon.png" />
            <span>围栏报警</span>
          </div>
          <div class="num">{{fenceAlarmCount||0}}</div>
        </div>
        <!-- 防拆报警 end -->

        <!-- 防拆报警 开始 -->
        <div class="cell" @click="linkToPage('/trialRun#/alarmCenter/tamper')">
          <div class="title">
            <img src="@/assets/images/stopicon.png" />
            <span>防拆报警</span>
          </div>
          <div class="num">{{alarmInfo.tearDownAlarmCount||0}}</div>
        </div>
        <!-- 防拆报警 end -->

        <!-- 离线预警 开始 -->
        <div class="cell" @click="linkToPage('/trialRun#/alarmCenter/offline',alarmInfo.offLineAlarmStartTime,alarmInfo.offLineAlarmEndTime)">
          <div class="title">
            <img src="@/assets/images/off-lineicon.png" />
            <span>离线预警</span>
          </div>
          <div class="num">{{alarmInfo.offLineAlarmCount||0}}</div>
        </div>
        <!-- 离线预警 end -->

        <!-- 大数据研判警情 开始 -->
        <div class="cell" @click="linkToPage('/trialRun#/alarmCenter/hadoop')">
          <div class="title">
            <img src="@/assets/images/equipmenticon.png" />
            <span>大数据研判警情</span>
          </div>
          <div class="num">{{alarmInfo.stuJudgeAlarmCount||0}}</div>
        </div>
        <!-- 大数据研判警情 end -->

      </div>
    </div>
    <!-- 常规报警 end -->

    <!-- 设备激活趋势 开始 -->
    <div class="alarm_box device_box">
      <div class="head">
        <span>设备激活趋势</span>
        <div>
          <el-button-group>
            <el-button v-for="(item,index) in links" :key="index" :type="active == item.id?'success':'default'" @click="linkEvent(item)" size="mini">{{item.name}}</el-button>
          </el-button-group>
        </div>
      </div>
      <div class="chart_box">
        <div class="chart_wrapper" id="activedChartBox"></div>
      </div>
    </div>
    <!-- 设备激活趋势 开始 -->

  </div>
</template>

<script>
import {
  GET_HOME_DEVICENUMBER,
  GET_HOME_ALARMNUMBER,
  GET_HOME_ACTIVEDEVICEINFO,
  GET_HOME_AUTHUSERORG,
  GET_HOME_NEWBINDDEVICEINFO,
  GET_FENCE_ALARM
} from "@/services/home";
//import chartConfig from "@/chart/chartConfig.js";
import * as echarts from "echarts/core";
import { LineChart,PieChart } from 'echarts/charts';
import {
  TitleComponent,
  TooltipComponent,
  GridComponent,
  DatasetComponent,
  TransformComponent
} from 'echarts/components';
import { CanvasRenderer } from 'echarts/renderers';
echarts.use([
  LineChart,
  PieChart,
  TitleComponent,
  TooltipComponent,
  GridComponent,
  DatasetComponent,
  TransformComponent,
  CanvasRenderer
])
export default {
  data() {
    return {
      links: [
        { name: "今天", id: 1 },
        { name: "昨天", id: 2 },
        { name: "近7天", id: 10 },
        { name: "本月", id: 5 },
        { name: "上月", id: 6 },
        { name: "近30日", id: 11 },
      ],
      active: 2,
      staticInfo: {},
      alarmInfo: {},
      isZhongli: false,
      maskFlag: true,
      fenceAlarmCount:0
    };
  },
  mounted() {
    this.getAlarm();
    this.getFenceAlarm()
    this.getActived(this.createActivedLineChart);
    this.getActived(this.createAllActivedLineChart, 11);
    this.getBindEchart();
    //GET_HOME_AUTHUSERORG().then((res) => {});
    this.getRoles();
  },
  activated() {
    this.getStatic();
  },
  methods: {
    // 是否有权限
    hasPermission(id) {
      let list = this.$root.parentCommon.getAuthData();
      let idx = list.findIndex((k) => k.origin.permissionTag == id);
      if (idx < 0) {
        return false;
      } else {
        return true;
      }
    },
    // 切换日期
    linkEvent(row) {
      this.active = row.id;
      this.getActived(this.createActivedLineChart);
    },

    // 获取统计数据
    getStatic() {
      GET_HOME_DEVICENUMBER().then((res) => {
        let obj = res.data || {};
        this.staticInfo = obj;

        // 在线率
        let m = [];
        m.push({ value: this.accSub(100, obj.onlineRate), name: "" });
        m.push({ value: obj.onlineRate, name: "" });
        if (obj.onlineRate == 0 || obj.onlineRate == 100) {
          this.unCreateBindChart("onlineChart", m);
        } else {
          this.createBindChart("onlineChart", m);
        }

        // 离线率
        let n = [];
        n.push({ value: obj.offlineRate, name: "" });
        n.push({ value: this.accSub(100, obj.offlineRate), name: "" });

        if (this.hasPermission('data_doard_offLine')) {
          n = []
          const b = this.accSub(100, obj.offlineRate)
          n.push({ value: this.accSub(obj.offlineRate, obj.fakeOfflineRate), name: "" });
          n.push({ value: this.addSub(b, obj.fakeOfflineRate), name: "" });
        }
        if (this.accSub(obj.offlineRate, obj.fakeOfflineRate) == 0 || this.accSub(obj.offlineRate, obj.fakeOfflineRate) == 100 || obj.offlineRate == 0 || obj.offlineRate == 100) {
          this.unCreateChart("offlineChart", n);
        } else {
          this.createChart("offlineChart", n);
        }

        // 假性离线率
        let x = []
        if (this.hasPermission('data_doard_offLine')) {
          x.push({ value: this.accSub(100, obj.fakeOfflineRate), name: "" });
          x.push({ value: obj.fakeOfflineRate, name: "" });
        }
        if (obj.fakeOfflineRate == 0 || obj.fakeOfflineRate == 100) {
          this.unCreateBindChart("fakeOfflineChart", x);
        } else {
          this.createBindChart("fakeOfflineChart", x);
        }
        this.maskFlag = false
      });
    },
    // 减法计算函数
    accSub(arg1, arg2) {
        let a = arg1 - arg2
        a = Math.round((a) * 100) / 100
        a.toFixed(2)
        return a
   },
   // 加法计算函数
   addSub(arg1, arg2) {
      let b = Number(arg1) + Number(arg2)
      b = Math.round((b) * 100) / 100
      b.toFixed(2)
      return b
   },
    // 获取警情统计
    getAlarm() {
      GET_HOME_ALARMNUMBER().then((res) => {
        this.alarmInfo = res.data || {};
      });
    },

    // 获取设备激活趋势
    getActived(callBack, id) {
      let oParams = {};
      oParams.period = id || this.active;
      console.log(oParams);
      GET_HOME_ACTIVEDEVICEINFO(oParams).then((res) => {
        console.log(res);
        if (res.code != 200) {
          return false;
        }
        let m = res.data || [];
        callBack(m);
      });
    },

    // 创建设备激活趋势折线图
    createActivedLineChart(m) {
      let xAxis = [];
      let yAxis = [];
      m.map((k) => {
        xAxis.push(k.activeDate);
        yAxis.push(k.activeNumber);
      });
      var aChart = echarts.init(document.getElementById("activedChartBox"));
      aChart.setOption({
        tooltip: {
          trigger: "axis",
        },
        xAxis: {
          type: "category",
          boundaryGap: false,
          data: xAxis,
          axisLabel: {
            rotate: 45,
          },
        },
        yAxis: {
          type: "value",
          minInterval: 1,
        },
        series: [
          {
            symbol: "none",
            smooth: true,
            data: yAxis,
            type: "line",
            areaStyle: {},
          },
        ],
      });
    },

    // 创建含有最小比例环形图表
    createBindChart(id, data) {
      var aChart = echarts.init(document.getElementById(id));
      aChart.setOption({
        tooltip: {
          show: true,
          formatter: "{c0}%",
        },
        legendHoverLink: false,
        color: [
          "#c0c0c0",
          "#0096fa",
          "#fac858",
          "#ee6666",
          "#73c0de",
          "#3ba272",
          "#fc8452",
          "#9a60b4",
          "#ea7ccc",
        ],
        series: [
          {
            type: "pie",
            radius: ["40%", "70%"],
            labelLine: {
              show: false,
            },
            data: data,
            minAngle: 11
          },
        ],
      });
    },
    // 创建没有最小比例环形图表
    unCreateBindChart(id, data) {
      var aChart = echarts.init(document.getElementById(id));
      aChart.setOption({
        tooltip: {
          show: true,
          formatter: "{c0}%",
        },
        legendHoverLink: false,
        color: [
          "#c0c0c0",
          "#0096fa",
          "#fac858",
          "#ee6666",
          "#73c0de",
          "#3ba272",
          "#fc8452",
          "#9a60b4",
          "#ea7ccc",
        ],
        series: [
          {
            type: "pie",
            radius: ["40%", "70%"],
            labelLine: {
              show: false,
            },
            data: data
          },
        ],
      });
    },
    // 含有最小比例离线率环形图表
    createChart(id, data) {
      var aChart = echarts.init(document.getElementById(id));
      aChart.setOption({
        tooltip: {
          show: true,
          formatter: "{c0}%",
        },
        legendHoverLink: false,
        color: [
          "#F6B06F",
          "#c0c0c0",
          "#fac858",
          "#ee6666",
          "#73c0de",
          "#3ba272",
          "#fc8452",
          "#9a60b4",
          "#ea7ccc",
        ],
        series: [
          {
            type: "pie",
            radius: ["40%", "70%"],
            labelLine: {
              show: false,
            },
            data: data,
            minAngle: 11
          },
        ],
      });
    },
    // 没有最小比例离线率环形图表
    unCreateChart(id, data) {
      var aChart = echarts.init(document.getElementById(id));
      aChart.setOption({
        tooltip: {
          show: true,
          formatter: "{c0}%",
        },
        legendHoverLink: false,
        color: [
          "#F6B06F",
          "#c0c0c0",
          "#fac858",
          "#ee6666",
          "#73c0de",
          "#3ba272",
          "#fc8452",
          "#9a60b4",
          "#ea7ccc",
        ],
        series: [
          {
            type: "pie",
            radius: ["40%", "70%"],
            labelLine: {
              show: false,
            },
            data: data
          },
        ],
      });
    },
    // 页面跳转
    linkToPage(path, start, end) {
      let row = { alarmStatus: 1 };
      this.$root.parentCommon.setBreadCrumbs(path);
      let url = path;
      if (start) {
        url = `${path}?startTime=${start}&endTime=${end}`;
      }
      history.pushState(row, "", url);
    },

    // 获取总绑定数报表
    getBindEchart() {
      GET_HOME_NEWBINDDEVICEINFO().then((res) => {
        let obj = res.data || [];
        let xAxis = [];
        let yAxis = [];
        obj.map((k) => {
          xAxis.push(k.bindDate);
          yAxis.push(k.bindDeviceNumber);
        });
        this.createLineChart("bindChart", xAxis, yAxis);
      });
    },

    // 创建折线图
    createLineChart(id, xDate, yDate) {
      var aChart = echarts.init(document.getElementById(id));
      aChart.setOption({
        tooltip: {
          trigger: "axis",
        },
        xAxis: {
          show: false,
          type: "category",
          boundaryGap: false,
          data: xDate,
        },
        yAxis: {
          show: false,
          type: "value",
        },
        series: [
          {
            symbol: "none",
            smooth: true,
            data: yDate,
            type: "line",
            areaStyle: {},
          },
        ],
      });
    },

    // 总激活数,折线图
    createAllActivedLineChart(m) {
      let xAxis = [];
      let yAxis = [];
      m.map((k) => {
        xAxis.push(k.activeDate);
        yAxis.push(k.activeNumber);
      });
      this.createLineChart("activedChart", xAxis, yAxis);
    },

    // 获取角色属性(针对仲利)
    getRoles() {
      GET_HOME_AUTHUSERORG().then((res) => {
        this.isZhongli = res.data;
      });
    },

    // 打开区域查车
    openAreaCar(){
      let _path = 'oEshield#/monitor/zoneCar?type=full'
      window.open(_path)
    },

    // 获取围栏报警数量
    getFenceAlarm(){
      GET_FENCE_ALARM().then(res => {
        console.log(res)
        let _obj = res.data || {};
        this.fenceAlarmCount = _obj.fenceAlarmCount || 0
      })
    }

  },
};
</script>

<style lang="scss" scoped>
@import "@/styles/home.scss";
</style>