refactor(secondTop): 优化营期设置和结束逻辑
使用getRequestParams统一处理请求参数 将硬编码的字符串值改为变量引用
This commit is contained in:
@@ -214,54 +214,106 @@ const totalCustomers = computed(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// const getStageCount = (stageType) => {
|
||||||
|
// // 成交阶段从payMoneyCustomersList获取数量
|
||||||
|
// if (stageType === '成交') {
|
||||||
|
// 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获取数量
|
||||||
|
// if (stageType === '课1-4' && props.courseCustomers?.['课1-4']) {
|
||||||
|
// return props.courseCustomers['课1-4'].length;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // 单独的课程阶段(课1、课2、课3、课4)
|
||||||
|
// if (['课1', '课2', '课3', '课4'].includes(stageType)) {
|
||||||
|
// if (props.courseCustomers?.['课1-4']) {
|
||||||
|
// const courseNumber = stageType.replace('课', '');
|
||||||
|
// return props.courseCustomers['课1-4'].filter(customer => {
|
||||||
|
// // 检查客户是否参加了指定课程
|
||||||
|
// return customer.class_num && customer.class_num.includes(courseNumber);
|
||||||
|
// }).length;
|
||||||
|
// }
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // 后3个阶段从courseCustomers中筛选
|
||||||
|
// if (['点击未支付', '付定金', '定金转化'].includes(stageType)) {
|
||||||
|
// if (props.courseCustomers?.['课1-4']) {
|
||||||
|
// return props.courseCustomers['课1-4'].filter(customer => customer.type === stageType).length;
|
||||||
|
// }
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // 前6个阶段从customersList中筛选
|
||||||
|
// if (props.customersList?.length) {
|
||||||
|
// return props.customersList.filter(customer => customer.type === stageType).length;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // 如果没有数据,使用props.data中的数据
|
||||||
|
// return props.data[stageType] || 0;
|
||||||
|
// };
|
||||||
const getStageCount = (stageType) => {
|
const getStageCount = (stageType) => {
|
||||||
// 成交阶段从payMoneyCustomersList获取数量
|
// 成交阶段从payMoneyCustomersList获取数量
|
||||||
if (stageType === '成交') {
|
if (stageType === '成交') {
|
||||||
return props.payMoneyCustomersCount || (props.payMoneyCustomersList?.length || 0);
|
return props.payMoneyCustomersCount || (props.payMoneyCustomersList?.length || 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 待填表单阶段:统计customer_occupation或customer_child_education字段为'未知'的客户数量
|
// 课1-4阶段从courseCustomers获取数量
|
||||||
if (stageType === '待填表单') {
|
if (stageType === '课1-4' && props.courseCustomers?.['课1-4']) {
|
||||||
if (props.customersList?.length) {
|
return props.courseCustomers['课1-4'].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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 待到课阶段:统计没有到课数据的客户数量
|
// 后3个阶段从courseCustomers中筛选
|
||||||
if (stageType === '待到课') {
|
if (['点击未支付', '付定金', '定金转化'].includes(stageType)) {
|
||||||
if (props.customersList?.length) {
|
if (props.courseCustomers?.['课1-4']) {
|
||||||
return props.customersList.filter(customer => {
|
return props.courseCustomers['课1-4'].filter(customer => customer.type === stageType).length;
|
||||||
// 根据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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 课1-4阶段从courseCustomers获取数量
|
// 课1-4阶段从courseCustomers获取数量
|
||||||
@@ -280,15 +332,6 @@ const getStageCount = (stageType) => {
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 后3个阶段从courseCustomers中筛选
|
|
||||||
if (['点击未支付', '付定金', '定金转化'].includes(stageType)) {
|
|
||||||
if (props.courseCustomers?.['课1-4']) {
|
|
||||||
return props.courseCustomers['课1-4'].filter(customer => customer.type === stageType).length;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 前6个阶段从customersList中筛选
|
// 前6个阶段从customersList中筛选
|
||||||
if (props.customersList?.length) {
|
if (props.customersList?.length) {
|
||||||
return props.customersList.filter(customer => customer.type === stageType).length;
|
return props.customersList.filter(customer => customer.type === stageType).length;
|
||||||
@@ -298,7 +341,6 @@ const getStageCount = (stageType) => {
|
|||||||
return props.data[stageType] || 0;
|
return props.data[stageType] || 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const stages = computed(() => {
|
const stages = computed(() => {
|
||||||
// 全部阶段的数量就是前6个阶段的数量
|
// 全部阶段的数量就是前6个阶段的数量
|
||||||
const totalCount = props.customersList?.length || 0;
|
const totalCount = props.customersList?.length || 0;
|
||||||
|
|||||||
@@ -381,7 +381,7 @@ const finishCamp = async () => {
|
|||||||
try {
|
try {
|
||||||
isCampFinished.value = true;
|
isCampFinished.value = true;
|
||||||
await CenterCampPeriodAdmin({
|
await CenterCampPeriodAdmin({
|
||||||
is_camp_finish: true
|
is_camp_finish: "11"
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('结束营期失败:', error);
|
console.error('结束营期失败:', error);
|
||||||
|
|||||||
@@ -246,11 +246,9 @@ const centerData = ref({
|
|||||||
// 保存营期
|
// 保存营期
|
||||||
const saveCampSettings = async () => {
|
const saveCampSettings = async () => {
|
||||||
recalculateStageDates();
|
recalculateStageDates();
|
||||||
|
|
||||||
// 准备API请求参数
|
// 准备API请求参数
|
||||||
const params = {
|
const params = {
|
||||||
user_name: userStore.userInfo.username,
|
...getRequestParams(),
|
||||||
user_level: userStore.userInfo.user_level.toString(),
|
|
||||||
receipt_data_time: dataReceivingStage.value.days.toString()
|
receipt_data_time: dataReceivingStage.value.days.toString()
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -267,14 +265,13 @@ const centerData = ref({
|
|||||||
alert('保存失败,请重试');
|
alert('保存失败,请重试');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const padding111 = ref('11')
|
||||||
// 结束营期
|
// 结束营期
|
||||||
const finishCamp = async () => {
|
const finishCamp = async () => {
|
||||||
try {
|
try {
|
||||||
const params = {
|
const params = {
|
||||||
user_name: userStore.userInfo.username,
|
...getRequestParams(),
|
||||||
user_level: userStore.userInfo.user_level.toString(),
|
is_camp_finish: padding111.value.toString()
|
||||||
is_camp_finish: "true"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const res = await getCampPeriodAdmin(params);
|
const res = await getCampPeriodAdmin(params);
|
||||||
|
|||||||
Reference in New Issue
Block a user