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 @@
进入预约表单,并自动带入日期;员工沿用当前筛选
-