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
| import { zip } from 'rxjs/observable/zip';
| import { Component, OnInit, OnDestroy } from '@angular/core';
| import { NzMessageService } from 'ng-zorro-antd';
| import { getTimeDistance, yuan, fixedZero } from '@delon/abc';
| import { _HttpClient } from '@delon/theme';
| import {HttpClient} from '@angular/common/http';
| import * as moment from 'moment';
|
| @Component({
| selector: 'app-dashboard-workplace',
| templateUrl: './workplace.component.html',
| styleUrls: ['./workplace.component.less']
| })
| export class DashboardWorkplaceComponent implements OnInit, OnDestroy {
|
| totalDeviceCountList: any[] = [];
| totalDeviceCount = 0;
| avgDeviceCount: string;
|
| notice: any[] = [];
| activities: any[] = [];
| radarData: any[] = [];
| loading = true;
|
| // region: mock data
| links = [
| {
| title: '操作一',
| href: '',
| },
| {
| title: '操作二',
| href: '',
| },
| {
| title: '操作三',
| href: '',
| },
| {
| title: '操作四',
| href: '',
| },
| {
| title: '操作五',
| href: '',
| },
| {
| title: '操作六',
| href: '',
| },
| ];
| members = [
| {
| id: 'members-1',
| title: '科学搬砖组',
| logo: 'https://gw.alipayobjects.com/zos/rmsportal/WdGqmHpayyMjiEhcKoVE.png',
| link: '',
| },
| {
| id: 'members-2',
| title: '程序员日常',
| logo: 'https://gw.alipayobjects.com/zos/rmsportal/zOsKZmFRdUtvpqCImOVY.png',
| link: '',
| },
| {
| id: 'members-3',
| title: '设计天团',
| logo: 'https://gw.alipayobjects.com/zos/rmsportal/dURIMkkrRFpPgTuzkwnB.png',
| link: '',
| },
| {
| id: 'members-4',
| title: '中二少女团',
| logo: 'https://gw.alipayobjects.com/zos/rmsportal/sfjbOqnsXXJgNCjCzDBL.png',
| link: '',
| },
| {
| id: 'members-5',
| title: '骗你学计算机',
| logo: 'https://gw.alipayobjects.com/zos/rmsportal/siCrBXXhmvTQGWPNLBow.png',
| link: '',
| },
| ];
| // endregion
|
| ngOnDestroy(): void {
| }
|
|
| data: any = {
| salesData: [],
| offlineData: []
| };
|
| q: any = {
| start: null,
| end: null
| };
| rankingListData: any[] = Array(7).fill({}).map((item, i) => {
| return {
| title: `工专路 ${i} 号店`,
| total: 323234
| };
| });
|
| constructor(private http: _HttpClient, public msg: NzMessageService,
| private http2: HttpClient) {}
|
| ngOnInit() {
|
| const today = new Date().getTime();
| const fakeDC = [60, 135, 70, 112, 80, 170, 200, 140, 52, 119, 164, 230];
| for (let i = 0; i < 12; i += 1) {
| this.totalDeviceCountList.push({
| x: moment(today).subtract(-1*i, 'months').format(
| "YYYY-MM"
| ),
| y: fakeDC[i]
| });
| this.totalDeviceCount += fakeDC[i];
| }
| this.avgDeviceCount = (this.totalDeviceCount/12).toFixed(0);
|
|
| const visitData = [];
| const beginDay = new Date().getTime();
|
| const fakeY = [7, 5, 4, 2, 4, 7, 5, 6, 5, 9, 6, 3, 1, 5, 3, 6, 5];
| for (let i = 0; i < fakeY.length; i += 1) {
| visitData.push({
| x: moment(new Date(beginDay + 1000 * 60 * 60 * 24 * i)).format(
| "YYYY-MM-DD"
| ),
| y: fakeY[i]
| });
| }
| const visitData2 = [];
| const fakeY2 = [1, 6, 4, 8, 3, 7, 2];
| for (let i = 0; i < fakeY2.length; i += 1) {
| visitData2.push({
| x: moment(new Date(beginDay + 1000 * 60 * 60 * 24 * i)).format(
| "YYYY-MM-DD"
| ),
| y: fakeY2[i]
| });
| }
| const salesData = [];
| for (let i = 0; i < 12; i += 1) {
| salesData.push({
| x: `${i + 1}月`,
| y: Math.floor(Math.random() * 1000) + 200
| });
| }
|
| const salesTypeData = [
| {
| x: "家用电器",
| y: 4544
| },
| {
| x: "食用酒水",
| y: 3321
| },
| {
| x: "个护健康",
| y: 3113
| },
| {
| x: "服饰箱包",
| y: 2341
| },
| {
| x: "母婴产品",
| y: 1231
| },
| {
| x: "其他",
| y: 1231
| }
| ];
|
| const salesTypeDataOnline = [
| {
| x: "家用电器",
| y: 244
| },
| {
| x: "食用酒水",
| y: 321
| },
| {
| x: "个护健康",
| y: 311
| },
| {
| x: "服饰箱包",
| y: 41
| },
| {
| x: "母婴产品",
| y: 121
| },
| {
| x: '其他',
| y: 111
| }
| ];
|
| const salesTypeDataOffline = [
| {
| x: '家用电器',
| y: 99
| },
| {
| x: '个护健康',
| y: 188
| },
| {
| x: '服饰箱包',
| y: 344
| },
| {
| x: '母婴产品',
| y: 255
| },
| {
| x: '其他',
| y: 65
| }
| ];
|
| const offlineData = [];
| for (let i = 0; i < 10; i += 1) {
| offlineData.push({
| name: `门店${i}`,
| cvr: Math.ceil(Math.random() * 9) / 10
| });
| }
| const offlineChartData = [];
| for (let i = 0; i < 20; i += 1) {
| offlineChartData.push({
| x: new Date().getTime() + 1000 * 60 * 30 * i,
| y1: Math.floor(Math.random() * 100) + 10,
| y2: Math.floor(Math.random() * 100) + 10
| });
| }
|
| const radarOriginData = [
| {
| name: '个人',
| ref: 10,
| koubei: 8,
| output: 4,
| contribute: 5,
| hot: 7
| },
| {
| name: '团队',
| ref: 3,
| koubei: 9,
| output: 6,
| contribute: 3,
| hot: 1
| },
| {
| name: '部门',
| ref: 4,
| koubei: 1,
| output: 6,
| contribute: 5,
| hot: 7
| }
| ];
|
| const radarData = [];
| const radarTitleMap = {
| ref: '引用',
| koubei: '口碑',
| output: '产量',
| contribute: '贡献',
| hot: '热度'
| };
| radarOriginData.forEach(item => {
| Object.keys(item).forEach(key => {
| if (key !== 'name') {
| radarData.push({
| name: item.name,
| label: radarTitleMap[key],
| value: item[key]
| });
| }
| });
| });
| const searchData = [];
| for (let i = 0; i < 50; i += 1) {
| searchData.push({
| index: i + 1,
| keyword: `搜索关键词-${i}`,
| count: Math.floor(Math.random() * 1000),
| range: Math.floor(Math.random() * 100),
| status: Math.floor((Math.random() * 10) % 2)
| });
| }
| var res = {
| visitData: visitData,
| salesData: salesData,
| visitData2: visitData2,
| salesTypeData: salesTypeData,
| salesTypeDataOnline: salesTypeDataOnline,
| salesTypeDataOffline: salesTypeDataOffline,
| offlineData: offlineData,
| offlineChartData: offlineChartData,
| radarOriginData: radarOriginData,
| radarData: radarData,
| searchData: searchData
| };
|
| res.offlineData.forEach((item: any) => {
| item.chart = Object.assign([], res.offlineChartData);
| });
| this.data = res;
| this.loading = false;
| this.changeSaleType();
|
| this.radarData = res.radarData;
|
| const titles = [
| 'Alipay',
| 'Angular',
| 'Ant Design',
| 'Ant Design Pro',
| 'Bootstrap',
| 'React',
| 'Vue',
| 'Webpack'
| ];
|
| const avatars = [
| 'https://gw.alipayobjects.com/zos/rmsportal/WdGqmHpayyMjiEhcKoVE.png', // Alipay
| 'https://gw.alipayobjects.com/zos/rmsportal/zOsKZmFRdUtvpqCImOVY.png', // Angular
| 'https://gw.alipayobjects.com/zos/rmsportal/dURIMkkrRFpPgTuzkwnB.png', // Ant Design
| 'https://gw.alipayobjects.com/zos/rmsportal/sfjbOqnsXXJgNCjCzDBL.png', // Ant Design Pro
| 'https://gw.alipayobjects.com/zos/rmsportal/siCrBXXhmvTQGWPNLBow.png', // Bootstrap
| 'https://gw.alipayobjects.com/zos/rmsportal/kZzEzemZyKLKFsojXItE.png', // React
| 'https://gw.alipayobjects.com/zos/rmsportal/ComBAopevLwENQdKWiIn.png', // Vue
| 'https://gw.alipayobjects.com/zos/rmsportal/nxkuOJlFJuAUhzlMTCEe.png' // Webpack
| ];
|
| var notice = [
| {
| id: 'xxx1',
| title: titles[0],
| logo: avatars[0],
| description: '那是一种内在的东西, 他们到达不了,也无法触及的',
| updatedAt: new Date(),
| member: '科学搬砖组',
| href: '',
| memberLink: '',
| },
| {
| id: 'xxx2',
| title: titles[1],
| logo: avatars[1],
| description: '希望是一个好东西,也许是最好的,好东西是不会消亡的',
| updatedAt: new Date('2017-07-24'),
| member: '全组都是吴彦祖',
| href: '',
| memberLink: '',
| },
| {
| id: 'xxx3',
| title: titles[2],
| logo: avatars[2],
| description: '城镇中有那么多的酒馆,她却偏偏走进了我的酒馆',
| updatedAt: new Date(),
| member: '中二少女团',
| href: '',
| memberLink: '',
| },
| {
| id: 'xxx4',
| title: titles[3],
| logo: avatars[3],
| description: '那时候我只会想自己想要什么,从不想自己拥有什么',
| updatedAt: new Date('2017-07-23'),
| member: '程序员日常',
| href: '',
| memberLink: '',
| },
| {
| id: 'xxx5',
| title: titles[4],
| logo: avatars[4],
| description: '凛冬将至',
| updatedAt: new Date('2017-07-23'),
| member: '高逼格设计天团',
| href: '',
| memberLink: '',
| },
| {
| id: 'xxx6',
| title: titles[5],
| logo: avatars[5],
| description: '生命就像一盒巧克力,结果往往出人意料',
| updatedAt: new Date('2017-07-23'),
| member: '骗你来学计算机',
| href: '',
| memberLink: '',
| },
| ];
| this.notice = notice;
|
| var activities = [
| {
| id: 'trend-1',
| updatedAt: new Date(),
| user: {
| name: '林东东',
| avatar: avatars[0],
| },
| group: {
| name: '高逼格设计天团',
| link: 'http://github.com/',
| },
| project: {
| name: '六月迭代',
| link: 'http://github.com/',
| },
| template: '在 @{group} 新建项目 @{project}',
| },
| {
| id: 'trend-2',
| updatedAt: new Date(),
| user: {
| name: '付小小',
| avatar: avatars[1],
| },
| group: {
| name: '高逼格设计天团',
| link: 'http://github.com/',
| },
| project: {
| name: '六月迭代',
| link: 'http://github.com/',
| },
| template: '在 @{group} 新建项目 @{project}',
| },
| {
| id: 'trend-3',
| updatedAt: new Date(),
| user: {
| name: '曲丽丽',
| avatar: avatars[2],
| },
| group: {
| name: '中二少女团',
| link: 'http://github.com/',
| },
| project: {
| name: '六月迭代',
| link: 'http://github.com/',
| },
| template: '在 @{group} 新建项目 @{project}',
| },
| {
| id: 'trend-4',
| updatedAt: new Date(),
| user: {
| name: '周星星',
| avatar: avatars[3],
| },
| project: {
| name: '5 月日常迭代',
| link: 'http://github.com/',
| },
| template: '将 @{project} 更新至已发布状态',
| },
| {
| id: 'trend-5',
| updatedAt: new Date(),
| user: {
| name: '朱偏右',
| avatar: avatars[4],
| },
| project: {
| name: '工程效能',
| link: 'http://github.com/',
| },
| comment: {
| name: '留言',
| link: 'http://github.com/',
| },
| template: '在 @{project} 发布了 @{comment}',
| },
| {
| id: 'trend-6',
| updatedAt: new Date(),
| user: {
| name: '乐哥',
| avatar: avatars[5],
| },
| group: {
| name: '程序员日常',
| link: 'http://github.com/',
| },
| project: {
| name: '品牌迭代',
| link: 'http://github.com/',
| },
| template: '在 @{group} 新建项目 @{project}',
| },
| ];
| this.activities = activities.map((item: any) => {
| item.template = item.template.split(/@\{([^{}]*)\}/gi).map((key: string) => {
| if (item[key]) return `<a>${item[key].name}</a>`;
| return key;
| });
| return item;
| });
|
|
|
| }
|
| setDate(type: any) {
| const rank = getTimeDistance(type);
| this.q.start = rank[0];
| this.q.end = rank[1];
| }
|
| sort(sortName, sortValue) {
| this.data.searchData = [
| ...(<any[]>this.data.searchData).sort((a, b) => {
| if (a[ sortName ] > b[ sortName ]) {
| return (sortValue === 'ascend') ? 1 : -1;
| } else if (a[ sortName ] < b[ sortName ]) {
| return (sortValue === 'ascend') ? -1 : 1;
| } else {
| return 0;
| }
| })
| ];
| }
|
| salesType = 'all';
| salesPieData: any;
| salesTotal = 0;
| 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);
| }
|
| _activeTab = 0;
| _tabChange(value: any) {
| console.log('tab', this._activeTab, value);
| }
| }
|
|