规划页并排展示待分配预约
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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;/)
|
||||
|
||||
|
||||
@@ -90,13 +90,14 @@
|
||||
</view>
|
||||
<scroll-view class="lane-scroll" scroll-x enable-flex>
|
||||
<view class="lanes" style="height: {{timelineHeight}}rpx; width: {{laneWidth}}rpx;">
|
||||
<view wx:for="{{dayLanes}}" wx:key="artistId" class="artist-lane" style="height: {{timelineHeight}}rpx; width: {{laneItemWidth}}rpx;">
|
||||
<view wx:for="{{dayLanes}}" wx:key="artistId" class="artist-lane" style="height: {{timelineHeight}}rpx; width: {{item.width || laneItemWidth}}rpx;">
|
||||
<view class="lane-head">
|
||||
<view class="chip-dot" style="background: {{item.color}};"></view>
|
||||
<text>{{item.name}}</text>
|
||||
<text wx:if="{{item.isUnassigned}}" class="lane-unassigned-tag">不占档期</text>
|
||||
</view>
|
||||
<view wx:for="{{hours}}" wx:for-item="hour" wx:key="value" class="hour-line" style="top: {{hour.top}}rpx;"></view>
|
||||
<view wx:for="{{item.blocks}}" wx:for-item="block" wx:key="orderItemId" class="appointment-block {{block.status === 0 ? 'pending' : ''}} {{block.compact ? 'compact' : ''}}" style="top: {{block.top}}rpx; height: {{block.height}}rpx; border-left-color: {{item.color}};" data-id="{{block.orderItemId}}" bindtap="openAppointment">
|
||||
<view wx:for="{{item.blocks}}" wx:for-item="block" wx:key="orderItemId" class="appointment-block {{item.isUnassigned ? 'unassigned-block' : ''}} {{block.status === 0 ? 'pending' : ''}} {{block.compact ? 'compact' : ''}}" style="top: {{block.top}}rpx; left: {{block.left}}rpx; width: {{block.width}}rpx; height: {{block.height}}rpx; border-left-color: {{item.color}};" data-id="{{block.orderItemId}}" bindtap="openAppointment">
|
||||
<text class="block-title">{{block.customerName}}</text>
|
||||
<text class="block-meta">{{block.timeText}} · {{block.productTitle}}</text>
|
||||
<view class="block-footer">
|
||||
@@ -123,6 +124,7 @@
|
||||
<text class="week-name">{{item.weekName}}</text>
|
||||
<text class="week-date">{{item.day}}</text>
|
||||
<text class="week-total">{{item.totalCount}}单</text>
|
||||
<text wx:if="{{item.unassignedCount > 0}}" class="week-unassigned-count">待分配 {{item.unassignedCount}}</text>
|
||||
<view class="week-bars {{item.totalCount === 0 ? 'empty' : ''}}">
|
||||
<view wx:for="{{item.artistCounts}}" wx:for-item="count" wx:key="artistId" class="week-bar" style="background: {{count.color}}; width: {{count.width}}%;"></view>
|
||||
</view>
|
||||
@@ -165,8 +167,11 @@
|
||||
<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>
|
||||
<text wx:elif="{{!item.isPast && item.dayStatus === 'rest'}}" class="day-mark rest">休</text>
|
||||
<view class="month-cell-badges">
|
||||
<text wx:if="{{item.unassignedCount > 0}}" class="month-unassigned-count">待 {{item.unassignedCount}}</text>
|
||||
<text wx:if="{{!item.isPast && item.dayStatus === 'full'}}" class="day-mark full">满</text>
|
||||
<text wx:elif="{{!item.isPast && item.dayStatus === 'rest'}}" class="day-mark rest">休</text>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:if="{{monthDisplayMode === 'count'}}" class="month-bars">
|
||||
<view wx:for="{{item.artistCounts}}" wx:for-item="count" wx:key="artistId" wx:if="{{count.count > 0}}" class="month-artist-bar" style="background: {{count.color}};">
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
- 规划日视图时间轴放大为每分钟4rpx,使30分钟预约卡片获得完整信息高度;收紧日期控制区和视图切换区的垂直留白。
|
||||
- 日视图整点横线与时间标签共用同一组刻度数据逐条绘制,避免背景渐变重复间距造成偏移。
|
||||
- 时间标签以刻度中心定位,横线同步居中绘制,确保视觉基准一致。
|
||||
- 未分配美甲师的预约在日视图待分配泳道按时间区间并排展示,不占用员工档期;月、周视图补充待分配数量标识。
|
||||
- 客户新增姓名必填、微信号和手机号选填并按姓名/微信号/手机号排列;客户可重名或复用联系方式,仅姓名、微信号、手机号组合完全相同时禁止建档,联系方式匹配按密文解密后的精确值校验。
|
||||
- 客户精确手机号匹配兼容历史未加密数据;新建美甲师微信号改为选填,店长微信号仍为必填。
|
||||
- 修复日历映射员工专属颜色时遗漏 `StringUtils` 导入导致的 Core 编译失败。
|
||||
|
||||
Reference in New Issue
Block a user