From deb4585d4b4456db02b1f9498170a50b5e7f041e Mon Sep 17 00:00:00 2001 From: puhui999 Date: Mon, 22 Apr 2024 11:04:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=80=82=E9=85=8D=20echarts=20map=20?= =?UTF-8?q?=E7=9A=84=E5=9C=B0=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/index.ts | 19 +++- .../components/PortraitCustomerArea.vue | 8 +- src/views/mall/statistics/member/index.vue | 89 +++++++++---------- 3 files changed, 62 insertions(+), 54 deletions(-) diff --git a/src/utils/index.ts b/src/utils/index.ts index 412a8b62..274ab7ca 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,4 +1,4 @@ -import { toNumber } from 'lodash-es' +import {toNumber} from 'lodash-es' /** * @@ -418,3 +418,20 @@ export const erpCalculatePercentage = (value: number, total: number) => { if (total === 0) return 0 return ((value / total) * 100).toFixed(2) } + +/** + * 适配 echarts map 的地名 + * + * @param areaName 地区名称 + */ +export const areaReplace = (areaName: string) => { + if (!areaName) { + return areaName + } + return areaName + .replace('维吾尔自治区', '') + .replace('壮族自治区', '') + .replace('回族自治区', '') + .replace('自治区', '') + .replace('省', '') +} diff --git a/src/views/crm/statistics/portrait/components/PortraitCustomerArea.vue b/src/views/crm/statistics/portrait/components/PortraitCustomerArea.vue index 84b43ac4..513936c9 100644 --- a/src/views/crm/statistics/portrait/components/PortraitCustomerArea.vue +++ b/src/views/crm/statistics/portrait/components/PortraitCustomerArea.vue @@ -24,6 +24,7 @@ import { CrmStatisticCustomerAreaRespVO, StatisticsPortraitApi } from '@/api/crm/statistics/portrait' +import { areaReplace } from '@/utils' defineOptions({ name: 'PortraitCustomerArea' }) const props = defineProps<{ queryParams: any }>() // 搜索参数 @@ -106,12 +107,7 @@ const loadData = async () => { areaStatisticsList.value = areaList.map((item: CrmStatisticCustomerAreaRespVO) => { return { ...item, - areaName: item.areaName // TODO @puhui999:这里最好注释下原因哈, 🤣 我从 mall copy 过来的;这块看着是适合 ercharts 的地名,要不抽个小的 js 方法,然后把涉及到的地方都替换掉。 - // .replace('维吾尔自治区', '') - // .replace('壮族自治区', '') - // .replace('回族自治区', '') - // .replace('自治区', '') - // .replace('省', '') + areaName: areaReplace(item.areaName) } }) buildLeftMap() diff --git a/src/views/mall/statistics/member/index.vue b/src/views/mall/statistics/member/index.vue index a075810d..0e1bbaf6 100644 --- a/src/views/mall/statistics/member/index.vue +++ b/src/views/mall/statistics/member/index.vue @@ -3,44 +3,44 @@
- + - + - + - + @@ -67,42 +67,42 @@ @@ -110,7 +110,7 @@ - + @@ -122,16 +122,16 @@