Commit a17225d6 by zhouzy

总览界面和接口

1 parent 522ce35c
......@@ -16,7 +16,8 @@
"better-scroll": "^1.15.2",
"dayjs": "^1.8.12",
"default-passive-events": "^2.0.0",
"element-ui": "^2.11.1",
"echarts": "^5.0.0",
"element-ui": "^2.14.1",
"file-saver": "^2.0.2",
"flex.css": "^1.1.7",
"fuse.js": "^3.4.4",
......
......@@ -50,3 +50,27 @@ export function appMarketList(data) {
return request(data)
}
//获取顶部数据
export function getStatisticData(data){
data.method = 'index/getStatisticData'
return request(data)
}
//获取饼状图数据
export function getGraphData(data){
data.method ='index/getGraphData'
return request(data)
}
//获取折线图数据
export function getPolylineData(data){
data.method = 'index/getPolylineData'
return request(data)
}
<!-- 首页 -->
<template>
<d2-container class="indexPage">
<!-- <div class="echarts">
<!-- <div class="">
<el-row>
<div :span="24">
<div
......@@ -13,106 +13,339 @@
</div> -->
<div class="show-num">
<div class="num-block">
<p>5</p>
<p>{{ TopNumberData.customerCount || 0 }}</p>
<p>注册客户数量</p>
</div>
<div class="num-block">
<p>741,113</p>
<p>{{ TopNumberData.deviceCount || 0 }}</p>
<p>接入设备数量</p>
</div>
<div class="num-block">
<p>541,113</p>
<p>{{ TopNumberData.userCount || 0 }}</p>
<p>注册用户数量</p>
</div>
<div class="num-block">
<p>122,341,113</p>
<p>{{ TopNumberData.apiCallCount || 0 }}</p>
<p>服务调用次数</p>
</div>
</div>
<el-row :gutter="50">
<div class="charts">
<el-col :span="12" ><div class="grid-content bg-purple">
<div class="chart" id="decivceType" ></div></div
></el-col>
<el-col :span="12"
><div class="grid-content bg-purple">
<div class="chart" id="serviceType" ></div></div
> </el-col>
</div>
</el-row>
<p class="Trend">设备接入趋势</p>
<div id="AccessTrend" style="width: 100%; height: 400px"></div>
<p class="Trend">服务调用趋势</p>
<div id="CallTrend" style="width: 100%; height: 400px"></div>
</d2-container>
</template>
<script>
import { reportApi } from '@api/systemMonitor'
import notice from '@/common/notice'
import _ from "lodash";
import { reportApi } from "@api/systemMonitor";
import notice from "@/common/notice";
import echarts from "echarts";
import { getStatisticData, getGraphData, getPolylineData } from "@api/api";
export default {
name: 'index',
name: "index",
data() {
return {
radio: '全部',
// myChart = '',
radio: "全部",
TopNumberData: {},
message: "",
// chartData:{
// apiCallGraphData:[{
// num:'',
// apiClassification: ''
// }],
// deviceGraphData:[{
// deviceType: "",
// num: ''
// }],
// },
// 绘图
totalECharts: '',
totalOptions: {
title: [{
text: '标题',
x: '49.5%',
y: '8%',
textAlign: 'center'
}],
tooltip: {},
series: [{
name: '在网情况',
type: 'pie',
radius: ['35%', '55%'],
label: {
normal: {
fontSize: 16,
formatter: '{b}: {c}'
}
option: {
title: {
top:"20",
text: "",
subtext: "",
left: "20",
},
tooltip: {
trigger: "item",
formatter: "{a} <br/>{b} : {c} ({d}%)",
},
legend: {
orient: "vertical",
left: "right",
data: [],
},
series: [
{
name: "访问来源",
type: "pie",
radius: "55%",
center: ["50%", "60%"],
data: [],
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: "rgba(0, 0, 0, 0.5)",
},
},
},
data: [{
name: '在网',
value: 0,
itemStyle: {
color: '#00b639'
}
}, {
name: '离网',
value: 0,
itemStyle: {
color: '#999999'
}
}]
}]
}
}
],
},
Trendoption: {
xAxis: {
type: "category",
data: [],
},
yAxis: {
type: "value",
},
series: [
{
data: [],
type: "line",
},
],
},
// option2 : {
// xAxis: {
// type: 'category',
// data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
// },
// yAxis: {
// type: 'value'
// },
// series: [{
// data: [820, 932, 901, 934, 1290, 1330, 1320],
// type: 'line'
// }]
// }
// totalOptions: {
// title: [{
// text: '标题',
// x: '49.5%',
// y: '8%',
// textAlign: 'center'
// }],
// tooltip: {},
// series: [{
// name: '在网情况',
// type: 'pie',
// radius: ['35%', '55%'],
// label: {
// normal: {
// fontSize: 16,
// formatter: '{b}: {c}'
// }
// },
// data: [{
// name: '在网',
// value: 0,
// itemStyle: {
// color: '#00b639'
// }
// }, {
// name: '离网',
// value: 0,
// itemStyle: {
// color: '#999999'
// }
// }]
// }],
// },
};
},
mounted() {
// this.$echarts = echarts
// this.totalECharts = this.$echarts.init(document.getElementById('totalEcharts'))
//初始化各表实例
this.$echarts = echarts;
this.totalECharts = this.$echarts.init(document.getElementById("decivceType"));
this.totalEChart2 = this.$echarts.init(document.getElementById("serviceType"));
this.trendCharts = this.$echarts.init(document.getElementById("AccessTrend"));
this.apiCallCharts = this.$echarts.init(document.getElementById("CallTrend"));
// this.getPie()
},
methods: {
//获取顶部数据
getStatisticData({}).then((res) => {
this.TopNumberData = res;
// console.log( this.TopNumberData)
this.TopNumberData.customerCount = this.formatNumber(res.customerCount);
this.TopNumberData.deviceCount = this.formatNumber(res.deviceCount);
this.TopNumberData.userCount = this.formatNumber(res.userCount);
this.TopNumberData.apiCallCount = this.formatNumber(res.apiCallCount);
});
//获取饼状图数据
getGraphData({}).then((res) => {
this.chartData = res;
// console.log(res)
//修改特定的数值,注意数组和对象的区别
//左图
var option1 = _.cloneDeep(this.option);
option1.legend.padding = [50,50,50,0]
option1.title.text = "设备接入类型分布";
option1.legend.data = res.deviceGraphData.map((item) => item.deviceType);
option1.series[0].data = res.deviceGraphData.map((item) => {
return {
value: item.num,
name: item.deviceType,
};
});
//右图
var option2 = _.cloneDeep(this.option);
option2.title.text = "调用服务类型分布";
// option2.legend.data=res.apiCallGraphData.map(item => item.apiClassification)
var formatData = res.apiCallGraphData.map((item) => {
return {
1: "授权管理",
2: "设备管理",
3: "数据服务",
}[item.apiClassification];
});
// formatData == '1' ? formatData = '授权管理' : (formatData== '2' ? formatData= '设备管理' : formatData = '数据服务')
// console.log(formatData)
option2.legend.data = formatData;
option2.legend.padding = [50,50,50,0]
option2.series[0].data = res.apiCallGraphData.map((item) => {
return {
value: item.num,
name: {
1: "授权管理",
2: "设备管理",
3: "数据服务",
}[item.apiClassification],
};
});
getPie(label = '') {
const params = {
subsystemTypeCode: label ? this.baseData.subsys.find(item => item.confValue === label).confCode : ''
// console.log(option2.series[0].data)
//渲染
this.totalEChart2.setOption(option2);
this.totalECharts.setOption(option1);
});
//折线图数据获取
getPolylineData({}).then((res) => {
var trendData = res;
console.log(trendData);
//接入设备折线图
var option3 = _.cloneDeep(this.Trendoption)
option3.grid ={
x:30,
y:50,
x2:10,
y2:50
}
reportApi(params).then(res => {
this.drawPie(res)
}).catch(() => {
notice.errorTips()
})
},
option3.xAxis.data = res.deviceAccessTrendList.map(item => item.activatTime)
option3.series[0].data = res.deviceAccessTrendList.map(item => item.num)
// console.log(option3)
//服务调用趋势
var option4 = _.cloneDeep(this.Trendoption)
option4.xAxis.data = res.apiCallTrendList.map(item => item.createTime)
option4.series[0].data = res.apiCallTrendList.map(item => item.num)
option4.grid ={
x:30,
y:50,
x2:10,
y2:50
}
this.trendCharts.setOption(option3);
this.apiCallCharts.setOption(option4);
});
// 渲染
// getUcSummaryStatistic({}).then(res => {
// this. ServiceTypeData.SummaryList = res
// console.log( this. ServiceTypeData.SummaryList)
// })
},
methods: {
// getPie(label = '') {
// const params = {
// subsystemTypeCode: label ? this.baseData.subsys.find(item => item.confValue === label).confCode : ''
// }
// reportApi(params).then(res => {
// this.drawPie(res)
// }).catch(() => {
// notice.errorTips()
// })
// },
/* 接口请求-end */
// onlineNum 在网数量
// offlineNum 离网数量
// normalNum 正常数量
// breakdownNum 故障数量
drawPie(params) {
const item = this.totalOptions.series[0]
item.data[0].value = params.onlineNum ? params.onlineNum : 0
item.data[1].value = params.offlineNum ? params.offlineNum : 0
// drawPie(params) {
// const item = this.totalOptions.series[0]
// item.data[0].value = params.onlineNum ? params.onlineNum : 0
// item.data[1].value = params.offlineNum ? params.offlineNum : 0
this.totalECharts.setOption(this.totalOptions)
}
}
}
// this.totalECharts.setOption(this.totalOptions)
// },
//每隔三位加一个逗号
formatNumber(n) {
var b = parseInt(n).toString();
var len = b.length;
if (len <= 3) {
return b;
}
var r = len % 3;
return r > 0
? b.slice(0, r) + "," + b.slice(r, len).match(/\d{3}/g).join(",")
: b.slice(r, len).match(/\d{3}/g).join(",");
},
},
};
</script>
<style>
.show-num {
display: flex;
}
......@@ -125,4 +358,56 @@ export default {
.show-num .num-block:last-child {
margin-right: 0px;
}
.el-row {
display: felx;
margin-bottom: 20px;
margin-top: 100px;
margin-right: 200px;
}
.el-row:last-child {
margin-bottom: 0;
}
.el-col {
border-radius: 1px;
}
.bg-purple-dark {
background: white;
}
.bg-purple {
background: white;
}
.bg-purple-light {
background: white;
}
.grid-content {
border-radius: 4px;
min-height: 36px;
}
.row-bg {
padding: 10px 0;
background-color: #f9fafc;
}
.Trend{
padding: 0px;
margin: 0px;
margin-left: 30px;
margin-top: 50px;
margin-bottom: -20px;
}
.charts{
display: flex;
}
.chart{
border: 1px solid #999999;
width:100%;
height: 400px
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!