From d5792be702a17a90c1438e0fcc97631705dccab6 Mon Sep 17 00:00:00 2001 From: lbw_9527443 <780139497@qq.com> Date: Mon, 1 Sep 2025 21:14:52 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E9=94=80=E5=94=AE=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E8=BD=B4):=20=E6=B7=BB=E5=8A=A0time=5Fand=5Fcamp=5Fstage?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E6=94=AF=E6=8C=81=E5=B9=B6=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E9=98=B6=E6=AE=B5=E7=AD=9B=E9=80=89=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在客户数据中添加time_and_camp_stage字段用于记录付款行为发生的课程阶段 - 重构课程阶段筛选逻辑,优先使用time_and_camp_stage字段进行精确匹配 - 移除已注释的旧代码 - 更新API基础路径为生产环境 --- my-vue-app/src/utils/https.js | 4 +- .../components/SalesTimelineWithTaskList.vue | 129 ++++++------------ my-vue-app/src/views/person/sale.vue | 15 +- 3 files changed, 50 insertions(+), 98 deletions(-) diff --git a/my-vue-app/src/utils/https.js b/my-vue-app/src/utils/https.js index 29dbac9..ae8c3b2 100644 --- a/my-vue-app/src/utils/https.js +++ b/my-vue-app/src/utils/https.js @@ -5,8 +5,8 @@ import { useUserStore } from '@/stores/user' // 创建axios实例 const service = axios.create({ - // baseURL: 'https://mldash.nycjy.cn/' || '', // API基础路径,支持完整URL - baseURL: 'http://192.168.15.121:8890' || '', // API基础路径,支持完整URL + baseURL: 'https://mldash.nycjy.cn/' || '', // API基础路径,支持完整URL + // baseURL: 'http://192.168.15.121:8890' || '', // API基础路径,支持完整URL timeout: 100000, // 请求超时时间 headers: { 'Content-Type': 'application/json;charset=UTF-8' diff --git a/my-vue-app/src/views/person/components/SalesTimelineWithTaskList.vue b/my-vue-app/src/views/person/components/SalesTimelineWithTaskList.vue index daca6ec..caf9466 100644 --- a/my-vue-app/src/views/person/components/SalesTimelineWithTaskList.vue +++ b/my-vue-app/src/views/person/components/SalesTimelineWithTaskList.vue @@ -374,90 +374,6 @@ const totalCustomers = computed(() => { return Math.max(...baseStages, 1); }); - -// 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) => { // 成交阶段从payMoneyCustomersList获取数量 if (stageType === '成交') { @@ -722,10 +638,27 @@ const getCourseStageCount = (courseNumber, stageType) => { return false; }); } else { - // 其他阶段:从courseCustomers中筛选 - const courseKey = `课${courseNumber}`; - if (props.courseCustomers?.[courseKey]) { - filteredCustomers = props.courseCustomers[courseKey].filter(customer => customer.type === stageType); + // 其他阶段:从courseCustomers['课1-4']中筛选 + if (props.courseCustomers?.['课1-4']) { + filteredCustomers = props.courseCustomers['课1-4'].filter(customer => { + // 检查客户的付款行为是否发生在指定课程阶段并且类型匹配 + let hasPaymentInCourse = false; + + // 优先使用time_and_camp_stage字段判断付款行为发生的课程阶段 + if (customer.time_and_camp_stage && Array.isArray(customer.time_and_camp_stage)) { + hasPaymentInCourse = customer.time_and_camp_stage.some(record => { + return record.camp_stage === `课${courseNumber}` && record.pay_status === stageType; + }); + } + + // 如果time_and_camp_stage没有匹配的记录,则回退到class_num字段 + if (!hasPaymentInCourse) { + const hasAttendedCourse = customer.class_num && Array.isArray(customer.class_num) && customer.class_num.includes(courseNumber); + hasPaymentInCourse = hasAttendedCourse && customer.type === stageType; + } + + return hasPaymentInCourse; + }); } } @@ -814,9 +747,23 @@ const selectCourseStage = (courseNumber, stageType) => { // 其他阶段:从courseCustomers中筛选 if (props.courseCustomers?.['课1-4']) { filteredCustomers = props.courseCustomers['课1-4'].filter(customer => { - // 检查客户是否参加了指定课程并且类型匹配 - const hasAttendedCourse = customer.class_num && customer.class_num.includes(courseNumber); - return hasAttendedCourse && customer.type === stageType; + // 检查客户的付款行为是否发生在指定课程阶段并且类型匹配 + let hasPaymentInCourse = false; + + // 优先使用time_and_camp_stage字段判断付款行为发生的课程阶段 + if (customer.time_and_camp_stage && Array.isArray(customer.time_and_camp_stage)) { + hasPaymentInCourse = customer.time_and_camp_stage.some(record => { + return record.camp_stage === `课${courseNumber}` && record.pay_status === stageType; + }); + } + + // 如果time_and_camp_stage没有匹配的记录,则回退到class_num字段 + if (!hasPaymentInCourse) { + const hasAttendedCourse = customer.class_num && customer.class_num.includes(courseNumber); + hasPaymentInCourse = hasAttendedCourse && customer.type === stageType; + } + + return hasPaymentInCourse; }); } } diff --git a/my-vue-app/src/views/person/sale.vue b/my-vue-app/src/views/person/sale.vue index 7ace4b2..45becf3 100644 --- a/my-vue-app/src/views/person/sale.vue +++ b/my-vue-app/src/views/person/sale.vue @@ -461,7 +461,8 @@ async function getTimeline() { class_situation: customer.class_situation, class_num: Object.keys(customer.class_situation || {}), // 添加class_num字段 pay_status: customer.pay_status, - records: [] + records: [], + time_and_camp_stage: customer.time_and_camp_stage || [] }; }) @@ -494,7 +495,8 @@ async function getTimeline() { class_situation: customer.class_situation, scrm_user_main_code: customer.scrm_user_main_code, weChat_avatar: customer.weChat_avatar, - pay_status: customer.pay_status + pay_status: customer.pay_status, + time_and_camp_stage: customer.time_and_camp_stage || [] }) // 后三个阶段的客户数据已存储在courseCustomers['课1-4']中,不需要合并到customersList } @@ -734,7 +736,8 @@ const handleStageSelect = (stage, extraData = null) => { scrm_user_main_code: customer.scrm_user_main_code, weChat_avatar: customer.weChat_avatar, class_situation: customer.class_situation, - records: customer.records + records: customer.records, + time_and_camp_stage: customer.time_and_camp_stage || [] })); // 更新当前筛选的客户数据 @@ -763,7 +766,8 @@ const handleStageSelect = (stage, extraData = null) => { class_situation: customer.class_situation, class_num: customer.class_num, // 添加class_num字段 pay_status: customer.pay_status, // 添加pay_status字段 - records: customer.records + records: customer.records, + time_and_camp_stage: customer.time_and_camp_stage || [] })); currentFilteredCustomers.value = courseContacts; @@ -802,7 +806,8 @@ const handleSubStageSelect = (eventData) => { scrm_user_main_code: customer.scrm_user_main_code, weChat_avatar: customer.weChat_avatar, class_situation: customer.class_situation, - records: customer.records + records: customer.records, + time_and_camp_stage: customer.time_and_camp_stage || [] })); // 更新当前筛选的客户数据,但保持selectedStage不变(保持子时间轴显示)