feat(统计模式): 添加按月/按期统计切换功能并优化客户阶段显示
- 在CenterOverview组件中添加统计模式切换按钮 - 实现统计模式切换逻辑并触发数据重新加载 - 优化SalesTimelineWithTaskList的客户阶段显示和计算逻辑 - 更新API调用参数以支持不同统计模式 - 调整样式和布局以适应新功能
This commit is contained in:
@@ -5,7 +5,7 @@ import { useUserStore } from '@/stores/user'
|
|||||||
|
|
||||||
// 创建axios实例
|
// 创建axios实例
|
||||||
const service = axios.create({
|
const service = axios.create({
|
||||||
baseURL: 'http://192.168.15.53:8890' || '', // API基础路径,支持完整URL
|
baseURL: 'http://192.168.15.121:8890' || '', // API基础路径,支持完整URL
|
||||||
timeout: 100000, // 请求超时时间
|
timeout: 100000, // 请求超时时间
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json;charset=UTF-8'
|
'Content-Type': 'application/json;charset=UTF-8'
|
||||||
|
|||||||
@@ -165,23 +165,23 @@ const tooltip = reactive({
|
|||||||
const metricDescriptions = {
|
const metricDescriptions = {
|
||||||
totalCalls: {
|
totalCalls: {
|
||||||
title: '总通话次数计算方式',
|
title: '总通话次数计算方式',
|
||||||
description: '统计该成员在选定时间范围内的所有外呼和接听通话的总次数,包括有效通话和无效通话。'
|
description: '统计在选定时间范围内的所有外呼和接听通话的总次数,包括有效通话和无效通话。'
|
||||||
},
|
},
|
||||||
callTime: {
|
callTime: {
|
||||||
title: '通话时长计算方式',
|
title: '通话时长计算方式',
|
||||||
description: '累计该成员所有有效通话的时长,以小时为单位显示,精确到小数点后一位。'
|
description: '累计所有有效通话的时长,以小时为单位显示,精确到小数点后一位。'
|
||||||
},
|
},
|
||||||
newClients: {
|
newClients: {
|
||||||
title: '新增客户计算方式',
|
title: '新增客户计算方式',
|
||||||
description: '统计该成员在选定时间范围内新建档的客户数量,不包括重复录入的客户。'
|
description: '在选定时间范围内新建档的客户数量,不包括重复录入的客户。'
|
||||||
},
|
},
|
||||||
deals: {
|
deals: {
|
||||||
title: '成交单数计算方式',
|
title: '成交单数计算方式',
|
||||||
description: '统计该成员在选定时间范围内成功签约的订单数量,包括全款和定金订单。'
|
description: '在选定时间范围内成功签约的订单数量,包括全款和定金订单。'
|
||||||
},
|
},
|
||||||
conversionRate: {
|
conversionRate: {
|
||||||
title: '转化率计算方式',
|
title: '转化率计算方式',
|
||||||
description: '成交单数 ÷ 新增客户数 × 100%,反映该成员将潜在客户转化为成交客户的能力。'
|
description: '成交单数 ÷ 新增客户数 × 100%'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,9 +25,12 @@
|
|||||||
<h3 class="stage-title">{{ stage.displayName || stage.name }}</h3>
|
<h3 class="stage-title">{{ stage.displayName || stage.name }}</h3>
|
||||||
<div class="stage-stats">
|
<div class="stage-stats">
|
||||||
<span class="stage-count">{{ stage.name === '全部' ? customersCount : stage.count }}</span>
|
<span class="stage-count">{{ stage.name === '全部' ? customersCount : stage.count }}</span>
|
||||||
<span class="stage-label">位客户</span>
|
<span class="stage-label">位</span>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="stage.name !== '全部'" class="stage-percentage">{{ getPercentage(stage.count) }}%</div>
|
<div class="stage-unName">
|
||||||
|
<span class="stage-unName" v-if="stage.unName">{{ stage.unName }}</span>
|
||||||
|
</div>
|
||||||
|
<div v-if="stage.name !== '全部'" class="stage-percentage">{{ getPercentage(stage.count, stage.id, stage.name) }}%</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -217,6 +220,50 @@ const getStageCount = (stageType) => {
|
|||||||
return props.payMoneyCustomersCount || (props.payMoneyCustomersList?.length || 0);
|
return props.payMoneyCustomersCount || (props.payMoneyCustomersList?.length || 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 待填表单阶段:统计customer_occupation或customer_child_education字段为'未知'的客户数量
|
||||||
|
if (stageType === '待填表单') {
|
||||||
|
if (props.customersList?.length) {
|
||||||
|
return props.customersList.filter(customer => {
|
||||||
|
return (customer.customer_occupation === '未知' || !customer.customer_occupation) ||
|
||||||
|
(customer.customer_child_education === '未知' || !customer.customer_child_education);
|
||||||
|
}).length;
|
||||||
|
}
|
||||||
|
return props.data[stageType] || 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 待到课阶段:统计没有到课数据的客户数量
|
||||||
|
if (stageType === '待到课') {
|
||||||
|
if (props.customersList?.length) {
|
||||||
|
return props.customersList.filter(customer => {
|
||||||
|
// 根据getAttendedLessons函数的逻辑判断是否为'未到课'
|
||||||
|
const classNum = customer.class_num;
|
||||||
|
const classSituation = customer.class_situation;
|
||||||
|
|
||||||
|
// 优先检查class_num字段
|
||||||
|
if (classNum && Array.isArray(classNum) && classNum.length > 0) {
|
||||||
|
return false; // 有class_num数据,不是待到课
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查class_situation字段
|
||||||
|
if (!classSituation) return true; // 没有class_situation,是待到课
|
||||||
|
|
||||||
|
if (Array.isArray(classSituation)) {
|
||||||
|
return classSituation.length === 0; // 空数组,是待到课
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof classSituation === 'object') {
|
||||||
|
const lessonNumbers = Object.keys(classSituation)
|
||||||
|
.map(key => parseInt(key))
|
||||||
|
.filter(num => !isNaN(num));
|
||||||
|
return lessonNumbers.length === 0; // 没有有效的课程数据,是待到课
|
||||||
|
}
|
||||||
|
|
||||||
|
return true; // 其他情况默认为待到课
|
||||||
|
}).length;
|
||||||
|
}
|
||||||
|
return props.data[stageType] || 0;
|
||||||
|
}
|
||||||
|
|
||||||
// 课1-4阶段从courseCustomers获取数量
|
// 课1-4阶段从courseCustomers获取数量
|
||||||
if (stageType === '课1-4' && props.courseCustomers?.['课1-4']) {
|
if (stageType === '课1-4' && props.courseCustomers?.['课1-4']) {
|
||||||
return props.courseCustomers['课1-4'].length;
|
return props.courseCustomers['课1-4'].length;
|
||||||
@@ -258,11 +305,11 @@ const stages = computed(() => {
|
|||||||
|
|
||||||
const stageList = [
|
const stageList = [
|
||||||
{ id: 0, name: '全部', displayName: '全部', count: totalCount, color: '#f3f4f6' },
|
{ id: 0, name: '全部', displayName: '全部', count: totalCount, color: '#f3f4f6' },
|
||||||
{ id: 1, name: '待加微', displayName: '待加微', count: getStageCount('待加微'), color: '#e3f2fd' },
|
{ id: 1, name: '待加微', displayName: '待加微', count: getStageCount('待加微'), color: '#e3f2fd' ,unName:'已加微'},
|
||||||
{ id: 2, name: '待填表单', displayName: '待填表单', count: getStageCount('待填表单'), color: '#90caf9' },
|
{ id: 2, name: '待填表单', displayName: '待填表单', count: getStageCount('待填表单'), color: '#90caf9' ,unName:'已填表单'},
|
||||||
{ id: 3, name: '待入群', displayName: '待入群', count: getStageCount('待入群'), color: '#bbdefb' },
|
{ id: 3, name: '待入群', displayName: '待入群', count: getStageCount('待入群'), color: '#bbdefb' ,unName:'已入群'},
|
||||||
{ id: 4, name: '待联系', displayName: '待联系', count: getStageCount('待联系'), color: '#bbdefb' },
|
{ id: 4, name: '待联系', displayName: '待联系', count: getStageCount('待联系'), color: '#bbdefb' ,unName:'已联系'},
|
||||||
{ id: 5, name: '待到课', displayName: '待到课', count: getStageCount('待到课'), color: '#bbdefb' },
|
{ id: 5, name: '待到课', displayName: '待到课', count: getStageCount('待到课'), color: '#bbdefb' ,unName:'已到课'},
|
||||||
{ id: 6, name: '课1', displayName: '课1', count: getStageCount('课1'), color: '#81c784' },
|
{ id: 6, name: '课1', displayName: '课1', count: getStageCount('课1'), color: '#81c784' },
|
||||||
{ id: 7, name: '课2', displayName: '课2', count: getStageCount('课2'), color: '#64b5f6' },
|
{ id: 7, name: '课2', displayName: '课2', count: getStageCount('课2'), color: '#64b5f6' },
|
||||||
{ id: 8, name: '课3', displayName: '课3', count: getStageCount('课3'), color: '#ffb74d' },
|
{ id: 8, name: '课3', displayName: '课3', count: getStageCount('课3'), color: '#ffb74d' },
|
||||||
@@ -277,9 +324,31 @@ const stages = computed(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
const getPercentage = (count) => {
|
const getPercentage = (count, stageId, stageName) => {
|
||||||
if (totalCustomers.value === 0) return 0;
|
if (totalCustomers.value === 0) return 0;
|
||||||
|
|
||||||
|
// 待填表单阶段特殊计算:(总数-有数据人数)/总数
|
||||||
|
if (stageName === '待填表单') {
|
||||||
|
return Math.round((totalCustomers.value - count) / totalCustomers.value * 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 待到课阶段特殊计算:(总数-有到课数据人数)/总数
|
||||||
|
if (stageName === '待到课') {
|
||||||
|
return Math.round((totalCustomers.value - count) / totalCustomers.value * 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 阶段1-5使用现在的算法(转化率)
|
||||||
|
if (stageId >= 1 && stageId <= 5) {
|
||||||
|
return Math.round((totalCustomers.value - count) / totalCustomers.value * 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 阶段5-13使用直接数量除以总数
|
||||||
|
if (stageId >5 && stageId <= 13) {
|
||||||
return Math.round((count / totalCustomers.value) * 100);
|
return Math.round((count / totalCustomers.value) * 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 其他阶段保持原有逻辑
|
||||||
|
return Math.round((totalCustomers.value - count) / totalCustomers.value * 100);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -328,6 +397,40 @@ const selectStage = (stageName) => {
|
|||||||
if (props.courseCustomers?.['课1-4']) {
|
if (props.courseCustomers?.['课1-4']) {
|
||||||
filteredCustomers = props.courseCustomers['课1-4'].filter(customer => customer.type === stageName);
|
filteredCustomers = props.courseCustomers['课1-4'].filter(customer => customer.type === stageName);
|
||||||
}
|
}
|
||||||
|
} else if (stageName === '待填表单') {
|
||||||
|
// 待填表单阶段:筛选customer_occupation或customer_child_education字段为'未知'的客户
|
||||||
|
filteredCustomers = props.customersList.filter(customer => {
|
||||||
|
return (customer.customer_occupation === '未知' || !customer.customer_occupation) ||
|
||||||
|
(customer.customer_child_education === '未知' || !customer.customer_child_education);
|
||||||
|
});
|
||||||
|
} else if (stageName === '待到课') {
|
||||||
|
// 待到课阶段:筛选没有到课数据的客户
|
||||||
|
filteredCustomers = props.customersList.filter(customer => {
|
||||||
|
// 根据getAttendedLessons函数的逻辑判断是否为'未到课'
|
||||||
|
const classNum = customer.class_num;
|
||||||
|
const classSituation = customer.class_situation;
|
||||||
|
|
||||||
|
// 优先检查class_num字段
|
||||||
|
if (classNum && Array.isArray(classNum) && classNum.length > 0) {
|
||||||
|
return false; // 有class_num数据,不是待到课
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查class_situation字段
|
||||||
|
if (!classSituation) return true; // 没有class_situation,是待到课
|
||||||
|
|
||||||
|
if (Array.isArray(classSituation)) {
|
||||||
|
return classSituation.length === 0; // 空数组,是待到课
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof classSituation === 'object') {
|
||||||
|
const lessonNumbers = Object.keys(classSituation)
|
||||||
|
.map(key => parseInt(key))
|
||||||
|
.filter(num => !isNaN(num));
|
||||||
|
return lessonNumbers.length === 0; // 没有有效的课程数据,是待到课
|
||||||
|
}
|
||||||
|
|
||||||
|
return true; // 其他情况默认为待到课
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
// 前6个阶段从customersList中筛选
|
// 前6个阶段从customersList中筛选
|
||||||
filteredCustomers = props.customersList.filter(customer => customer.type === stageName);
|
filteredCustomers = props.customersList.filter(customer => customer.type === stageName);
|
||||||
@@ -650,8 +753,9 @@ $indigo: #4f46e5;
|
|||||||
|
|
||||||
.stage-content {
|
.stage-content {
|
||||||
.stage-title {
|
.stage-title {
|
||||||
|
font-size: 1rem;
|
||||||
color: $slate-800;
|
color: $slate-800;
|
||||||
font-weight: 600;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
.stage-count {
|
.stage-count {
|
||||||
|
|||||||
@@ -1,14 +1,28 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="center-overview">
|
<div class="center-overview">
|
||||||
|
<div class="overview-header">
|
||||||
<h2>中心整体概览</h2>
|
<h2>中心整体概览</h2>
|
||||||
|
<div class="stats-toggle">
|
||||||
|
<button
|
||||||
|
:class="['toggle-btn', { active: statsMode === 'monthly' }]"
|
||||||
|
@click="switchStatsMode('monthly')"
|
||||||
|
>
|
||||||
|
按月统计
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
:class="['toggle-btn', { active: statsMode === 'period' }]"
|
||||||
|
@click="switchStatsMode('period')"
|
||||||
|
>
|
||||||
|
按期统计
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="overview-grid">
|
<div class="overview-grid">
|
||||||
<div class="overview-card primary">
|
<div class="overview-card primary">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<span class="card-title">
|
<span class="card-title">
|
||||||
中心总业绩
|
中心总业绩
|
||||||
<i
|
<i @mouseenter="showTooltip($event, 'centerPerformance')" @mouseleave="hideTooltip">ⓘ</i>
|
||||||
@mouseenter="showTooltip($event, 'centerPerformance')"
|
|
||||||
@mouseleave="hideTooltip">ⓘ</i>
|
|
||||||
</span>
|
</span>
|
||||||
<span class="card-trend positive">{{ props.overallData.CenterPerformance?.center_monthly_vs_previous_deals }} vs 上期</span>
|
<span class="card-trend positive">{{ props.overallData.CenterPerformance?.center_monthly_vs_previous_deals }} vs 上期</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -100,9 +114,24 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { reactive } from 'vue'
|
import { reactive, ref } from 'vue'
|
||||||
import Tooltip from '@/components/Tooltip.vue'
|
import Tooltip from '@/components/Tooltip.vue'
|
||||||
|
|
||||||
|
// 统计模式状态
|
||||||
|
const statsMode = ref('monthly') // 默认按月统计
|
||||||
|
|
||||||
|
// 定义emit事件
|
||||||
|
const emit = defineEmits(['update-check-type'])
|
||||||
|
|
||||||
|
// 切换统计模式
|
||||||
|
const switchStatsMode = (mode) => {
|
||||||
|
statsMode.value = mode
|
||||||
|
// 向父组件发送事件,修改CheckType的值
|
||||||
|
const checkTypeValue = mode === 'monthly' ? 'month' : 'period'
|
||||||
|
emit('update-check-type', checkTypeValue)
|
||||||
|
console.log('切换统计模式:', mode, '发送CheckType值:', checkTypeValue)
|
||||||
|
}
|
||||||
|
|
||||||
// 中心整体概览组件
|
// 中心整体概览组件
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
overallData: {
|
overallData: {
|
||||||
@@ -352,8 +381,69 @@ const hideTooltip = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 切换按钮样式
|
||||||
|
.overview-header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
margin: 0;
|
||||||
|
color: #1e293b;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stats-toggle {
|
||||||
|
display: flex;
|
||||||
|
background: #f1f5f9;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 4px;
|
||||||
|
gap: 2px;
|
||||||
|
|
||||||
|
.toggle-btn {
|
||||||
|
padding: 8px 16px;
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
color: #64748b;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
font-weight: 500;
|
||||||
|
border-radius: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: #e2e8f0;
|
||||||
|
color: #475569;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
background: #ffffff;
|
||||||
|
color: #0f172a;
|
||||||
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 移动端适配
|
// 移动端适配
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
|
.overview-header {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 1rem;
|
||||||
|
|
||||||
|
.stats-toggle {
|
||||||
|
align-self: stretch;
|
||||||
|
|
||||||
|
.toggle-btn {
|
||||||
|
flex: 1;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.center-overview {
|
.center-overview {
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
<!-- Top Section - Center Overview and Action Items -->
|
<!-- Top Section - Center Overview and Action Items -->
|
||||||
<div class="top-section">
|
<div class="top-section">
|
||||||
<!-- Center Performance Overview -->
|
<!-- Center Performance Overview -->
|
||||||
<CenterOverview :overall-data="overallCenterPerformance" />
|
<CenterOverview :overall-data="overallCenterPerformance" @update-check-type="updateCheckType" />
|
||||||
|
|
||||||
<!-- Action Items (Compact) -->
|
<!-- Action Items (Compact) -->
|
||||||
<div class="action-items-compact">
|
<div class="action-items-compact">
|
||||||
@@ -181,6 +181,7 @@
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
// 用户store实例
|
// 用户store实例
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
const CheckType = ref('month')
|
||||||
// 营期调控逻辑
|
// 营期调控逻辑
|
||||||
// This would ideally come from a prop or API call based on the logged-in user
|
// This would ideally come from a prop or API call based on the logged-in user
|
||||||
const centerData = ref({
|
const centerData = ref({
|
||||||
@@ -417,7 +418,10 @@ const centerData = ref({
|
|||||||
const params = getRequestParams()
|
const params = getRequestParams()
|
||||||
const hasParams = params.user_name
|
const hasParams = params.user_name
|
||||||
try {
|
try {
|
||||||
const res = await getOverallCenterPerformance(hasParams ? params : undefined)
|
const res = await getOverallCenterPerformance(hasParams ? {
|
||||||
|
...params,
|
||||||
|
check_type: CheckType.value
|
||||||
|
} : {check_type: CheckType.value})
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
overallCenterPerformance.value.CenterPerformance = res.data
|
overallCenterPerformance.value.CenterPerformance = res.data
|
||||||
}
|
}
|
||||||
@@ -430,7 +434,10 @@ const centerData = ref({
|
|||||||
const params = getRequestParams()
|
const params = getRequestParams()
|
||||||
const hasParams = params.user_name
|
const hasParams = params.user_name
|
||||||
try {
|
try {
|
||||||
const res = await getTotalGroupCount(hasParams ? params : undefined)
|
const res = await getTotalGroupCount(hasParams ? {
|
||||||
|
...params,
|
||||||
|
check_type: CheckType.value
|
||||||
|
} : {check_type: CheckType.value})
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
overallCenterPerformance.value.TotalGroupCount = res.data
|
overallCenterPerformance.value.TotalGroupCount = res.data
|
||||||
}
|
}
|
||||||
@@ -443,7 +450,10 @@ const centerData = ref({
|
|||||||
const params = getRequestParams()
|
const params = getRequestParams()
|
||||||
const hasParams = params.user_name
|
const hasParams = params.user_name
|
||||||
try {
|
try {
|
||||||
const res = await getCenterConversionRate(hasParams ? params : undefined)
|
const res = await getCenterConversionRate(hasParams ? {
|
||||||
|
...params,
|
||||||
|
check_type: CheckType.value
|
||||||
|
} : {check_type: CheckType.value})
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
overallCenterPerformance.value.CenterConversionRate = res.data
|
overallCenterPerformance.value.CenterConversionRate = res.data
|
||||||
}
|
}
|
||||||
@@ -456,7 +466,10 @@ const centerData = ref({
|
|||||||
const params = getRequestParams()
|
const params = getRequestParams()
|
||||||
const hasParams = params.user_name
|
const hasParams = params.user_name
|
||||||
try {
|
try {
|
||||||
const res = await getTotalCallCount(hasParams ? params : undefined)
|
const res = await getTotalCallCount(hasParams ? {
|
||||||
|
...params,
|
||||||
|
check_type: CheckType.value
|
||||||
|
} : {check_type: CheckType.value})
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
overallCenterPerformance.value.TotalCallCount = res.data
|
overallCenterPerformance.value.TotalCallCount = res.data
|
||||||
}
|
}
|
||||||
@@ -469,7 +482,10 @@ const centerData = ref({
|
|||||||
const params = getRequestParams()
|
const params = getRequestParams()
|
||||||
const hasParams = params.user_name
|
const hasParams = params.user_name
|
||||||
try {
|
try {
|
||||||
const res = await getNewCustomer(hasParams ? params : undefined)
|
const res = await getNewCustomer(hasParams ? {
|
||||||
|
...params,
|
||||||
|
check_type: CheckType.value
|
||||||
|
} : {check_type: CheckType.value})
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
overallCenterPerformance.value.NewCustomer = res.data
|
overallCenterPerformance.value.NewCustomer = res.data
|
||||||
}
|
}
|
||||||
@@ -482,7 +498,10 @@ const centerData = ref({
|
|||||||
const params = getRequestParams()
|
const params = getRequestParams()
|
||||||
const hasParams = params.user_name
|
const hasParams = params.user_name
|
||||||
try {
|
try {
|
||||||
const res = await getDepositConversionRate(hasParams ? params : undefined)
|
const res = await getDepositConversionRate(hasParams ? {
|
||||||
|
...params,
|
||||||
|
check_type: CheckType.value
|
||||||
|
} : {check_type: CheckType.value})
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
overallCenterPerformance.value.DepositConversionRate = res.data
|
overallCenterPerformance.value.DepositConversionRate = res.data
|
||||||
}
|
}
|
||||||
@@ -773,6 +792,27 @@ const conversionRateVsAverage = ref({})
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 更新CheckType并重新获取数据
|
||||||
|
const updateCheckType = async (newValue) => {
|
||||||
|
CheckType.value = newValue
|
||||||
|
console.log('CheckType已更新为:', newValue)
|
||||||
|
|
||||||
|
// 重新调用相关API函数
|
||||||
|
isLoading.value = true
|
||||||
|
try {
|
||||||
|
await CenterOverallCenterPerformance()
|
||||||
|
await CenterTotalGroupCount()
|
||||||
|
await CenterConversionRate()
|
||||||
|
await CenterTotalCallCount()
|
||||||
|
await CenterNewCustomer()
|
||||||
|
await CenterDepositConversionRate()
|
||||||
|
} catch (error) {
|
||||||
|
console.error('重新获取数据失败:', error)
|
||||||
|
} finally {
|
||||||
|
isLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 工具提示状态
|
// 工具提示状态
|
||||||
const tooltip = reactive({
|
const tooltip = reactive({
|
||||||
visible: false,
|
visible: false,
|
||||||
|
|||||||
@@ -1,6 +1,22 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="center-overview">
|
<div class="center-overview">
|
||||||
|
<div class="overview-header">
|
||||||
<h2>整体概览</h2>
|
<h2>整体概览</h2>
|
||||||
|
<div class="stats-toggle">
|
||||||
|
<button
|
||||||
|
:class="['toggle-btn', { active: statsMode === 'monthly' }]"
|
||||||
|
@click="switchStatsMode('monthly')"
|
||||||
|
>
|
||||||
|
按月统计
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
:class="['toggle-btn', { active: statsMode === 'period' }]"
|
||||||
|
@click="switchStatsMode('period')"
|
||||||
|
>
|
||||||
|
按期统计
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="overview-grid">
|
<div class="overview-grid">
|
||||||
<div class="overview-card primary">
|
<div class="overview-card primary">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
@@ -87,9 +103,24 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, reactive } from 'vue'
|
import { computed, reactive, ref } from 'vue'
|
||||||
import Tooltip from '@/components/Tooltip.vue'
|
import Tooltip from '@/components/Tooltip.vue'
|
||||||
|
|
||||||
|
// 统计模式状态
|
||||||
|
const statsMode = ref('monthly') // 默认按月统计
|
||||||
|
|
||||||
|
// 定义emit事件
|
||||||
|
const emit = defineEmits(['update-check-type'])
|
||||||
|
|
||||||
|
// 切换统计模式
|
||||||
|
const switchStatsMode = (mode) => {
|
||||||
|
statsMode.value = mode
|
||||||
|
// 向父组件发送事件,修改CheckType的值
|
||||||
|
const checkTypeValue = mode === 'monthly' ? 'month' : 'period'
|
||||||
|
emit('update-check-type', checkTypeValue)
|
||||||
|
console.log('切换统计模式:', mode, '发送CheckType值:', checkTypeValue)
|
||||||
|
}
|
||||||
|
|
||||||
// 中心整体概览组件
|
// 中心整体概览组件
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
overallTeamPerformance: {
|
overallTeamPerformance: {
|
||||||
@@ -193,6 +224,44 @@ const hideTooltip = () => {
|
|||||||
padding: 0.5rem;
|
padding: 0.5rem;
|
||||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
||||||
|
|
||||||
|
.overview-header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
|
||||||
|
.stats-toggle {
|
||||||
|
display: flex;
|
||||||
|
background: #f8fafc;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 4px;
|
||||||
|
gap: 2px;
|
||||||
|
|
||||||
|
.toggle-btn {
|
||||||
|
padding: 8px 16px;
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
font-weight: 500;
|
||||||
|
color: #64748b;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: #e2e8f0;
|
||||||
|
color: #475569;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
background: #3b82f6;
|
||||||
|
color: white;
|
||||||
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
font-size: 1.3rem;
|
font-size: 1.3rem;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
@@ -365,6 +434,19 @@ const hideTooltip = () => {
|
|||||||
.center-overview {
|
.center-overview {
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
|
|
||||||
|
.overview-header {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 1rem;
|
||||||
|
|
||||||
|
.stats-toggle {
|
||||||
|
.toggle-btn {
|
||||||
|
padding: 6px 12px;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.overview-grid {
|
.overview-grid {
|
||||||
grid-template-columns: repeat(2, 1fr);
|
grid-template-columns: repeat(2, 1fr);
|
||||||
gap: 0.75rem;
|
gap: 0.75rem;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
<CenterOverview
|
<CenterOverview
|
||||||
style="height: 330px;"
|
style="height: 330px;"
|
||||||
:overallTeamPerformance="overallTeamPerformance"
|
:overallTeamPerformance="overallTeamPerformance"
|
||||||
|
@update-check-type="updateCheckType"
|
||||||
/>
|
/>
|
||||||
<div class="action-items-compact">
|
<div class="action-items-compact">
|
||||||
<TeamAlerts style="height: 300px;" :abnormalData="teamAlerts" />
|
<TeamAlerts style="height: 300px;" :abnormalData="teamAlerts" />
|
||||||
@@ -175,6 +176,29 @@ const averageResponseTime = ref(15)
|
|||||||
const timeoutResponseRate = ref(5)
|
const timeoutResponseRate = ref(5)
|
||||||
const severeTimeoutRate = ref(2)
|
const severeTimeoutRate = ref(2)
|
||||||
const formCompletionRate = ref(90)
|
const formCompletionRate = ref(90)
|
||||||
|
const CheckType = ref('month')
|
||||||
|
|
||||||
|
// 更新CheckType的方法
|
||||||
|
const updateCheckType = async (newValue) => {
|
||||||
|
CheckType.value = newValue
|
||||||
|
console.log('CheckType已更新为:', newValue)
|
||||||
|
|
||||||
|
// 重新获取所有使用CheckType的数据
|
||||||
|
try {
|
||||||
|
isLoading.value = true
|
||||||
|
await fetchOverallTeamPerformance()
|
||||||
|
await fetchActiveGroups()
|
||||||
|
await fetchConversionRate()
|
||||||
|
await fetchTotalCallCount()
|
||||||
|
await fetchNewCustomers()
|
||||||
|
await fetchDepositConversions()
|
||||||
|
console.log('数据已根据新的统计模式重新加载')
|
||||||
|
} catch (error) {
|
||||||
|
console.error('重新加载数据失败:', error)
|
||||||
|
} finally {
|
||||||
|
isLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
// 路由实例
|
// 路由实例
|
||||||
@@ -216,7 +240,10 @@ async function fetchOverallTeamPerformance() {
|
|||||||
const hasParams = params.user_name
|
const hasParams = params.user_name
|
||||||
// 团队总业绩
|
// 团队总业绩
|
||||||
try {
|
try {
|
||||||
const response = await getOverallTeamPerformance(hasParams ? params : undefined)
|
const response = await getOverallTeamPerformance(hasParams ? {
|
||||||
|
...params,
|
||||||
|
check_type: CheckType.value
|
||||||
|
} : {check_type: CheckType.value})
|
||||||
overallTeamPerformance.value.totalPerformance = response.data
|
overallTeamPerformance.value.totalPerformance = response.data
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取整体概览数据失败:', error)
|
console.error('获取整体概览数据失败:', error)
|
||||||
@@ -227,7 +254,10 @@ async function fetchActiveGroups() {
|
|||||||
const params = getRequestParams()
|
const params = getRequestParams()
|
||||||
const hasParams = params.user_name
|
const hasParams = params.user_name
|
||||||
try {
|
try {
|
||||||
const response = await getTotalGroupCount(hasParams ? params : undefined)
|
const response = await getTotalGroupCount(hasParams ? {
|
||||||
|
...params,
|
||||||
|
check_type: CheckType.value
|
||||||
|
} : {check_type: CheckType.value})
|
||||||
overallTeamPerformance.value.activeGroups = response.data
|
overallTeamPerformance.value.activeGroups = response.data
|
||||||
console.log('活跃组数:', response.data)
|
console.log('活跃组数:', response.data)
|
||||||
|
|
||||||
@@ -240,7 +270,10 @@ async function fetchConversionRate() {
|
|||||||
const params = getRequestParams()
|
const params = getRequestParams()
|
||||||
const hasParams = params.user_name
|
const hasParams = params.user_name
|
||||||
try {
|
try {
|
||||||
const response = await getConversionRate(hasParams ? params : undefined)
|
const response = await getConversionRate(hasParams ? {
|
||||||
|
...params,
|
||||||
|
check_type: CheckType.value
|
||||||
|
} : {check_type: CheckType.value})
|
||||||
overallTeamPerformance.value.conversionRate = response.data
|
overallTeamPerformance.value.conversionRate = response.data
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取团队转化率失败:', error)
|
console.error('获取团队转化率失败:', error)
|
||||||
@@ -251,7 +284,10 @@ async function fetchTotalCallCount() {
|
|||||||
const params = getRequestParams()
|
const params = getRequestParams()
|
||||||
const hasParams = params.user_name
|
const hasParams = params.user_name
|
||||||
try {
|
try {
|
||||||
const response = await getTotalCallCount(hasParams ? params : undefined)
|
const response = await getTotalCallCount(hasParams ? {
|
||||||
|
...params,
|
||||||
|
check_type: CheckType.value
|
||||||
|
} : {check_type: CheckType.value})
|
||||||
overallTeamPerformance.value.totalCalls = response.data
|
overallTeamPerformance.value.totalCalls = response.data
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取通话次数失败:', error)
|
console.error('获取通话次数失败:', error)
|
||||||
@@ -262,7 +298,10 @@ async function fetchNewCustomers() {
|
|||||||
const params = getRequestParams()
|
const params = getRequestParams()
|
||||||
const hasParams = params.user_name
|
const hasParams = params.user_name
|
||||||
try {
|
try {
|
||||||
const response = await getNewCustomer(hasParams ? params : undefined)
|
const response = await getNewCustomer(hasParams ? {
|
||||||
|
...params,
|
||||||
|
check_type: CheckType.value
|
||||||
|
} : {check_type: CheckType.value})
|
||||||
overallTeamPerformance.value.newCustomers = response.data
|
overallTeamPerformance.value.newCustomers = response.data
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取新增客户失败:', error)
|
console.error('获取新增客户失败:', error)
|
||||||
@@ -273,7 +312,10 @@ async function fetchDepositConversions() {
|
|||||||
const params = getRequestParams()
|
const params = getRequestParams()
|
||||||
const hasParams = params.user_name
|
const hasParams = params.user_name
|
||||||
try {
|
try {
|
||||||
const response = await getDepositConversionRate(hasParams ? params : undefined)
|
const response = await getDepositConversionRate(hasParams ? {
|
||||||
|
...params,
|
||||||
|
check_type: CheckType.value
|
||||||
|
} : {check_type: CheckType.value})
|
||||||
overallTeamPerformance.value.depositConversions = response.data
|
overallTeamPerformance.value.depositConversions = response.data
|
||||||
console.log(99888999,response.data)
|
console.log(99888999,response.data)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user