TheLayout.vue 29.4 KB
Newer Older
YazhouChen's avatar
YazhouChen committed
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 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793
<template>
  <!-- 告警音频 -->
  <div class="h-all">
    <audio ref="audioAlarm" :src="curAudioSrc" muted="muted"></audio>
    <el-row class="page">
      <el-col :span="24" class="head">
        <the-header></the-header>
      </el-col>
      <el-col :span="24" class="head-nav">
        <the-header1></the-header1>
      </el-col>

      <el-col :span="24" class="page-main">
        <div id="box">
          <div id="left" >
            <div class="sidebar">
              <vue-scroll>
                <the-sidebar :deviceCollection="deviceCollection"
                             :modifyDevice="modifyDevice"
                             :addDevice = "addDevice"
                             :deleteDevice = "deleteDevice"
                             :subnetCollection="subnetCollection"
                             :linkCollection="linkCollection"
                             :alarmCollection="alarmCollection"
                             :alarmLevelConfig="alarmLevelConfig"
                             :curClickSubnetId.sync="curClickSubnetId"
                             :curClickDeviceId.sync="curClickDeviceId">
                </the-sidebar>
              </vue-scroll>
            </div>
          </div>
          <div id="resize">&nbsp;</div>
          <div id="right">
            <div class="page-content">
              <!--<vue-scroll :ops="ops">-->
                <the-main :deviceCollection.sync="deviceCollection"
                          :topologyCollection.sync="topologyCollection"
                          :alarmCollection.sync="alarmCollection"
                          :linkCollection.sync="linkCollection"
                          :subnetCollection.sync="subnetCollection"
                          :alarmLevelConfig.sync="alarmLevelConfig"
                          :curClickSubnetId="curClickSubnetId"
                          :curClickDeviceId.sync="curClickDeviceId"
                          :elineCollection="elineCollection"
                          :discoveryCollection.sync="discoveryCollection"
                          :isdotshow="isdotshow"
                          :configFileDifferenceCollection.sync ="configFileDifferenceCollection"
                          :discoverElementCollection.sync = "discoverElementCollection"
                ></the-main>
              <!--</vue-scroll>-->
            </div>
          </div>
        </div>
      </el-col>

    </el-row>
  </div>
</template>

<script>
import TheLayoutHeader from './TheLayoutHeader'
import TheLayoutHeader1 from './TheLayoutHeader1'
import TheLayoutSidebar from './TheLayoutSidebar'
import TheLayoutMain from './TheLayoutMain'
import DeviceStateService from '../../domain/services/DeviceStateService'
import AlarmService from '../../domain/services/AlarmService'
import AlarmLevelConfigService from '../../domain/services/AlarmLevelConfigService'
import AlarmFilterConfigService from '../../domain/services/AlarmFilterConfigService'
import DeviceService from '../../domain/services/DeviceService'
import SubnetService from '../../domain/services/SubnetService'
import LinkService from '../../domain/services/LinkService'
import AlarmManager from '../../domain/models/AlarmManager'
import LinkManager from '../../domain/models/LinkManager'
import DeviceStateSocketApi from '../../api/websocketApis/DeviceStateSocketApi'
import WebSocketService from '../../domain/services/WebSocketService'
import ElineService from '../../domain/services/Business/ElineService'
import ServerService from '../../domain/services/ServerService'
import { EventBus } from '../../domain/EventBus'
import HelperUtil from '../../utils/HelperUtil'
import UserService from '../../domain/services/UserService'

