Commit fde4edb2 by cwq0219

修改

1 parent 1b27a34f
...@@ -73,30 +73,25 @@ export function appMarketList(data) { ...@@ -73,30 +73,25 @@ export function appMarketList(data) {
return request(data) return request(data)
} }
//获取顶部数据 // 获取顶部数据
export function getStatisticData(data){ export function getStatisticData(data) {
data.method = 'index/getStatisticData' data.method = 'index/getStatisticData'
return request(data) return request(data)
} }
// 获取饼状图数据
export function getGraphData(data) {
//获取饼状图数据 data.method = 'index/getGraphData'
export function getGraphData(data){
data.method ='index/getGraphData'
return request(data) return request(data)
} }
//获取折线图数据 // 获取折线图数据
export function getPolylineData(data){ export function getPolylineData(data) {
data.method = 'index/getPolylineData' data.method = 'index/getPolylineData'
return request(data) return request(data)
} }
// APP营销-上架/下架 // APP营销-上架/下架
export function appStartandstop(data) { export function appStartandstop(data) {
data.method = 'admgr/startandstop' data.method = 'admgr/startandstop'
......
...@@ -30,49 +30,57 @@ ...@@ -30,49 +30,57 @@
</div> </div>
</div> </div>
<el-row :gutter="50"> <el-row :gutter="50">
<div class="charts"> <div class="charts">
<el-col :span="12" ><div class="grid-content bg-purple"> <el-col :span="12">
<div class="chart" id="decivceType" ></div></div <div class="grid-content bg-purple">
></el-col> <div
class="chart"
id="decivceType"
></div>
</div>
</el-col>
<el-col :span="12" <el-col :span="12">
><div class="grid-content bg-purple"> <div class="grid-content bg-purple">
<div class="chart" id="serviceType" ></div></div <div
> </el-col> class="chart"
id="serviceType"
></div>
</div>
</el-col>
</div> </div>
</el-row> </el-row>
<p class="Trend">设备接入趋势</p> <p class="Trend">设备接入趋势</p>
<div id="AccessTrend" style="width: 100%; height: 400px"></div> <div
id="AccessTrend"
style="width: 100%; height: 400px"
></div>
<p class="Trend">服务调用趋势</p> <p class="Trend">服务调用趋势</p>
<div id="CallTrend" style="width: 100%; height: 400px"></div> <div
id="CallTrend"
style="width: 100%; height: 400px"
></div>
</d2-container> </d2-container>
</template> </template>
<script> <script>
import _ from "lodash"; import _ from 'lodash'
import { reportApi } from "@api/systemMonitor"; import echarts from 'echarts'
import notice from "@/common/notice"; import { getStatisticData, getGraphData, getPolylineData } from '@api/api'
import echarts from "echarts";
import { getStatisticData, getGraphData, getPolylineData } from "@api/api";
export default { export default {
name: "index", name: 'index',
data() { data() {
return { return {
// myChart = '', // myChart = '',
radio: "全部", radio: '全部',
TopNumberData: {}, TopNumberData: {},
message: "", message: '',
// chartData:{ // chartData:{
// apiCallGraphData:[{ // apiCallGraphData:[{
...@@ -90,53 +98,53 @@ export default { ...@@ -90,53 +98,53 @@ export default {
option: { option: {
title: { title: {
top:"20", top: '20',
text: "", text: '',
subtext: "", subtext: '',
left: "20", left: '20'
}, },
tooltip: { tooltip: {
trigger: "item", trigger: 'item',
formatter: "{a} <br/>{b} : {c} ({d}%)", formatter: '{a} <br/>{b} : {c} ({d}%)'
}, },
legend: { legend: {
orient: "vertical", orient: 'vertical',
left: "right", left: 'right',
data: [], data: []
}, },
series: [ series: [
{ {
name: "访问来源", name: '访问来源',
type: "pie", type: 'pie',
radius: "55%", radius: '55%',
center: ["50%", "60%"], center: ['50%', '60%'],
data: [], data: [],
emphasis: { emphasis: {
itemStyle: { itemStyle: {
shadowBlur: 10, shadowBlur: 10,
shadowOffsetX: 0, shadowOffsetX: 0,
shadowColor: "rgba(0, 0, 0, 0.5)", shadowColor: 'rgba(0, 0, 0, 0.5)'
}, }
}, }
}, }
], ]
}, },
Trendoption: { Trendoption: {
xAxis: { xAxis: {
type: "category", type: 'category',
data: [], data: []
}, },
yAxis: { yAxis: {
type: "value", type: 'value'
}, },
series: [ series: [
{ {
data: [], data: [],
type: "line", type: 'line'
}, }
], ]
}, }
// option2 : { // option2 : {
// xAxis: { // xAxis: {
...@@ -186,116 +194,112 @@ export default { ...@@ -186,116 +194,112 @@ export default {
// }], // }],
// }, // },
}; }
}, },
mounted() { mounted() {
//初始化各表实例 // 初始化各表实例
this.$echarts = echarts; this.$echarts = echarts
this.totalECharts = this.$echarts.init(document.getElementById("decivceType")); this.totalECharts = this.$echarts.init(document.getElementById('decivceType'))
this.totalEChart2 = this.$echarts.init(document.getElementById("serviceType")); this.totalEChart2 = this.$echarts.init(document.getElementById('serviceType'))
this.trendCharts = this.$echarts.init(document.getElementById("AccessTrend")); this.trendCharts = this.$echarts.init(document.getElementById('AccessTrend'))
this.apiCallCharts = this.$echarts.init(document.getElementById("CallTrend")); this.apiCallCharts = this.$echarts.init(document.getElementById('CallTrend'))
// this.getPie() // this.getPie()
//获取顶部数据 // 获取顶部数据
getStatisticData({}).then((res) => { getStatisticData({}).then((res) => {
this.TopNumberData = res; this.TopNumberData = res
// console.log( this.TopNumberData) // console.log( this.TopNumberData)
this.TopNumberData.customerCount = this.formatNumber(res.customerCount); this.TopNumberData.customerCount = this.formatNumber(res.customerCount)
this.TopNumberData.deviceCount = this.formatNumber(res.deviceCount); this.TopNumberData.deviceCount = this.formatNumber(res.deviceCount)
this.TopNumberData.userCount = this.formatNumber(res.userCount); this.TopNumberData.userCount = this.formatNumber(res.userCount)
this.TopNumberData.apiCallCount = this.formatNumber(res.apiCallCount); this.TopNumberData.apiCallCount = this.formatNumber(res.apiCallCount)
}); })
//获取饼状图数据 // 获取饼状图数据
getGraphData({}).then((res) => { getGraphData({}).then((res) => {
this.chartData = res; this.chartData = res
// console.log(res) // console.log(res)
//修改特定的数值,注意数组和对象的区别 // 修改特定的数值,注意数组和对象的区别
//左图 // 左图
var option1 = _.cloneDeep(this.option); var option1 = _.cloneDeep(this.option)
option1.legend.padding = [50,50,50,0] option1.legend.padding = [50, 50, 50, 0]
option1.title.text = "设备接入类型分布"; option1.title.text = '设备接入类型分布'
option1.legend.data = res.deviceGraphData.map((item) => item.deviceType); option1.legend.data = res.deviceGraphData.map((item) => item.deviceType)
option1.series[0].data = res.deviceGraphData.map((item) => { option1.series[0].data = res.deviceGraphData.map((item) => {
return { return {
value: item.num, value: item.num,
name: item.deviceType, name: item.deviceType
}; }
}); })
//右图 // 右图
var option2 = _.cloneDeep(this.option); var option2 = _.cloneDeep(this.option)
option2.title.text = "调用服务类型分布"; option2.title.text = '调用服务类型分布'
// option2.legend.data=res.apiCallGraphData.map(item => item.apiClassification) // option2.legend.data=res.apiCallGraphData.map(item => item.apiClassification)
var formatData = res.apiCallGraphData.map((item) => { var formatData = res.apiCallGraphData.map((item) => {
return { return {
1: "授权管理", 1: '授权管理',
2: "设备管理", 2: '设备管理',
3: "数据服务", 3: '数据服务'
}[item.apiClassification]; }[item.apiClassification]
}); })
// formatData == '1' ? formatData = '授权管理' : (formatData== '2' ? formatData= '设备管理' : formatData = '数据服务') // formatData == '1' ? formatData = '授权管理' : (formatData== '2' ? formatData= '设备管理' : formatData = '数据服务')
// console.log(formatData) // console.log(formatData)
option2.legend.data = formatData; option2.legend.data = formatData
option2.legend.padding = [50,50,50,0] option2.legend.padding = [50, 50, 50, 0]
option2.series[0].data = res.apiCallGraphData.map((item) => { option2.series[0].data = res.apiCallGraphData.map((item) => {
return { return {
value: item.num, value: item.num,
name: { name: {
1: "授权管理", 1: '授权管理',
2: "设备管理", 2: '设备管理',
3: "数据服务", 3: '数据服务'
}[item.apiClassification], }[item.apiClassification]
}; }
}); })
// console.log(option2.series[0].data) // console.log(option2.series[0].data)
//渲染 // 渲染
this.totalEChart2.setOption(option2); this.totalEChart2.setOption(option2)
this.totalECharts.setOption(option1); this.totalECharts.setOption(option1)
}); })
//折线图数据获取
// 折线图数据获取
getPolylineData({}).then((res) => { getPolylineData({}).then((res) => {
var trendData = res; var trendData = res
console.log(trendData); console.log(trendData)
// 接入设备折线图
//接入设备折线图
var option3 = _.cloneDeep(this.Trendoption) var option3 = _.cloneDeep(this.Trendoption)
option3.grid ={ option3.grid = {
x:30, x: 30,
y:50, y: 50,
x2:10, x2: 10,
y2:50 y2: 50
} }
option3.xAxis.data = res.deviceAccessTrendList.map(item => item.activatTime) option3.xAxis.data = res.deviceAccessTrendList.map(item => item.activatTime)
option3.series[0].data = res.deviceAccessTrendList.map(item => item.num) option3.series[0].data = res.deviceAccessTrendList.map(item => item.num)
// console.log(option3) // console.log(option3)
//服务调用趋势 // 服务调用趋势
var option4 = _.cloneDeep(this.Trendoption) var option4 = _.cloneDeep(this.Trendoption)
option4.xAxis.data = res.apiCallTrendList.map(item => item.createTime) option4.xAxis.data = res.apiCallTrendList.map(item => item.createTime)
option4.series[0].data = res.apiCallTrendList.map(item => item.num) option4.series[0].data = res.apiCallTrendList.map(item => item.num)
option4.grid ={ option4.grid = {
x:30, x: 30,
y:50, y: 50,
x2:10, x2: 10,
y2:50 y2: 50
} }
this.trendCharts.setOption(option3); this.trendCharts.setOption(option3)
this.apiCallCharts.setOption(option4); this.apiCallCharts.setOption(option4)
}); })
// 渲染 // 渲染
...@@ -329,23 +333,22 @@ export default { ...@@ -329,23 +333,22 @@ export default {
// this.totalECharts.setOption(this.totalOptions) // this.totalECharts.setOption(this.totalOptions)
// }, // },
//每隔三位加一个逗号 // 每隔三位加一个逗号
formatNumber(n) { formatNumber(n) {
var b = parseInt(n).toString(); var b = parseInt(n).toString()
var len = b.length; var len = b.length
if (len <= 3) { if (len <= 3) {
return b; return b
} }
var r = len % 3; var r = len % 3
return r > 0 return r > 0
? b.slice(0, r) + "," + b.slice(r, len).match(/\d{3}/g).join(",") ? b.slice(0, r) + ',' + b.slice(r, len).match(/\d{3}/g).join(',')
: b.slice(r, len).match(/\d{3}/g).join(","); : b.slice(r, len).match(/\d{3}/g).join(',')
}, }
}, }
}; }
</script> </script>
<style> <style>
.show-num { .show-num {
display: flex; display: flex;
} }
...@@ -366,7 +369,7 @@ export default { ...@@ -366,7 +369,7 @@ export default {
} }
.el-row:last-child { .el-row:last-child {
margin-bottom: 0; margin-bottom: 0;
} }
.el-col { .el-col {
border-radius: 1px; border-radius: 1px;
...@@ -389,25 +392,19 @@ export default { ...@@ -389,25 +392,19 @@ export default {
background-color: #f9fafc; background-color: #f9fafc;
} }
.Trend{ .Trend {
padding: 0px; padding: 0px;
margin: 0px; margin: 0px;
margin-left: 30px; margin-left: 30px;
margin-top: 50px; margin-top: 50px;
margin-bottom: -20px; margin-bottom: -20px;
} }
.charts{ .charts {
display: flex; display: flex;
} }
.chart{ .chart {
border: 1px solid #999999; border: 1px solid #999999;
width:100%; width: 100%;
height: 400px height: 400px;
} }
</style> </style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!