2024-03-01 00:10:38 +08:00
|
|
|
|
<!-- 成交周期分析 -->
|
|
|
|
|
<template>
|
|
|
|
|
<!-- Echarts图 -->
|
|
|
|
|
<el-card shadow="never">
|
|
|
|
|
<el-skeleton :loading="loading" animated>
|
|
|
|
|
<Echart :height="500" :options="echartsOption" />
|
|
|
|
|
</el-skeleton>
|
|
|
|
|
</el-card>
|
|
|
|
|
|
|
|
|
|
<!-- 统计列表 -->
|
|
|
|
|
<el-card shadow="never" class="mt-16px">
|
|
|
|
|
<el-table v-loading="loading" :data="list">
|
|
|
|
|
<el-table-column label="序号" align="center" type="index" width="80" />
|
2024-03-04 23:51:42 +08:00
|
|
|
|
<el-table-column label="日期" align="center" prop="ownerUserName" min-width="200" />
|
|
|
|
|
<el-table-column
|
|
|
|
|
label="成交周期(天)"
|
|
|
|
|
align="center"
|
|
|
|
|
prop="customerDealCycle"
|
|
|
|
|
min-width="200"
|
|
|
|
|
/>
|
|
|
|
|
<el-table-column label="成交客户数" align="center" prop="customerDealCount" min-width="200" />
|
2024-03-01 00:10:38 +08:00
|
|
|
|
</el-table>
|
|
|
|
|
</el-card>
|
|
|
|
|
</template>
|
|
|
|
|
<script setup lang="ts">
|
2024-03-04 23:51:42 +08:00
|
|
|
|
import {
|
|
|
|
|
StatisticsCustomerApi,
|
|
|
|
|
CrmStatisticsCustomerDealCycleByDateRespVO,
|
|
|
|
|
CrmStatisticsCustomerSummaryByDateRespVO,
|
|
|
|
|
} from '@/api/crm/statistics/customer'
|
2024-03-01 00:10:38 +08:00
|
|
|
|
import { EChartsOption } from 'echarts'
|
|
|
|
|
|
2024-03-04 23:51:42 +08:00
|
|
|
|
defineOptions({ name: 'CustomerDealCycle' })
|
2024-04-06 15:38:04 +08:00
|
|
|
|
|
2024-03-01 00:10:38 +08:00
|
|
|
|
const props = defineProps<{ queryParams: any }>() // 搜索参数
|
|
|
|
|
|
|
|
|
|
const loading = ref(false) // 加载中
|
2024-03-04 23:51:42 +08:00
|
|
|
|
const list = ref<CrmStatisticsCustomerDealCycleByDateRespVO[]>([]) // 列表的数据
|
2024-03-01 00:10:38 +08:00
|
|
|
|
|
|
|
|
|
/** 柱状图配置:纵向 */
|
|
|
|
|
const echartsOption = reactive<EChartsOption>({
|
|
|
|
|
grid: {
|
|
|
|
|
left: 20,
|
2024-04-06 15:38:04 +08:00
|
|
|
|
right: 40, // 让X轴右侧显示完整
|
2024-03-01 00:10:38 +08:00
|
|
|
|
bottom: 20,
|
|
|
|
|
containLabel: true
|
|
|
|
|
},
|
2024-03-04 23:51:42 +08:00
|
|
|
|
legend: {},
|
2024-03-01 00:10:38 +08:00
|
|
|
|
series: [
|
|
|
|
|
{
|
|
|
|
|
name: '成交周期(天)',
|
|
|
|
|
type: 'bar',
|
2024-04-06 15:38:04 +08:00
|
|
|
|
data: [],
|
|
|
|
|
yAxisIndex: 0,
|
2024-03-01 00:10:38 +08:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '成交客户数',
|
|
|
|
|
type: 'bar',
|
2024-04-06 15:38:04 +08:00
|
|
|
|
data: [],
|
|
|
|
|
yAxisIndex: 1,
|
2024-03-04 23:51:42 +08:00
|
|
|
|
}
|
2024-03-01 00:10:38 +08:00
|
|
|
|
],
|
|
|
|
|
toolbox: {
|
|
|
|
|
feature: {
|
|
|
|
|
dataZoom: {
|
|
|
|
|
xAxisIndex: false // 数据区域缩放:Y 轴不缩放
|
|
|
|
|
},
|
|
|
|
|
brush: {
|
|
|
|
|
type: ['lineX', 'clear'] // 区域缩放按钮、还原按钮
|
|
|
|
|
},
|
|
|
|
|
saveAsImage: { show: true, name: '成交周期分析' } // 保存为图片
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
tooltip: {
|
|
|
|
|
trigger: 'axis',
|
|
|
|
|
axisPointer: {
|
|
|
|
|
type: 'shadow'
|
|
|
|
|
}
|
|
|
|
|
},
|
2024-04-06 15:38:04 +08:00
|
|
|
|
yAxis: [
|
|
|
|
|
{
|
|
|
|
|
type: 'value',
|
|
|
|
|
name: '成交周期(天)',
|
|
|
|
|
min: 0,
|
|
|
|
|
minInterval: 1, // 显示整数刻度
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'value',
|
|
|
|
|
name: '成交客户数',
|
|
|
|
|
min: 0,
|
|
|
|
|
minInterval: 1, // 显示整数刻度
|
|
|
|
|
splitLine: {
|
|
|
|
|
lineStyle: {
|
|
|
|
|
type: 'dotted', // 右侧网格线虚化, 减少混乱
|
|
|
|
|
opacity: 0.7,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
],
|
2024-03-01 00:10:38 +08:00
|
|
|
|
xAxis: {
|
|
|
|
|
type: 'category',
|
|
|
|
|
name: '日期',
|
|
|
|
|
data: []
|
|
|
|
|
}
|
|
|
|
|
}) as EChartsOption
|
|
|
|
|
|
2024-04-06 15:38:04 +08:00
|
|
|
|
/** 获取数据并填充图表 */
|
|
|
|
|
const fetchAndFill = async () => {
|
2024-03-01 00:10:38 +08:00
|
|
|
|
// 1. 加载统计数据
|
2024-03-04 23:51:42 +08:00
|
|
|
|
const customerDealCycleByDate = await StatisticsCustomerApi.getCustomerDealCycleByDate(
|
|
|
|
|
props.queryParams
|
|
|
|
|
)
|
|
|
|
|
const customerSummaryByDate = await StatisticsCustomerApi.getCustomerSummaryByDate(
|
|
|
|
|
props.queryParams
|
|
|
|
|
)
|
|
|
|
|
const customerDealCycleByUser = await StatisticsCustomerApi.getCustomerDealCycleByUser(
|
|
|
|
|
props.queryParams
|
|
|
|
|
)
|
2024-03-01 00:10:38 +08:00
|
|
|
|
// 2.1 更新 Echarts 数据
|
|
|
|
|
if (echartsOption.xAxis && echartsOption.xAxis['data']) {
|
2024-03-04 23:51:42 +08:00
|
|
|
|
echartsOption.xAxis['data'] = customerDealCycleByDate.map(
|
|
|
|
|
(s: CrmStatisticsCustomerDealCycleByDateRespVO) => s.time
|
|
|
|
|
)
|
2024-03-01 00:10:38 +08:00
|
|
|
|
}
|
|
|
|
|
if (echartsOption.series && echartsOption.series[0] && echartsOption.series[0]['data']) {
|
2024-03-04 23:51:42 +08:00
|
|
|
|
echartsOption.series[0]['data'] = customerDealCycleByDate.map(
|
|
|
|
|
(s: CrmStatisticsCustomerDealCycleByDateRespVO) => s.customerDealCycle
|
|
|
|
|
)
|
2024-03-01 00:10:38 +08:00
|
|
|
|
}
|
|
|
|
|
if (echartsOption.series && echartsOption.series[1] && echartsOption.series[1]['data']) {
|
2024-03-04 23:51:42 +08:00
|
|
|
|
echartsOption.series[1]['data'] = customerSummaryByDate.map(
|
|
|
|
|
(s: CrmStatisticsCustomerSummaryByDateRespVO) => s.customerDealCount
|
|
|
|
|
)
|
2024-03-01 00:10:38 +08:00
|
|
|
|
}
|
|
|
|
|
// 2.2 更新列表数据
|
2024-03-04 23:51:42 +08:00
|
|
|
|
list.value = customerDealCycleByUser
|
2024-04-06 15:38:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取统计数据 */
|
|
|
|
|
const loadData = async () => {
|
|
|
|
|
loading.value = true
|
|
|
|
|
try {
|
|
|
|
|
fetchAndFill()
|
|
|
|
|
}
|
|
|
|
|
finally {
|
|
|
|
|
loading.value = false
|
|
|
|
|
}
|
2024-03-01 00:10:38 +08:00
|
|
|
|
}
|
|
|
|
|
defineExpose({ loadData })
|
|
|
|
|
|
|
|
|
|
/** 初始化 */
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
loadData()
|
|
|
|
|
})
|
|
|
|
|
</script>
|