Commit bfbc4d19 by 胡悦

修复bug

1 parent b9dd55ed
...@@ -3,19 +3,19 @@ import Vue from 'vue' ...@@ -3,19 +3,19 @@ import Vue from 'vue'
export default new Vue({ export default new Vue({
methods: { methods: {
warningTips(message) { warningTips(message) {
this.$notify({ this.$message({
type: 'warning', type: 'warning',
title: message title: message
}) })
}, },
okTips(message) { okTips(message) {
this.$notify({ this.$message({
type: 'success', type: 'success',
title: message || '操作成功' title: message || '操作成功'
}) })
}, },
errorTips(message) { errorTips(message) {
this.$notify({ this.$message({
type: 'error', type: 'error',
title: message || '操作失败' title: message || '操作失败'
}) })
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
<div class="echarts"> <div class="echarts">
<el-row> <el-row>
<el-col :span="24"> <el-col :span="24">
<div class="nodata" v-if="noDevice">暂无数据</div>
<div <div
id="deviceTrends" id="deviceTrends"
style="width: 100%; height: 400px;" style="width: 100%; height: 400px;"
...@@ -26,6 +27,7 @@ ...@@ -26,6 +27,7 @@
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="24"> <el-col :span="24">
<div class="nodata" v-if="noUser">暂无数据</div>
<div <div
id="userTrends" id="userTrends"
style="width: 100%; height: 400px;" style="width: 100%; height: 400px;"
...@@ -34,6 +36,7 @@ ...@@ -34,6 +36,7 @@
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="24"> <el-col :span="24">
<div class="nodata" v-if="noApp">暂无数据</div>
<div <div
id="appTrends" id="appTrends"
style="width: 100%; height: 400px;" style="width: 100%; height: 400px;"
...@@ -64,7 +67,10 @@ export default { ...@@ -64,7 +67,10 @@ export default {
userECharts: '', userECharts: '',
userOptions: {}, userOptions: {},
appECharts: '', appECharts: '',
appOptions: {} appOptions: {},
noDevice: false,
noUser: false,
noApp: false
} }
}, },
...@@ -74,9 +80,9 @@ export default { ...@@ -74,9 +80,9 @@ export default {
this.userECharts = this.$echarts.init(document.getElementById('userTrends'), 'walden') this.userECharts = this.$echarts.init(document.getElementById('userTrends'), 'walden')
this.appECharts = this.$echarts.init(document.getElementById('appTrends'), 'walden') this.appECharts = this.$echarts.init(document.getElementById('appTrends'), 'walden')
this.getTotal() this.getTotal()
this.drawLine(getDeviceStatistic, this.deviceOptions, this.deviceECharts, '设备激活趋势') this.drawLine(getDeviceStatistic, this.deviceOptions, this.deviceECharts, '设备激活趋势', 'noDevice')
this.drawLine(getUserStatistic, this.userOptions, this.userECharts, '用户活跃趋势') this.drawLine(getUserStatistic, this.userOptions, this.userECharts, '用户活跃趋势' , 'noUser')
this.drawLine(getAppStatistic, this.appOptions, this.appECharts, 'APP下载趋势') this.drawLine(getAppStatistic, this.appOptions, this.appECharts, 'APP下载趋势', 'noApp')
}, },
methods: { methods: {
...@@ -85,11 +91,12 @@ export default { ...@@ -85,11 +91,12 @@ export default {
this.totalNum = res this.totalNum = res
}) })
}, },
drawLine(api, options, charts, title) { drawLine(api, options, charts, title, nodata) {
api(this.params).then(res => { api(this.params).then(res => {
if (res) { this[nodata] = !res.length
let x = [] console.log(this[nodata])
let y = [] let x
let y
res.map(item => { res.map(item => {
x.push(item.time) x.push(item.time)
y.push(item.count) y.push(item.count)
...@@ -100,11 +107,6 @@ export default { ...@@ -100,11 +107,6 @@ export default {
yAxisData: y yAxisData: y
}) })
charts.setOption(options) charts.setOption(options)
} else {
var html = '<div style="color:#868686; font-size: 16px;text-align:center;line-height:380px;">暂无数据</div>'
charts.innerHTML = html
charts.removeAttribute('_echarts_instance_')
}
}) })
} }
} }
...@@ -134,4 +136,14 @@ li { ...@@ -134,4 +136,14 @@ li {
font-size: 24px; font-size: 24px;
margin-bottom: 10px; margin-bottom: 10px;
} }
.nodata {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
/* width: 100%; */
/* height: 400px; */
/* margin: 0 auto;
text-align: center; */
}
</style> </style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!