Report.vue
18.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
<template>
<section class="report-container">
<!-- <template>
<el-row class="export-wrap">
<el-button @click="exportDialogVisable = true">导出报表</el-button>
</el-row>
</template> -->
<!-- 概览标题 -->
<div class="title mb20">概览</div>
<!-- basicOverview 基础概览 -->
<template>
<el-row :gutter="20" class="base-overview">
<el-col :span="6">
<div class="base-overview-item">
<div class="num-wrap">
<div>
<span class="num1">{{dairyBasicOverview.pv}}</span>
<span class="num3"> / {{basicOverview.pv}}</span>
</div>
<div class="num2">PV
<span class="num4">(今日/总量)</span>
</div>
</div>
<div class="icon-wrap">
<i class="fa fa-users fa-2x" aria-hidden="true"></i>
</div>
</div>
</el-col>
<el-col :span="6">
<div class="base-overview-item">
<div class="num-wrap">
<div>
<span class="num1">{{dairyBasicOverview.uv}}</span>
<span class="num3"> / {{basicOverview.uv}}</span>
</div>
<div class="num2">UV
<span class="num4">(今日/总量)</span>
</div>
</div>
<div class="icon-wrap">
<i class="fa fa-user fa-2x" aria-hidden="true"></i>
</div>
</div>
</el-col>
<el-col :span="6">
<div class="base-overview-item">
<div class="num-wrap">
<div>
<span class="num1">{{dairyBasicOverview.prizeWin}}</span>
<span class="num3"> / {{basicOverview.prizeWin}}</span>
</div>
<div class="num2">奖品派发
<span class="num4">(今日/总量)</span>
</div>
</div>
<div class="icon-wrap">
<i class="fa fa-gift fa-2x" aria-hidden="true"></i>
</div>
</div>
</el-col>
<el-col :span="6">
<div class="base-overview-item">
<div class="num-wrap">
<div>
<span class="num1">{{dairyBasicOverview.intercept}}</span>
<span class="num3"> / {{basicOverview.intercept}}</span>
</div>
<div class="num2">拦截数量
<span class="num4">(今日/总量)</span>
</div>
</div>
<div class="icon-wrap">
<i class="fa fa-exclamation-triangle fa-2x" aria-hidden="true"></i>
</div>
</div>
</el-col>
</el-row>
<!-- 奖品和拦截概述 -->
<el-row :gutter="20" class="pi-overview">
<!-- 奖品概述 -->
<el-col :span="12">
<div class="pi-overview-item">
<el-table :data="prizeOverview" highlight-current-row max-height="528" style="width: 100%;" :header-cell-style="{color:'#475669',fontWeight:'bold'}">
<el-table-column prop="key" label="派奖 详情" width="200">
</el-table-column>
<el-table-column prop="dairyTotal" label="派发量 (今日/总量)" min-width="180" align="right" header-align="right">
</el-table-column>
</el-table>
</div>
</el-col>
<!-- 拦截概述 -->
<el-col :span="12">
<div class="pi-overview-item">
<el-table :data="interceptOverview" highlight-current-row max-height="528" style="width: 100%;" :header-cell-style="{color:'#475669',fontWeight:'bold'}">
<el-table-column prop="key" label="拦截 详情" width="200">
</el-table-column>
<el-table-column prop="dairyTotal" label="拦截次数 (今日/总量)" min-width="180" align="right" header-align="right">
</el-table-column>
</el-table>
</div>
</el-col>
</el-row>
</template>
<!-- 省市 和 手机类型 -->
<template>
<el-row :gutter="20" class="pi-overview">
<!-- 奖品概述 -->
<el-col :span="12">
<div class="pi-overview-item">
<div class="tit">省级数据分布</div>
<div class="map-wrap">
<div id="chartProvince" style="width:90%; height:400px;"></div>
<div class="map-aside-wrap">
<div v-for="(item,idx) in this.provinceOverview" :key="idx">
{{item.key}} : {{item.size}}
</div>
</div>
</div>
</div>
</el-col>
<!-- 拦截概述 -->
<el-col :span="12">
<div class="pi-overview-item">
<div class="tit">用户设备top10</div>
<div id="chartMobileBrand" style="width:100%; height:400px;"></div>
</div>
</el-col>
</el-row>
</template>
<div class="title mb20">历史趋势</div>
<!-- 表格 -->
<template>
<div class="block mb20">
<div>
<el-date-picker :picker-options="pickerOptions" v-model="selDate" @change="dateChangeHandler" value-format="yyyy-MM-dd" type="daterange" align="right" unlink-panels range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
</el-date-picker>
<div class="date-button-wrap">
<div>
<el-button @click="setLastDateTime(7)">近一周</el-button>
<el-button @click="setLastDateTime(30)">近30天</el-button>
</div>
</div>
</div>
<div>
<el-button @click="exportDialogVisable = true">导出报表</el-button>
</div>
</div>
<!-- echart表格 折线图 -->
<template>
<el-row>
<el-col :span="24">
<div id="chartLine" style="width:100%; height:400px;"></div>
</el-col>
</el-row>
</template>
</template>
<template>
<el-dialog title="导出报表" :visible.sync="exportDialogVisable" :close-on-click-modal="false">
<div class="block2 mb20">
<el-date-picker class="mb20" :picker-options="pickerOptions" v-model="selDate" @change="dateChangeHandler" value-format="yyyy-MM-dd" type="daterange" align="right" unlink-panels range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
</el-date-picker>
<div class="date-button-wrap-2 mb20">
<el-button @click="setLastDateTime(7)">近一周</el-button>
<el-button @click="setLastDateTime(30)">近30天</el-button>
</div>
<div class="export-tips">*导出明细不含当日数据</div>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click.native="exportDialogVisable = false">取消</el-button>
<el-button type="primary" @click.native="exportReport">导出</el-button>
</div>
</el-dialog>
</template>
</section>
</template>
<script>
import {
getStatView,
getStatDashboardList,
getStatViewDump
} from "./../../api/api.js";
import { formatDate } from "./../../common/utils.js";
import echarts from "echarts";
import chinaJson from "./../../assets/echarts/map/china.json";
export default {
data() {
return {
exportDialogVisable: false,
basicOverview: {}, //基本概述
prizeOverview: [], //奖品概述
interceptOverview: [], //拦截概述
dairyBasicOverview: [], //当日基本概述
dairyPrizeOverview: [], //当日奖品概述
dairyInterceptOverview: [], //当日拦截概述
provinceOverview: [],
cityOverview: [],
mobileBrandOverview: [],
pickerOptions: {
disabledDate(time) {
return time.getTime() > Date.now() - 3600 * 1000 * 24 * 1;
},
shortcuts: [
{
text: "最近一周",
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
picker.$emit("pick", [start, end]);
}
},
{
text: "最近一个月",
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
picker.$emit("pick", [start, end]);
}
}
]
},
selDate: [],
lastQueryDate: 7, //默认请求的日期
chartLine: null, //折线图对象
chartProvince: null, //省柱状图
chartMobileBrand: null //设备柱状图
};
},
methods: {
// 导出报表
exportReport() {
if (this.selDate && this.selDate[0] && this.selDate[1]) {
let code = this.$route.query.code;
let parm = {
appCode: code,
start: this.selDate[0],
end: this.selDate[1]
};
getStatViewDump(parm).then(res => {});
}
},
// 日期选择变更
dateChangeHandler() {
this.reqGetStatDashboardList();
},
// 请求趋势列表
reqGetStatDashboardList() {
if (this.selDate && this.selDate[0] && this.selDate[1]) {
let code = this.$route.query.code;
let parm = {
appCode: code,
start: this.selDate[0],
end: this.selDate[1]
};
getStatDashboardList(parm).then(res => {
let { code, content } = res;
if (code == 200 && content) {
this.setChartLineData(content);
}
// else if (code == 404) {
// this.$router.push({
// path: "/login"
// });
// }
});
}
},
// 省图表数据
setChartProvinceData() {
let xAxisData = [];
let seriesData = [];
let unknowIndex = -1;
this.provinceOverview.forEach((element, idx) => {
xAxisData.push(element.key);
seriesData.push(element.size);
if (element.key == "未知") {
unknowIndex = idx;
}
});
if (unknowIndex >= 0) {
let unknowKey = xAxisData.splice(unknowIndex, 1);
xAxisData.push(unknowKey[0]);
let unknowSize = seriesData.splice(unknowIndex, 1);
seriesData.push(unknowSize[0]);
}
this.chartProvince.setOption({
title: { text: "" },
tooltip: {},
xAxis: {
data: xAxisData
},
yAxis: {},
series: [
{
name: "总量",
type: "bar",
data: seriesData
}
]
});
},
//获取地图热度
setMapHeat() {
let max = 0;
let seriesData = [];
this.provinceOverview.forEach(element => {
let tempSeriesData = {
name: element.key,
value: element.size
};
if (element.size > max && element.key != "未知") {
max = element.size;
}
seriesData.push(tempSeriesData);
});
// 海南诸岛
seriesData.push({
name: "南海诸岛",
value: 0,
itemStyle: { normal: { opacity: 1 } }
});
echarts.registerMap("china", chinaJson);
this.chartProvince.setOption({
dataRange: {
min: 0,
max: max,
x: "center",
y: "bottom",
// text: ['高', '低'], // 文本,默认为数值文本
calculable: true,
orient: "horizontal"
},
series: [
{
type: "map",
mapType: "china",
// roam: false,
itemStyle: {
// normal:{label:{show:true}},
// emphasis:{label:{show:true}}
},
data: seriesData
}
]
});
},
// 设备图表数据
setChartMobileBrandData() {
let xAxisData = [];
let seriesData = [];
let unknowIndex = -1;
this.mobileBrandOverview.forEach((element, idx) => {
xAxisData.push(element.key);
seriesData.push(element.size);
if (element.key == "其他") {
unknowIndex = idx;
}
});
if (unknowIndex >= 0) {
let unknowKey = xAxisData.splice(unknowIndex, 1);
xAxisData.push(unknowKey[0]);
let unknowSize = seriesData.splice(unknowIndex, 1);
seriesData.push(unknowSize[0]);
}
this.chartMobileBrand.setOption({
title: { text: "" },
tooltip: {},
xAxis: {
data: xAxisData
},
yAxis: {},
series: [
{
name: "总量",
type: "bar",
data: seriesData
}
]
});
},
// 设置表格数据
setChartLineData(opt) {
let statDays = [];
let pv = [];
let uv = [];
let prize = [];
let intercept = [];
opt.forEach(element => {
statDays.push(element.statDay);
let datas = element.datas;
datas.forEach(ele2 => {
if (ele2.key == "pv") pv.push(ele2.size);
if (ele2.key == "uv") uv.push(ele2.size);
if (ele2.key == "prize") prize.push(ele2.size);
if (ele2.key == "intercept") intercept.push(ele2.size);
});
});
this.chartLine.setOption({
title: {
text: ""
},
tooltip: {
trigger: "axis"
},
legend: {
data: ["pv", "uv", "奖品数量", "拦截数量"]
},
grid: {
left: "3%",
right: "4%",
bottom: "3%",
containLabel: true
},
xAxis: {
type: "category",
boundaryGap: false,
data: statDays
},
yAxis: {
type: "value"
},
series: [
{
name: "pv",
type: "line",
data: pv
},
{
name: "uv",
type: "line",
stack: "总量",
data: uv
},
{
name: "奖品数量",
type: "line",
data: prize
},
{
name: "拦截数量",
type: "line",
data: intercept
}
]
});
},
// 格式化数据
formatData() {
this.prizeOverview.forEach(element => {
this.dairyPrizeOverview.forEach(element2 => {
if (element.code == element2.code) {
element.dairyTotal = element2.size + "/" + element.size;
}
});
});
this.interceptOverview.forEach(element => {
this.dairyInterceptOverview.forEach(element2 => {
if (element.code == element2.code) {
element.dairyTotal = element2.size + "/" + element.size;
}
});
});
},
// 请求整体报告
reqGetApplication() {
let code = this.$route.query.code;
let parm = {
appCode: code
};
getStatView(parm).then(res => {
let { code, content } = res;
if (code == 200 && content) {
Object.assign(this, content);
// 合并prizeOverview
// 合并interceptOverview
this.formatData();
// this.setChartProvinceData();
this.setChartMobileBrandData();
this.setMapHeat();
}
// else if (code == 404) {
// this.$router.push({
// path: "/login"
// });
// }
});
},
// 设置当天起的筹齐时间
setLastDateTime(day = 7) {
this.lastQueryDate = day + 1;
let end = new Date();
let start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * this.lastQueryDate);
end.setTime(end.getTime() - 3600 * 1000 * 24 * 1);
this.$set(this.selDate, 0, formatDate.format(start));
this.$set(this.selDate, 1, formatDate.format(end));
this.reqGetStatDashboardList();
},
initData() {
this.chartLine = echarts.init(document.getElementById("chartLine"));
this.chartProvince = echarts.init(
document.getElementById("chartProvince")
);
this.chartMobileBrand = echarts.init(
document.getElementById("chartMobileBrand")
);
this.reqGetApplication();
this.setLastDateTime(30);
}
},
mounted() {
this.initData();
}
};
</script>
<style scoped lang="less">
@import "./../../styles/mixin.less";
.report-container {
padding: 20px 0px 80px;
.fontw {
color: red;
}
.mb20 {
margin-bottom: 20px;
}
.border4 {
border-radius: 4px;
border: solid 1px #cccccc;
}
.el-row {
.mb20;
}
.export-wrap {
display: flex;
justify-content: flex-end;
}
.title {
font-weight: bold;
padding: 0 12px;
@titleHeight: 36px;
background-color: #dddddd;
height: @titleHeight;
line-height: @titleHeight;
}
.tit {
font-weight: bold;
@titleHeight: 36px;
height: @titleHeight;
line-height: @titleHeight;
}
.base-overview {
&-item {
.border4;
height: 72px;
.fj;
.num-wrap {
padding-top: 2px;
padding-left: 12px;
.num1 {
font-size: 32px;
font-weight: bold;
}
.num3 {
// font-weight: bold;
display: inline-block;
// padding-left: 2px;
}
.num2 {
padding-top: 2px;
color: #888888;
}
.num4 {
font-size: 12px;
color: #cccccc;
}
}
.icon-wrap {
.fj;
align-items: center;
width: 40px;
}
}
}
.pi-overview {
&-item {
.border4;
padding: 0 12px;
.map-wrap {
position: relative;
.map-aside-wrap {
text-align: right;
max-height: 450px;
overflow-y: auto;
font-size: 12px;
transform: scale(0.8);
transform-origin: 100% 0;
color: #888888;
position: absolute;
top: 0px;
right: 0px;
}
}
}
}
.block {
width: 100%;
display: flex;
justify-content: space-between;
.date-button-wrap {
display: inline-block;
margin-left: 12px;
}
.date-button-wrap-2 {
}
}
.block2 {
// text-align: center;
padding: 0 40px;
}
.export-tips {
text-align: left;
color: #aaaaaa;
}
}
</style>