feat(销售管理): 实现团队业绩排名和客户问题统计功能

- 添加团队业绩排名和客户迫切问题API接口
- 重构ProblemRanking组件以使用真实API数据
- 修改GroupComparison组件以支持团队排名数据展示
- 优化样式和移除调试日志
- 添加数据默认值处理防止渲染错误
This commit is contained in:
2025-08-12 22:00:32 +08:00
parent c48f39fb5e
commit 3a38dba08a
7 changed files with 187 additions and 40 deletions

View File

@@ -26,35 +26,47 @@
</template>
<script setup>
import { reactive, computed } from 'vue';
import { computed } from 'vue';
// 问题排行榜数据
const problemData = reactive([
{ value: 180, name: '学习成绩提升' },
{ value: 150, name: '学习习惯培养' },
{ value: 120, name: '兴趣爱好发展' },
{ value: 100, name: '心理健康问题' },
{ value: 80, name: '升学规划' },
{ value: 70, name: '亲子关系改善' }
]);
// 接收父组件传递的数据
const props = defineProps({
problemRanking: {
type: Object,
default: () => ({})
}
});
// 将API数据转换为组件需要的格式
const problemData = computed(() => {
const urgentIssues = props.problemRanking.urgent_issue_consultations || {};
return Object.entries(urgentIssues).map(([name, value]) => ({
name,
value
}));
});
// 计算属性
const sortedProblemData = computed(() => {
return [...problemData].sort((a, b) => b.value - a.value);
return [...problemData.value].sort((a, b) => b.value - a.value);
});
const totalProblemCount = computed(() => {
return problemData.reduce((sum, item) => sum + item.value, 0);
return problemData.value.reduce((sum, item) => sum + item.value, 0);
});
// 排行榜相关方法
const getPercentage = (value) => ((value / totalProblemCount.value) * 100).toFixed(1);
const getPercentage = (value) => {
if (totalProblemCount.value === 0) return '0.0';
return ((value / totalProblemCount.value) * 100).toFixed(1);
};
const getRankingClass = (index) => ({
'rank-first': index === 0,
'rank-second': index === 1,
'rank-third': index === 2,
'rank-other': index > 2
});
const getRankBadgeClass = (index) => ({
'badge-gold': index === 0,
'badge-silver': index === 1,