|
| 1 | +<!-- 客户总量统计 --> |
| 2 | +<template> |
| 3 | + <!-- Echarts图 --> |
| 4 | + <el-card shadow="never"> |
| 5 | + <el-skeleton :loading="loading" animated> |
| 6 | + <Echart :height="500" :options="echartsOption" /> |
| 7 | + </el-skeleton> |
| 8 | + </el-card> |
| 9 | + |
| 10 | + <!-- 统计列表 --> |
| 11 | + <el-card class="mt-16px" shadow="never"> |
| 12 | + <el-table v-loading="loading" :data="list"> |
| 13 | + <el-table-column align="center" fixed="left" label="序号" type="index" width="80" /> |
| 14 | + <el-table-column align="center" fixed="left" label="商机名称" prop="name" width="160"> |
| 15 | + <template #default="scope"> |
| 16 | + <el-link :underline="false" type="primary" @click="openDetail(scope.row.id)"> |
| 17 | + {{ scope.row.name }} |
| 18 | + </el-link> |
| 19 | + </template> |
| 20 | + </el-table-column> |
| 21 | + <el-table-column align="center" fixed="left" label="客户名称" prop="customerName" width="120"> |
| 22 | + <template #default="scope"> |
| 23 | + <el-link |
| 24 | + :underline="false" |
| 25 | + type="primary" |
| 26 | + @click="openCustomerDetail(scope.row.customerId)" |
| 27 | + > |
| 28 | + {{ scope.row.customerName }} |
| 29 | + </el-link> |
| 30 | + </template> |
| 31 | + </el-table-column> |
| 32 | + <el-table-column |
| 33 | + :formatter="erpPriceTableColumnFormatter" |
| 34 | + align="center" |
| 35 | + label="商机金额(元)" |
| 36 | + prop="totalPrice" |
| 37 | + width="140" |
| 38 | + /> |
| 39 | + <el-table-column |
| 40 | + :formatter="dateFormatter" |
| 41 | + align="center" |
| 42 | + label="预计成交日期" |
| 43 | + prop="dealTime" |
| 44 | + width="180px" |
| 45 | + /> |
| 46 | + <el-table-column align="center" label="备注" prop="remark" width="200" /> |
| 47 | + <el-table-column |
| 48 | + :formatter="dateFormatter" |
| 49 | + align="center" |
| 50 | + label="下次联系时间" |
| 51 | + prop="contactNextTime" |
| 52 | + width="180px" |
| 53 | + /> |
| 54 | + <el-table-column align="center" label="负责人" prop="ownerUserName" width="100px" /> |
| 55 | + <el-table-column align="center" label="所属部门" prop="ownerUserDeptName" width="100px" /> |
| 56 | + <el-table-column |
| 57 | + :formatter="dateFormatter" |
| 58 | + align="center" |
| 59 | + label="最后跟进时间" |
| 60 | + prop="contactLastTime" |
| 61 | + width="180px" |
| 62 | + /> |
| 63 | + <el-table-column |
| 64 | + :formatter="dateFormatter" |
| 65 | + align="center" |
| 66 | + label="更新时间" |
| 67 | + prop="updateTime" |
| 68 | + width="180px" |
| 69 | + /> |
| 70 | + <el-table-column |
| 71 | + :formatter="dateFormatter" |
| 72 | + align="center" |
| 73 | + label="创建时间" |
| 74 | + prop="createTime" |
| 75 | + width="180px" |
| 76 | + /> |
| 77 | + <el-table-column align="center" label="创建人" prop="creatorName" width="100px" /> |
| 78 | + <el-table-column |
| 79 | + align="center" |
| 80 | + fixed="right" |
| 81 | + label="商机状态组" |
| 82 | + prop="statusTypeName" |
| 83 | + width="140" |
| 84 | + /> |
| 85 | + <el-table-column |
| 86 | + align="center" |
| 87 | + fixed="right" |
| 88 | + label="商机阶段" |
| 89 | + prop="statusName" |
| 90 | + width="120" |
| 91 | + /> |
| 92 | + </el-table> |
| 93 | + <!-- 分页 --> |
| 94 | + <Pagination |
| 95 | + v-model:limit="queryParams0.pageSize" |
| 96 | + v-model:page="queryParams0.pageNo" |
| 97 | + :total="total" |
| 98 | + @pagination="getList" |
| 99 | + /> |
| 100 | + </el-card> |
| 101 | +</template> |
| 102 | +<script lang="ts" setup> |
| 103 | +import { |
| 104 | + CrmStatisticsBusinessInversionRateSummaryByDateRespVO, |
| 105 | + StatisticFunnelApi |
| 106 | +} from '@/api/crm/statistics/funnel' |
| 107 | +import { EChartsOption } from 'echarts' |
| 108 | +import { erpCalculatePercentage, erpPriceTableColumnFormatter } from '@/utils' |
| 109 | +import { dateFormatter } from '@/utils/formatTime' |
| 110 | +
|
| 111 | +defineOptions({ name: 'BusinessSummary' }) |
| 112 | +
|
| 113 | +const props = defineProps<{ queryParams: any }>() // 搜索参数 |
| 114 | +const queryParams0 = reactive({ |
| 115 | + pageNo: 1, |
| 116 | + pageSize: 10 |
| 117 | +}) |
| 118 | +const loading = ref(false) // 加载中 |
| 119 | +const list = ref([]) // 列表的数据 |
| 120 | +const total = ref(0) |
| 121 | +/** 将传进来的值赋值给 queryParams0 */ |
| 122 | +watch( |
| 123 | + () => props.queryParams, |
| 124 | + (data) => { |
| 125 | + if (!data) { |
| 126 | + return |
| 127 | + } |
| 128 | + const newObj = { ...queryParams0, ...data } |
| 129 | + Object.assign(queryParams0, newObj) |
| 130 | + }, |
| 131 | + { |
| 132 | + immediate: true |
| 133 | + } |
| 134 | +) |
| 135 | +/** 柱状图配置:纵向 */ |
| 136 | +const echartsOption = reactive<EChartsOption>({ |
| 137 | + color: ['#6ca2ff', '#6ac9d7', '#ff7474'], |
| 138 | + tooltip: { |
| 139 | + trigger: 'axis', |
| 140 | + axisPointer: { |
| 141 | + // 坐标轴指示器,坐标轴触发有效 |
| 142 | + type: 'shadow' // 默认为直线,可选为:'line' | 'shadow' |
| 143 | + } |
| 144 | + }, |
| 145 | + legend: { |
| 146 | + data: ['赢单转化率', '商机总数', '赢单商机数'], |
| 147 | + bottom: '0px', |
| 148 | + itemWidth: 14 |
| 149 | + }, |
| 150 | + grid: { |
| 151 | + top: '40px', |
| 152 | + left: '40px', |
| 153 | + right: '40px', |
| 154 | + bottom: '40px', |
| 155 | + containLabel: true, |
| 156 | + borderColor: '#fff' |
| 157 | + }, |
| 158 | + xAxis: [ |
| 159 | + { |
| 160 | + type: 'category', |
| 161 | + data: [], |
| 162 | + axisTick: { |
| 163 | + alignWithLabel: true, |
| 164 | + lineStyle: { width: 0 } |
| 165 | + }, |
| 166 | + axisLabel: { |
| 167 | + color: '#BDBDBD' |
| 168 | + }, |
| 169 | + /** 坐标轴轴线相关设置 */ |
| 170 | + axisLine: { |
| 171 | + lineStyle: { color: '#BDBDBD' } |
| 172 | + }, |
| 173 | + splitLine: { |
| 174 | + show: false |
| 175 | + } |
| 176 | + } |
| 177 | + ], |
| 178 | + yAxis: [ |
| 179 | + { |
| 180 | + type: 'value', |
| 181 | + name: '赢单转化率', |
| 182 | + axisTick: { |
| 183 | + alignWithLabel: true, |
| 184 | + lineStyle: { width: 0 } |
| 185 | + }, |
| 186 | + axisLabel: { |
| 187 | + color: '#BDBDBD', |
| 188 | + formatter: '{value}%' |
| 189 | + }, |
| 190 | + /** 坐标轴轴线相关设置 */ |
| 191 | + axisLine: { |
| 192 | + lineStyle: { color: '#BDBDBD' } |
| 193 | + }, |
| 194 | + splitLine: { |
| 195 | + show: false |
| 196 | + } |
| 197 | + }, |
| 198 | + { |
| 199 | + type: 'value', |
| 200 | + name: '商机数', |
| 201 | + axisTick: { |
| 202 | + alignWithLabel: true, |
| 203 | + lineStyle: { width: 0 } |
| 204 | + }, |
| 205 | + axisLabel: { |
| 206 | + color: '#BDBDBD', |
| 207 | + formatter: '{value}个' |
| 208 | + }, |
| 209 | + /** 坐标轴轴线相关设置 */ |
| 210 | + axisLine: { |
| 211 | + lineStyle: { color: '#BDBDBD' } |
| 212 | + }, |
| 213 | + splitLine: { |
| 214 | + show: false |
| 215 | + } |
| 216 | + } |
| 217 | + ], |
| 218 | + series: [ |
| 219 | + { |
| 220 | + name: '赢单转化率', |
| 221 | + type: 'line', |
| 222 | + yAxisIndex: 0, |
| 223 | + data: [] |
| 224 | + }, |
| 225 | + { |
| 226 | + name: '商机总数', |
| 227 | + type: 'bar', |
| 228 | + yAxisIndex: 1, |
| 229 | + barWidth: 15, |
| 230 | + data: [] |
| 231 | + }, |
| 232 | + { |
| 233 | + name: '赢单商机数', |
| 234 | + type: 'bar', |
| 235 | + yAxisIndex: 1, |
| 236 | + barWidth: 15, |
| 237 | + data: [] |
| 238 | + } |
| 239 | + ] |
| 240 | +}) as EChartsOption |
| 241 | +
|
| 242 | +/** 获取数据并填充图表 */ |
| 243 | +const fetchAndFill = async () => { |
| 244 | + // 1. 加载统计数据 |
| 245 | + const businessSummaryByDate = await StatisticFunnelApi.getBusinessInversionRateSummaryByDate( |
| 246 | + props.queryParams |
| 247 | + ) |
| 248 | + // 2.1 更新 Echarts 数据 |
| 249 | + if (echartsOption.xAxis && echartsOption.xAxis[0] && echartsOption.xAxis[0]['data']) { |
| 250 | + echartsOption.xAxis[0]['data'] = businessSummaryByDate.map( |
| 251 | + (s: CrmStatisticsBusinessInversionRateSummaryByDateRespVO) => s.time |
| 252 | + ) |
| 253 | + } |
| 254 | + if (echartsOption.series && echartsOption.series[0] && echartsOption.series[0]['data']) { |
| 255 | + echartsOption.series[0]['data'] = businessSummaryByDate.map( |
| 256 | + (s: CrmStatisticsBusinessInversionRateSummaryByDateRespVO) => |
| 257 | + erpCalculatePercentage(s.businessWinCount, s.businessCount) |
| 258 | + ) |
| 259 | + } |
| 260 | + if (echartsOption.series && echartsOption.series[1] && echartsOption.series[1]['data']) { |
| 261 | + echartsOption.series[1]['data'] = businessSummaryByDate.map( |
| 262 | + (s: CrmStatisticsBusinessInversionRateSummaryByDateRespVO) => s.businessCount |
| 263 | + ) |
| 264 | + } |
| 265 | + if (echartsOption.series && echartsOption.series[2] && echartsOption.series[2]['data']) { |
| 266 | + echartsOption.series[2]['data'] = businessSummaryByDate.map( |
| 267 | + (s: CrmStatisticsBusinessInversionRateSummaryByDateRespVO) => s.businessWinCount |
| 268 | + ) |
| 269 | + } |
| 270 | +
|
| 271 | + // 2.2 更新列表数据 |
| 272 | + await getList() |
| 273 | +} |
| 274 | +/** 获取商机列表 */ |
| 275 | +const getList = async () => { |
| 276 | + const data = await StatisticFunnelApi.getBusinessPageByDate(props.queryParams) |
| 277 | + list.value = data.list |
| 278 | + total.value = data.total |
| 279 | +} |
| 280 | +/** 打开客户详情 */ |
| 281 | +const { push } = useRouter() |
| 282 | +const openDetail = (id: number) => { |
| 283 | + push({ name: 'CrmBusinessDetail', params: { id } }) |
| 284 | +} |
| 285 | +
|
| 286 | +/** 打开客户详情 */ |
| 287 | +const openCustomerDetail = (id: number) => { |
| 288 | + push({ name: 'CrmCustomerDetail', params: { id } }) |
| 289 | +} |
| 290 | +
|
| 291 | +/** 获取统计数据 */ |
| 292 | +const loadData = async () => { |
| 293 | + loading.value = true |
| 294 | + try { |
| 295 | + await fetchAndFill() |
| 296 | + } finally { |
| 297 | + loading.value = false |
| 298 | + } |
| 299 | +} |
| 300 | +
|
| 301 | +defineExpose({ loadData }) |
| 302 | +
|
| 303 | +/** 初始化 */ |
| 304 | +onMounted(() => { |
| 305 | + loadData() |
| 306 | +}) |
| 307 | +</script> |
0 commit comments