|
| 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 | + grid: { |
| 138 | + left: 30, |
| 139 | + right: 30, // 让 X 轴右侧显示完整 |
| 140 | + bottom: 20, |
| 141 | + containLabel: true |
| 142 | + }, |
| 143 | + legend: {}, |
| 144 | + series: [ |
| 145 | + { |
| 146 | + name: '商机总数', |
| 147 | + type: 'bar', |
| 148 | + yAxisIndex: 0, |
| 149 | + data: [] |
| 150 | + }, |
| 151 | + { |
| 152 | + name: '赢单商机数', |
| 153 | + type: 'bar', |
| 154 | + yAxisIndex: 1, |
| 155 | + data: [] |
| 156 | + }, |
| 157 | + { |
| 158 | + name: '赢单转化率', |
| 159 | + type: 'bar', |
| 160 | + yAxisIndex: 2, |
| 161 | + data: [] |
| 162 | + } |
| 163 | + ], |
| 164 | + toolbox: { |
| 165 | + feature: { |
| 166 | + dataZoom: { |
| 167 | + xAxisIndex: false // 数据区域缩放:Y 轴不缩放 |
| 168 | + }, |
| 169 | + brush: { |
| 170 | + type: ['lineX', 'clear'] // 区域缩放按钮、还原按钮 |
| 171 | + }, |
| 172 | + saveAsImage: { show: true, name: '商机转化率分析' } // 保存为图片 |
| 173 | + } |
| 174 | + }, |
| 175 | + tooltip: { |
| 176 | + trigger: 'axis', |
| 177 | + axisPointer: { |
| 178 | + type: 'shadow' |
| 179 | + } |
| 180 | + }, |
| 181 | + yAxis: [ |
| 182 | + { |
| 183 | + type: 'value', |
| 184 | + name: '商机总数', |
| 185 | + min: 0, |
| 186 | + minInterval: 1 // 显示整数刻度 |
| 187 | + }, |
| 188 | + { |
| 189 | + type: 'value', |
| 190 | + name: '赢单商机数', |
| 191 | + min: 0, |
| 192 | + minInterval: 1 // 显示整数刻度 |
| 193 | + }, |
| 194 | + { |
| 195 | + type: 'value', |
| 196 | + name: '赢单转化率', |
| 197 | + min: 0, |
| 198 | + minInterval: 1, // 显示整数刻度 |
| 199 | + splitLine: { |
| 200 | + lineStyle: { |
| 201 | + type: 'dotted', // 右侧网格线虚化, 减少混乱 |
| 202 | + opacity: 0.7 |
| 203 | + } |
| 204 | + } |
| 205 | + } |
| 206 | + ], |
| 207 | + xAxis: { |
| 208 | + type: 'category', |
| 209 | + name: '日期', |
| 210 | + data: [] |
| 211 | + } |
| 212 | +}) as EChartsOption |
| 213 | +
|
| 214 | +/** 获取数据并填充图表 */ |
| 215 | +const fetchAndFill = async () => { |
| 216 | + // 1. 加载统计数据 |
| 217 | + const businessSummaryByDate = await StatisticFunnelApi.getBusinessInversionRateSummaryByDate( |
| 218 | + props.queryParams |
| 219 | + ) |
| 220 | + // 2.1 更新 Echarts 数据 |
| 221 | + if (echartsOption.xAxis && echartsOption.xAxis['data']) { |
| 222 | + echartsOption.xAxis['data'] = businessSummaryByDate.map( |
| 223 | + (s: CrmStatisticsBusinessInversionRateSummaryByDateRespVO) => s.time |
| 224 | + ) |
| 225 | + } |
| 226 | + if (echartsOption.series && echartsOption.series[0] && echartsOption.series[0]['data']) { |
| 227 | + echartsOption.series[0]['data'] = businessSummaryByDate.map( |
| 228 | + (s: CrmStatisticsBusinessInversionRateSummaryByDateRespVO) => s.businessCount |
| 229 | + ) |
| 230 | + } |
| 231 | + if (echartsOption.series && echartsOption.series[1] && echartsOption.series[1]['data']) { |
| 232 | + echartsOption.series[1]['data'] = businessSummaryByDate.map( |
| 233 | + (s: CrmStatisticsBusinessInversionRateSummaryByDateRespVO) => s.businessWinCount |
| 234 | + ) |
| 235 | + } |
| 236 | + if (echartsOption.series && echartsOption.series[2] && echartsOption.series[2]['data']) { |
| 237 | + echartsOption.series[2]['data'] = businessSummaryByDate.map( |
| 238 | + (s: CrmStatisticsBusinessInversionRateSummaryByDateRespVO) => |
| 239 | + erpCalculatePercentage(s.businessWinCount, s.businessCount) |
| 240 | + ) |
| 241 | + } |
| 242 | + // 2.2 更新列表数据 |
| 243 | + await getList() |
| 244 | +} |
| 245 | +/** 获取商机列表 */ |
| 246 | +const getList = async () => { |
| 247 | + const data = await StatisticFunnelApi.getBusinessPageByDate(props.queryParams) |
| 248 | + list.value = data.list |
| 249 | + total.value = data.total |
| 250 | +} |
| 251 | +/** 打开客户详情 */ |
| 252 | +const { push } = useRouter() |
| 253 | +const openDetail = (id: number) => { |
| 254 | + push({ name: 'CrmBusinessDetail', params: { id } }) |
| 255 | +} |
| 256 | +
|
| 257 | +/** 打开客户详情 */ |
| 258 | +const openCustomerDetail = (id: number) => { |
| 259 | + push({ name: 'CrmCustomerDetail', params: { id } }) |
| 260 | +} |
| 261 | +
|
| 262 | +/** 获取统计数据 */ |
| 263 | +const loadData = async () => { |
| 264 | + loading.value = true |
| 265 | + try { |
| 266 | + await fetchAndFill() |
| 267 | + } finally { |
| 268 | + loading.value = false |
| 269 | + } |
| 270 | +} |
| 271 | +
|
| 272 | +defineExpose({ loadData }) |
| 273 | +
|
| 274 | +/** 初始化 */ |
| 275 | +onMounted(() => { |
| 276 | + loadData() |
| 277 | +}) |
| 278 | +</script> |
0 commit comments