From eb1a41bfd159d3304823c2e8ac2fcb70c49c5f81 Mon Sep 17 00:00:00 2001 From: xiaowang <2161656029@qq.com> Date: Thu, 29 Oct 2026 21:01:01 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=84=E5=88=92=E9=A1=B5=E5=B9=B6=E6=8E=92?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=E5=BE=85=E5=88=86=E9=85=8D=E9=A2=84=E7=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- JC-Salon-WeChat/pages/planning/index.js | 83 ++++++++++++++++---- JC-Salon-WeChat/pages/planning/index.test.js | 34 ++++++++ JC-Salon-WeChat/pages/planning/index.wxml | 13 ++- JC-Salon-WeChat/pages/planning/index.wxss | 46 ++++++++++- docs/项目变更记录.md | 1 + 5 files changed, 157 insertions(+), 20 deletions(-) diff --git a/JC-Salon-WeChat/pages/planning/index.js b/JC-Salon-WeChat/pages/planning/index.js index 531ae68f..17488e10 100644 --- a/JC-Salon-WeChat/pages/planning/index.js +++ b/JC-Salon-WeChat/pages/planning/index.js @@ -47,6 +47,60 @@ function resolveAppointmentTimeText(item) { return `${startText}-${endText}` } +function layoutAppointmentBlocks(items, startMinute, minuteScale, laneHeaderHeight, defaultLaneWidth) { + const entries = (items || []) + .filter(item => item.startTime) + .map(item => { + const itemStart = resolveAppointmentStartMinute(item) + const requestedDuration = Number(item.durationMinutes || 60) + const duration = Math.max(15, Number.isFinite(requestedDuration) ? requestedDuration : 60) + return { ...item, itemStart, itemEnd: itemStart + duration, durationMinutes: duration } + }) + .sort((left, right) => left.itemStart - right.itemStart || left.itemEnd - right.itemEnd) + + const groups = [] + entries.forEach(entry => { + let group = groups[groups.length - 1] + if (!group || entry.itemStart >= group.end) { + group = { entries: [], end: entry.itemEnd, columnCount: 0 } + groups.push(group) + } + group.entries.push(entry) + group.end = Math.max(group.end, entry.itemEnd) + }) + + let maxColumns = 1 + groups.forEach(group => { + const columnEnds = [] + group.entries.forEach(entry => { + let columnIndex = columnEnds.findIndex(end => end <= entry.itemStart) + if (columnIndex < 0) columnIndex = columnEnds.length + columnEnds[columnIndex] = entry.itemEnd + entry.columnIndex = columnIndex + }) + group.columnCount = columnEnds.length + group.entries.forEach(entry => { entry.columnCount = group.columnCount }) + maxColumns = Math.max(maxColumns, group.columnCount) + }) + + const laneWidth = Math.max(defaultLaneWidth, maxColumns * defaultLaneWidth) + const blocks = entries.map(entry => { + const slotWidth = laneWidth / entry.columnCount + return { + ...entry, + top: Math.max(0, entry.itemStart - startMinute) * minuteScale + laneHeaderHeight, + height: entry.durationMinutes * minuteScale, + left: Math.round(entry.columnIndex * slotWidth + 12), + width: Math.round(slotWidth - 24), + compact: entry.durationMinutes <= 15, + overlapCount: entry.columnCount, + timeText: resolveAppointmentTimeText(entry) + } + }) + + return { blocks, laneWidth } +} + Page({ data: { viewMode: 'month', @@ -494,31 +548,30 @@ Page({ ...item, top: Math.max(0, itemStart - startMinute) * minuteScale + laneHeaderHeight, height: Math.max(60, (item.durationMinutes || 60) * minuteScale), + left: 12, + width: 224, compact: Number(item.durationMinutes || 60) <= 15, timeText: resolveAppointmentTimeText(item) } }) - return { ...artist, artistId: artist.id, blocks } + return { ...artist, artistId: artist.id, blocks, width: 248 } }) - const unassignedBlocks = dayAppointments - .filter(item => !item.artistId) - .filter(item => item.startTime) - .map(item => { - const itemStart = resolveAppointmentStartMinute(item) - return { - ...item, - top: Math.max(0, itemStart - startMinute) * minuteScale + laneHeaderHeight, - height: Math.max(60, (item.durationMinutes || 60) * minuteScale), - compact: Number(item.durationMinutes || 60) <= 15, - timeText: resolveAppointmentTimeText(item) - } - }) + const unassignedLayout = layoutAppointmentBlocks( + dayAppointments.filter(item => !item.artistId), + startMinute, + minuteScale, + laneHeaderHeight, + 248 + ) + const unassignedBlocks = unassignedLayout.blocks const lanes = this.data.selectedArtistId ? employeeLanes : [{ id: '__unassigned__', artistId: '__unassigned__', name: '待分配', color: '#D59A52', blocks: unassignedBlocks, + width: unassignedLayout.laneWidth, + isUnassigned: true, emptyText: '暂无待分配' }, ...employeeLanes] const pendingCount = dayAppointments.filter(item => item.status === 0).length @@ -528,7 +581,7 @@ Page({ timelineHeight: timelineHeight + laneHeaderHeight, laneHeaderHeight, laneItemWidth: 248, - laneWidth: Math.max(720, lanes.length * 248), + laneWidth: Math.max(720, lanes.reduce((width, lane) => width + (lane.width || 248), 0)), dayTotal: dayAppointments.length, freeArtistCount: employeeLanes.filter(item => item.blocks.every(block => block.historicalBackfill)).length, pendingCount, diff --git a/JC-Salon-WeChat/pages/planning/index.test.js b/JC-Salon-WeChat/pages/planning/index.test.js index 8bc6fbb1..21435ba1 100644 --- a/JC-Salon-WeChat/pages/planning/index.test.js +++ b/JC-Salon-WeChat/pages/planning/index.test.js @@ -76,6 +76,14 @@ async function run() { }) assert.strictEqual(monthDays.length, 42) assert.strictEqual(monthDays.some(item => item.artistCounts.some(count => count.artistId === '__unassigned__' && count.count === 1)), true) + assert.strictEqual(monthDays.find(item => item.unassignedCount === 1).unassignedCount, 1) + const weekStart = dateUtil.formatDate(dateUtil.startOfWeek(page.data.currentDateText)) + const weekDays = definition.buildWeekDays.call(page, { + artists: [{ id: 1, name: '美甲师', shortName: '员', color: '#000' }], + daySummaries: [{ date: weekStart, totalCount: 2, unassignedCount: 2, artistCounts: [] }] + }) + assert.strictEqual(weekDays[0].unassignedCount, 2) + assert.strictEqual(weekDays[0].artistCounts[0].artistId, '__unassigned__') const dayPage = createPage({ currentDateText: '2026-10-12', selectedArtistId: '' }) const dayState = dayPage.buildDayView({ @@ -104,6 +112,32 @@ async function run() { assert.match(planningWxml, /class="hour-line" style="top: \{\{hour\.top\}\}rpx;"/) assert.match(planningWxml, /class="time-label" style="top: \{\{item\.top\}\}rpx;"/) assert.match(planningWxss, /\.hour-line\s*\{[^}]*transform:\s*translateY\(-50%\);/) + const overlappingState = dayPage.buildDayView({ + businessStartTime: '10:00', + businessEndTime: '12:00', + artists: [{ id: 1, name: '美甲师', color: '#000' }], + appointments: [ + { orderItemId: 11, date: '2026-10-12', startTime: '2026-10-12 10:00:00', durationMinutes: 60, artistId: null }, + { orderItemId: 12, date: '2026-10-12', startTime: '2026-10-12 10:30:00', durationMinutes: 60, artistId: null }, + { orderItemId: 13, date: '2026-10-12', startTime: '2026-10-12 10:45:00', durationMinutes: 30, artistId: null }, + { orderItemId: 14, date: '2026-10-12', startTime: '2026-10-12 11:30:00', durationMinutes: 60, artistId: null } + ] + }) + assert.strictEqual(overlappingState.dayLanes[0].width, 744) + const overlappingBlocks = overlappingState.dayLanes[0].blocks + assert.deepStrictEqual(overlappingBlocks.map(block => block.left), [12, 260, 508, 12]) + assert.deepStrictEqual(overlappingBlocks.map(block => block.width), [224, 224, 224, 720]) + const overlaps = (left, right) => left.itemStart < right.itemEnd && right.itemStart < left.itemEnd + overlappingBlocks.slice(0, 3).forEach((left, index, blocks) => { + blocks.slice(index + 1).forEach(right => { + if (overlaps(left, right)) { + assert.ok(left.left + left.width <= right.left || right.left + right.width <= left.left) + } + }) + }) + assert.match(planningWxml, /class="lane-unassigned-tag">不占档期/) + assert.match(planningWxml, /class="week-unassigned-count">待分配 \{\{item\.unassignedCount\}\}/) + assert.match(planningWxml, /class="month-unassigned-count">待 \{\{item\.unassignedCount\}\}/) assert.doesNotMatch(planningWxss, /background-size:\s*100% 240rpx/) assert.match(planningWxss, /\.control-card\s*\{[^}]*padding:\s*8rpx 14rpx;/) diff --git a/JC-Salon-WeChat/pages/planning/index.wxml b/JC-Salon-WeChat/pages/planning/index.wxml index 103d4d13..f19d0841 100644 --- a/JC-Salon-WeChat/pages/planning/index.wxml +++ b/JC-Salon-WeChat/pages/planning/index.wxml @@ -90,13 +90,14 @@ - + {{item.name}} + 不占档期 - + {{block.customerName}} {{block.timeText}} · {{block.productTitle}} @@ -123,6 +124,7 @@ {{item.weekName}} {{item.day}} {{item.totalCount}}单 + 待分配 {{item.unassignedCount}} @@ -165,8 +167,11 @@ {{item.day}} - 满 - 休 + + 待 {{item.unassignedCount}} + 满 + 休 + diff --git a/JC-Salon-WeChat/pages/planning/index.wxss b/JC-Salon-WeChat/pages/planning/index.wxss index 929532cf..0acea536 100644 --- a/JC-Salon-WeChat/pages/planning/index.wxss +++ b/JC-Salon-WeChat/pages/planning/index.wxss @@ -347,6 +347,13 @@ background: #ffffff; } +.lane-unassigned-tag { + margin-left: auto; + color: #a56b24; + font-size: 17rpx; + font-weight: 600; +} + .hour-line { position: absolute; z-index: 0; @@ -375,7 +382,7 @@ .appointment-block { position: absolute; z-index: 1; - right: 12rpx; + right: auto; left: 12rpx; display: flex; flex-direction: column; @@ -392,6 +399,11 @@ transition: transform 160ms ease; } +.appointment-block.unassigned-block { + border-style: dashed; + background: #fff6e8; +} + .appointment-block:active { transform: scale(0.98); } @@ -400,6 +412,11 @@ background: #fff3f6; } +.appointment-block.unassigned-block.pending { + background: #fff6e8; + border-color: rgba(185, 111, 30, 0.18); +} + .block-title { color: #17211f; font-size: 22rpx; @@ -494,6 +511,18 @@ font-size: 22rpx; } +.week-unassigned-count { + display: inline-flex; + align-self: flex-start; + margin-top: 8rpx; + padding: 4rpx 8rpx; + border-radius: 6rpx; + background: #fff1dc; + color: #a56b24; + font-size: 18rpx; + font-weight: 800; +} + .week-date { margin: 8rpx 0; color: #17211f; @@ -723,6 +752,12 @@ min-height: 32rpx; } +.month-cell-badges { + display: flex; + align-items: center; + gap: 4rpx; +} + .month-day { color: #17211f; font-size: 22rpx; @@ -746,6 +781,15 @@ color: #8aaeca; } +.month-unassigned-count { + padding: 3rpx 6rpx; + border-radius: 5rpx; + background: #fff1dc; + color: #a56b24; + font-size: 16rpx; + font-weight: 800; +} + .month-bars { display: flex; flex-direction: column; diff --git a/docs/项目变更记录.md b/docs/项目变更记录.md index db0a2a64..d62b956d 100644 --- a/docs/项目变更记录.md +++ b/docs/项目变更记录.md @@ -5,6 +5,7 @@ - 规划日视图时间轴放大为每分钟4rpx,使30分钟预约卡片获得完整信息高度;收紧日期控制区和视图切换区的垂直留白。 - 日视图整点横线与时间标签共用同一组刻度数据逐条绘制,避免背景渐变重复间距造成偏移。 - 时间标签以刻度中心定位,横线同步居中绘制,确保视觉基准一致。 +- 未分配美甲师的预约在日视图待分配泳道按时间区间并排展示,不占用员工档期;月、周视图补充待分配数量标识。 - 客户新增姓名必填、微信号和手机号选填并按姓名/微信号/手机号排列;客户可重名或复用联系方式,仅姓名、微信号、手机号组合完全相同时禁止建档,联系方式匹配按密文解密后的精确值校验。 - 客户精确手机号匹配兼容历史未加密数据;新建美甲师微信号改为选填,店长微信号仍为必填。 - 修复日历映射员工专属颜色时遗漏 `StringUtils` 导入导致的 Core 编译失败。