feat(组件): 为KPI指标添加工具提示功能并优化业绩显示
1. 在KpiMetrics和CenterOverview组件中添加工具提示功能,显示各指标的计算说明 2. 修改GroupComparison组件中业绩数据的显示方式,移除货币格式化 3. 添加Tooltip组件用于显示指标说明 4. 优化工具提示的样式和交互效果
This commit is contained in:
@@ -17,7 +17,12 @@
|
||||
<!-- 1. 主卡片:中心总业绩 -->
|
||||
<div class="kpi-card primary">
|
||||
<div class="card-header">
|
||||
<span class="card-label">总成交单数</span>
|
||||
<span class="card-label">
|
||||
总成交单数
|
||||
<span class="info-icon"
|
||||
@mouseenter="showTooltip($event, 'totalSales')"
|
||||
@mouseleave="hideTooltip">!</span>
|
||||
</span>
|
||||
<span class="card-trend" :class="getTrendClass(kpiData.totalSales.trend)">
|
||||
{{ formatTrend(kpiData.totalSales.trend) }} vs 上期
|
||||
</span>
|
||||
@@ -34,7 +39,12 @@
|
||||
<!-- 2. 定金转化率 -->
|
||||
<div class="kpi-card">
|
||||
<div class="card-header">
|
||||
<span class="card-label">定金转化率</span>
|
||||
<span class="card-label">
|
||||
定金转化率
|
||||
<span class="info-icon"
|
||||
@mouseenter="showTooltip($event, 'depositConversion')"
|
||||
@mouseleave="hideTooltip">!</span>
|
||||
</span>
|
||||
<span class="card-trend" :class="getTrendClass(kpiData.activeTeams.trend)">
|
||||
{{ formatTrend(kpiData.activeTeams.trend, true) }} vs 上期
|
||||
</span>
|
||||
@@ -51,7 +61,12 @@
|
||||
<!-- 3. 总通话次数 -->
|
||||
<div class="kpi-card">
|
||||
<div class="card-header">
|
||||
<span class="card-label">总通话</span>
|
||||
<span class="card-label">
|
||||
总通话
|
||||
<span class="info-icon"
|
||||
@mouseenter="showTooltip($event, 'totalCalls')"
|
||||
@mouseleave="hideTooltip">!</span>
|
||||
</span>
|
||||
<span class="card-trend" :class="getTrendClass(kpiData.totalCalls.trend)">
|
||||
{{ formatTrend(kpiData.totalCalls.trend) }} vs 上期
|
||||
</span>
|
||||
@@ -68,7 +83,12 @@
|
||||
<!-- 4. 新增客户 -->
|
||||
<div class="kpi-card">
|
||||
<div class="card-header">
|
||||
<span class="card-label">新增客户</span>
|
||||
<span class="card-label">
|
||||
新增客户
|
||||
<span class="info-icon"
|
||||
@mouseenter="showTooltip($event, 'newCustomers')"
|
||||
@mouseleave="hideTooltip">!</span>
|
||||
</span>
|
||||
<span class="card-trend" :class="getTrendClass(kpiData.newCustomers.trend)">
|
||||
{{ formatTrend(kpiData.newCustomers.trend) }} vs 上期
|
||||
</span>
|
||||
@@ -85,7 +105,12 @@
|
||||
<!-- 5. 中心转化率 -->
|
||||
<div class="kpi-card">
|
||||
<div class="card-header">
|
||||
<span class="card-label">转化率</span>
|
||||
<span class="card-label">
|
||||
转化率
|
||||
<span class="info-icon"
|
||||
@mouseenter="showTooltip($event, 'conversionRate')"
|
||||
@mouseleave="hideTooltip">!</span>
|
||||
</span>
|
||||
<span class="card-trend" :class="getTrendClass(kpiData.conversionRate.trend)">
|
||||
{{ formatTrend(kpiData.conversionRate.trend, true) }} vs 上期
|
||||
</span>
|
||||
@@ -96,11 +121,21 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Tooltip组件 -->
|
||||
<Tooltip
|
||||
:visible="tooltip.visible"
|
||||
:x="tooltip.x"
|
||||
:y="tooltip.y"
|
||||
:title="tooltip.title"
|
||||
:description="tooltip.description"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, watch } from 'vue';
|
||||
import { ref, computed, watch, reactive } from 'vue';
|
||||
import Tooltip from '@/components/Tooltip.vue';
|
||||
|
||||
// 定义props
|
||||
const props = defineProps({
|
||||
@@ -117,6 +152,54 @@ const props = defineProps({
|
||||
const isLoading = ref(false);
|
||||
const error = ref(null);
|
||||
|
||||
// Tooltip状态管理
|
||||
const tooltip = reactive({
|
||||
visible: false,
|
||||
x: 0,
|
||||
y: 0,
|
||||
title: '',
|
||||
description: ''
|
||||
});
|
||||
|
||||
// 指标描述
|
||||
const metricDescriptions = {
|
||||
totalSales: {
|
||||
title: '总成交单数计算方式',
|
||||
description: '统计公司在选定时间范围内所有已完成的成交订单总数,包括各个中心、各个团队的成交业绩汇总。'
|
||||
},
|
||||
depositConversion: {
|
||||
title: '定金转化率计算方式',
|
||||
description: '定金转化率 = (支付定金客户数 / 意向客户总数) × 100%,反映从意向客户到付费客户的转化效果。'
|
||||
},
|
||||
totalCalls: {
|
||||
title: '总通话次数计算方式',
|
||||
description: '统计公司所有销售人员在选定时间范围内的外呼和接听通话总次数,包括有效通话和无效通话。'
|
||||
},
|
||||
newCustomers: {
|
||||
title: '新增客户计算方式',
|
||||
description: '统计在选定时间范围内新建档的客户数量,不包括重复录入的客户,按首次录入时间计算。'
|
||||
},
|
||||
conversionRate: {
|
||||
title: '中心转化率计算方式',
|
||||
description: '中心转化率 = (成交客户数 / 总客户数) × 100%,反映整体销售转化效果和业务质量。'
|
||||
}
|
||||
};
|
||||
|
||||
// 显示tooltip
|
||||
function showTooltip(event, metricType) {
|
||||
const rect = event.target.getBoundingClientRect();
|
||||
tooltip.visible = true;
|
||||
tooltip.x = rect.left + rect.width / 2;
|
||||
tooltip.y = rect.top - 10;
|
||||
tooltip.title = metricDescriptions[metricType].title;
|
||||
tooltip.description = metricDescriptions[metricType].description;
|
||||
}
|
||||
|
||||
// 隐藏tooltip
|
||||
function hideTooltip() {
|
||||
tooltip.visible = false;
|
||||
}
|
||||
|
||||
// 计算属性:将API数据转换为组件需要的格式
|
||||
const kpiData = computed(() => {
|
||||
const data = props.kpiData;
|
||||
@@ -355,4 +438,39 @@ function formatTrend(trend, isPercentagePoint = false) {
|
||||
font-size: 40px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 感叹号图标样式 */
|
||||
.info-icon {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
color: #fff;
|
||||
border-radius: 50%;
|
||||
font-size: 10px;
|
||||
font-weight: bold;
|
||||
margin-left: 6px;
|
||||
cursor: pointer;
|
||||
opacity: 0.7;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.info-icon:hover {
|
||||
opacity: 1;
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
/* 非主卡片中的图标样式 */
|
||||
.kpi-card:not(.primary) .info-icon {
|
||||
background: rgba(0, 0, 0, 0.1);
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.kpi-card:not(.primary) .info-icon:hover {
|
||||
background: rgba(0, 0, 0, 0.15);
|
||||
color: #333;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user