From df4344dd4627e9fccd42c71412e9a94fc0c2f17a Mon Sep 17 00:00:00 2001 From: xiaowang <2161656029@qq.com> Date: Wed, 22 Jul 2026 20:01:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E8=A7=84=E5=88=92=E9=A1=B5?= =?UTF-8?q?=E7=89=B9=E6=AE=8A=E6=97=A5=E6=9C=9F=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- JY-Salon-WeChat/pages/planning/index.js | 97 ++++++++++--- JY-Salon-WeChat/pages/planning/index.wxml | 37 ++++- JY-Salon-WeChat/pages/planning/index.wxss | 157 ++++++++++++++++++++-- 3 files changed, 258 insertions(+), 33 deletions(-) diff --git a/JY-Salon-WeChat/pages/planning/index.js b/JY-Salon-WeChat/pages/planning/index.js index 72823051..71cf98b1 100644 --- a/JY-Salon-WeChat/pages/planning/index.js +++ b/JY-Salon-WeChat/pages/planning/index.js @@ -52,6 +52,23 @@ function buildAppointmentFormUrl(date, artistId) { return `/pages/appointment-form/index?date=${date}&artistId=${artistId || ''}` } +const SPECIAL_DATE_TYPES = [ + { value: 'REST', label: '休息日', desc: '当天不开放预约', icon: '休', tone: 'rest', requiresTime: false }, + { value: 'EXTRA_WORK', label: '临时营业', desc: '原休息日也可开放预约', icon: '营', tone: 'work', requiresTime: true }, + { value: 'CHANGE_SHIFT', label: '临时改班', desc: '当天改成指定营业时段', icon: '改', tone: 'shift', requiresTime: true } +] + +function resolveSpecialDateType(value) { + return SPECIAL_DATE_TYPES.find(item => item.value === value) || SPECIAL_DATE_TYPES[0] +} + +function buildSpecialDateTypes(activeValue) { + return SPECIAL_DATE_TYPES.map(item => ({ + ...item, + active: item.value === activeValue + })) +} + function resolveAppointmentDate(item) { if (item.date) return item.date return String(item.startTime || '').slice(0, 10) @@ -200,7 +217,13 @@ Page({ pendingEmptyDate: '', pendingEmptyDateTitle: '', pendingEmptyDateLabel: '', - savingRestDate: false + specialDateTypes: buildSpecialDateTypes('REST'), + pendingSpecialDateType: 'REST', + pendingSpecialDateTypeLabel: '休息日', + pendingSpecialDateRequiresTime: false, + pendingSpecialDateStartTime: '10:00', + pendingSpecialDateEndTime: '22:00', + savingSpecialDate: false }, onLoad() { @@ -247,7 +270,7 @@ Page({ const currentDate = dateUtil.formatDate(event.currentTarget.dataset.date) if (this.data.viewMode === 'month') { const monthDay = this.data.monthDays.find(item => item.date === currentDate) - if (monthDay && monthDay.isCurrentMonth && Number(monthDay.totalCount || 0) === 0 && !monthDay.shopRest) { + if (monthDay && monthDay.isCurrentMonth && !monthDay.isPast && Number(monthDay.totalCount || 0) === 0) { this.openEmptyDateAction(currentDate) return } @@ -259,36 +282,73 @@ Page({ emptyDateActionVisible: false, pendingEmptyDate: '', pendingEmptyDateTitle: '', - pendingEmptyDateLabel: '' + pendingEmptyDateLabel: '', + savingSpecialDate: false }) this.prepareView() }, openEmptyDateAction(date) { const currentDate = dateUtil.formatDate(date) + const monthDay = this.data.monthDays.find(item => item.date === currentDate) + const typeValue = monthDay && monthDay.shopRest ? 'EXTRA_WORK' : 'REST' + const option = resolveSpecialDateType(typeValue) this.setData({ currentDate, currentDateText: currentDate, emptyDateActionVisible: true, pendingEmptyDate: currentDate, pendingEmptyDateTitle: formatActionDate(currentDate), - pendingEmptyDateLabel: formatShortDate(currentDate) + pendingEmptyDateLabel: formatShortDate(currentDate), + specialDateTypes: buildSpecialDateTypes(option.value), + pendingSpecialDateType: option.value, + pendingSpecialDateTypeLabel: option.label, + pendingSpecialDateRequiresTime: option.requiresTime, + pendingSpecialDateStartTime: this.data.businessStartTime, + pendingSpecialDateEndTime: this.data.businessEndTime, + savingSpecialDate: false }) this.prepareView() }, closeEmptyDateAction() { + const option = resolveSpecialDateType('REST') this.setData({ emptyDateActionVisible: false, pendingEmptyDate: '', pendingEmptyDateTitle: '', pendingEmptyDateLabel: '', - savingRestDate: false + specialDateTypes: buildSpecialDateTypes(option.value), + pendingSpecialDateType: option.value, + pendingSpecialDateTypeLabel: option.label, + pendingSpecialDateRequiresTime: option.requiresTime, + pendingSpecialDateStartTime: this.data.businessStartTime, + pendingSpecialDateEndTime: this.data.businessEndTime, + savingSpecialDate: false }) }, stopTap() {}, + selectEmptyDateSpecialType(event) { + const value = String(event.currentTarget.dataset.value || 'REST') + const option = resolveSpecialDateType(value) + this.setData({ + specialDateTypes: buildSpecialDateTypes(option.value), + pendingSpecialDateType: option.value, + pendingSpecialDateTypeLabel: option.label, + pendingSpecialDateRequiresTime: option.requiresTime + }) + }, + + onEmptyDateStartTimeChange(event) { + this.setData({ pendingSpecialDateStartTime: event.detail.value }) + }, + + onEmptyDateEndTimeChange(event) { + this.setData({ pendingSpecialDateEndTime: event.detail.value }) + }, + prevRange() { this.shiftRange(-1) }, @@ -655,31 +715,38 @@ Page({ }) }, - async setEmptyDateAsRest() { + async saveEmptyDateSpecialDate() { if (!this.data.pendingEmptyDate) { - wx.showToast({ title: '请选择休息日期', icon: 'none' }) + wx.showToast({ title: '请选择特殊日期', icon: 'none' }) return } - if (this.data.savingRestDate) { + if (this.data.savingSpecialDate) { return } - this.setData({ savingRestDate: true }) + const option = resolveSpecialDateType(this.data.pendingSpecialDateType) + const startTime = this.data.pendingSpecialDateStartTime + const endTime = this.data.pendingSpecialDateEndTime + if (option.requiresTime && (!startTime || !endTime || startTime >= endTime)) { + wx.showToast({ title: '请设置正确营业时间', icon: 'none' }) + return + } + this.setData({ savingSpecialDate: true }) try { await shopApi.saveScheduleException({ workDate: this.data.pendingEmptyDate, - exceptionType: 'REST', - startTime: null, - endTime: null, + exceptionType: option.value, + startTime: option.requiresTime ? startTime : null, + endTime: option.requiresTime ? endTime : null, remark: '规划页快速设置' }) markPlanningRefresh() - wx.showToast({ title: '已设为休息日', icon: 'success' }) + wx.showToast({ title: '特殊日期已保存', icon: 'success' }) this.closeEmptyDateAction() await this.loadCalendar() } catch (error) { - wx.showToast({ title: error.message || '休息日设置失败', icon: 'none' }) + wx.showToast({ title: error.message || '特殊日期保存失败', icon: 'none' }) } finally { - this.setData({ savingRestDate: false }) + this.setData({ savingSpecialDate: false }) } }, diff --git a/JY-Salon-WeChat/pages/planning/index.wxml b/JY-Salon-WeChat/pages/planning/index.wxml index 67a14abc..f6d4a4af 100644 --- a/JY-Salon-WeChat/pages/planning/index.wxml +++ b/JY-Salon-WeChat/pages/planning/index.wxml @@ -160,7 +160,7 @@ {{pendingEmptyDateTitle}} - 当前日期暂无预约,可以直接创建预约或设为特殊休息日 + 当前日期暂无预约,可以直接创建预约或设为特殊日期 @@ -172,12 +172,35 @@ 进入预约表单,并自动带入日期;员工沿用当前筛选 - + + + + + 开始 + {{pendingSpecialDateStartTime}} + + + + + 结束 + {{pendingSpecialDateEndTime}} + + + + diff --git a/JY-Salon-WeChat/pages/planning/index.wxss b/JY-Salon-WeChat/pages/planning/index.wxss index 30860bae..96214826 100644 --- a/JY-Salon-WeChat/pages/planning/index.wxss +++ b/JY-Salon-WeChat/pages/planning/index.wxss @@ -851,10 +851,13 @@ .empty-date-sheet { width: 100%; + max-height: 88vh; padding: 22rpx 28rpx calc(28rpx + env(safe-area-inset-bottom)); border-radius: 22px 22px 0 0; background: #fffdf8; box-shadow: 0 -18rpx 44rpx rgba(38, 35, 31, 0.18); + overflow-y: auto; + -webkit-overflow-scrolling: touch; animation: emptyDateSheetIn 180ms ease both; } @@ -923,8 +926,13 @@ .empty-date-action { display: flex; align-items: center; + justify-content: flex-start; + box-sizing: border-box; width: 100%; + min-width: 100%; + max-width: 100%; min-height: 136rpx; + margin: 0; padding: 22rpx; border-radius: 12px; text-align: left; @@ -936,12 +944,6 @@ box-shadow: 0 8rpx 18rpx rgba(111, 143, 131, 0.24); } -.empty-date-action.rest { - border: 1rpx solid #f0d7d3; - background: #fff8f6; - color: #6a4743; -} - .empty-date-action-icon { display: flex; align-items: center; @@ -962,11 +964,6 @@ color: #fff; } -.empty-date-action.rest .empty-date-action-icon { - background: #ffe9e5; - color: #c56f6f; -} - .empty-date-action-copy { display: flex; flex: 1; @@ -988,6 +985,144 @@ opacity: 0.82; } +.empty-date-special { + display: flex; + flex-direction: column; + gap: 16rpx; + margin-top: 26rpx; +} + +.empty-date-section-title { + color: #5d554d; + font-size: 24rpx; + font-weight: 900; +} + +.empty-date-type-list { + display: flex; + flex-direction: column; + gap: 14rpx; +} + +.empty-date-type { + display: flex; + align-items: center; + justify-content: flex-start; + box-sizing: border-box; + width: 100%; + min-width: 100%; + max-width: 100%; + min-height: 124rpx; + margin: 0; + padding: 20rpx 22rpx; + border: 1rpx solid #ede5dc; + border-radius: 12px; + background: #fffaf3; + color: #665e55; + text-align: left; +} + +.empty-date-type.active { + border-color: #d4b27e; + background: #fff7e9; + color: #5d4828; +} + +.empty-date-type.rest.active { + border-color: #f0d7d3; + background: #fff8f6; + color: #6a4743; +} + +.empty-date-type.work.active { + border-color: #c8dccf; + background: #f5fbf6; + color: #436447; +} + +.empty-date-type.shift.active { + border-color: #d9c8ee; + background: #fbf7ff; + color: #5a4770; +} + +.empty-date-type.rest .empty-date-action-icon { + background: #ffe9e5; + color: #c56f6f; +} + +.empty-date-type.work .empty-date-action-icon { + background: #e6f3e8; + color: #589060; +} + +.empty-date-type.shift .empty-date-action-icon { + background: #eee2fb; + color: #7d63a8; +} + +.empty-date-type-check { + min-width: 64rpx; + margin-left: 16rpx; + color: #b38642; + font-size: 22rpx; + font-weight: 900; + text-align: right; +} + +.empty-date-time-fields { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 14rpx; +} + +.empty-date-time-fields picker { + min-width: 0; +} + +.empty-date-time-field { + display: flex; + align-items: center; + justify-content: space-between; + min-height: 88rpx; + padding: 0 22rpx; + border: 1rpx solid #e8ded2; + border-radius: 10px; + background: #fffdf8; +} + +.empty-date-time-label { + color: #8f877e; + font-size: 24rpx; + font-weight: 800; +} + +.empty-date-time-value { + color: #2e2a25; + font-size: 30rpx; + font-weight: 900; +} + +.empty-date-save { + display: flex; + align-items: center; + justify-content: center; + box-sizing: border-box; + width: 100%; + min-width: 100%; + max-width: 100%; + height: 88rpx; + min-height: 88rpx; + margin: 2rpx 0 0; + padding: 0 24rpx; + border-radius: 12px; + background: #2d2a26; + color: #fffdf8; + font-size: 28rpx; + font-weight: 900; + line-height: 88rpx; +} + @keyframes pageFadeIn { from { opacity: 0;