区分预约完成和取消状态标识
This commit is contained in:
@@ -243,7 +243,11 @@ const timeRange = (item: ArtistCalendarAppointment) => `${formatClock(item.appoi
|
||||
/** weekText is a local helper used by this page script. */
|
||||
const weekText = (key: string) => ['周日', '周一', '周二', '周三', '周四', '周五', '周六'][new Date(`${key}T00:00:00`).getDay()] || ''
|
||||
/** statusClass is a local helper used by this page script. */
|
||||
const statusClass = (status: number) => status === 2 ? 'is-completed' : 'is-pending'
|
||||
const statusClass = (status: number) => {
|
||||
if (status === 2) return 'is-completed'
|
||||
if (status === 3) return 'is-cancelled'
|
||||
return 'is-pending'
|
||||
}
|
||||
|
||||
onMounted(loadAppointments)
|
||||
</script>
|
||||
@@ -267,9 +271,13 @@ onMounted(loadAppointments)
|
||||
.day-label strong { font-size: 20px; }
|
||||
.day-label span, .day-label em { color: var(--text-secondary); font-style: normal; font-size: 12px; }
|
||||
.day-line { position: relative; display: grid; gap: 10px; padding-left: 18px; border-left: 2px solid var(--theme-border); }
|
||||
.appointment-block { width: 100%; display: grid; gap: 5px; padding: 14px 16px; border: 1px solid var(--theme-border); border-radius: 8px; background: var(--theme-card-bg); text-align: left; color: var(--text-primary); box-shadow: 0 10px 22px color-mix(in srgb, var(--theme-primary) 8%, transparent); cursor: pointer; transition: transform .18s ease, border-color .18s ease; }
|
||||
.appointment-block { position: relative; width: 100%; display: grid; gap: 5px; overflow: hidden; padding: 14px 16px; border: 1px solid var(--theme-border); border-radius: 8px; background: var(--theme-card-bg); text-align: left; color: var(--text-primary); box-shadow: 0 10px 22px color-mix(in srgb, var(--theme-primary) 8%, transparent); cursor: pointer; transition: transform .18s ease, border-color .18s ease; }
|
||||
.appointment-block:hover { transform: translateY(-2px); border-color: var(--theme-primary); }
|
||||
.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 { content: ""; position: absolute; right: 10px; left: 10px; top: 50%; border-top: 3px solid; pointer-events: none; transform: rotate(-10deg); transform-origin: center; }
|
||||
.appointment-block.is-completed::after { border-color: rgba(69, 130, 91, 0.78); }
|
||||
.appointment-block.is-cancelled::after { border-color: rgba(198, 78, 91, 0.8); }
|
||||
.appointment-block .time { color: var(--theme-primary); font-weight: 700; }
|
||||
.appointment-block small { color: var(--text-secondary); }
|
||||
.detail-body { display: grid; gap: 18px; }
|
||||
|
||||
@@ -14,12 +14,14 @@ function formatClock(value) {
|
||||
}
|
||||
|
||||
function formatAppointment(item) {
|
||||
const orderStatus = Number(item.orderStatus)
|
||||
return {
|
||||
...item,
|
||||
dayText: String(item.appointmentStartTime || '').slice(5, 10),
|
||||
timeText: `${formatClock(item.appointmentStartTime)}-${formatClock(item.appointmentEndTime)}`,
|
||||
amountText: `¥${formatPrice(item.actualAmount || item.totalAmount)}`,
|
||||
dateTimeText: formatDateTime(item.appointmentStartTime)
|
||||
dateTimeText: formatDateTime(item.appointmentStartTime),
|
||||
statusClass: orderStatus === 2 ? 'is-completed' : (orderStatus === 3 ? 'is-cancelled' : '')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
</view>
|
||||
|
||||
<view wx:elif="{{appointments.length}}">
|
||||
<view wx:for="{{appointments}}" wx:key="orderItemId" class="page-card appointment-card">
|
||||
<view wx:for="{{appointments}}" wx:key="orderItemId" class="page-card appointment-card {{item.statusClass}}">
|
||||
<view class="day-box">
|
||||
<text>{{item.dayText}}</text>
|
||||
<text>{{item.timeText}}</text>
|
||||
|
||||
@@ -1,10 +1,43 @@
|
||||
.appointment-card {
|
||||
position: relative;
|
||||
display: flex;
|
||||
gap: 18rpx;
|
||||
overflow: hidden;
|
||||
margin-top: 22rpx;
|
||||
padding: 24rpx;
|
||||
}
|
||||
|
||||
.appointment-card.is-completed {
|
||||
background: #f5fff7;
|
||||
border-color: #c8ead1;
|
||||
}
|
||||
|
||||
.appointment-card.is-cancelled {
|
||||
background: #fff5f6;
|
||||
border-color: #e8c7cc;
|
||||
}
|
||||
|
||||
.appointment-card.is-completed::after,
|
||||
.appointment-card.is-cancelled::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
right: 20rpx;
|
||||
left: 20rpx;
|
||||
border-top: 5rpx solid;
|
||||
transform: rotate(-10deg);
|
||||
transform-origin: center;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.appointment-card.is-completed::after {
|
||||
border-color: rgba(69, 130, 91, 0.78);
|
||||
}
|
||||
|
||||
.appointment-card.is-cancelled::after {
|
||||
border-color: rgba(198, 78, 91, 0.8);
|
||||
}
|
||||
|
||||
.day-box {
|
||||
width: 136rpx;
|
||||
flex: 0 0 auto;
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
v-for="block in lane.blocks"
|
||||
:key="String(block.orderItemId)"
|
||||
class="appointment-block"
|
||||
:class="{ pending: block.status === 0 }"
|
||||
:class="appointmentStatusClass(block.status)"
|
||||
type="button"
|
||||
:style="{ top: `${block.top}px`, height: `${block.height}px`, borderLeftColor: lane.color || '#b8b0a6' }"
|
||||
@click="openAppointment(block.orderItemId)"
|
||||
@@ -88,7 +88,7 @@
|
||||
v-for="day in weekDays"
|
||||
:key="day.date"
|
||||
class="card week-day-card"
|
||||
:class="{ active: day.date === currentDateText }"
|
||||
:class="[{ active: day.date === currentDateText }, day.statusClass]"
|
||||
type="button"
|
||||
@click="selectDate(day.date)"
|
||||
>
|
||||
@@ -109,6 +109,7 @@
|
||||
v-for="count in day.artistCounts"
|
||||
:key="String(count.artistId)"
|
||||
class="week-count-bar"
|
||||
:class="count.statusClass"
|
||||
:style="{ width: `${count.barWidth}%`, backgroundColor: count.color }"
|
||||
>
|
||||
{{ count.shortName }}{{ count.count }}
|
||||
@@ -147,18 +148,18 @@
|
||||
<span v-if="!day.isPast && day.totalCount > 0 && day.dayStatus === 'full'" class="day-mark full">满</span>
|
||||
<span v-else-if="!day.isPast && day.totalCount > 0 && day.dayStatus === 'rest'" class="day-mark rest">休</span>
|
||||
<div v-if="monthDisplayMode === 'count'" class="month-bars">
|
||||
<span v-for="count in day.artistCounts.filter(item => item.count > 0)" :key="String(count.artistId)" :style="{ backgroundColor: count.color }">
|
||||
<span v-for="count in day.artistCounts.filter(item => item.count > 0)" :key="count.key || String(count.artistId)" :class="count.statusClass" :style="{ backgroundColor: count.color }">
|
||||
<b>{{ resolveMonthCountName(count) }}</b>
|
||||
<em>{{ count.count }}</em>
|
||||
</span>
|
||||
<small v-if="day.totalCount === 0">空</small>
|
||||
</div>
|
||||
<div v-else-if="monthDisplayMode === 'blocks'" class="month-blocks">
|
||||
<span v-for="block in day.expandedBlocks" :key="block.key" :style="{ backgroundColor: block.color }"></span>
|
||||
<span v-for="block in day.expandedBlocks" :key="block.key" :class="block.statusClass" :style="{ backgroundColor: block.color }"></span>
|
||||
<small v-if="day.totalCount === 0">空</small>
|
||||
</div>
|
||||
<div v-else class="month-blocks month-blocks--rows">
|
||||
<span v-for="block in day.rowBlocks" :key="block.key" :style="{ backgroundColor: block.color }">{{ monthRowLabelVisible ? block.artistName : '' }}</span>
|
||||
<span v-for="block in day.rowBlocks" :key="block.key" :class="block.statusClass" :style="{ backgroundColor: block.color }">{{ monthRowLabelVisible ? block.artistName : '' }}</span>
|
||||
<small v-if="day.totalCount === 0">空</small>
|
||||
</div>
|
||||
</button>
|
||||
@@ -205,12 +206,15 @@ type ViewMode = 'day' | 'week' | 'month'
|
||||
type MonthDisplayMode = 'count' | 'blocks' | 'rows'
|
||||
|
||||
interface NormalizedCount {
|
||||
key?: string
|
||||
artistId: IdType
|
||||
artistName?: string
|
||||
shortName?: string
|
||||
color: string
|
||||
count: number
|
||||
status?: string
|
||||
statusClass?: string
|
||||
orderItemId?: IdType
|
||||
width?: number
|
||||
barWidth?: number
|
||||
}
|
||||
@@ -221,6 +225,7 @@ interface MonthBlock {
|
||||
color: string
|
||||
shortName?: string
|
||||
artistName?: string
|
||||
statusClass?: string
|
||||
}
|
||||
|
||||
interface MonthDay {
|
||||
@@ -233,6 +238,7 @@ interface MonthDay {
|
||||
artistCounts: NormalizedCount[]
|
||||
expandedBlocks: MonthBlock[]
|
||||
rowBlocks: MonthBlock[]
|
||||
statusClass: string
|
||||
}
|
||||
|
||||
interface WeekDay {
|
||||
@@ -241,6 +247,7 @@ interface WeekDay {
|
||||
day: number
|
||||
totalCount: number
|
||||
artistCounts: NormalizedCount[]
|
||||
statusClass: string
|
||||
}
|
||||
|
||||
interface DayLane extends Artist {
|
||||
@@ -302,6 +309,64 @@ const resolveRange = (): { start: string; end: string } => {
|
||||
return { start: currentDateText.value, end: currentDateText.value }
|
||||
}
|
||||
|
||||
const isCompletedStatus = (status?: number | string): boolean => Number(status) === 2
|
||||
const isCancelledStatus = (status?: number | string): boolean => Number(status) === 3
|
||||
|
||||
const appointmentStatusClass = (status?: number | string): string => {
|
||||
if (isCompletedStatus(status)) return 'is-completed'
|
||||
if (isCancelledStatus(status)) return 'is-cancelled'
|
||||
if (Number(status) === 0) return 'pending'
|
||||
return ''
|
||||
}
|
||||
|
||||
const completedOrCancelledClass = (status?: number | string): string => {
|
||||
if (isCompletedStatus(status)) return 'is-completed'
|
||||
if (isCancelledStatus(status)) return 'is-cancelled'
|
||||
return ''
|
||||
}
|
||||
|
||||
const resolveDayStatusClass = (items: Appointment[]): string => {
|
||||
if (items.length === 0) return ''
|
||||
if (items.every(item => isCompletedStatus(item.status))) return 'is-completed'
|
||||
if (items.every(item => isCancelledStatus(item.status))) return 'is-cancelled'
|
||||
return ''
|
||||
}
|
||||
|
||||
const appointmentsByDate = (date: string): Appointment[] => appointments.value.filter(item => resolveAppointmentDate(item) === date)
|
||||
|
||||
const appointmentCountsByDate = (date: string): NormalizedCount[] => {
|
||||
const dayItems = appointmentsByDate(date)
|
||||
const artistMap = artists.value.reduce<Record<string, Artist>>((result, artist) => {
|
||||
result[String(resolveArtistUserId(artist))] = artist
|
||||
return result
|
||||
}, {})
|
||||
const grouped = new Map<string, NormalizedCount>()
|
||||
dayItems.forEach((item, index) => {
|
||||
const artist = artistMap[String(item.artistId)]
|
||||
const artistName = item.artistName || artist?.name
|
||||
const shortName = artist?.shortName || String(artistName || '?').slice(0, 1)
|
||||
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,
|
||||
color: artist?.color || '#b8b0a6',
|
||||
count: 1,
|
||||
status: String(item.status ?? ''),
|
||||
statusClass
|
||||
})
|
||||
}
|
||||
})
|
||||
return Array.from(grouped.values())
|
||||
}
|
||||
|
||||
const normalizeArtistCounts = (counts: NonNullable<DaySummary['artistCounts']>): NormalizedCount[] => {
|
||||
const artistMap = artists.value.reduce<Record<string, Artist>>((result, artist) => {
|
||||
result[String(resolveArtistUserId(artist))] = artist
|
||||
@@ -310,6 +375,7 @@ const normalizeArtistCounts = (counts: NonNullable<DaySummary['artistCounts']>):
|
||||
return counts.map(count => {
|
||||
const artist = artistMap[String(count.artistId)]
|
||||
return {
|
||||
key: `${String(count.artistId)}-${count.status || 'summary'}`,
|
||||
artistId: count.artistId,
|
||||
artistName: count.artistName || artist?.name,
|
||||
shortName: count.shortName || artist?.shortName || String(count.artistName || artist?.name || '?').slice(0, 1),
|
||||
@@ -322,11 +388,12 @@ const normalizeArtistCounts = (counts: NonNullable<DaySummary['artistCounts']>):
|
||||
|
||||
const buildExpandedBlocks = (counts: NormalizedCount[]): MonthBlock[] => {
|
||||
return counts.flatMap(count => Array.from({ length: count.count }, (_item, index) => ({
|
||||
key: `${count.artistId}-${index}`,
|
||||
key: count.key ? `${count.key}-${index}` : `${count.artistId}-${index}`,
|
||||
artistId: count.artistId,
|
||||
color: count.color,
|
||||
shortName: count.shortName,
|
||||
artistName: count.artistName
|
||||
artistName: count.artistName,
|
||||
statusClass: count.statusClass
|
||||
})))
|
||||
}
|
||||
|
||||
@@ -348,7 +415,10 @@ const buildMonthDays = (): MonthDay[] => {
|
||||
}))
|
||||
return monthGrid(currentDateText.value).map(day => {
|
||||
const summary = map[day.date]
|
||||
const artistCounts = normalizeArtistCounts(summary?.artistCounts || artistTemplate)
|
||||
const dayAppointments = appointmentsByDate(day.date)
|
||||
const artistCounts = dayAppointments.length > 0
|
||||
? appointmentCountsByDate(day.date)
|
||||
: normalizeArtistCounts(summary?.artistCounts || artistTemplate)
|
||||
return {
|
||||
...day,
|
||||
isPast: day.date < todayText,
|
||||
@@ -356,7 +426,8 @@ const buildMonthDays = (): MonthDay[] => {
|
||||
dayStatus: summary?.dayStatus || 'free',
|
||||
artistCounts,
|
||||
expandedBlocks: buildExpandedBlocks(artistCounts),
|
||||
rowBlocks: buildExpandedBlocks(artistCounts)
|
||||
rowBlocks: buildExpandedBlocks(artistCounts),
|
||||
statusClass: resolveDayStatusClass(dayAppointments)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -368,14 +439,15 @@ const buildWeekDays = (): WeekDay[] => {
|
||||
const target = addDays(start, index)
|
||||
const date = formatDate(target)
|
||||
const summary = map[date]
|
||||
const counts = normalizeArtistCounts(summary?.artistCounts || [])
|
||||
const dayAppointments = appointmentsByDate(date)
|
||||
const counts = (dayAppointments.length > 0 ? appointmentCountsByDate(date) : normalizeArtistCounts(summary?.artistCounts || []))
|
||||
.filter(count => count.count > 0)
|
||||
.map(count => ({
|
||||
...count,
|
||||
width: Math.max(12, Math.min(100, count.count * 22)),
|
||||
barWidth: Math.max(14, Math.min(100, count.count * 18))
|
||||
}))
|
||||
return { date, weekName: `周${label}`, day: target.getDate(), totalCount: summary?.totalCount || 0, artistCounts: counts }
|
||||
return { date, weekName: `周${label}`, day: target.getDate(), totalCount: summary?.totalCount || 0, artistCounts: counts, statusClass: resolveDayStatusClass(dayAppointments) }
|
||||
})
|
||||
}
|
||||
|
||||
@@ -722,6 +794,41 @@ onMounted(() => {
|
||||
background: #fff0de;
|
||||
}
|
||||
|
||||
.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;
|
||||
right: 8px;
|
||||
left: 8px;
|
||||
top: 50%;
|
||||
border-top: 3px solid;
|
||||
pointer-events: none;
|
||||
transform: rotate(-15deg);
|
||||
transform-origin: center;
|
||||
}
|
||||
|
||||
.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);
|
||||
}
|
||||
|
||||
.appointment-block strong,
|
||||
.appointment-block span,
|
||||
.appointment-block small {
|
||||
@@ -746,12 +853,23 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
.week-day-card {
|
||||
position: relative;
|
||||
display: grid;
|
||||
justify-items: center;
|
||||
flex: 0 0 86px;
|
||||
padding: 12px 8px;
|
||||
}
|
||||
|
||||
.week-day-card.is-completed {
|
||||
background: #f5fff7;
|
||||
border-color: #c8ead1;
|
||||
}
|
||||
|
||||
.week-day-card.is-cancelled {
|
||||
background: #fff5f6;
|
||||
border-color: #e8c7cc;
|
||||
}
|
||||
|
||||
.week-day-card.active {
|
||||
color: var(--accent);
|
||||
outline: 2px solid var(--accent-soft);
|
||||
@@ -802,6 +920,7 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
.week-count-bar {
|
||||
position: relative;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
min-width: 28px;
|
||||
@@ -811,6 +930,53 @@ onMounted(() => {
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.week-count-bar.is-completed::after,
|
||||
.week-count-bar.is-cancelled::after,
|
||||
.month-bars span.is-completed::after,
|
||||
.month-bars span.is-cancelled::after,
|
||||
.month-blocks span.is-completed::after,
|
||||
.month-blocks span.is-cancelled::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
right: 3px;
|
||||
left: 3px;
|
||||
top: 50%;
|
||||
border-top: 2px solid rgba(255, 255, 255, 0.92);
|
||||
pointer-events: none;
|
||||
transform: rotate(-15deg);
|
||||
transform-origin: center;
|
||||
}
|
||||
|
||||
.week-count-bar.is-completed::before,
|
||||
.week-count-bar.is-cancelled::before,
|
||||
.month-bars span.is-completed::before,
|
||||
.month-bars span.is-cancelled::before,
|
||||
.month-blocks span.is-completed::before,
|
||||
.month-blocks span.is-cancelled::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
right: 3px;
|
||||
left: 3px;
|
||||
top: 50%;
|
||||
border-top: 1px solid;
|
||||
pointer-events: none;
|
||||
transform: rotate(-15deg);
|
||||
transform-origin: center;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.week-count-bar.is-completed::before,
|
||||
.month-bars span.is-completed::before,
|
||||
.month-blocks span.is-completed::before {
|
||||
border-color: rgba(69, 130, 91, 0.9);
|
||||
}
|
||||
|
||||
.week-count-bar.is-cancelled::before,
|
||||
.month-bars span.is-cancelled::before,
|
||||
.month-blocks span.is-cancelled::before {
|
||||
border-color: rgba(198, 78, 91, 0.92);
|
||||
}
|
||||
|
||||
.month-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -910,6 +1076,7 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
.month-bars span {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
@@ -944,6 +1111,7 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
.month-blocks span {
|
||||
position: relative;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
|
||||
@@ -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