<template> <div class="main-page"> <div class="main-header"> <div class="main-title"> <img src="@/assets/dashboard_images/icon-title.png"> <span>{{ title }}</span> </div> </div> <div class="home-icon"> <a @click="backToIndex"> <img src="@/assets/global_images/home-logo.png"> </a> </div> <div class="exit-icon"> <a href="#" @click="logout"> <img src="@/assets/global_images/exit-logo.png"> </a> </div> <!-- 左上角设备状态区域 --> <div class="dev-status-block"> <el-row :gutter="20" style="width: 300px"> <el-col :span="6" class="sub-data-block"> <div class="statis-block"> <span class="big-size" v-text="dev.alarm"/> </div> <div class="sub-title">报警</div> </el-col> <el-col :span="6" class="sub-data-block"> <div class="statis-block"> <span class="big-size" v-text="dev.onLine"/> </div> <div class="sub-title">开启</div> </el-col> <el-col :span="6" class="sub-data-block"> <div class="statis-block"> <span class="big-size" v-text="dev.closed"/> </div> <div class="sub-title">关闭</div> </el-col> <el-col :span="6" class="sub-data-block"> <div class="statis-block"> <span class="big-size" v-text="dev.offLine"/> </div> <div class="sub-title">离线</div> </el-col> </el-row> </div> <!-- 左侧当前报警列表区域 --> <div v-show="alarmList.length > 0" class="alarm-now-block"> <div class="map-alarm-div-header">报警列表 <span class="icon-right" @click="tableShow=!tableShow"> <i v-if="tableShow" class="el-icon-arrow-up"/> <i v-else class="el-icon-arrow-down"/> </span> </div> <transition name="el-collapse-transition"> <el-scrollbar v-show="tableShow" :style="{ visibility: tableShow ? 'visible' : 'hidden'}" :class="{ moredatascollor: alarmList.length > 6 }" :native="false"> <el-table :data="alarmList" class="alarm-list-table" border @row-click="alarmRowClick"> <el-table-column v-for="column in alarmColumns" :key="column.value" :label="column.text" :width="column.width" :align="column.align" show-overflow-tooltip> <template slot-scope="scope"> {{ scope.row[column.value] }} </template> </el-table-column> </el-table> </el-scrollbar> </transition> </div> <!-- 中间平面图区域 --> <div class="map-overview"> <img ref="bgImg" :src="bgImageSrc" height="100%" @load="getBgImageSize"> <div v-for="item in devList" :id="item.id" :key="item.id" :class="setClass(item)" @click="detailDev(item)" /> <!-- <div v-for="key in rounds" v-show="round" :key="key" :class="setClass('round', key)" @click="detailDev(key)" />--> <!-- <div v-for="key in guns" v-show="gun" :key="key" :class="setClass('gun', key)" />--> <!-- <div v-for="key in faces" v-show="face" :key="key" :class="setClass('face', key)" />--> <!-- <div v-for="key in cars" v-show="car" :key="key" :class="setClass('car', key)" />--> <!-- <div v-for="key in perimeters" v-show="perimeter" :key="key" :class="setClass('perimeter', key)" />--> </div> <!-- 平面图区域设备类型按钮 --> <el-row :gutter="20" class="dev-footer"> <el-col class="dev-icon" style="margin-left: 10vw;"> <img src="@/assets/overview_images/icons/icon-all.png"> <span>全部</span> </el-col> <el-col class="dev-icon"> <img src="@/assets/overview_images/icons/icon-fence.png"> <span>人脸识别</span> </el-col> <el-col class="dev-icon"> <img src="@/assets/overview_images/icons/icon-car.png"> <span>车牌识别</span> </el-col> </el-row> <!-- 右侧设备详情及操作区域 --> <div class="dev-detail-block"> <el-row :gutter="20"> <el-col :span="20">设备名称 <span>{{ dataForm.name }}</span> </el-col> </el-row> <el-row> <el-col :span="20">设备编号 <span>{{ dataForm.devcode }}</span> </el-col> </el-row> <el-row> <el-col :span="20">设备类型 <span>{{ dataForm.typeName }}</span> </el-col> </el-row> <el-row :gutter="20"> <el-col :span="20">设备型号 <span>{{ dataForm.model }}</span> </el-col> </el-row> <el-row :gutter="20"> <el-col :span="20">在线状态 <span>{{ dataForm.onlineStatusName }}</span> </el-col> </el-row> <el-row :gutter="20"> <el-col :span="20">安装日期 <span>{{ dataForm.installDate }}</span> </el-col> </el-row> <el-row :gutter="20"> <el-col :span="20">安装位置 <span>{{ dataForm.position }}</span> </el-col> </el-row> <el-row v-show="isDoor" :gutter="20"> <el-col :span="12"> <span>{{ dataForm.inOutName }}</span> </el-col> </el-row> </div> </div> </template> <script> import { getProject } from '@/utils/baseConfig' import { overviewDeviceList, overviewDeviceStatus, getDetailDevice } from '@/api/device' import { alarmListOverview } from '@/api/alarm' import DeviceDetail from '@/views/deviceManage/deviceDetail' import tg_main from '../../assets/overview_images/tg/mapOverviewTg.jpg' export default { name: 'DoorOverviewDevice', components: { DeviceDetail }, data() { return { title: getProject().title, bgImageSrc: tg_main, devListParams: { picture: '1', areaTypeId: 1 }, dev: { alarm: 0, onLine: 0, closed: 0, offLine: 0 }, imgSizeOriginal: { width: 2245, height: 1586 }, // 图片原尺寸 imgSize: { width: 2245, height: 1586 }, winSize: { width: 1440, height: 789 }, // 屏幕窗口尺寸 alarmList: [], alarmColumns: [ { text: '设备编号', value: 'devcode', align: 'center' }, { text: '报警内容', value: 'alarmContent', align: 'center' }, { text: '报警时间', value: 'alarmTime', align: 'center' } ], // 显示列 tableShow: true, // 是否显示告警列表 devList: [], dataForm: { id: '', // id name: '', // 设备名 devcode: '', // 设备编号 typeName: '', // 设备类型 model: '', // 设备型号 onlineStatusName: '', // 在线状态 deviceStatusName: '', // 设备状态 position: '', // 安装位置 installDate: '', // 安装日期 inOutName: '' // 进出营 }, // 表单 isDoor: true } }, activated() { this.fetchData() this.fetchDeviceData() this.fetchAlarmNowData() }, mounted() { // this.getBgImageSize() // this.reDrawDevs() const that = this window.onresize = function() { that.getBgImageSize() } }, methods: { getBgImageSize() { // 获取图片尺寸 this.imgSize = { width: this.$refs['bgImg'].width, height: this.$refs['bgImg'].height } // 获取窗体尺寸 this.winSize = { width: document.documentElement.clientWidth, height: document.documentElement.clientHeight } this.reDrawDevs() }, reDrawDevs() { // this.getBgImageSize() const halfLeft = (this.winSize.width - this.imgSize.width) / 2 // 调整球机的设备位置 const that = this this.devList.forEach(function(item) { const point = document.getElementById(item.id) if (item.x !== '' && item.y !== '') { point.style.position = 'absolute' point.style.top = item.y * that.imgSize.height / that.imgSizeOriginal.height + 'px' point.style.left = (item.x * that.imgSize.width / that.imgSizeOriginal.width + halfLeft) + 'px' } else { point.style.display = 'none' } }) }, // 获取设备状态 fetchData() { overviewDeviceStatus({ areaTypeId: this.devListParams.areaTypeId }).then(response => { if (response.code === 200) { this.dev.alarm = response.data.alarm.length this.dev.onLine = response.data.onLine.length this.dev.closed = response.data.closed.length this.dev.offLine = response.data.offLine.length } }) }, fetchDeviceData() { overviewDeviceList(this.devListParams).then(response => { if (response.code === 200) { this.devList = response.data } }) }, fetchAlarmNowData() { alarmListOverview({ areaTypeId: this.devListParams.areaTypeId }).then(response => { if (response.code === 200) { this.alarmList = response.data } else { this.$message.error(response.message) } }) }, logout() { this.$store.dispatch('LogOut').then(() => { location.reload() // 为了重新实例化vue-router对象 避免bug }) }, backToIndex() { this.$router.push('/door/alarm/now') }, setClass(key) { const classObj = {} classObj['point'] = true return classObj }, detailDev(dev) { getDetailDevice(dev.id).then(response => { if (response.code === 200) { this.dataForm = { id: dev.id, name: dev.name, devcode: dev.devcode, typeName: response.data.typeName, model: dev.model, onlineStatusName: response.data.onlineStatusName, position: dev.position, installDate: dev.installDate, inOutName: response.data.inOutName, deviceStatusName: response.data.deviceStatusName } } else { this.$message.error(response.message) } }) }, alarmRowClick(dev, column, event) { } } } </script> <style lang="scss" scoped> .main-page { background-size: cover; background-color: #023d83; height: 100vh; } .main-header { width: 100vw; } .main-title { height: 74px; text-align: center; padding-top: 21px; background: url("../../assets/overview_images/title-background-1920.png"); } .main-title img { display: inline-block; margin-right: 15px; width: 52px; height: 32px; vertical-align: text-bottom; } .home-icon { width: 26px; height: 26px; position: fixed; left: 20px; top: 12px; } .exit-icon { width: 26px; height: 26px; position: fixed; right: 20px; top: 12px; } .home-icon img, .exit-icon img { width: 26px; height: 26px; } .main-title span { color: #FFFFFF; font-size: 32px; font-weight: bold; font-family: 'Microsoft YaHei'; } .map-overview { margin-top: 30px; height: calc(90vh - 140px); text-align: center; position: relative; } .dev-status-block { position: absolute; top: 100px; left: 20px; color: #ffffff; } .alarm-now-block { position: absolute; z-index: 500; background-color: rgba(255, 234, 241,0.8); top: 150px; left: 20px; width: 280px; .map-alarm-div-header { line-height: 40px; width: 504px; padding-left: 10px; .icon-right { position: absolute; right: 15px; } .icon-right:hover { color: #409EFF; cursor: pointer; } } .el-scrollbar { /*height: 200px;*/ width: 100%; } .moredatascollor { height: 200px; } .el-scrollbar__wrap { overflow-y: auto; overflow-x: hidden; margin-bottom: 0px !important; } .el-table { font-size: 12px; } .el-table th { /*background-color: rgba(255, 229, 230, 0.8);*/ padding: 7px 0px; } .el-table td { /*background-color: rgba(255, 234, 241, 0.8);*/ padding: 5px 0px; /*line-height: 1;*/ } .el-table td:hover { /*background-color: rgba(255, 234, 241, 0.8);*/ } .transition-box { margin-bottom: 10px; width: 200px; height: 100px; border-radius: 4px; background-color: #409EFF; text-align: center; color: #fff; padding: 40px 20px; box-sizing: border-box; margin-right: 20px; } } .map-tab { position: absolute; right: 30px; top: 100px; width: 100px; button { margin: 5px 0px; } } .dev-detail-block { position: absolute; right: 30px; top: 400px; width: 300px; color: #00FFFF; font-size: 12px; font-family: "Microsoft YaHei"; } .dev-footer { position: fixed; bottom: 50px; } .dev-icon { width: calc(10vw - 5px); vertical-align: middle; border: 1px solid #00ffff; padding: 10px 5px !important; margin-left: 5px; cursor: pointer; } .dev-icon img { height: 40px; vertical-align:middle; } .dev-icon span { font-size: 14px; color: #00D2FF; line-height: 40px; height: 40px; vertical-align:middle; float: right; } .point { width: 16px; height: 16px; position: relative; display: inline-block; cursor: pointer; background: url("../../assets/overview_images/icons/icon-camera.png"); background-size: contain; } @media(max-width: 1440px) { .main-title { height: 56px; padding-top: 15px; background: url("../../assets/overview_images/title-background-1440.png"); } .main-title span { font-size: 24px; } .main-title img { margin-right: 15px; width: 32px; height: 32px; } .home-icon { left: 18px; width: 18px; height: 18px; } .exit-icon { right: 18px; width: 18px; height: 18px; } .home-icon img, .exit-icon img { width: 18px; height: 18px; } .dev-icon span { font-size: 12px; } } @media(max-width: 1366px) { .main-title { height: 53px; padding-top: 11px; background: url("../../assets/overview_images/title-background-1366.png"); } .main-title span { font-size: 24px; } .main-title img { margin-right: 15px; width: 32px; height: 32px; } .home-icon { left: 16px; width: 16px; height: 16px; } .exit-icon { right: 16px; width: 16px; height: 16px; } .home-icon img, .exit-icon img { width: 15px; height: 15px; } .dev-icon span { font-size: 12px; } } </style>