From 0627caf37c54880a854ee61fc56b577e53129171 Mon Sep 17 00:00:00 2001 From: lbw_9527443 <780139497@qq.com> Date: Thu, 28 Aug 2025 15:34:51 +0800 Subject: [PATCH] =?UTF-8?q?fix(Calendar):=20=E6=B7=BB=E5=8A=A0=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E6=8C=89=E9=92=AE=E9=98=B2=E6=8A=96=E5=B9=B6=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E8=90=A5=E6=9C=9F=E5=BC=80=E5=A7=8B=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加isSaving状态防止重复提交保存请求 移除不再需要的campStartDate字段及相关逻辑 保存按钮在提交时显示加载状态 --- .../views/secondTop/components/Calendar.vue | 74 ++++--------------- 1 file changed, 15 insertions(+), 59 deletions(-) diff --git a/my-vue-app/src/views/secondTop/components/Calendar.vue b/my-vue-app/src/views/secondTop/components/Calendar.vue index f9e17d7..0d2e518 100644 --- a/my-vue-app/src/views/secondTop/components/Calendar.vue +++ b/my-vue-app/src/views/secondTop/components/Calendar.vue @@ -120,8 +120,11 @@
@@ -262,9 +265,9 @@ const tooltipPosition = ref({ x: 0, y: 0 }); // 营期设置相关 const showCampModal = ref(false); -const campStartDate = ref(''); const campDays = ref(); const restDays = ref(); +const isSaving = ref(false); const isCampFinished = ref(false); // 结束营期确认弹框相关 @@ -435,10 +438,11 @@ const loadHistoryPeriods = async () => { // 方法:保存营期设置 const saveCampSettings = async () => { - if (!campStartDate.value) { - alert('请选择营期开始时间'); + // 防抖:如果正在保存中,直接返回 + if (isSaving.value) { return; } + if (!campDays.value || campDays.value < 1) { alert('请输入有效的接数据天数'); return; @@ -448,10 +452,11 @@ const saveCampSettings = async () => { return; } + isSaving.value = true; + try { // 调用API设置营期参数并获取营期安排 const result = await CenterCampPeriodAdmin({ - receipt_data_start_time: campStartDate.value, receipt_data_time: campDays.value.toString(), rest_days: restDays.value.toString() }); @@ -459,7 +464,6 @@ const saveCampSettings = async () => { if (result && result.data) { showCampModal.value = false; // 重置表单数据 - campStartDate.value = ''; campDays.value = null; restDays.value = null; alert('营期设置成功!'); @@ -467,59 +471,12 @@ const saveCampSettings = async () => { } catch (error) { console.error('保存营期设置失败:', error); alert('保存营期设置失败,请重试'); + } finally { + isSaving.value = false; } }; -// 方法:生成营期日程安排 -const generateCampSchedule = () => { - const startDate = new Date(campStartDate.value); - const dataDays = campDays.value || 2; // 接数据天数,默认2天 - let currentDate = new Date(startDate); - let eventId = events.value.length + 1; - - // 清除之前的营期相关事件 - events.value = events.value.filter(event => !event.isCampEvent); - - // 添加接数据日程 - for (let i = 0; i < dataDays; i++) { - const dateStr = formatDateToString(currentDate); - events.value.push({ - id: eventId++, - date: dateStr, - title: `接数据 第${i + 1}天`, - description: '营期数据接收阶段', - isCampEvent: true, - type: 'data' - }); - currentDate.setDate(currentDate.getDate() + 1); - } - - // 添加课程日程 - const courses = ['课1', '课2', '课3', '课4']; - courses.forEach((course, index) => { - const dateStr = formatDateToString(currentDate); - events.value.push({ - id: eventId++, - date: dateStr, - title: course, - description: `${course}`, - isCampEvent: true, - type: 'course' - }); - currentDate.setDate(currentDate.getDate() + 1); - }); - - // 添加休息日程 - const restDateStr = formatDateToString(currentDate); - events.value.push({ - id: eventId++, - date: restDateStr, - title: '休息', - description: '营期休息日', - isCampEvent: true, - type: 'rest' - }); -}; + // 辅助方法:格式化日期为字符串 const formatDateToString = (date) => { @@ -689,9 +646,8 @@ async function CenterCampPeriodAdmin(data = {}) { // 兼容原有逻辑,使用全局变量 if (isCampFinished.value) { Finsh.is_camp_finish = isCampFinished.value - } else if (campStartDate.value && campDays.value) { + } else if (campDays.value) { // 只有在有营期设置数据时才传递参数 - Finsh.receipt_data_start_time = campStartDate.value Finsh.receipt_data_time = campDays.value.toString() if (restDays.value) { Finsh.rest_days = restDays.value.toString()