qa-prevention-gwj-vue/src/views/map/components/menjin2.vue

471 lines
11 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<div class="menjin">
<div class="block1">
<layout-title title="设备在线情况"/>
<div class="options">
<div v-for="(item,index) in block1OptionsList" :key="index" class="option">
<div class="title active">{{ item.title }}</div>
<div class="circular">
<img :src="item.img" alt="">
</div>
<div class="label">
{{ item.label1 }}<count-to :start-val="0" :end-val="item.count1" :duration="3600"/>
</div>
<div v-if="item.label2" class="label">
{{ item.label2 }}<count-to :start-val="0" :end-val="item.count2" :duration="3600"/>
</div>
</div>
</div>
</div>
<div class="block4">
<layout-title title="区域进出记录"/>
<div class="content">
<div class="options">
<div
v-for="(item,index) in block4OptionsTabs"
:key="index"
:class="['title', {active:index === block4OptionsIndex}]"
@click="block4OptionsClick(index)"
>
{{ item }}
</div>
</div>
<div id="main1"/>
</div>
</div>
<div class="block3">
<layout-title title="口门进出记录"/>
<div class="content">
<div class="options">
<div
v-for="(item,index) in block3OptionsList"
:key="index"
:class="['title', {active:index === block3OptionsIndex}]"
@click="block3OptionsClick(index)"
>
{{ item }}
</div>
</div>
<div class="table">
<div class="tr">
<div class="td">卡口名称</div>
<div class="td">{{ block3OptionsIndex===0 ? '人员':'车牌' }}</div>
<div class="td">时间</div>
<div class="td">状态</div>
</div>
<div v-for="(item,index) in block3List" :key="index" class="tr">
<div class="td line1">{{ item.DOORNAME }}</div>
<div class="td">{{ item.NAME }}</div>
<div class="td line1">{{ item.TIME.substring(11) }}</div>
<div class="td">{{ item.STATUS }}</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import layoutTitle from './title.vue'
import CountTo from 'vue-count-to'
import { requestFN } from '@/utils/request'
import * as echarts from 'echarts'
let myChart1
export default {
components: {
layoutTitle,
CountTo
},
props: {
corpInfoId: {
type: String,
default: ''
},
area: {
type: String,
default: ''
},
gangkou: {
type: String,
default: ''
}
},
data() {
return {
block1OptionsList: [
{
title: '人员闸机数',
img: require('../../../assets/map/menjin/ico1.png'),
label1: '在线数',
count1: 0
// label2: '离线数',
// count2: 0
},
{
title: '车辆闸机数',
img: require('../../../assets/map/menjin/ico2.png'),
label1: '在线数',
count1: 0
// label2: '离线数',
// count2: 0
},
{
title: '摄像头数',
img: require('../../../assets/map/menjin/ico3.png'),
label1: '摄像头数',
count1: 0
}
],
block3OptionsList: ['人员闸机', '车辆闸机'],
block3OptionsIndex: 1,
block2List: [],
block3List: [],
block4OptionsTabs: ['人员', '车辆'],
block4OptionsIndex: 0,
block4OptionsList: []
}
},
mounted() {
this.getMachineCount() // 设备数
this.getEntryAndExitCount()// echar
this.listPerpleCarGateMachine('1') // 进出记录
window.onresize = function() {
myChart1 && myChart1.resize()
}
},
destroyed() {
myChart1 = null
},
methods: {
getEntryAndExitCount() {
requestFN(
'/mkmjRelation/getAllCarAndPeopleInfoCountByArea',
{ CORPINFO_ID: this.corpInfoId }
).then((data) => {
this.block4OptionsList = data.varList
this.initEcharts1(this.block4OptionsList)
}).catch((e) => {
})
},
initEcharts1(data) {
const xAxisData = []
const entryData = []
const exitData = []
for (let i = 0; i < data.length; i++) {
if (this.block4OptionsIndex === 0) {
if (data[i].TYPE === 'person') {
xAxisData.push(data[i].AREA_NAME)
console.log(data[i])
entryData.push(data[i].INPERSONCOUNT)
exitData.push(data[i].OUTPERSONCOUNT)
}
}
if (this.block4OptionsIndex === 1) {
if (data[i].TYPE === 'car') {
xAxisData.push(data[i].AREA_NAME)
console.log(data[i])
entryData.push(data[i].INCARCOUNT)
exitData.push(data[i].OUTCARCOUNT)
}
}
}
myChart1 && myChart1.dispose()
myChart1 = echarts.init(document.querySelector('#main1'))
const option = {
tooltip: {
trigger: 'axis',
axisPointer: { // 坐标轴指示器,坐标轴触发有效
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
}
},
grid: {
left: '2%',
right: '4%',
bottom: '8%',
top: '16%',
containLabel: true
},
legend: {
data: ['进', '出'],
right: 10,
top: 12,
textStyle: {
color: '#fff'
},
itemWidth: 12,
itemHeight: 10
},
xAxis: {
type: 'category',
data: xAxisData,
axisLine: {
lineStyle: {
color: 'white'
}
},
axisLabel: {
textStyle: {
fontFamily: 'Microsoft YaHei'
}
}
},
yAxis: {
type: 'value',
axisLine: {
show: false,
lineStyle: {
color: 'white'
}
},
splitLine: {
show: true,
lineStyle: {
color: 'rgba(255,255,255,0.3)'
}
},
axisLabel: {}
},
series: [{
name: '进',
type: 'bar',
barWidth: '15%',
itemStyle: {
normal: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0,
color: '#8bd46e'
}, {
offset: 1,
color: '#09bcb7'
}]),
barBorderRadius: 12
}
},
data: entryData
},
{
name: '出',
type: 'bar',
barWidth: '15%',
itemStyle: {
normal: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0,
color: '#fccb05'
}, {
offset: 1,
color: '#f5804d'
}]),
barBorderRadius: 11
}
},
data: exitData
}
]
}
myChart1.setOption(option)
},
block4OptionsClick(index) {
console.log(index)
this.block4OptionsIndex = index
this.initEcharts1(this.block4OptionsList)
},
getMachineCount() {
requestFN(
'/map/getDoorCount',
{
CORPINFO_ID: this.corpInfoId
}
).then((data) => {
this.block1OptionsList[0].count1 = data.data.personMachineCount
this.block1OptionsList[1].count1 = data.data.carMachineCount
this.block1OptionsList[2].count1 = data.data.cameraCount
}).catch((e) => {
})
},
listPerpleCarGateMachine(type) {
requestFN(
'/map/getDoorRecord',
{
TYPE: type,
CORPINFO_ID: this.corpInfoId
}
).then((data) => {
this.block3List = data.varList.slice(0, 8)
}).catch((e) => {
})
},
block3OptionsClick(index) {
this.block3OptionsIndex = index
this.listPerpleCarGateMachine(index)
}
}
}
</script>
<style lang="scss" scoped>
.menjin {
.title {
background-image: url("../../../assets/map/menjin/title_on.png");
background-size: 100% 100%;
background-repeat: no-repeat;
width: 113px;
height: 26px;
font-size: 14px;
line-height: 26px;
text-align: center;
color: #fff;
&.active {
background-image: url("../../../assets/map/menjin/title.png");
}
}
.block1 {
width: 410px;
background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.8));
.options {
display: flex;
justify-content: space-between;
padding: 10px 15px;
border: 1px solid;
border-image: linear-gradient(to bottom, rgba(58, 122, 149, 0), rgba(58, 122, 149, 1)) 1;
border-top: none;
.option {
display: flex;
flex-direction: column;
align-items: center;
.circular {
margin-top: 5px;
background-image: url("../../../assets/map/menjin/img1.png");
background-size: 100% 100%;
background-repeat: no-repeat;
width: 50px;
height: 50px;
text-align: center;
padding-top: 13px;
img {
width: 30px;
height: 26px;
animation: scale 2s infinite;
}
}
.label {
margin-top: 5px;
font-size: 12px;
color: #fff;
}
}
}
}
.block4 {
margin-top: 10px;
width: 410px;
background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.8));
.content {
border: 1px solid;
border-image: linear-gradient(to bottom, rgba(58, 122, 149, 0), rgba(58, 122, 149, 1)) 1;
border-top: none;
padding: 10px;
.options {
display: flex;
justify-content: flex-end;
.title {
cursor: pointer;
}
}
#main1{
margin-top: 10px;
width: 100%;
height: 200px;
}
}
}
.block3 {
margin-top: 10px;
width: 410px;
background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.8));
.content {
border: 1px solid;
border-image: linear-gradient(to bottom, rgba(58, 122, 149, 0), rgba(58, 122, 149, 1)) 1;
border-top: none;
padding: 10px;
.options {
display: flex;
justify-content: flex-end;
.title {
cursor: pointer;
}
}
.table {
margin-top: 5px;
.tr {
display: flex;
&:nth-child(odd) {
background-color: rgba(42, 86, 158, 0.53);
}
.td {
flex: 1;
text-align: center;
font-size: 12px;
color: #fff;
padding: 5px;
&:nth-child(2) {
flex-basis: 20%;
}
&.green {
color: #7ccf41;
}
&.yellow {
color: #ffcb05;
}
}
}
}
}
}
}
@keyframes scale {
0% {
transform: scale(1);
}
50% {
transform: scale(0.8);
}
100% {
transform: scale(1);
}
}
.line1 {
width: 150px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>