2019-08-16 14:25:20 +08:00
|
|
|
|
<template>
|
|
|
|
|
<div>
|
|
|
|
|
<div :id="id" :style="{height: size.height+'px', width: size.width+'px'}" />
|
|
|
|
|
<div class="lesson-select">
|
2019-08-16 16:55:16 +08:00
|
|
|
|
<el-select v-model="mapName" placeholder="请选择地图线路" size="mini" style="width: 300px">
|
2019-08-16 14:25:20 +08:00
|
|
|
|
<el-option v-for="name in mapNameList" :key="name" :label="name" :value="name" />
|
|
|
|
|
</el-select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import echarts from 'echarts';
|
|
|
|
|
import { listUserPermision } from '@/api/management/author';
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
props: {
|
|
|
|
|
id: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: 'chart'
|
|
|
|
|
},
|
|
|
|
|
size: {
|
|
|
|
|
type: Object,
|
|
|
|
|
required: true
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
option: {
|
|
|
|
|
backgroundColor: '#F0F2F5',
|
2019-08-19 09:15:25 +08:00
|
|
|
|
title: [{
|
2019-08-16 14:25:20 +08:00
|
|
|
|
text: '',
|
|
|
|
|
subtext: '',
|
2019-08-16 16:55:16 +08:00
|
|
|
|
subtextStyle: {
|
|
|
|
|
color: '#909399'
|
|
|
|
|
},
|
2019-08-16 14:40:42 +08:00
|
|
|
|
y: 10,
|
2019-08-16 14:25:20 +08:00
|
|
|
|
left: 'center',
|
|
|
|
|
textAlign: 'center'
|
2019-08-19 09:15:25 +08:00
|
|
|
|
}, {
|
|
|
|
|
top: '12%',
|
|
|
|
|
left: '25%',
|
|
|
|
|
text: '',
|
|
|
|
|
textStyle: {
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
fontWeight: 'normal'
|
|
|
|
|
}
|
|
|
|
|
}, {
|
|
|
|
|
top: '35%',
|
|
|
|
|
left: '25%',
|
|
|
|
|
text: '',
|
|
|
|
|
textStyle: {
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
fontWeight: 'normal'
|
|
|
|
|
}
|
|
|
|
|
}, {
|
|
|
|
|
top: '58%',
|
|
|
|
|
left: '25%',
|
|
|
|
|
text: '',
|
|
|
|
|
textStyle: {
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
fontWeight: 'normal'
|
|
|
|
|
}
|
|
|
|
|
}],
|
2019-08-16 14:25:20 +08:00
|
|
|
|
tooltip: {
|
|
|
|
|
},
|
|
|
|
|
grid: [{
|
2019-08-19 09:15:25 +08:00
|
|
|
|
top: '15%',
|
2019-08-18 21:12:38 +08:00
|
|
|
|
width: '45%',
|
2019-08-19 09:15:25 +08:00
|
|
|
|
bottom: '68%',
|
2019-08-18 21:12:38 +08:00
|
|
|
|
left: 10,
|
|
|
|
|
containLabel: true
|
2019-08-19 09:15:25 +08:00
|
|
|
|
}, {
|
|
|
|
|
top: '38%',
|
2019-08-18 21:12:38 +08:00
|
|
|
|
width: '45%',
|
2019-08-19 09:15:25 +08:00
|
|
|
|
bottom: '45%',
|
2019-08-18 21:12:38 +08:00
|
|
|
|
left: 10,
|
|
|
|
|
containLabel: true
|
2019-08-19 09:15:25 +08:00
|
|
|
|
}, {
|
|
|
|
|
top: '62%',
|
2019-08-18 21:12:38 +08:00
|
|
|
|
width: '45%',
|
2019-08-19 09:15:25 +08:00
|
|
|
|
bottom: '7%',
|
2019-08-16 14:25:20 +08:00
|
|
|
|
left: 10,
|
|
|
|
|
containLabel: true
|
|
|
|
|
}],
|
2019-08-16 19:09:44 +08:00
|
|
|
|
xAxis: [{
|
2019-08-16 15:41:20 +08:00
|
|
|
|
type: 'value',
|
2019-08-16 16:28:11 +08:00
|
|
|
|
show: false,
|
2019-08-19 09:15:25 +08:00
|
|
|
|
minInterval: 1,
|
|
|
|
|
name: '权限(个)'
|
2019-08-16 19:09:44 +08:00
|
|
|
|
}, {
|
|
|
|
|
type: 'value',
|
|
|
|
|
show: false,
|
2019-08-18 21:12:38 +08:00
|
|
|
|
gridIndex: 1,
|
2019-08-19 09:15:25 +08:00
|
|
|
|
minInterval: 1,
|
|
|
|
|
name: '权限(个)'
|
2019-08-16 19:09:44 +08:00
|
|
|
|
}, {
|
|
|
|
|
type: 'value',
|
|
|
|
|
show: false,
|
2019-08-18 21:12:38 +08:00
|
|
|
|
gridIndex: 2,
|
2019-08-19 09:15:25 +08:00
|
|
|
|
minInterval: 1,
|
|
|
|
|
name: '权限(个)'
|
2019-08-16 19:09:44 +08:00
|
|
|
|
}],
|
|
|
|
|
yAxis: [{
|
2019-08-16 14:25:20 +08:00
|
|
|
|
type: 'category',
|
2019-08-16 15:41:20 +08:00
|
|
|
|
show: false,
|
2019-08-16 14:25:20 +08:00
|
|
|
|
axisLabel: {
|
|
|
|
|
interval: 0,
|
|
|
|
|
rotate: 30
|
|
|
|
|
},
|
2019-08-18 21:12:38 +08:00
|
|
|
|
splitLine: {
|
|
|
|
|
show: false
|
|
|
|
|
},
|
2019-08-16 15:41:20 +08:00
|
|
|
|
data: []
|
2019-08-16 19:09:44 +08:00
|
|
|
|
}, {
|
|
|
|
|
type: 'category',
|
|
|
|
|
show: false,
|
2019-08-18 21:12:38 +08:00
|
|
|
|
gridIndex: 1,
|
2019-08-16 19:09:44 +08:00
|
|
|
|
axisLabel: {
|
|
|
|
|
interval: 0,
|
|
|
|
|
rotate: 30
|
|
|
|
|
},
|
2019-08-18 21:12:38 +08:00
|
|
|
|
splitLine: {
|
|
|
|
|
show: false
|
|
|
|
|
},
|
2019-08-16 19:09:44 +08:00
|
|
|
|
data: []
|
|
|
|
|
}, {
|
|
|
|
|
type: 'category',
|
|
|
|
|
show: false,
|
2019-08-18 21:12:38 +08:00
|
|
|
|
gridIndex: 2,
|
2019-08-16 19:09:44 +08:00
|
|
|
|
axisLabel: {
|
|
|
|
|
interval: 0,
|
|
|
|
|
rotate: 30
|
|
|
|
|
},
|
2019-08-18 21:12:38 +08:00
|
|
|
|
splitLine: {
|
|
|
|
|
show: false
|
|
|
|
|
},
|
2019-08-16 19:09:44 +08:00
|
|
|
|
data: []
|
|
|
|
|
}],
|
2019-08-16 14:25:20 +08:00
|
|
|
|
series: [{
|
|
|
|
|
type: 'bar',
|
|
|
|
|
z: 3,
|
2019-08-18 21:12:38 +08:00
|
|
|
|
barWidth: 10,
|
2019-08-16 14:25:20 +08:00
|
|
|
|
tooltip: {
|
|
|
|
|
formatter: params => { return `${params.marker} ${params.name}: ${params.value}个`; }
|
|
|
|
|
},
|
|
|
|
|
data: []
|
2019-08-16 18:59:19 +08:00
|
|
|
|
}, {
|
|
|
|
|
type: 'bar',
|
|
|
|
|
z: 3,
|
2019-08-18 21:12:38 +08:00
|
|
|
|
xAxisIndex: 1,
|
2019-08-19 09:15:25 +08:00
|
|
|
|
yAxisIndex: 1,
|
2019-08-18 21:12:38 +08:00
|
|
|
|
barWidth: 10,
|
2019-08-16 18:59:19 +08:00
|
|
|
|
tooltip: {
|
|
|
|
|
formatter: params => { return `${params.marker} ${params.name}: ${params.value}个`; }
|
|
|
|
|
},
|
|
|
|
|
data: []
|
|
|
|
|
}, {
|
|
|
|
|
type: 'bar',
|
|
|
|
|
z: 3,
|
2019-08-18 21:12:38 +08:00
|
|
|
|
xAxisIndex: 2,
|
2019-08-19 09:15:25 +08:00
|
|
|
|
yAxisIndex: 2,
|
2019-08-18 21:12:38 +08:00
|
|
|
|
barWidth: 10,
|
2019-08-16 18:59:19 +08:00
|
|
|
|
tooltip: {
|
|
|
|
|
formatter: params => { return `${params.marker} ${params.name}: ${params.value}个`; }
|
|
|
|
|
},
|
|
|
|
|
data: []
|
2019-08-16 14:25:20 +08:00
|
|
|
|
}, {
|
|
|
|
|
type: 'pie',
|
|
|
|
|
radius: [0, '70%'],
|
2019-08-19 09:15:25 +08:00
|
|
|
|
center: ['75%', '52%'],
|
2019-08-16 14:25:20 +08:00
|
|
|
|
tooltip: {
|
|
|
|
|
formatter: params => { return `${params.marker} ${params.name}: ${params.percent}%`; }
|
|
|
|
|
},
|
|
|
|
|
data: []
|
|
|
|
|
}]
|
|
|
|
|
},
|
2019-08-16 15:41:20 +08:00
|
|
|
|
mapName: null,
|
2019-08-16 14:25:20 +08:00
|
|
|
|
mapNameList: [],
|
|
|
|
|
permissionList: [],
|
|
|
|
|
chart: null
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
size() {
|
|
|
|
|
return this.chart.resize({...this.size, silent: false});
|
|
|
|
|
},
|
|
|
|
|
async mapName(val) {
|
|
|
|
|
await this.loadExamData(val);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
|
this.initChart();
|
|
|
|
|
},
|
|
|
|
|
beforeDestroy() {
|
|
|
|
|
if (!this.chart) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.chart.dispose();
|
|
|
|
|
this.chart = null;
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
initChart() {
|
|
|
|
|
listUserPermision({pageSize: 9000, pageNum: 1}).then(resp => {
|
2019-08-16 15:41:20 +08:00
|
|
|
|
this.permissionList = resp.data.list.filter(elem => { return parseInt(elem.status) > 0; });
|
2019-08-18 21:12:38 +08:00
|
|
|
|
this.mapNameList = [...new Set(this.permissionList.map(elem => { return elem.mapName; }))];
|
2019-08-16 14:25:20 +08:00
|
|
|
|
this.$nextTick(() => { this.mapName = this.mapNameList[0] || ''; });
|
|
|
|
|
});
|
|
|
|
|
this.chart = echarts.init(document.getElementById(this.id));
|
|
|
|
|
this.chart.setOption(this.option);
|
|
|
|
|
},
|
|
|
|
|
async loadExamData(mapName) {
|
2019-08-16 15:41:20 +08:00
|
|
|
|
if (mapName) {
|
2019-08-16 18:59:19 +08:00
|
|
|
|
var permissionMap = {};
|
|
|
|
|
var permissionList = await this.$Dictionary.permissionType();
|
|
|
|
|
|
|
|
|
|
if (permissionList) {
|
|
|
|
|
(permissionList ||[]).forEach(elem => {
|
|
|
|
|
permissionMap[elem.code] = elem.name;
|
2019-08-16 18:16:19 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-18 21:12:38 +08:00
|
|
|
|
var lessonMap = {
|
|
|
|
|
'ATS现地工作站-课程权限': 0,
|
2019-08-19 09:15:25 +08:00
|
|
|
|
'ATS行调工作站-课程权限': 0
|
2019-08-18 21:12:38 +08:00
|
|
|
|
};
|
|
|
|
|
var examMap = {
|
|
|
|
|
'ATS现地工作站-考试权限': 0,
|
2019-08-19 09:15:25 +08:00
|
|
|
|
'ATS行调工作站-考试权限': 0
|
2019-08-18 21:12:38 +08:00
|
|
|
|
};
|
|
|
|
|
var simulationMap = {
|
|
|
|
|
'ATS现地工作站-仿真权限': 0,
|
|
|
|
|
'ATS行调工作站-仿真权限': 0,
|
|
|
|
|
'综合演练云平台-仿真权限': 0,
|
|
|
|
|
'司机模拟驾驶系统-仿真权限': 0,
|
|
|
|
|
'大屏系统权限': 0
|
|
|
|
|
};
|
2019-08-16 18:16:19 +08:00
|
|
|
|
(this.permissionList.filter(elem => { return elem.mapName == mapName; })|| []).forEach(elem => {
|
2019-08-18 21:12:38 +08:00
|
|
|
|
switch (elem.type) {
|
2019-08-19 09:15:25 +08:00
|
|
|
|
case '01':
|
|
|
|
|
lessonMap[`${elem.mapProductName}-${permissionMap[elem.type]}`] = elem.remains;
|
|
|
|
|
break;
|
|
|
|
|
case '02':
|
|
|
|
|
examMap[`${elem.mapProductName}-${permissionMap[elem.type]}`] = elem.remains;
|
|
|
|
|
break;
|
|
|
|
|
case '03':
|
|
|
|
|
simulationMap[`${elem.mapProductName}-${permissionMap[elem.type]}`] = elem.remains;
|
|
|
|
|
break;
|
2019-08-18 21:12:38 +08:00
|
|
|
|
}
|
2019-08-16 15:41:20 +08:00
|
|
|
|
});
|
|
|
|
|
|
2019-08-18 21:12:38 +08:00
|
|
|
|
const keys = [...Object.keys(lessonMap), ...Object.keys(examMap), ...Object.keys(simulationMap)];
|
|
|
|
|
const values = [...Object.values(lessonMap), ...Object.values(examMap), ...Object.values(simulationMap)];
|
|
|
|
|
const sum = values.reduce((total, num) => total + num);
|
|
|
|
|
|
2019-08-19 09:15:25 +08:00
|
|
|
|
this.option.title[0].text = `剩余权限分布图(${mapName})`;
|
|
|
|
|
this.option.title[0].subtext = `权限总计${sum}个`;
|
|
|
|
|
this.option.title[1].text = `课程权限`;
|
|
|
|
|
this.option.title[2].text = `考试权限`;
|
|
|
|
|
this.option.title[3].text = `仿真权限`;
|
2019-08-18 21:12:38 +08:00
|
|
|
|
|
|
|
|
|
this.option.xAxis[0].show = this.option.xAxis[1].show = this.option.xAxis[2].show = true;
|
|
|
|
|
this.option.yAxis[0].show = this.option.yAxis[1].show = this.option.yAxis[2].show = true;
|
|
|
|
|
|
|
|
|
|
this.option.yAxis[0].data = Object.keys(lessonMap);
|
|
|
|
|
this.option.series[0].data = Object.values(lessonMap);
|
|
|
|
|
|
|
|
|
|
this.option.yAxis[1].data = Object.keys(examMap);
|
2019-08-19 09:15:25 +08:00
|
|
|
|
this.option.series[1].data = Object.values(examMap);
|
|
|
|
|
|
2019-08-18 21:12:38 +08:00
|
|
|
|
this.option.yAxis[2].data = Object.keys(simulationMap);
|
|
|
|
|
this.option.series[2].data = Object.values(simulationMap);
|
|
|
|
|
|
2019-08-19 09:15:25 +08:00
|
|
|
|
this.option.series[3].data = keys.map((name, index) => { return {name, value: values[index]}; });
|
2019-08-16 15:41:20 +08:00
|
|
|
|
} else {
|
2019-08-19 09:15:25 +08:00
|
|
|
|
this.option.title[0].text = `剩余权限分布图(暂无地图线路数据)`;
|
|
|
|
|
this.option.title[0].subtext = `权限总计0个`;
|
|
|
|
|
this.option.title[1].text = ``;
|
|
|
|
|
this.option.title[2].text = ``;
|
|
|
|
|
this.option.title[3].text = ``;
|
2019-08-18 21:12:38 +08:00
|
|
|
|
this.option.xAxis[0].show = this.option.xAxis[1].show = this.option.xAxis[2].show = false;
|
|
|
|
|
this.option.yAxis[0].show = this.option.yAxis[1].show = this.option.yAxis[2].show = false;
|
|
|
|
|
this.option.yAxis[0].data = this.option.yAxis[1].data = this.option.yAxis[2].data = [];
|
|
|
|
|
this.option.series[0].data = this.option.series[1].data = this.option.series[2].data = [];
|
2019-08-16 15:41:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-16 14:25:20 +08:00
|
|
|
|
this.chart.setOption(this.option);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
<style scoped>
|
|
|
|
|
.lesson-select {
|
|
|
|
|
position: absolute;
|
|
|
|
|
display: flex;
|
2019-08-16 14:40:42 +08:00
|
|
|
|
top: 30px;
|
|
|
|
|
right: 30px;
|
2019-08-16 14:25:20 +08:00
|
|
|
|
}
|
|
|
|
|
</style>
|