优化:规划日期快捷新增预约

This commit is contained in:
2026-10-12 17:15:27 +08:00
parent e4aff0803a
commit 2714bd7201
4 changed files with 82 additions and 16 deletions
+22 -13
View File
@@ -51,9 +51,9 @@ Page({
data: {
viewMode: 'month',
viewModes: [
{ value: 'day', label: '日' },
{ value: 'month', label: '月' },
{ value: 'week', label: '周' },
{ value: 'month', label: '月' }
{ value: 'day', label: '日' }
],
monthDisplayMode: 'count',
monthDisplayModes: [
@@ -234,14 +234,17 @@ Page({
this.loadCalendar()
},
selectDate(event) {
const currentDate = dateUtil.formatDate(event.currentTarget.dataset.date)
this.setData({
currentDate,
currentDateText: currentDate,
viewMode: this.data.viewMode === 'month' ? 'day' : this.data.viewMode
})
this.prepareView()
quickCreateAppointment(event) {
if (!this.data.canCreateAppointment) {
wx.showToast({ title: '当前账号仅支持查看预约', icon: 'none' })
return
}
const appointmentDate = dateUtil.formatDate(event.currentTarget.dataset.date)
if (appointmentDate < dateUtil.formatDate(new Date())) {
wx.showToast({ title: '不能为历史日期新增预约', icon: 'none' })
return
}
this.openAppointmentForm(appointmentDate)
},
prevRange() {
@@ -545,9 +548,15 @@ Page({
wx.showToast({ title: '当前账号仅支持查看预约', icon: 'none' })
return
}
wx.navigateTo({
url: `/pages/appointment-form/index?date=${this.data.currentDateText}&artistId=${this.data.selectedArtistId || ''}`
})
this.openAppointmentForm(this.data.currentDateText)
},
openAppointmentForm(appointmentDate) {
const query = [`date=${encodeURIComponent(appointmentDate)}`]
if (this.data.selectedArtistId) {
query.push(`artistId=${encodeURIComponent(this.data.selectedArtistId)}`)
}
wx.navigateTo({ url: `/pages/appointment-form/index?${query.join('&')}` })
},
openAppointment(event) {
+36 -1
View File
@@ -1,5 +1,6 @@
const assert = require('assert')
const planningApi = require('../../api/planning')
const dateUtil = require('../../utils/date')
global.wx = {
getAccountInfoSync: () => ({ miniProgram: { envVersion: 'develop' } }),
@@ -9,7 +10,8 @@ global.wx = {
removeStorageSync: () => {},
showToast: () => {},
showModal: ({ success }) => success({ confirm: false }),
switchTab: () => {}
switchTab: () => {},
navigateTo: () => {}
}
const appMock = { globalData: { userInfo: {} } }
global.getApp = () => appMock
@@ -41,6 +43,9 @@ function createPage(data = {}) {
}
async function run() {
assert.deepStrictEqual(definition.data.viewModes.map(item => item.value), ['month', 'week', 'day'])
assert.strictEqual(definition.data.viewMode, 'month')
const page = createPage({ viewMode: 'week' })
let monthBuilds = 0
let weekBuilds = 0
@@ -85,6 +90,36 @@ async function run() {
assert.strictEqual(switched, true)
assert.strictEqual(appMock.globalData.reviewNoticeShown, true)
assert.strictEqual(appMock.globalData.openEmployeeReview, true)
const navigations = []
const toasts = []
global.wx.navigateTo = options => navigations.push(options.url)
global.wx.showToast = options => toasts.push(options.title)
const quickCreatePage = createPage({ canCreateAppointment: true, selectedArtistId: '88' })
const today = dateUtil.formatDate(new Date())
quickCreatePage.quickCreateAppointment({ currentTarget: { dataset: { date: today } } })
assert.strictEqual(navigations.pop(), `/pages/appointment-form/index?date=${today}&artistId=88`)
quickCreatePage.quickCreateAppointment({ currentTarget: { dataset: { date: '2099-12-31' } } })
assert.strictEqual(navigations.pop(), '/pages/appointment-form/index?date=2099-12-31&artistId=88')
quickCreatePage.data.selectedArtistId = ''
quickCreatePage.quickCreateAppointment({ currentTarget: { dataset: { date: '2099-11-30' } } })
assert.strictEqual(navigations.pop(), '/pages/appointment-form/index?date=2099-11-30')
quickCreatePage.quickCreateAppointment({ currentTarget: { dataset: { date: '2000-01-01' } } })
assert.strictEqual(navigations.length, 0)
assert.strictEqual(toasts.pop(), '不能为历史日期新增预约')
const readonlyPage = createPage({ canCreateAppointment: false, selectedArtistId: '88' })
readonlyPage.quickCreateAppointment({ currentTarget: { dataset: { date: '2099-12-31' } } })
assert.strictEqual(navigations.length, 0)
assert.strictEqual(toasts.pop(), '当前账号仅支持查看预约')
const fabPage = createPage({ canCreateAppointment: true, currentDateText: '2026-10-12', selectedArtistId: '99' })
fabPage.createAppointment()
assert.strictEqual(navigations.pop(), '/pages/appointment-form/index?date=2026-10-12&artistId=99')
}
run().catch(error => {
+2 -2
View File
@@ -99,7 +99,7 @@
<view wx:if="{{viewMode === 'week'}}" class="section">
<scroll-view class="week-strip" scroll-x enable-flex>
<view wx:for="{{weekDays}}" wx:key="date" class="week-day-card card {{item.date === currentDateText ? 'active' : ''}}" data-date="{{item.date}}" bindtap="selectDate">
<view wx:for="{{weekDays}}" wx:key="date" class="week-day-card card {{item.date === currentDateText ? 'active' : ''}}" data-date="{{item.date}}" bindtap="quickCreateAppointment">
<text class="week-name">{{item.weekName}}</text>
<text class="week-date">{{item.day}}</text>
<text class="week-total">{{item.totalCount}}单</text>
@@ -140,7 +140,7 @@
<text wx:for="{{weekLabels}}" wx:key="*this">{{item}}</text>
</view>
<view class="month-grid">
<view wx:for="{{monthDays}}" wx:key="date" class="month-cell {{item.isCurrentMonth ? '' : 'out-month'}} {{item.date === currentDateText ? 'selected' : ''}}" data-date="{{item.date}}" bindtap="selectDate">
<view wx:for="{{monthDays}}" wx:key="date" class="month-cell {{item.isCurrentMonth ? '' : 'out-month'}} {{item.date === currentDateText ? 'selected' : ''}}" data-date="{{item.date}}" bindtap="quickCreateAppointment">
<view class="month-cell-head">
<text class="month-day">{{item.day}}</text>
<text wx:if="{{!item.isPast && item.dayStatus === 'full'}}" class="day-mark full">满</text>
@@ -0,0 +1,22 @@
# 规划页日期快速新增预约设计
## 目标
规划页视图入口按“月、周、日”排列。月视图和周视图中的日期点击统一改为快速新增预约,减少先进入日视图再点击新增的操作步骤。
## 交互
- 默认保持月视图,日视图仍可通过顶部“日”按钮进入。
- 点击月历或周视图中的今天、未来日期,直接进入新增预约页并预填所点日期。
- 当前筛选具体员工时一并传递员工 ID;“全部员工”状态下不预选员工。
- 历史日期禁止新增并显示明确提示;只读员工优先提示无新增权限。
- 月历中跨月显示的未来日期与本月日期行为一致。
- 右下角“+”按钮继续按当前规划日期和员工筛选条件进入新增预约。
## 技术边界
复用新增预约页已有的 `date`、`artistId` 查询参数,不修改后端接口、数据库、Nacos、后台管理或 ArtList。
## 验证
覆盖视图顺序、默认视图、月周快速新增、员工参数、全部员工、历史日期、只读权限、跨月未来日期和原“+”按钮行为。当前会话未提供 GitNexus `impact` 与 `detect_changes` 工具,使用静态引用检查、小程序测试和 Git 差异检查替代。