Skip to content

Commit deb4585

Browse files
author
puhui999
committed
fix: 适配 echarts map 的地名
1 parent afdee2c commit deb4585

File tree

3 files changed

+56
-48
lines changed

3 files changed

+56
-48
lines changed

src/utils/index.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { toNumber } from 'lodash-es'
1+
import {toNumber} from 'lodash-es'
22

33
/**
44
*
@@ -418,3 +418,20 @@ export const erpCalculatePercentage = (value: number, total: number) => {
418418
if (total === 0) return 0
419419
return ((value / total) * 100).toFixed(2)
420420
}
421+
422+
/**
423+
* 适配 echarts map 的地名
424+
*
425+
* @param areaName 地区名称
426+
*/
427+
export const areaReplace = (areaName: string) => {
428+
if (!areaName) {
429+
return areaName
430+
}
431+
return areaName
432+
.replace('维吾尔自治区', '')
433+
.replace('壮族自治区', '')
434+
.replace('回族自治区', '')
435+
.replace('自治区', '')
436+
.replace('省', '')
437+
}

src/views/crm/statistics/portrait/components/PortraitCustomerArea.vue

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
CrmStatisticCustomerAreaRespVO,
2525
StatisticsPortraitApi
2626
} from '@/api/crm/statistics/portrait'
27+
import { areaReplace } from '@/utils'
2728
2829
defineOptions({ name: 'PortraitCustomerArea' })
2930
const props = defineProps<{ queryParams: any }>() // 搜索参数
@@ -106,12 +107,7 @@ const loadData = async () => {
106107
areaStatisticsList.value = areaList.map((item: CrmStatisticCustomerAreaRespVO) => {
107108
return {
108109
...item,
109-
areaName: item.areaName // TODO @puhui999:这里最好注释下原因哈, 🤣 我从 mall copy 过来的;这块看着是适合 ercharts 的地名,要不抽个小的 js 方法,然后把涉及到的地方都替换掉。
110-
// .replace('维吾尔自治区', '')
111-
// .replace('壮族自治区', '')
112-
// .replace('回族自治区', '')
113-
// .replace('自治区', '')
114-
// .replace('省', '')
110+
areaName: areaReplace(item.areaName)
115111
}
116112
})
117113
buildLeftMap()

src/views/mall/statistics/member/index.vue

Lines changed: 36 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,44 @@
33

44
<div class="flex flex-col">
55
<el-row :gutter="16" class="summary">
6-
<el-col :sm="6" :xs="12" v-loading="loading">
6+
<el-col v-loading="loading" :sm="6" :xs="12">
77
<SummaryCard
8-
title="累计会员数"
8+
:value="summary?.userCount || 0"
99
icon="fa-solid:users"
10-
icon-color="bg-blue-100"
1110
icon-bg-color="text-blue-500"
12-
:value="summary?.userCount || 0"
11+
icon-color="bg-blue-100"
12+
title="累计会员数"
1313
/>
1414
</el-col>
15-
<el-col :sm="6" :xs="12" v-loading="loading">
15+
<el-col v-loading="loading" :sm="6" :xs="12">
1616
<SummaryCard
17-
title="累计充值人数"
17+
:value="summary?.rechargeUserCount || 0"
1818
icon="fa-solid:user"
19-
icon-color="bg-purple-100"
2019
icon-bg-color="text-purple-500"
21-
:value="summary?.rechargeUserCount || 0"
20+
icon-color="bg-purple-100"
21+
title="累计充值人数"
2222
/>
2323
</el-col>
24-
<el-col :sm="6" :xs="12" v-loading="loading">
24+
<el-col v-loading="loading" :sm="6" :xs="12">
2525
<SummaryCard
26-
title="累计充值金额"
26+
:decimals="2"
27+
:value="fenToYuan(summary?.rechargePrice || 0)"
2728
icon="fa-solid:money-check-alt"
28-
icon-color="bg-yellow-100"
2929
icon-bg-color="text-yellow-500"
30+
icon-color="bg-yellow-100"
3031
prefix=""
31-
:decimals="2"
32-
:value="fenToYuan(summary?.rechargePrice || 0)"
32+
title="累计充值金额"
3333
/>
3434
</el-col>
35-
<el-col :sm="6" :xs="12" v-loading="loading">
35+
<el-col v-loading="loading" :sm="6" :xs="12">
3636
<SummaryCard
37-
title="累计消费金额"
37+
:decimals="2"
38+
:value="fenToYuan(summary?.expensePrice || 0)"
3839
icon="fa-solid:yen-sign"
39-
icon-color="bg-green-100"
4040
icon-bg-color="text-green-500"
41+
icon-color="bg-green-100"
4142
prefix=""
42-
:decimals="2"
43-
:value="fenToYuan(summary?.expensePrice || 0)"
43+
title="累计消费金额"
4444
/>
4545
</el-col>
4646
</el-row>
@@ -67,50 +67,50 @@
6767
<el-col :span="14">
6868
<el-table :data="areaStatisticsList" :height="300">
6969
<el-table-column
70-
label="省份"
71-
prop="areaName"
70+
:sort-method="(obj1, obj2) => obj1.areaName.localeCompare(obj2.areaName, 'zh-CN')"
7271
align="center"
72+
label="省份"
7373
min-width="80"
74+
prop="areaName"
7475
show-overflow-tooltip
7576
sortable
76-
:sort-method="(obj1, obj2) => obj1.areaName.localeCompare(obj2.areaName, 'zh-CN')"
7777
/>
7878
<el-table-column
79-
label="会员数量"
80-
prop="userCount"
8179
align="center"
80+
label="会员数量"
8281
min-width="105"
82+
prop="userCount"
8383
sortable
8484
/>
8585
<el-table-column
86-
label="订单创建数量"
87-
prop="orderCreateUserCount"
8886
align="center"
87+
label="订单创建数量"
8988
min-width="135"
89+
prop="orderCreateUserCount"
9090
sortable
9191
/>
9292
<el-table-column
93-
label="订单支付数量"
94-
prop="orderPayUserCount"
9593
align="center"
94+
label="订单支付数量"
9695
min-width="135"
96+
prop="orderPayUserCount"
9797
sortable
9898
/>
9999
<el-table-column
100-
label="订单支付金额"
101-
prop="orderPayPrice"
100+
:formatter="fenToYuanFormat"
102101
align="center"
102+
label="订单支付金额"
103103
min-width="135"
104+
prop="orderPayPrice"
104105
sortable
105-
:formatter="fenToYuanFormat"
106106
/>
107107
</el-table>
108108
</el-col>
109109
</el-row>
110110
</el-card>
111111
</el-col>
112112
<el-col :md="6" :sm="24">
113-
<el-card shadow="never" v-loading="loading">
113+
<el-card v-loading="loading" shadow="never">
114114
<template #header>
115115
<CardTitle title="会员性别比例" />
116116
</template>
@@ -122,16 +122,16 @@
122122
</template>
123123
<script lang="ts" setup>
124124
import * as MemberStatisticsApi from '@/api/mall/statistics/member'
125-
import SummaryCard from '@/components/SummaryCard/index.vue'
126-
import { EChartsOption } from 'echarts'
127-
import china from '@/assets/map/json/china.json'
128-
import { fenToYuan } from '@/utils'
129125
import {
130126
MemberAreaStatisticsRespVO,
131127
MemberSexStatisticsRespVO,
132128
MemberSummaryRespVO,
133129
MemberTerminalStatisticsRespVO
134130
} from '@/api/mall/statistics/member'
131+
import SummaryCard from '@/components/SummaryCard/index.vue'
132+
import { EChartsOption } from 'echarts'
133+
import china from '@/assets/map/json/china.json'
134+
import { areaReplace, fenToYuan } from '@/utils'
135135
import { DICT_TYPE, DictDataType, getIntDictOptions } from '@/utils/dict'
136136
import echarts from '@/plugins/echarts'
137137
import { fenToYuanFormat } from '@/utils/formatter'
@@ -246,12 +246,7 @@ const getMemberAreaStatisticsList = async () => {
246246
areaStatisticsList.value = list.map((item: MemberAreaStatisticsRespVO) => {
247247
return {
248248
...item,
249-
areaName: item.areaName
250-
.replace('维吾尔自治区', '')
251-
.replace('壮族自治区', '')
252-
.replace('回族自治区', '')
253-
.replace('自治区', '')
254-
.replace('', '')
249+
areaName: areaReplace(item.areaName)
255250
}
256251
})
257252
let min = 0

0 commit comments

Comments
 (0)