完善规划页特殊日期弹窗
This commit is contained in:
@@ -52,6 +52,23 @@ function buildAppointmentFormUrl(date, artistId) {
|
|||||||
return `/pages/appointment-form/index?date=${date}&artistId=${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) {
|
function resolveAppointmentDate(item) {
|
||||||
if (item.date) return item.date
|
if (item.date) return item.date
|
||||||
return String(item.startTime || '').slice(0, 10)
|
return String(item.startTime || '').slice(0, 10)
|
||||||
@@ -200,7 +217,13 @@ Page({
|
|||||||
pendingEmptyDate: '',
|
pendingEmptyDate: '',
|
||||||
pendingEmptyDateTitle: '',
|
pendingEmptyDateTitle: '',
|
||||||
pendingEmptyDateLabel: '',
|
pendingEmptyDateLabel: '',
|
||||||
savingRestDate: false
|
specialDateTypes: buildSpecialDateTypes('REST'),
|
||||||
|
pendingSpecialDateType: 'REST',
|
||||||
|
pendingSpecialDateTypeLabel: '休息日',
|
||||||
|
pendingSpecialDateRequiresTime: false,
|
||||||
|
pendingSpecialDateStartTime: '10:00',
|
||||||
|
pendingSpecialDateEndTime: '22:00',
|
||||||
|
savingSpecialDate: false
|
||||||
},
|
},
|
||||||
|
|
||||||
onLoad() {
|
onLoad() {
|
||||||
@@ -247,7 +270,7 @@ Page({
|
|||||||
const currentDate = dateUtil.formatDate(event.currentTarget.dataset.date)
|
const currentDate = dateUtil.formatDate(event.currentTarget.dataset.date)
|
||||||
if (this.data.viewMode === 'month') {
|
if (this.data.viewMode === 'month') {
|
||||||
const monthDay = this.data.monthDays.find(item => item.date === currentDate)
|
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)
|
this.openEmptyDateAction(currentDate)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -259,36 +282,73 @@ Page({
|
|||||||
emptyDateActionVisible: false,
|
emptyDateActionVisible: false,
|
||||||
pendingEmptyDate: '',
|
pendingEmptyDate: '',
|
||||||
pendingEmptyDateTitle: '',
|
pendingEmptyDateTitle: '',
|
||||||
pendingEmptyDateLabel: ''
|
pendingEmptyDateLabel: '',
|
||||||
|
savingSpecialDate: false
|
||||||
})
|
})
|
||||||
this.prepareView()
|
this.prepareView()
|
||||||
},
|
},
|
||||||
|
|
||||||
openEmptyDateAction(date) {
|
openEmptyDateAction(date) {
|
||||||
const currentDate = dateUtil.formatDate(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({
|
this.setData({
|
||||||
currentDate,
|
currentDate,
|
||||||
currentDateText: currentDate,
|
currentDateText: currentDate,
|
||||||
emptyDateActionVisible: true,
|
emptyDateActionVisible: true,
|
||||||
pendingEmptyDate: currentDate,
|
pendingEmptyDate: currentDate,
|
||||||
pendingEmptyDateTitle: formatActionDate(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()
|
this.prepareView()
|
||||||
},
|
},
|
||||||
|
|
||||||
closeEmptyDateAction() {
|
closeEmptyDateAction() {
|
||||||
|
const option = resolveSpecialDateType('REST')
|
||||||
this.setData({
|
this.setData({
|
||||||
emptyDateActionVisible: false,
|
emptyDateActionVisible: false,
|
||||||
pendingEmptyDate: '',
|
pendingEmptyDate: '',
|
||||||
pendingEmptyDateTitle: '',
|
pendingEmptyDateTitle: '',
|
||||||
pendingEmptyDateLabel: '',
|
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() {},
|
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() {
|
prevRange() {
|
||||||
this.shiftRange(-1)
|
this.shiftRange(-1)
|
||||||
},
|
},
|
||||||
@@ -655,31 +715,38 @@ Page({
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
async setEmptyDateAsRest() {
|
async saveEmptyDateSpecialDate() {
|
||||||
if (!this.data.pendingEmptyDate) {
|
if (!this.data.pendingEmptyDate) {
|
||||||
wx.showToast({ title: '请选择休息日期', icon: 'none' })
|
wx.showToast({ title: '请选择特殊日期', icon: 'none' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (this.data.savingRestDate) {
|
if (this.data.savingSpecialDate) {
|
||||||
return
|
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 {
|
try {
|
||||||
await shopApi.saveScheduleException({
|
await shopApi.saveScheduleException({
|
||||||
workDate: this.data.pendingEmptyDate,
|
workDate: this.data.pendingEmptyDate,
|
||||||
exceptionType: 'REST',
|
exceptionType: option.value,
|
||||||
startTime: null,
|
startTime: option.requiresTime ? startTime : null,
|
||||||
endTime: null,
|
endTime: option.requiresTime ? endTime : null,
|
||||||
remark: '规划页快速设置'
|
remark: '规划页快速设置'
|
||||||
})
|
})
|
||||||
markPlanningRefresh()
|
markPlanningRefresh()
|
||||||
wx.showToast({ title: '已设为休息日', icon: 'success' })
|
wx.showToast({ title: '特殊日期已保存', icon: 'success' })
|
||||||
this.closeEmptyDateAction()
|
this.closeEmptyDateAction()
|
||||||
await this.loadCalendar()
|
await this.loadCalendar()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
wx.showToast({ title: error.message || '休息日设置失败', icon: 'none' })
|
wx.showToast({ title: error.message || '特殊日期保存失败', icon: 'none' })
|
||||||
} finally {
|
} finally {
|
||||||
this.setData({ savingRestDate: false })
|
this.setData({ savingSpecialDate: false })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -160,7 +160,7 @@
|
|||||||
<view class="empty-date-head">
|
<view class="empty-date-head">
|
||||||
<view class="empty-date-title-wrap">
|
<view class="empty-date-title-wrap">
|
||||||
<text class="empty-date-title">{{pendingEmptyDateTitle}}</text>
|
<text class="empty-date-title">{{pendingEmptyDateTitle}}</text>
|
||||||
<text class="empty-date-subtitle">当前日期暂无预约,可以直接创建预约或设为特殊休息日</text>
|
<text class="empty-date-subtitle">当前日期暂无预约,可以直接创建预约或设为特殊日期</text>
|
||||||
</view>
|
</view>
|
||||||
<button class="empty-date-close" bindtap="closeEmptyDateAction">×</button>
|
<button class="empty-date-close" bindtap="closeEmptyDateAction">×</button>
|
||||||
</view>
|
</view>
|
||||||
@@ -172,12 +172,35 @@
|
|||||||
<text class="empty-date-action-desc">进入预约表单,并自动带入日期;员工沿用当前筛选</text>
|
<text class="empty-date-action-desc">进入预约表单,并自动带入日期;员工沿用当前筛选</text>
|
||||||
</view>
|
</view>
|
||||||
</button>
|
</button>
|
||||||
<button class="empty-date-action rest" loading="{{savingRestDate}}" bindtap="setEmptyDateAsRest">
|
|
||||||
<view class="empty-date-action-icon">休</view>
|
|
||||||
<view class="empty-date-action-copy">
|
|
||||||
<text class="empty-date-action-title">设为特殊休息日期</text>
|
|
||||||
<text class="empty-date-action-desc">保存后月历标记为“休”,当天不再生成可约时间</text>
|
|
||||||
</view>
|
</view>
|
||||||
|
<view class="empty-date-special">
|
||||||
|
<text class="empty-date-section-title">特殊日期</text>
|
||||||
|
<view class="empty-date-type-list">
|
||||||
|
<button wx:for="{{specialDateTypes}}" wx:key="value" class="empty-date-type {{item.tone}} {{item.active ? 'active' : ''}}" data-value="{{item.value}}" bindtap="selectEmptyDateSpecialType">
|
||||||
|
<view class="empty-date-action-icon">{{item.icon}}</view>
|
||||||
|
<view class="empty-date-action-copy">
|
||||||
|
<text class="empty-date-action-title">{{item.label}}</text>
|
||||||
|
<text class="empty-date-action-desc">{{item.desc}}</text>
|
||||||
|
</view>
|
||||||
|
<text class="empty-date-type-check">{{item.active ? '已选' : ''}}</text>
|
||||||
|
</button>
|
||||||
|
</view>
|
||||||
|
<view wx:if="{{pendingSpecialDateRequiresTime}}" class="empty-date-time-fields">
|
||||||
|
<picker mode="time" value="{{pendingSpecialDateStartTime}}" bindchange="onEmptyDateStartTimeChange">
|
||||||
|
<view class="empty-date-time-field">
|
||||||
|
<text class="empty-date-time-label">开始</text>
|
||||||
|
<text class="empty-date-time-value">{{pendingSpecialDateStartTime}}</text>
|
||||||
|
</view>
|
||||||
|
</picker>
|
||||||
|
<picker mode="time" value="{{pendingSpecialDateEndTime}}" bindchange="onEmptyDateEndTimeChange">
|
||||||
|
<view class="empty-date-time-field">
|
||||||
|
<text class="empty-date-time-label">结束</text>
|
||||||
|
<text class="empty-date-time-value">{{pendingSpecialDateEndTime}}</text>
|
||||||
|
</view>
|
||||||
|
</picker>
|
||||||
|
</view>
|
||||||
|
<button class="empty-date-save" loading="{{savingSpecialDate}}" bindtap="saveEmptyDateSpecialDate">
|
||||||
|
<text>保存{{pendingSpecialDateTypeLabel}}</text>
|
||||||
</button>
|
</button>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -851,10 +851,13 @@
|
|||||||
|
|
||||||
.empty-date-sheet {
|
.empty-date-sheet {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
max-height: 88vh;
|
||||||
padding: 22rpx 28rpx calc(28rpx + env(safe-area-inset-bottom));
|
padding: 22rpx 28rpx calc(28rpx + env(safe-area-inset-bottom));
|
||||||
border-radius: 22px 22px 0 0;
|
border-radius: 22px 22px 0 0;
|
||||||
background: #fffdf8;
|
background: #fffdf8;
|
||||||
box-shadow: 0 -18rpx 44rpx rgba(38, 35, 31, 0.18);
|
box-shadow: 0 -18rpx 44rpx rgba(38, 35, 31, 0.18);
|
||||||
|
overflow-y: auto;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
animation: emptyDateSheetIn 180ms ease both;
|
animation: emptyDateSheetIn 180ms ease both;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -923,8 +926,13 @@
|
|||||||
.empty-date-action {
|
.empty-date-action {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
justify-content: flex-start;
|
||||||
|
box-sizing: border-box;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
min-width: 100%;
|
||||||
|
max-width: 100%;
|
||||||
min-height: 136rpx;
|
min-height: 136rpx;
|
||||||
|
margin: 0;
|
||||||
padding: 22rpx;
|
padding: 22rpx;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
@@ -936,12 +944,6 @@
|
|||||||
box-shadow: 0 8rpx 18rpx rgba(111, 143, 131, 0.24);
|
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 {
|
.empty-date-action-icon {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -962,11 +964,6 @@
|
|||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.empty-date-action.rest .empty-date-action-icon {
|
|
||||||
background: #ffe9e5;
|
|
||||||
color: #c56f6f;
|
|
||||||
}
|
|
||||||
|
|
||||||
.empty-date-action-copy {
|
.empty-date-action-copy {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
@@ -988,6 +985,144 @@
|
|||||||
opacity: 0.82;
|
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 {
|
@keyframes pageFadeIn {
|
||||||
from {
|
from {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user