diff --git a/JC-Salon-WeChat/pages/planning/index.js b/JC-Salon-WeChat/pages/planning/index.js index 4e93a4ff..abb3ee04 100644 --- a/JC-Salon-WeChat/pages/planning/index.js +++ b/JC-Salon-WeChat/pages/planning/index.js @@ -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) { diff --git a/JC-Salon-WeChat/pages/planning/index.test.js b/JC-Salon-WeChat/pages/planning/index.test.js index f3007179..4682b513 100644 --- a/JC-Salon-WeChat/pages/planning/index.test.js +++ b/JC-Salon-WeChat/pages/planning/index.test.js @@ -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 => { diff --git a/JC-Salon-WeChat/pages/planning/index.wxml b/JC-Salon-WeChat/pages/planning/index.wxml index 6f2ec1e4..7103e842 100644 --- a/JC-Salon-WeChat/pages/planning/index.wxml +++ b/JC-Salon-WeChat/pages/planning/index.wxml @@ -99,7 +99,7 @@ - + {{item.weekName}} {{item.day}} {{item.totalCount}}单 @@ -140,7 +140,7 @@ {{item}} - + {{item.day}} 满 diff --git a/docs/superpowers/specs/2026-10-12-规划页日期快速新增预约-design.md b/docs/superpowers/specs/2026-10-12-规划页日期快速新增预约-design.md new file mode 100644 index 00000000..fe3cefed --- /dev/null +++ b/docs/superpowers/specs/2026-10-12-规划页日期快速新增预约-design.md @@ -0,0 +1,22 @@ +# 规划页日期快速新增预约设计 + +## 目标 + +规划页视图入口按“月、周、日”排列。月视图和周视图中的日期点击统一改为快速新增预约,减少先进入日视图再点击新增的操作步骤。 + +## 交互 + +- 默认保持月视图,日视图仍可通过顶部“日”按钮进入。 +- 点击月历或周视图中的今天、未来日期,直接进入新增预约页并预填所点日期。 +- 当前筛选具体员工时一并传递员工 ID;“全部员工”状态下不预选员工。 +- 历史日期禁止新增并显示明确提示;只读员工优先提示无新增权限。 +- 月历中跨月显示的未来日期与本月日期行为一致。 +- 右下角“+”按钮继续按当前规划日期和员工筛选条件进入新增预约。 + +## 技术边界 + +复用新增预约页已有的 `date`、`artistId` 查询参数,不修改后端接口、数据库、Nacos、后台管理或 ArtList。 + +## 验证 + +覆盖视图顺序、默认视图、月周快速新增、员工参数、全部员工、历史日期、只读权限、跨月未来日期和原“+”按钮行为。当前会话未提供 GitNexus `impact` 与 `detect_changes` 工具,使用静态引用检查、小程序测试和 Git 差异检查替代。