let _this = null
export default {
  name: 'TheLayout',
  data () {
    return {
      // 设备集合(含状态)
      deviceCollection: null,
      // 修改的设备
      modifyDevice: [],
      // 新建设备集合
      addDevice: [],
      // 删除设备集合
      deleteDevice: [],
      // 子网集合(含deviceCollection)
      subnetCollection: null,
      // 告警集合
      alarmCollection: null,
      // 链路集合(含状态)
      linkCollection: null,
      // 拓扑集合(含状态)
      topologyCollection: null,
      // 告警配置对象
      alarmLevelConfig: null,
      // 当前告警音频URL
      curAudioSrc: '',
      // 当前所点击的子网ID
      curClickSubnetId: '',
      // 当前所点击的设备ID
      curClickDeviceId: '',
      // webSocket对象
      webSocket: null,
      // 告警音频定时器
      intervalAlarmVoice: null,
      // websocket 心跳机制
      intervalWebSocketHeartBeat: null,
      // eline业务集合
      elineCollection: null,
      // 网元发现集合
      discoveryCollection: null,
      // 配置差异性文件集合
      configFileDifferenceCollection:null,

      // 网元发现集合
      discoverElementCollection:null,

      isdotshow: [
        true, // 默认值不可删
        true // 默认值不可删
      ],
      isMonitor: false
    }
  },

  methods: {

    /**
     * @description(临时)模拟网元发现WebSocket接口
     * @author weixin
     * @date 2020/7/21 23:28
     */
    fakeDiscoveryWebsocket (templateKey) {
      console.log(`选择的模板:${templateKey}`)
      // 设置定时器,每 5s 返回一个网元发现对象
      this.intervalDiscovery && clearInterval(this.intervalDiscovery)
      const fakeReturnObj = [
        {
          findPercent: 0,
          checkFindIsEnd: false,
          devicesInDb: [],
          linksInDb: [],
          devicesNew: [],
          linksNew: []
        },
        {
          findPercent: 20,
          checkFindIsEnd: false,
          devicesInDb: [],
          linksInDb: [],
          devicesNew: [],
          linksNew: []
        },
        {
          findPercent: 50,
          checkFindIsEnd: false,
          devicesInDb: [],
          linksInDb: [],
          devicesNew: [],
          linksNew: []
        },
        {
          findPercent: 80,
          checkFindIsEnd: false,
          devicesInDb: [],
          linksInDb: [],
          devicesNew: [],
          linksNew: []
        },
        {
          findPercent: 100,
          checkFindIsEnd: true,
          devicesInDb: [
            {"deviceKey":"15948880548541140","uuid":"235","hostName":"","displayName":"235","deviceTypeKey":"SWITCH","deviceModel":"CZ.T-T65D.C.30W.T","deviceVersion":"1.0.0","deviceDesc":"","description":"","subnetKey":"15874354140291166","subnetName":null,"station":"11","ipAddress":"1.21.2.244","bussIpAddress":"3.21.2.244","mac":"","snmpVersion":0,"snmpPort":161,"trapPort":162,"snmpGroup":"public","ipmiUserName":"","ipmiPassword":"","deviceStatus":0,"startTime":"20200717.162354","delFlag":0,"firmwareKey":"","firmwareFileName":"","configFileKey":"","configFileName":"","locationName":"11","manageType":0,"bussManageType":0,"brand":"","manufacturerLiaison":"","manufacturerPhone":"","manager":"","managerPhone":"","modifyTime":"20200722.164421.141","status":2},
            {"deviceKey":"15948880548551189","uuid":"287","hostName":"","displayName":"287","deviceTypeKey":"SWITCH","deviceModel":"CZ.T-T65D.C.30W.T","deviceVersion":"1.0.0","deviceDesc":"","description":"","subnetKey":"15874354140291166","subnetName":null,"station":"11","ipAddress":"1.21.3.50","bussIpAddress":"3.21.3.50","mac":"","snmpVersion":0,"snmpPort":161,"trapPort":162,"snmpGroup":"public","ipmiUserName":"","ipmiPassword":"","deviceStatus":0,"startTime":"20200717.162354","delFlag":0,"firmwareKey":"","firmwareFileName":"","configFileKey":"","configFileName":"","locationName":"11","manageType":0,"bussManageType":0,"brand":"","manufacturerLiaison":"","manufacturerPhone":"","manager":"","managerPhone":"","modifyTime":"20200722.164421.313","status":2},
          ],
          linksInDb: [
            {"linkKey":"15954907078581847","linkName":"111","startDeviceKey":"15948880548541140","startDeviceName":"__vue_devtool_undefined__","startPortName":"1","endDeviceKey":"15948880548551189","endDeviceName":"__vue_devtool_undefined__","endPortName":"2","linkStatus":0,"linkType":0,"modifyTime":"20200723.155147.858","startGroupID":"","endGroupID":"","delFlag":0,"status":"-1","bandwidthUsed":"0","bandwidthMax":"0","source":{"topologyKey":"15964465736933386","elementKey":"15948880548541140","topologyName":"235","nodeType":0,"belongSubnet":"15874354140291166","horizontalAxis":525,"verticalAxis":42,"modifyTime":null,"delFlag":0,"timestamp":null,"status":2},"target":{"topologyKey":"15964465736933387","elementKey":"15948880548551189","topologyName":"287","nodeType":0,"belongSubnet":"15874354140291166","horizontalAxis":220,"verticalAxis":43,"modifyTime":null,"delFlag":0,"timestamp":null,"status":2}},
            {"linkKey":"15954908276312949","linkName":"222","startDeviceKey":"15948880548541140","startDeviceName":"__vue_devtool_undefined__","startPortName":"4","endDeviceKey":"15948880548551189","endDeviceName":"__vue_devtool_undefined__","endPortName":"5","linkStatus":0,"linkType":0,"modifyTime":"20200723.155347.631","startGroupID":"","endGroupID":"","delFlag":0,"status":"-1","bandwidthUsed":"0","bandwidthMax":"0","source":{"topologyKey":"15964465736933386","elementKey":"15948880548541140","topologyName":"235","nodeType":0,"belongSubnet":"15874354140291166","horizontalAxis":525,"verticalAxis":42,"modifyTime":null,"delFlag":0,"timestamp":null,"status":2},"target":{"topologyKey":"15964465736933387","elementKey":"15948880548551189","topologyName":"287","nodeType":0,"belongSubnet":"15874354140291166","horizontalAxis":220,"verticalAxis":43,"modifyTime":null,"delFlag":0,"timestamp":null,"status":2}},
            {"linkKey":"15954908434912980","linkName":"333","startDeviceKey":"15948880548541140","startDeviceName":"__vue_devtool_undefined__","startPortName":"6","endDeviceKey":"15948880548551189","endDeviceName":"__vue_devtool_undefined__","endPortName":"7","linkStatus":0,"linkType":0,"modifyTime":"20200723.155403.491","startGroupID":"","endGroupID":"","delFlag":0,"status":"-1","bandwidthUsed":"0","bandwidthMax":"0","source":{"topologyKey":"15964465736933386","elementKey":"15948880548541140","topologyName":"235","nodeType":0,"belongSubnet":"15874354140291166","horizontalAxis":525,"verticalAxis":42,"modifyTime":null,"delFlag":0,"timestamp":null,"status":2},"target":{"topologyKey":"15964465736933387","elementKey":"15948880548551189","topologyName":"287","nodeType":0,"belongSubnet":"15874354140291166","horizontalAxis":220,"verticalAxis":43,"modifyTime":null,"delFlag":0,"timestamp":null,"status":2}},
          ],
          devicesNew: [
            {
              uuid: '132435645',
              deviceKey: '123124565464',
              hostName: '主机名称1',
              displayName: '网元名称1',
              deviceTypeKey: 'SWITCH',
              deviceModel: '网元型号1',
              deviceVersion: '网元版本1',
              deviceDesc: '网元描述信息1',
              description: '描述信息1',
              subnetKey: '所属子网1',
              station: '所属车站1',
              ipAddress: '1.21.3.50',
              bussIpAddress: '业务口IP地址1',
              mac: 'mac地址1',
              snmpVersion: 0,
              snmpPort: 22,
              trapPort: 23,
              snmpGroup: 'snmp团体名1',
              ipmiUserName: 'IPMI用户名1',
              ipmiPassword: 'IPMI密码1',
              deviceStatus: 0,
              startTime: '开站时间1',
              delFlag: 0,
            },
            {
              uuid: '132435645',
              deviceKey: '123124524356564',
              hostName: '主机名称2',
              displayName: '网元名称2',
              deviceTypeKey: 'SWITCH',
              deviceModel: '网元型号2',
              deviceVersion: '网元版本2',
              deviceDesc: '网元描述信息2',
              description: '描述信息2',
              subnetKey: '所属子网2',
              station: '所属车站2',
              ipAddress: '1.21.2.244',
              bussIpAddress: '业务口IP地址2',
              mac: 'mac地址2',
              snmpVersion: 0,
              snmpPort: 22,
              trapPort: 23,
              snmpGroup: 'snmp团体名2',
              ipmiUserName: 'IPMI用户名2',
              ipmiPassword: 'IPMI密码2',
              deviceStatus: 0,
              startTime: '开站时间2',
              delFlag: 0,
            },
            {
              uuid: '132435645',
              deviceKey: '123124567564',
              hostName: '主机名称2',
              displayName: '网元名称2',
              deviceTypeKey: 'SWITCH',
              deviceModel: '网元型号2',
              deviceVersion: '网元版本2',
              deviceDesc: '网元描述信息2',
              description: '描述信息2',
              subnetKey: '所属子网2',
              station: '所属车站2',
              ipAddress: '2',
              bussIpAddress: '业务口IP地址2',
              mac: 'mac地址2',
              snmpVersion: 0,
              snmpPort: 22,
              trapPort: 23,
              snmpGroup: 'snmp团体名2',
              ipmiUserName: 'IPMI用户名2',
              ipmiPassword: 'IPMI密码2',
              deviceStatus: 0,
              startTime: '开站时间2',
              delFlag: 0,
            },
            {
              uuid: '132435645',
              deviceKey: '123128959564',
              hostName: '主机名称2',
              displayName: '网元名称2',
              deviceTypeKey: 'SWITCH',
              deviceModel: '网元型号2',
              deviceVersion: '网元版本2',
              deviceDesc: '网元描述信息2',
              description: '描述信息2',
              subnetKey: '所属子网2',
              station: '所属车站2',
              ipAddress: '3',
              bussIpAddress: '业务口IP地址2',
              mac: 'mac地址2',
              snmpVersion: 0,
              snmpPort: 22,
              trapPort: 23,
              snmpGroup: 'snmp团体名2',
              ipmiUserName: 'IPMI用户名2',
              ipmiPassword: 'IPMI密码2',
              deviceStatus: 0,
              startTime: '开站时间2',
              delFlag: 0,
            },
            {
              uuid: '132435645',
              deviceKey: '123124564593564',
              hostName: '主机名称2',
              displayName: '网元名称2',
              deviceTypeKey: 'SWITCH',
              deviceModel: '网元型号2',
              deviceVersion: '网元版本2',
              deviceDesc: '网元描述信息2',
              description: '描述信息2',
              subnetKey: '所属子网2',
              station: '所属车站2',
              ipAddress: '4',
              bussIpAddress: '业务口IP地址2',
              mac: 'mac地址2',
              snmpVersion: 0,
              snmpPort: 22,
              trapPort: 23,
              snmpGroup: 'snmp团体名2',
              ipmiUserName: 'IPMI用户名2',
              ipmiPassword: 'IPMI密码2',
              deviceStatus: 0,
              startTime: '开站时间2',
              delFlag: 0,
            },
            {
              uuid: '132435645',
              deviceKey: '123122467564',
              hostName: '主机名称2',
              displayName: '网元名称2',
              deviceTypeKey: 'SWITCH',
              deviceModel: '网元型号2',
              deviceVersion: '网元版本2',
              deviceDesc: '网元描述信息2',
              description: '描述信息2',
              subnetKey: '所属子网2',
              station: '所属车站2',
              ipAddress: '5',
              bussIpAddress: '业务口IP地址2',
              mac: 'mac地址2',
              snmpVersion: 0,
              snmpPort: 22,
              trapPort: 23,
              snmpGroup: 'snmp团体名2',
              ipmiUserName: 'IPMI用户名2',
              ipmiPassword: 'IPMI密码2',
              deviceStatus: 0,
              startTime: '开站时间2',
              delFlag: 0,
            },
            {
              uuid: '132435645',
              deviceKey: '965845824567564',
              hostName: '主机名称2',
              displayName: '网元名称2',
              deviceTypeKey: 'SWITCH',
              deviceModel: '网元型号2',
              deviceVersion: '网元版本2',
              deviceDesc: '网元描述信息2',
              description: '描述信息2',
              subnetKey: '所属子网2',
              station: '所属车站2',
              ipAddress: '6',
              bussIpAddress: '业务口IP地址2',
              mac: 'mac地址2',
              snmpVersion: 0,
              snmpPort: 22,
              trapPort: 23,
              snmpGroup: 'snmp团体名2',
              ipmiUserName: 'IPMI用户名2',
              ipmiPassword: 'IPMI密码2',
              deviceStatus: 0,
              startTime: '开站时间2',
              delFlag: 0,
            },
            {
              uuid: '132435645',
              deviceKey: '12323957968564',
              hostName: '主机名称2',
              displayName: '网元名称2',
              deviceTypeKey: 'SWITCH',
              deviceModel: '网元型号2',
              deviceVersion: '网元版本2',
              deviceDesc: '网元描述信息2',
              description: '描述信息2',
              subnetKey: '所属子网2',
              station: '所属车站2',
              ipAddress: '7',
              bussIpAddress: '业务口IP地址2',
              mac: 'mac地址2',
              snmpVersion: 0,
              snmpPort: 22,
              trapPort: 23,
              snmpGroup: 'snmp团体名2',
              ipmiUserName: 'IPMI用户名2',
              ipmiPassword: 'IPMI密码2',
              deviceStatus: 0,
              startTime: '开站时间2',
              delFlag: 0,
            },
          ],
          linksNew: [
            {
              linkName: '链路名称1',
              startDeviceKey: '15948880548551189',
              startPortName: '1.21.3.50',
              endDeviceKey: '123124565464',
              endPortName: '1.21.3.50',
              linkKey: '124354657665734'
            },
          ]
        },
      ]
      this.discoveryCollection = fakeReturnObj[0]
      let index = 1
      this.intervalDiscovery = setInterval(() => {
        // 新的网元发现进度赋值给discoveryCollection
        this.discoveryCollection = fakeReturnObj[index]
        // index增加模拟返回新进度
        index = index + 1
        // WebSocket返回完毕后清除此定时器
        if (index === fakeReturnObj.length) {
          clearInterval(this.intervalDiscovery)
          delete this.intervalDiscovery
        }
      }, 200)
    },
    /**
     * @Description  :处理对流量监控按钮的打开与否的响应
     * @author       : yjz
     * @param        :
     * @return       :
     * @exception    :
     * @date         :
     */
    handleMonitor (monitoring) {
      if (monitoring) { // 流量监控按钮打开
        _this.openMonitor()
      } else {
        _this.closeMonitor()
      }
    },
    handle1: function (lan) {
      this.webSocket.send(lan)
    },
    /**
    * @Description  :处理对点击设备ID的监听
    * @author       : yjz
    * @param        :
    * @return       :
    * @exception    :
    * @date         :
    */
    handleTestClickDeviceId (clickDeviceId) {
      _this.curClickDeviceId = clickDeviceId
    },
    /**
     * 处理对点击子网的监听
     */
    handleClickSubnet (clickSubnetId) {
      _this.curClickSubnetId = clickSubnetId
    },
    /**
    * @Description  :处理对同步按钮的监听
    * @author       : yjz
    * @param        :
    * @return       :
    * @exception    :
    * @date         :
    */
    handleTestSync (syncAllDataFlag) {
      if (syncAllDataFlag) {
        _this.syncData()
      }
    },

    drag: function () {
      $(document).ready(function () {
        var resize = document.getElementById('resize')
        var left = document.getElementById('left')
        var right = document.getElementById('right')
        var box = document.getElementById('box')
        resize.onmousedown = function (e) {
          var startX = e.clientX
          resize.left = resize.offsetLeft
          document.onmousemove = function (e) {
            var endX = e.clientX
            var moveLen = resize.left + (endX - startX)
            var maxT = box.clientWidth - resize.offsetWidth
            if (moveLen < 30) moveLen = 30
            if (moveLen > maxT - 30) moveLen = maxT - 30
            resize.style.left = moveLen
            left.style.width = moveLen + 'px'
            // right.style.width = (box.clientWidth - moveLen - 5) + "px";
            // 触发告警列表高度的计算
            EventBus.$emit('cal-table-height')
          }
          document.onmouseup = function (evt) {
            document.onmousemove = null
            document.onmouseup = null
            resize.releaseCapture && resize.releaseCapture()
          }
          resize.setCapture && resize.setCapture()
          return false
        }
      }
      )
    },

    // 设置页面状态更新标志
    setUpdateFlag: function (flag) {
      if (_this.$store.state.activeIndex == '/TheLayout/main' && flag == 0) {
        return
      }
      if (_this.$store.state.activeIndex == '/TheLayout/ServiceStatusUpdate' && flag == 1) {
        return
      }
      _this.isdotshow[flag] = false
    },

    // 同步操作
    syncData: function () {
      // _this.systemModeAdapter[_this.$store.state.systemMode].unregisterWebSocketEvent(_this);
      // _this.systemModeAdapter[_this.$store.state.systemMode].syncDeviceState(_this);
      // _this.systemModeAdapter[_this.$store.state.systemMode].registerWebSocketEvent(_this);
      _this.closeWebSocket()
      _this.InfoTip.successTip(_this, HelperUtil.getStatusCodeObjectByCode(_this.successCode.OTHERS_CODE))
      _this.initAllDate()
    },

    // 若告警列表中 存在未被确认的告警信息,则一直播放提示音
    alarmVoice: function () {
      let _this = this
      for (var alarmKey in _this.alarmCollection) {
        if ((_this.alarmCollection[alarmKey].alarmStatus === 0 || _this.alarmCollection[alarmKey].alarmStatus === 1 || _this.alarmCollection[alarmKey].alarmStatus === 2) && _this.alarmCollection[alarmKey].alarmStatus === 0) {
          // let src = _this.curAudioSrc;
          // let src1 = _this.alarmLevelConfig;
          //TODO 一直报错,先注释掉
          // _this.$refs.audioAlarm.play();
          break
        }
      }
    },
    // 设置告警音频定时器
    setAlarmAudioInterval: function () {
      let _this = this
      // 设置定时器,每 1s 播放一次
      if (_this.intervalAlarmVoice != null) return
      _this.intervalAlarmVoice = setInterval(() => {
        _this.alarmVoice()
      }, 1000)
    },

    setWebSocketHeartBeat: function () {
      let _this = this
      // 设置定时器,每 30s 发送一次消息
      if (_this.intervalWebSocketHeartBeat != null) return
      _this.intervalWebSocketHeartBeat = setInterval(() => {
        _this.webSocket.send('websocket')
      }, 30000)
    },

    // 销毁告警音频定时器
    destroyAlarmAudioInterval: function () {
      clearInterval(_this.intervalAlarmVoice)
      _this.intervalAlarmVoice = null
    },

    // 销毁websocket心跳定时器
    destroyWebSocketHeartBeatInterval: function () {
      clearInterval(_this.intervalWebSocketHeartBeat)
      _this.intervalWebSocketHeartBeat = null
    },

    // 开启websocket服务
    openWebSocket: function () {
      _this.systemModeAdapter[_this.$store.state.systemMode].openWebSocket(_this)
    },

    // 关闭webSocket服务
    closeWebSocket: function () {
      _this.systemModeAdapter[_this.$store.state.systemMode].closeWebSocket(_this)
    },

    // 页面数据初始化
    initAllDate: function () {
      _this.systemModeAdapter[_this.$store.state.systemMode].initAllDate(_this)
    },

    // 开启流量监控
    openMonitor: function () {
      ElineService.getAllTunnelWidthCollection().then(result => {
        var linkManager = LinkManager(_this.linkCollection)
        _this.linkCollection = linkManager.getLinkListWithBandWidth(result)
        // 开启 流量监控的 websocket 请求
        if (_this.webSocket !== null) {
          ElineService(_this.webSocket).subscribeBandWidth(_this.linkCollection)
        }
      })
    },

    // 关闭流量监控
    closeMonitor: function () {
      if (_this.webSocket !== null) {
        ElineService(_this.webSocket).unsubscribeBandWidth(_this.linkCollection)
      }
    },
    /***
     * @Description  : 用户退出
     * @author       : zf
     * @date         : 2019/05/06 16:29
     */
    beforeunloadHandler (e) {
      let _this = this
      UserService.logout().then((result) => {
        HelperUtil.toLoginPage()
        _this.InfoTip.successTip(_this, HelperUtil.getStatusCodeObjectByCode(_this.successCode.OTHERS_CODE))
      }).catch((err) => {
        _this.InfoTip.errorTip(_this, err)
      })
    }
  },
  components: {
    'the-header': TheLayoutHeader,
    'the-header1': TheLayoutHeader1,
    'the-sidebar': TheLayoutSidebar,
    'the-main': TheLayoutMain
  },
  watch: {
    alarmLevelConfig: {
      handler (newVal, OldVal) {
        _this.alarmLevelConfig = newVal
        let alarmManager = AlarmManager(_this.alarmCollection)
        _this.curAudioSrc = alarmManager.getCurAudioSrc(_this.alarmLevelConfig)
      },
      deep: true
    },
    alarmCollection: {
      handler (newVal, OldVal) {
        _this.alarmCollection = newVal
        let alarmManager = AlarmManager(_this.alarmCollection)
        _this.curAudioSrc = alarmManager.getCurAudioSrc(_this.alarmLevelConfig)
      },
      deep: true
    },
    curClickDeviceId: {
      handler (newVal, OldVal) {
        _this.curClickDeviceId = newVal
      },
      deep: true
    },
    deviceCollection: {
      handler (newVal, OldVal) {
        _this.deviceCollection = newVal
      },
      deep: true
    },
    subnetCollection: {
      handler (newVal, OldVal) {
        _this.subnetCollection = newVal
      },
      deep: true
    },
    linkCollection: {
      handler (newVal, OldVal) {
        _this.linkCollection = newVal
      },
      deep: true
    },
    topologyCollection: {
      handler (newVal, OldVal) {
        let time = new Date()
        console.log('1数据刚来============' + time.getMinutes() + 'm' + time.getSeconds() + 's' + time.getMilliseconds() + 'ms')
        console.log('layout local data !!');
        _this.topologyCollection = newVal
      },
      deep: true
    },
    discoveryCollection: {
      handler (newVal, OldVal) {
        _this.discoveryCollection = newVal ? newVal : null
      },
      deep: true
    },

    discoverElementCollection: {
      handler (newVal, OldVal) {
        _this.discoverElementCollection = newVal
      },
      deep: true
    },

    configFileDifferenceCollection: {
      handler (newVal, OldVal) {
        _this.configFileDifferenceCollection = newVal
      },
      deep: true
    }
  },
  created () {
    _this = this
    // 页面数据初始化
    _this.initAllDate()
    // 设置 websocket 心跳
    _this.setWebSocketHeartBeat()
    // 设置告警音频定时器
    _this.setAlarmAudioInterval()
  },
  mounted () {
    let _this = this
    _this.drag()
    EventBus.$on('i-got-syncFlag', _this.handleTestSync)
    EventBus.$on('i-got-clickDeviceId', _this.handleTestClickDeviceId)
    EventBus.$on('i-got-clickSubnetId', _this.handleClickSubnet)
    EventBus.$on('i-got-isMonitor', _this.handleMonitor)// 通过全局事件总线将按钮的开关传送给顶层组件
    EventBus.$on('ws', _this.handle1)
    // (临时)添加一个假的模拟网元发现websocket返回数据的监听
    EventBus.$on('fake-discovery', _this.fakeDiscoveryWebsocket)
    // 关闭确认:跳转其它网址、关闭窗口
    window.onbeforeunload = function (e) {
      e = e || window.event
      // 兼容IE8和Firefox 4之前的版本
      if (e) {
        e.returnValue = HelperUtil.getCheckStatusCodeObjectByCode(_this.SYSTEM_EXIT_CODE)
      }
      // Chrome, Safari, Firefox 4+, Opera 12+ , IE 9+
      return e.returnValue
    }
    window.onresize = function () {
      var cliWidth = document.body.scrollWidth
      var cliHeight = document.body.scrollHeight
      var resize = document.getElementById('resize')
      var left = document.getElementById('left')
      var right = document.getElementById('right')
      var box = document.getElementById('box')
      // $('#box').css("width", cliWidth+"px");
      // $('#left').css("width", cliWidth * 0.14 +"px");
      // $('#right').css("width", cliWidth * 0.86 - 5 +"px");
    }
  },
  destroyed () {
    // 销毁告警音频定时器
    _this.destroyAlarmAudioInterval()
    // 销毁websocket心跳定时器
    _this.destroyWebSocketHeartBeatInterval()
    // 关闭websocket连接
    _this.closeWebSocket()
    window.onresize = null
  }
}
</script>

<style scoped lang="scss">
  #box{
    width:100%;
    height:100%;
    overflow:hidden;
  }
  #left{
    width:200px;
    height:100%;
    float: left;
    border: #e6e6e6 0px;
  }

  #resize{
    width:5px;
    float: left;
    height:100%;
    cursor: w-resize;
  }

  #right{
    height:100%;
  }
  .page {
      height: 100%;
      width: 100%;
  }
  .head{
    height:50px;
    position: absolute;
    top:0;
  }
  .head-nav {
    position: absolute;
    top: 50px;
  }
  .page-main {
    margin-top: 100px;
    height: calc(100% - 100px);
  }
  .sidebar {
    height: 100%;
    width: 100%;
    border-right: 0px solid gainsboro;
    user-select: none;
  }
  .page-content {
    height: 100%;
  }
</style>