/
analysis.component.ts
77 lines (65 loc) · 2.29 KB
/
analysis.component.ts
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
import { Component, OnInit } from '@angular/core';
import { NzMessageService } from 'ng-zorro-antd';
import { getTimeDistance, yuan, SimpleTableColumn } from '@delon/abc';
import { _HttpClient } from '@delon/theme';
@Component({
selector: 'app-dashboard-analysis',
templateUrl: './analysis.component.html',
styleUrls: ['./analysis.component.less']
})
export class DashboardAnalysisComponent implements OnInit {
data: any = {
salesData: [],
offlineData: []
};
loading = true;
q: any = {
start: null,
end: null
};
rankingListData: any[] = Array(7).fill({}).map((item, i) => {
return {
title: `工专路 ${i} 号店`,
total: 323234
};
});
searchColumn: SimpleTableColumn[] = [
{ title: '排名', index: 'index' },
{ title: '搜索关键词', index: 'keyword', click: (item: any) => this.msg.success(item.keyword) },
{ type: 'number', title: '用户数', index: 'count', sorter: (a, b) => a.count - b.count },
{ type: 'number', title: '周涨幅', index: 'range', render: 'range', sorter: (a, b) => a.range - b.range }
];
salesType = 'all';
salesPieData: any;
salesTotal = 0;
_activeTab = 0;
constructor(private http: _HttpClient, public msg: NzMessageService) { }
ngOnInit() {
console.log('analysis ...');
this.http.get('/chart').subscribe((res: any) => {
res.offlineData.forEach((item: any) => {
item.chart = Object.assign([], res.offlineChartData);
});
this.data = res;
this.loading = false;
this.changeSaleType();
});
}
setDate(type: any) {
const rank = getTimeDistance(type);
this.q.start = rank[0];
this.q.end = rank[1];
}
changeSaleType() {
this.salesPieData = this.salesType === 'all' ? this.data.salesTypeData : (
this.salesType === 'online' ? this.data.salesTypeDataOnline : this.data.salesTypeDataOffline
);
if (this.salesPieData) { this.salesTotal = this.salesPieData.reduce((pre, now) => now.y + pre, 0); }
}
handlePieValueFormat(value: any) {
return yuan(value);
}
_tabChange(value: any) {
console.log('tab', this._activeTab, value);
}
}