CRM: 完善用户画像数据统计

This commit is contained in:
puhui999 2024-04-11 15:25:48 +08:00
parent f6e4753b34
commit 64af029c86
8 changed files with 34 additions and 36 deletions

View File

@ -6,11 +6,11 @@
"private": false, "private": false,
"scripts": { "scripts": {
"i": "pnpm install", "i": "pnpm install",
"dev": "vite --mode local-dev", "local-server": "vite --mode local-dev",
"dev-server": "vite --mode dev", "dev-server": "vite --mode dev",
"ts:check": "vue-tsc --noEmit", "ts:check": "vue-tsc --noEmit",
"build:local-dev": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode local-dev", "build:local": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode local-dev",
"build:dev": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode local-dev", "build:dev": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode dev",
"build:test": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode test", "build:test": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode test",
"build:stage": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode stage", "build:stage": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode stage",
"build:prod": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode prod", "build:prod": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode prod",

View File

@ -33,7 +33,6 @@ import { getBoolDictOptions, getIntDictOptions, getStrDictOptions } from '@/util
// //
interface Props { interface Props {
modelValue?: any //
dictType: string // dictType: string //
valueType: string // valueType: string //
} }

View File

@ -25,8 +25,7 @@ import {
StatisticsPortraitApi StatisticsPortraitApi
} from '@/api/crm/statistics/portrait' } from '@/api/crm/statistics/portrait'
// TODO @puhui999address area defineOptions({ name: 'CustomerArea' })
defineOptions({ name: 'CustomerAddress' })
const props = defineProps<{ queryParams: any }>() // const props = defineProps<{ queryParams: any }>() //
// //
@ -107,22 +106,21 @@ const loadData = async () => {
areaStatisticsList.value = areaList.map((item: CrmStatisticCustomerAreaRespVO) => { areaStatisticsList.value = areaList.map((item: CrmStatisticCustomerAreaRespVO) => {
return { return {
...item, ...item,
areaName: item.areaName // TODO @puhui999 areaName: item.areaName // TODO @puhui999, 🤣 mall copy
.replace('维吾尔自治区', '') // .replace('', '')
.replace('壮族自治区', '') // .replace('', '')
.replace('回族自治区', '') // .replace('', '')
.replace('自治区', '') // .replace('', '')
.replace('省', '') // .replace('', '')
} }
}) })
builderLeftMap() buildLeftMap()
builderRightMap() buildRightMap()
loading.value = false loading.value = false
} }
defineExpose({ loadData }) defineExpose({ loadData })
// TODO @puhui999builder build const buildLeftMap = () => {
const builderLeftMap = () => {
let min = 0 let min = 0
let max = 0 let max = 0
echartsOption.series![0].data = areaStatisticsList.value.map((item) => { echartsOption.series![0].data = areaStatisticsList.value.map((item) => {
@ -134,7 +132,7 @@ const builderLeftMap = () => {
echartsOption.visualMap!['max'] = max echartsOption.visualMap!['max'] = max
} }
const builderRightMap = () => { const buildRightMap = () => {
let min = 0 let min = 0
let max = 0 let max = 0
echartsOption2.series![0].data = areaStatisticsList.value.map((item) => { echartsOption2.series![0].data = areaStatisticsList.value.map((item) => {

View File

@ -39,7 +39,7 @@ import {
} from '@/api/crm/statistics/portrait' } from '@/api/crm/statistics/portrait'
import { EChartsOption } from 'echarts' import { EChartsOption } from 'echarts'
import { DICT_TYPE, getDictLabel } from '@/utils/dict' import { DICT_TYPE, getDictLabel } from '@/utils/dict'
import { getSumValue } from '@/utils' import { erpCalculatePercentage, getSumValue } from '@/utils'
import { isEmpty } from '@/utils/is' import { isEmpty } from '@/utils/is'
defineOptions({ name: 'CustomerIndustry' }) defineOptions({ name: 'CustomerIndustry' })
@ -185,8 +185,9 @@ const calculateProportion = (sourceList: CrmStatisticCustomerIndustryRespVO[]) =
const sumDealCount = getSumValue(list.map((item) => item.dealCount)) const sumDealCount = getSumValue(list.map((item) => item.dealCount))
list.forEach((item) => { list.forEach((item) => {
item.industryPortion = item.industryPortion =
item.customerCount === 0 ? 0 : ((item.customerCount / sumCustomerCount) * 100).toFixed(2) item.customerCount === 0 ? 0 : erpCalculatePercentage(item.customerCount, sumCustomerCount)
item.dealPortion = item.dealCount === 0 ? 0 : ((item.dealCount / sumDealCount) * 100).toFixed(2) item.dealPortion =
item.dealCount === 0 ? 0 : erpCalculatePercentage(item.dealCount, sumDealCount)
}) })
} }

View File

@ -39,7 +39,7 @@ import {
} from '@/api/crm/statistics/portrait' } from '@/api/crm/statistics/portrait'
import { EChartsOption } from 'echarts' import { EChartsOption } from 'echarts'
import { DICT_TYPE, getDictLabel } from '@/utils/dict' import { DICT_TYPE, getDictLabel } from '@/utils/dict'
import { getSumValue } from '@/utils' import { erpCalculatePercentage, getSumValue } from '@/utils'
import { isEmpty } from '@/utils/is' import { isEmpty } from '@/utils/is'
defineOptions({ name: 'CustomerSource' }) defineOptions({ name: 'CustomerSource' })
@ -184,10 +184,10 @@ const calculateProportion = (levelList: CrmStatisticCustomerLevelRespVO[]) => {
const sumCustomerCount = getSumValue(list.map((item) => item.customerCount)) const sumCustomerCount = getSumValue(list.map((item) => item.customerCount))
const sumDealCount = getSumValue(list.map((item) => item.dealCount)) const sumDealCount = getSumValue(list.map((item) => item.dealCount))
list.forEach((item) => { list.forEach((item) => {
// TODO @puhui999使 erpCalculatePercentage
item.levelPortion = item.levelPortion =
item.customerCount === 0 ? 0 : ((item.customerCount / sumCustomerCount) * 100).toFixed(2) item.customerCount === 0 ? 0 : erpCalculatePercentage(item.customerCount, sumCustomerCount)
item.dealPortion = item.dealCount === 0 ? 0 : ((item.dealCount / sumDealCount) * 100).toFixed(2) item.dealPortion =
item.dealCount === 0 ? 0 : erpCalculatePercentage(item.dealCount, sumDealCount)
}) })
} }

View File

@ -40,7 +40,7 @@ import {
import { EChartsOption } from 'echarts' import { EChartsOption } from 'echarts'
import { DICT_TYPE, getDictLabel } from '@/utils/dict' import { DICT_TYPE, getDictLabel } from '@/utils/dict'
import { isEmpty } from '@/utils/is' import { isEmpty } from '@/utils/is'
import { getSumValue } from '@/utils' import { erpCalculatePercentage, getSumValue } from '@/utils'
defineOptions({ name: 'CustomerSource' }) defineOptions({ name: 'CustomerSource' })
const props = defineProps<{ queryParams: any }>() // const props = defineProps<{ queryParams: any }>() //
@ -185,8 +185,9 @@ const calculateProportion = (sourceList: CrmStatisticCustomerSourceRespVO[]) =>
const sumDealCount = getSumValue(list.map((item) => item.dealCount)) const sumDealCount = getSumValue(list.map((item) => item.dealCount))
list.forEach((item) => { list.forEach((item) => {
item.sourcePortion = item.sourcePortion =
item.customerCount === 0 ? 0 : ((item.customerCount / sumCustomerCount) * 100).toFixed(2) item.customerCount === 0 ? 0 : erpCalculatePercentage(item.customerCount, sumCustomerCount)
item.dealPortion = item.dealCount === 0 ? 0 : ((item.dealCount / sumDealCount) * 100).toFixed(2) item.dealPortion =
item.dealCount === 0 ? 0 : erpCalculatePercentage(item.dealCount, sumDealCount)
}) })
} }

View File

@ -61,19 +61,19 @@
<el-tabs v-model="activeTab"> <el-tabs v-model="activeTab">
<!-- 城市分布分析 --> <!-- 城市分布分析 -->
<el-tab-pane label="城市分布分析" lazy name="addressRef"> <el-tab-pane label="城市分布分析" lazy name="addressRef">
<CustomerAddress ref="addressRef" :query-params="queryParams" /> <CrmStatisticsPortraitCustomerArea ref="addressRef" :query-params="queryParams" />
</el-tab-pane> </el-tab-pane>
<!-- 客户级别分析 --> <!-- 客户级别分析 -->
<el-tab-pane label="客户级别分析" lazy name="levelRef"> <el-tab-pane label="客户级别分析" lazy name="levelRef">
<CustomerLevel ref="levelRef" :query-params="queryParams" /> <CrmStatisticsPortraitCustomerLevel ref="levelRef" :query-params="queryParams" />
</el-tab-pane> </el-tab-pane>
<!-- 客户来源分析 --> <!-- 客户来源分析 -->
<el-tab-pane label="客户来源分析" lazy name="sourceRef"> <el-tab-pane label="客户来源分析" lazy name="sourceRef">
<CustomerSource ref="sourceRef" :query-params="queryParams" /> <CrmStatisticsPortraitCustomerSource ref="sourceRef" :query-params="queryParams" />
</el-tab-pane> </el-tab-pane>
<!-- 客户行业分析 --> <!-- 客户行业分析 -->
<el-tab-pane label="客户行业分析" lazy name="industryRef"> <el-tab-pane label="客户行业分析" lazy name="industryRef">
<CustomerIndustry ref="industryRef" :query-params="queryParams" /> <CrmStatisticsPortraitCustomerIndustry ref="industryRef" :query-params="queryParams" />
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</el-col> </el-col>
@ -85,11 +85,10 @@ import * as UserApi from '@/api/system/user'
import { useUserStore } from '@/store/modules/user' import { useUserStore } from '@/store/modules/user'
import { beginOfDay, defaultShortcuts, endOfDay, formatDate } from '@/utils/formatTime' import { beginOfDay, defaultShortcuts, endOfDay, formatDate } from '@/utils/formatTime'
import { defaultProps, handleTree } from '@/utils/tree' import { defaultProps, handleTree } from '@/utils/tree'
// TODO @puhui999CrmStatisticsPortrait import CrmStatisticsPortraitCustomerArea from './components/CrmStatisticsPortraitCustomerArea.vue'
import CustomerAddress from './components/CustomerAddress.vue' import CrmStatisticsPortraitCustomerIndustry from './components/CrmStatisticsPortraitCustomerIndustry.vue'
import CustomerIndustry from './components/CustomerIndustry.vue' import CrmStatisticsPortraitCustomerSource from './components/CrmStatisticsPortraitCustomerSource.vue'
import CustomerSource from './components/CustomerSource.vue' import CrmStatisticsPortraitCustomerLevel from './components/CrmStatisticsPortraitCustomerLevel.vue'
import CustomerLevel from './components/CustomerLevel.vue'
defineOptions({ name: 'CrmStatisticsPortrait' }) defineOptions({ name: 'CrmStatisticsPortrait' })