区分预约完成和取消状态标识
This commit is contained in:
@@ -41,6 +41,34 @@ function resolveAppointmentTimeText(item) {
|
||||
return `${startText}-${endText}`
|
||||
}
|
||||
|
||||
function isCompletedStatus(status) {
|
||||
return Number(status) === 2
|
||||
}
|
||||
|
||||
function isCancelledStatus(status) {
|
||||
return Number(status) === 3
|
||||
}
|
||||
|
||||
function appointmentStatusClass(status) {
|
||||
if (isCompletedStatus(status)) return 'is-completed'
|
||||
if (isCancelledStatus(status)) return 'is-cancelled'
|
||||
if (Number(status) === 0) return 'pending'
|
||||
return ''
|
||||
}
|
||||
|
||||
function completedOrCancelledClass(status) {
|
||||
if (isCompletedStatus(status)) return 'is-completed'
|
||||
if (isCancelledStatus(status)) return 'is-cancelled'
|
||||
return ''
|
||||
}
|
||||
|
||||
function resolveDayStatusClass(items) {
|
||||
if (!items.length) return ''
|
||||
if (items.every(item => isCompletedStatus(item.status))) return 'is-completed'
|
||||
if (items.every(item => isCancelledStatus(item.status))) return 'is-cancelled'
|
||||
return ''
|
||||
}
|
||||
|
||||
Page({
|
||||
data: {
|
||||
viewMode: 'month',
|
||||
@@ -272,7 +300,10 @@ Page({
|
||||
}))
|
||||
return dateUtil.monthGrid(this.data.currentDateText).map(day => {
|
||||
const summary = summaryMap[day.date] || {}
|
||||
const artistCounts = this.normalizeArtistCounts(summary.artistCounts || artistTemplate)
|
||||
const dayAppointments = this.appointmentsByDate(day.date)
|
||||
const artistCounts = dayAppointments.length
|
||||
? this.appointmentCountsByDate(day.date)
|
||||
: this.normalizeArtistCounts(summary.artistCounts || artistTemplate)
|
||||
return {
|
||||
...day,
|
||||
isPast: day.date < todayText,
|
||||
@@ -280,7 +311,8 @@ Page({
|
||||
dayStatus: summary.dayStatus || 'free',
|
||||
artistCounts,
|
||||
expandedBlocks: this.buildExpandedBlocks(artistCounts),
|
||||
rowBlocks: this.buildRowBlocks(artistCounts)
|
||||
rowBlocks: this.buildRowBlocks(artistCounts),
|
||||
statusClass: resolveDayStatusClass(dayAppointments)
|
||||
}
|
||||
})
|
||||
},
|
||||
@@ -292,12 +324,14 @@ Page({
|
||||
const target = dateUtil.addDays(start, index)
|
||||
const date = dateUtil.formatDate(target)
|
||||
const summary = summaryMap[date] || { artistCounts: [], totalCount: 0 }
|
||||
const artistCounts = this.normalizeArtistCounts(summary.artistCounts || []).filter(count => count.count > 0)
|
||||
const dayAppointments = this.appointmentsByDate(date)
|
||||
const artistCounts = (dayAppointments.length ? this.appointmentCountsByDate(date) : this.normalizeArtistCounts(summary.artistCounts || [])).filter(count => count.count > 0)
|
||||
return {
|
||||
date,
|
||||
weekName: `周${label}`,
|
||||
day: target.getDate(),
|
||||
totalCount: summary.totalCount || 0,
|
||||
statusClass: resolveDayStatusClass(dayAppointments),
|
||||
artistCounts: artistCounts.map(count => ({
|
||||
...count,
|
||||
width: Math.max(12, Math.min(100, count.count * 22)),
|
||||
@@ -333,7 +367,8 @@ Page({
|
||||
...item,
|
||||
top: Math.max(0, itemStart - startMinute) + laneHeaderHeight,
|
||||
height: Math.max(64, item.durationMinutes || 60),
|
||||
timeText: resolveAppointmentTimeText(item)
|
||||
timeText: resolveAppointmentTimeText(item),
|
||||
statusClass: appointmentStatusClass(item.status)
|
||||
}
|
||||
})
|
||||
return { ...artist, blocks }
|
||||
@@ -359,6 +394,41 @@ Page({
|
||||
}, {})
|
||||
},
|
||||
|
||||
appointmentsByDate(date) {
|
||||
return (this.data.appointments || []).filter(item => resolveAppointmentDate(item) === date)
|
||||
},
|
||||
|
||||
appointmentCountsByDate(date) {
|
||||
const artistMap = (this.data.artists || []).reduce((map, artist) => {
|
||||
map[String(artist.id)] = artist
|
||||
return map
|
||||
}, {})
|
||||
const grouped = new Map()
|
||||
this.appointmentsByDate(date).forEach((item, index) => {
|
||||
const artist = artistMap[String(item.artistId)] || {}
|
||||
const artistName = item.artistName || artist.name
|
||||
const statusClass = completedOrCancelledClass(item.status)
|
||||
const key = `${String(item.artistId || item.orderItemId)}-${statusClass || 'active'}`
|
||||
const existing = grouped.get(key)
|
||||
if (existing) {
|
||||
grouped.set(key, { ...existing, count: existing.count + 1 })
|
||||
} else {
|
||||
grouped.set(key, {
|
||||
key: `${key}-${index}`,
|
||||
orderItemId: item.orderItemId,
|
||||
artistId: item.artistId || item.orderItemId,
|
||||
artistName,
|
||||
shortName: artist.shortName || String(artistName || '?').slice(0, 1),
|
||||
color: artist.color || '#B8B0A6',
|
||||
count: 1,
|
||||
status: item.status,
|
||||
statusClass
|
||||
})
|
||||
}
|
||||
})
|
||||
return Array.from(grouped.values())
|
||||
},
|
||||
|
||||
normalizeArtistCounts(counts) {
|
||||
const colorMap = this.data.artists.reduce((map, artist) => {
|
||||
map[artist.id] = artist
|
||||
@@ -368,6 +438,7 @@ Page({
|
||||
const artist = colorMap[count.artistId] || {}
|
||||
return {
|
||||
...count,
|
||||
key: `${String(count.artistId)}-${count.status || 'summary'}`,
|
||||
color: count.color || artist.color || '#B8B0A6',
|
||||
shortName: count.shortName || artist.shortName || '?',
|
||||
count: Number(count.count || 0)
|
||||
@@ -379,10 +450,11 @@ Page({
|
||||
return (artistCounts || []).reduce((blocks, count) => {
|
||||
for (let index = 0; index < Number(count.count || 0); index += 1) {
|
||||
blocks.push({
|
||||
key: `${count.artistId || count.shortName}-${index}`,
|
||||
key: count.key ? `${count.key}-${index}` : `${count.artistId || count.shortName}-${index}`,
|
||||
artistId: count.artistId,
|
||||
color: count.color,
|
||||
shortName: count.shortName
|
||||
shortName: count.shortName,
|
||||
statusClass: count.statusClass
|
||||
})
|
||||
}
|
||||
return blocks
|
||||
@@ -393,11 +465,12 @@ Page({
|
||||
return (artistCounts || []).reduce((rows, count) => {
|
||||
for (let index = 0; index < Number(count.count || 0); index += 1) {
|
||||
rows.push({
|
||||
key: `${count.artistId || count.shortName}-row-${index}`,
|
||||
key: count.key ? `${count.key}-row-${index}` : `${count.artistId || count.shortName}-row-${index}`,
|
||||
artistId: count.artistId,
|
||||
color: count.color,
|
||||
shortName: count.shortName,
|
||||
artistName: count.artistName || count.shortName
|
||||
artistName: count.artistName || count.shortName,
|
||||
statusClass: count.statusClass
|
||||
})
|
||||
}
|
||||
return rows
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
<view class="chip-dot" style="background: {{item.color}};"></view>
|
||||
<text>{{item.name}}</text>
|
||||
</view>
|
||||
<view wx:for="{{item.blocks}}" wx:for-item="block" wx:key="orderItemId" class="appointment-block {{block.status === 0 ? 'pending' : ''}}" 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 {{block.statusClass}}" style="top: {{block.top}}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>
|
||||
<text class="block-status">{{block.statusText}}</text>
|
||||
@@ -78,12 +78,12 @@
|
||||
|
||||
<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' : ''}} {{item.statusClass}}" data-date="{{item.date}}" bindtap="selectDate">
|
||||
<text class="week-name">{{item.weekName}}</text>
|
||||
<text class="week-date">{{item.day}}</text>
|
||||
<text class="week-total">{{item.totalCount}}单</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 wx:for="{{item.artistCounts}}" wx:for-item="count" wx:key="key" class="week-bar {{count.statusClass}}" style="background: {{count.color}}; width: {{count.width}}%;"></view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
@@ -95,7 +95,7 @@
|
||||
<view wx:for="{{weekDays}}" wx:key="date" class="week-line">
|
||||
<view class="week-line-date">{{item.weekName}} {{item.day}}</view>
|
||||
<view class="week-line-bars {{item.totalCount === 0 ? 'empty' : ''}}">
|
||||
<view wx:for="{{item.artistCounts}}" wx:for-item="count" wx:key="artistId" class="week-count-bar" style="background: {{count.color}}; width: {{count.barWidth}}%;">
|
||||
<view wx:for="{{item.artistCounts}}" wx:for-item="count" wx:key="key" class="week-count-bar {{count.statusClass}}" style="background: {{count.color}}; width: {{count.barWidth}}%;">
|
||||
<text>{{count.shortName}}{{count.count}}</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -126,18 +126,18 @@
|
||||
<text wx:elif="{{!item.isPast && item.dayStatus === 'rest'}}" class="day-mark rest">休</text>
|
||||
</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}};">
|
||||
<view wx:for="{{item.artistCounts}}" wx:for-item="count" wx:key="key" wx:if="{{count.count > 0}}" class="month-artist-bar {{count.statusClass}}" style="background: {{count.color}};">
|
||||
<text>{{count.shortName}}{{count.count}}</text>
|
||||
</view>
|
||||
<view wx:if="{{item.totalCount === 0}}" class="month-empty">空</view>
|
||||
</view>
|
||||
<view wx:else class="month-blocks">
|
||||
<block wx:if="{{monthDisplayMode === 'blocks'}}">
|
||||
<view wx:for="{{item.expandedBlocks}}" wx:for-item="block" wx:key="key" class="month-order-block" style="background: {{block.color}};"></view>
|
||||
<view wx:for="{{item.expandedBlocks}}" wx:for-item="block" wx:key="key" class="month-order-block {{block.statusClass}}" style="background: {{block.color}};"></view>
|
||||
<view wx:if="{{item.totalCount === 0}}" class="month-empty">空</view>
|
||||
</block>
|
||||
<block wx:else>
|
||||
<view wx:for="{{item.rowBlocks}}" wx:for-item="block" wx:key="key" class="month-row-block {{monthRowLabelVisible ? 'named' : ''}}" style="background: {{block.color}};">
|
||||
<view wx:for="{{item.rowBlocks}}" wx:for-item="block" wx:key="key" class="month-row-block {{monthRowLabelVisible ? 'named' : ''}} {{block.statusClass}}" style="background: {{block.color}};">
|
||||
<text wx:if="{{monthRowLabelVisible}}">{{block.artistName}}</text>
|
||||
</view>
|
||||
<view wx:if="{{item.totalCount === 0}}" class="month-empty">空</view>
|
||||
|
||||
@@ -307,6 +307,41 @@
|
||||
background: #fff3f6;
|
||||
}
|
||||
|
||||
.appointment-block.is-completed {
|
||||
background: #f5fff7;
|
||||
border-color: #c8ead1;
|
||||
}
|
||||
|
||||
.appointment-block.is-cancelled {
|
||||
background: #fff5f6;
|
||||
border-color: #e8c7cc;
|
||||
}
|
||||
|
||||
.appointment-block.is-completed::after,
|
||||
.appointment-block.is-cancelled::after,
|
||||
.week-day-card.is-completed::after,
|
||||
.week-day-card.is-cancelled::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
right: 14rpx;
|
||||
left: 14rpx;
|
||||
border-top: 5rpx solid;
|
||||
transform: rotate(-15deg);
|
||||
transform-origin: center;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.appointment-block.is-completed::after,
|
||||
.week-day-card.is-completed::after {
|
||||
border-color: rgba(69, 130, 91, 0.78);
|
||||
}
|
||||
|
||||
.appointment-block.is-cancelled::after,
|
||||
.week-day-card.is-cancelled::after {
|
||||
border-color: rgba(198, 78, 91, 0.8);
|
||||
}
|
||||
|
||||
.block-title {
|
||||
color: #2c2823;
|
||||
font-size: 24rpx;
|
||||
@@ -339,6 +374,7 @@
|
||||
}
|
||||
|
||||
.week-day-card {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
flex-direction: column;
|
||||
width: 148rpx;
|
||||
@@ -347,6 +383,16 @@
|
||||
padding: 16rpx;
|
||||
}
|
||||
|
||||
.week-day-card.is-completed {
|
||||
background: #f5fff7;
|
||||
border-color: #c8ead1;
|
||||
}
|
||||
|
||||
.week-day-card.is-cancelled {
|
||||
background: #fff5f6;
|
||||
border-color: #e8c7cc;
|
||||
}
|
||||
|
||||
.week-day-card.active {
|
||||
outline: 3rpx solid #8fb89a;
|
||||
}
|
||||
@@ -377,6 +423,7 @@
|
||||
}
|
||||
|
||||
.week-bar {
|
||||
position: relative;
|
||||
height: 8rpx;
|
||||
border-radius: 999rpx;
|
||||
}
|
||||
@@ -422,6 +469,7 @@
|
||||
}
|
||||
|
||||
.week-count-bar {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-width: 58rpx;
|
||||
@@ -433,6 +481,65 @@
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.week-bar.is-completed::after,
|
||||
.week-bar.is-cancelled::after,
|
||||
.week-count-bar.is-completed::after,
|
||||
.week-count-bar.is-cancelled::after,
|
||||
.month-artist-bar.is-completed::after,
|
||||
.month-artist-bar.is-cancelled::after,
|
||||
.month-order-block.is-completed::after,
|
||||
.month-order-block.is-cancelled::after,
|
||||
.month-row-block.is-completed::after,
|
||||
.month-row-block.is-cancelled::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
right: 4rpx;
|
||||
left: 4rpx;
|
||||
border-top: 3rpx solid rgba(255, 255, 255, 0.92);
|
||||
transform: rotate(-15deg);
|
||||
transform-origin: center;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.week-bar.is-completed::before,
|
||||
.week-bar.is-cancelled::before,
|
||||
.week-count-bar.is-completed::before,
|
||||
.week-count-bar.is-cancelled::before,
|
||||
.month-artist-bar.is-completed::before,
|
||||
.month-artist-bar.is-cancelled::before,
|
||||
.month-order-block.is-completed::before,
|
||||
.month-order-block.is-cancelled::before,
|
||||
.month-row-block.is-completed::before,
|
||||
.month-row-block.is-cancelled::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
right: 4rpx;
|
||||
left: 4rpx;
|
||||
z-index: 1;
|
||||
border-top: 2rpx solid;
|
||||
transform: rotate(-15deg);
|
||||
transform-origin: center;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.week-bar.is-completed::before,
|
||||
.week-count-bar.is-completed::before,
|
||||
.month-artist-bar.is-completed::before,
|
||||
.month-order-block.is-completed::before,
|
||||
.month-row-block.is-completed::before {
|
||||
border-color: rgba(69, 130, 91, 0.9);
|
||||
}
|
||||
|
||||
.week-bar.is-cancelled::before,
|
||||
.week-count-bar.is-cancelled::before,
|
||||
.month-artist-bar.is-cancelled::before,
|
||||
.month-order-block.is-cancelled::before,
|
||||
.month-row-block.is-cancelled::before {
|
||||
border-color: rgba(198, 78, 91, 0.92);
|
||||
}
|
||||
|
||||
.month-card {
|
||||
overflow: hidden;
|
||||
}
|
||||
@@ -607,6 +714,7 @@
|
||||
}
|
||||
|
||||
.month-artist-bar {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
@@ -631,6 +739,7 @@
|
||||
}
|
||||
|
||||
.month-order-block {
|
||||
position: relative;
|
||||
width: 22rpx;
|
||||
height: 12rpx;
|
||||
border-radius: 999rpx;
|
||||
@@ -638,6 +747,7 @@
|
||||
}
|
||||
|
||||
.month-row-block {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
Reference in New Issue
Block a user