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
| import type { VxeTableGridOptions } from '#/adapter/vxe-table';
| import type { MallMemberStatisticsApi } from '#/api/mall/statistics/member';
|
| import { fenToYuan } from '..\..\..\..\..\packages\utils\src';
|
| /** 会员地域分布图表配置 */
| export function getAreaChartOptions(
| data: MallMemberStatisticsApi.AreaStatisticsRespVO[],
| ): any {
| if (!data || data.length === 0) {
| return {
| title: {
| text: '暂无数据',
| left: 'center',
| top: 'center',
| textStyle: {
| color: '#999',
| fontSize: 14,
| },
| },
| };
| }
|
| // 计算 min 和 max 值
| let min = Number.POSITIVE_INFINITY;
| let max = Number.NEGATIVE_INFINITY;
| const mapData = data.map((item) => {
| const payUserCount = item.orderPayUserCount || 0;
| min = Math.min(min, payUserCount);
| max = Math.max(max, payUserCount);
| return {
| ...item,
| name: item.areaName,
| value: payUserCount,
| };
| });
| // 如果所有值都为 0,设置合理的 min 和 max 值
| if (min === max && min === 0) {
| min = 0;
| max = 10;
| }
|
| // 返回图表配置
| return {
| tooltip: {
| trigger: 'item',
| formatter: (params: any) => {
| const itemData = params?.data;
| if (!itemData) {
| return `${params?.name || ''}<br/>暂无数据`;
| }
| return `${itemData.areaName || params.name}<br/>
| 会员数量:${itemData.userCount || 0}<br/>
| 订单创建数量:${itemData.orderCreateUserCount || 0}<br/>
| 订单支付数量:${itemData.orderPayUserCount || 0}<br/>
| 订单支付金额:¥${Number(fenToYuan(itemData.orderPayPrice || 0)).toFixed(2)}`;
| },
| },
| visualMap: {
| text: ['高', '低'],
| realtime: false,
| calculable: true,
| top: 'middle',
| left: 10,
| min,
| max,
| inRange: {
| color: ['#e6f3ff', '#1890ff', '#0050b3'],
| },
| },
| series: [
| {
| name: '会员地域分布',
| type: 'map',
| map: 'china',
| roam: false,
| selectedMode: false,
| itemStyle: {
| borderColor: '#389e0d',
| borderWidth: 0.5,
| },
| emphasis: {
| itemStyle: {
| areaColor: '#ffec3d',
| borderWidth: 1,
| },
| },
| data: mapData,
| },
| ],
| };
| }
|
| /** VXE Grid 表格列配置 */
| export function getAreaTableColumns(): VxeTableGridOptions['columns'] {
| return [
| {
| field: 'areaName',
| title: '省份',
| minWidth: 80,
| sortable: true,
| showOverflow: 'tooltip',
| },
| {
| field: 'userCount',
| title: '会员数量',
| minWidth: 100,
| sortable: true,
| },
| {
| field: 'orderCreateUserCount',
| title: '订单创建数量',
| minWidth: 120,
| sortable: true,
| },
| {
| field: 'orderPayUserCount',
| title: '订单支付数量',
| minWidth: 120,
| sortable: true,
| },
| {
| field: 'orderPayPrice',
| title: '订单支付金额',
| minWidth: 120,
| sortable: true,
| formatter: 'formatFenToYuanAmount',
| },
| ];
| }
|
|