周视图从七列卡片改为单卡片七行列表,行高 108rpx,行内依次为周几与日期、营业状态、396x28rpx 单量量轨、单量与待分配徽标;量轨按美甲师分段,1 单 75.2rpx、段间 4rpx,段内显示姓名与单量并单行裁切。 三色条更新为 #43789E/#96684B/#587959,旧默认员工色统一映射,月视图条与筛选 chip 色点同步;今日行浅绿底加左侧竖条,待分配使用琥珀徽标;顶部保留标题、日期范围、图例与周汇总。仅呈现层调整,接口、字段与状态流转未改动。
This commit is contained in:
@@ -20,6 +20,35 @@ function resolveCalendarErrorMessage(error) {
|
||||
|
||||
const LANE_TINTS = ['#EAF3FA', '#FBF1EB', '#EEF5EF']
|
||||
|
||||
const DESIGN_ARTIST_COLORS = {
|
||||
张小雨: '#43789E',
|
||||
林小满: '#96684B',
|
||||
陈小桃: '#587959'
|
||||
}
|
||||
|
||||
const LEGACY_ARTIST_COLORS = {
|
||||
'#7BA7C7': '#43789E',
|
||||
'#D7A86E': '#96684B',
|
||||
'#8FB89A': '#587959'
|
||||
}
|
||||
|
||||
function resolveDisplayColor(artist = {}, fallback) {
|
||||
const name = String(artist.nickname || artist.name || artist.artistName || '')
|
||||
const matchedName = Object.keys(DESIGN_ARTIST_COLORS).find(key => name.includes(key))
|
||||
if (matchedName) return DESIGN_ARTIST_COLORS[matchedName]
|
||||
const color = String(artist.color || fallback || '')
|
||||
return LEGACY_ARTIST_COLORS[color.toUpperCase()] || color || '#B8B0A6'
|
||||
}
|
||||
|
||||
function buildWeekSegments(artistCounts) {
|
||||
const counts = (artistCounts || []).map(count => ({ ...count, width: Math.round(count.count * 75.2) }))
|
||||
const usable = 396 - Math.max(0, counts.length - 1) * 4
|
||||
const rawTotal = counts.reduce((total, count) => total + count.width, 0)
|
||||
if (rawTotal <= usable || rawTotal === 0) return counts
|
||||
const scale = usable / rawTotal
|
||||
return counts.map(count => ({ ...count, width: Math.max(8, Math.floor(count.width * scale)) }))
|
||||
}
|
||||
|
||||
function toLocalDate(value) {
|
||||
return value instanceof Date ? new Date(value.getTime()) : new Date(String(value).replace(/-/g, '/'))
|
||||
}
|
||||
@@ -166,6 +195,10 @@ Page({
|
||||
artists: [],
|
||||
monthDays: [],
|
||||
weekDays: [],
|
||||
weekTotalCount: 0,
|
||||
weekUnassignedTotal: 0,
|
||||
weekLegend: [],
|
||||
todayText: dateUtil.formatDate(new Date()),
|
||||
dayLanes: [],
|
||||
hours: [],
|
||||
hasTimedAppointments: false,
|
||||
@@ -449,6 +482,9 @@ Page({
|
||||
artists: [],
|
||||
monthDays: [],
|
||||
weekDays: [],
|
||||
weekTotalCount: 0,
|
||||
weekUnassignedTotal: 0,
|
||||
weekLegend: [],
|
||||
dayLanes: [],
|
||||
hours: [],
|
||||
hasTimedAppointments: false,
|
||||
@@ -484,7 +520,10 @@ Page({
|
||||
businessStartTime: businessHours ? businessHours.start : '',
|
||||
businessEndTime: businessHours ? businessHours.end : '',
|
||||
businessHoursConfigured: hasBusinessHours(calendar),
|
||||
artists: Array.isArray(calendar.artists) ? calendar.artists : [],
|
||||
artists: (Array.isArray(calendar.artists) ? calendar.artists : []).map(artist => ({
|
||||
...artist,
|
||||
color: resolveDisplayColor({ name: artist.name || artist.nickname, color: artist.color })
|
||||
})),
|
||||
appointments: Array.isArray(calendar.appointments) ? calendar.appointments : [],
|
||||
daySummaries: Array.isArray(calendar.daySummaries) ? calendar.daySummaries : []
|
||||
}
|
||||
@@ -536,7 +575,22 @@ Page({
|
||||
return state
|
||||
}
|
||||
if (this.data.viewMode === 'week') {
|
||||
state.weekDays = this.buildWeekDays(calendar)
|
||||
const weekDays = this.buildWeekDays(calendar)
|
||||
const legendMap = {}
|
||||
weekDays.forEach(day => {
|
||||
day.artistCounts.forEach(count => {
|
||||
if (!count.artistId || count.artistId === '__unassigned__' || legendMap[count.artistId]) return
|
||||
legendMap[count.artistId] = {
|
||||
artistId: count.artistId,
|
||||
name: count.artistName || count.shortName || '?',
|
||||
color: count.color
|
||||
}
|
||||
})
|
||||
})
|
||||
state.weekDays = weekDays
|
||||
state.weekTotalCount = weekDays.reduce((total, day) => total + Number(day.totalCount || 0), 0)
|
||||
state.weekUnassignedTotal = weekDays.reduce((total, day) => total + Number(day.unassignedCount || 0), 0)
|
||||
state.weekLegend = Object.keys(legendMap).map(key => legendMap[key])
|
||||
return state
|
||||
}
|
||||
return { ...state, ...this.buildDayView(calendar) }
|
||||
@@ -576,15 +630,13 @@ Page({
|
||||
buildWeekDays(calendar) {
|
||||
const start = dateUtil.startOfWeek(this.data.currentDateText)
|
||||
const summaryMap = this.summaryMap(calendar)
|
||||
return this.data.weekLabels.map((label, index) => {
|
||||
const days = this.data.weekLabels.map((label, index) => {
|
||||
const target = dateUtil.addDays(start, index)
|
||||
const date = dateUtil.formatDate(target)
|
||||
const summary = summaryMap[date] || { artistCounts: [], totalCount: 0 }
|
||||
const unassignedCount = Number(summary.unassignedCount || 0)
|
||||
const artistCounts = this.withUnassignedCount(
|
||||
this.normalizeArtistCounts(summary.artistCounts || [], calendar),
|
||||
unassignedCount
|
||||
).filter(count => count.count > 0)
|
||||
const artistCounts = this.normalizeArtistCounts(summary.artistCounts || [], calendar)
|
||||
.filter(count => count.count > 0 && count.artistId !== '__unassigned__')
|
||||
return {
|
||||
date,
|
||||
weekName: `周${label}`,
|
||||
@@ -592,16 +644,11 @@ Page({
|
||||
totalCount: summary.totalCount || 0,
|
||||
unassignedCount,
|
||||
shopOpen: summary.shopOpen !== false,
|
||||
statusText: this.resolveDisplayStatus(summary, artistCounts) === 'rest'
|
||||
? '休'
|
||||
: this.resolveDisplayStatus(summary, artistCounts) === 'full' ? '满' : '营业',
|
||||
artistCounts: artistCounts.map(count => ({
|
||||
...count,
|
||||
width: Math.max(12, Math.min(100, count.count * 22)),
|
||||
barWidth: Math.max(14, Math.min(100, count.count * 18))
|
||||
}))
|
||||
statusText: this.resolveDisplayStatus(summary, artistCounts) === 'rest' ? '休' : '营业',
|
||||
artistCounts: buildWeekSegments(artistCounts)
|
||||
}
|
||||
})
|
||||
return days
|
||||
},
|
||||
|
||||
buildDayView(calendar) {
|
||||
@@ -775,10 +822,12 @@ Page({
|
||||
}, {})
|
||||
return (counts || []).map(count => {
|
||||
const artist = colorMap[count.artistId] || {}
|
||||
const artistName = count.artistName || artist.name || artist.nickname || ''
|
||||
return {
|
||||
...count,
|
||||
color: count.color || artist.color || '#B8B0A6',
|
||||
color: resolveDisplayColor({ name: artistName, color: count.color || artist.color }),
|
||||
shortName: count.shortName || artist.shortName || '?',
|
||||
artistName,
|
||||
count: Number(count.count || 0)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -111,7 +111,7 @@ async function run() {
|
||||
daySummaries: [{ date: weekStart, totalCount: 2, unassignedCount: 2, artistCounts: [] }]
|
||||
})
|
||||
assert.strictEqual(weekDays[0].unassignedCount, 2)
|
||||
assert.strictEqual(weekDays[0].artistCounts[0].artistId, '__unassigned__')
|
||||
assert.strictEqual(weekDays[0].artistCounts.some(count => count.artistId === '__unassigned__'), false)
|
||||
|
||||
const dayPage = createPage({ currentDateText: '2026-10-12', selectedArtistId: '' })
|
||||
const dayState = dayPage.buildDayView({
|
||||
@@ -196,7 +196,11 @@ async function run() {
|
||||
assert.match(planningWxml, /class="lane-unassigned-tag">不占档期/)
|
||||
assert.match(planningWxml, /门店营业时间未设置/)
|
||||
assert.match(planningWxml, /bindtap="openShopSettings"/)
|
||||
assert.match(planningWxml, /class="week-unassigned-count">待 \{\{item\.unassignedCount\}\}/)
|
||||
assert.match(planningWxml, /class="week-card card"/)
|
||||
assert.match(planningWxml, /class="week-row-pending">待分配 \{\{item\.unassignedCount\}\}/)
|
||||
assert.match(planningWxml, /class="week-segment" style="width: \{\{count\.width\}\}rpx;/)
|
||||
assert.match(planningWxss, /\.week-track\s*\{[^}]*width:\s*396rpx;[^}]*height:\s*28rpx;/)
|
||||
assert.match(planningWxss, /\.week-row\s*\{[^}]*height:\s*108rpx;/)
|
||||
assert.match(planningWxml, /wx:if="\{\{canCreateAppointment && businessHoursConfigured && !calendarError && \(viewMode !== 'day' \|\| currentShopOpen\)\}\}" class="fab" bindtap="createAppointment"/)
|
||||
assert.match(planningWxml, /class="month-unassigned-count">待 \{\{item\.unassignedCount\}\}/)
|
||||
assert.doesNotMatch(planningWxss, /background-size:\s*100% 240rpx/)
|
||||
@@ -287,7 +291,7 @@ async function run() {
|
||||
|
||||
assert.match(planningWxml, /bindtap="selectMonthDate" aria-label="查看\{\{item\.date\}\}日程"/)
|
||||
assert.match(planningWxml, /bindtap="selectWeekDate" aria-label="查看\{\{item\.date\}\}日程"/)
|
||||
assert.match(planningWxss, /grid-template-columns:\s*repeat\(7,\s*minmax\(0,\s*1fr\)\)/)
|
||||
assert.match(planningWxss, /\.week-list\s*\{/)
|
||||
}
|
||||
|
||||
run().catch(error => {
|
||||
|
||||
@@ -132,18 +132,38 @@
|
||||
</view>
|
||||
|
||||
<view wx:if="{{viewMode === 'week'}}" class="section">
|
||||
<view class="week-head">
|
||||
<text class="week-head-title">本周概览</text>
|
||||
<text class="week-head-range">{{weekRange}}</text>
|
||||
</view>
|
||||
<view class="week-strip">
|
||||
<view wx:for="{{weekDays}}" wx:key="date" class="week-day-card card {{item.date === currentDateText ? 'active' : ''}}" data-date="{{item.date}}" bindtap="selectWeekDate" aria-label="查看{{item.date}}日程">
|
||||
<view class="week-card-head"><text class="week-name">{{item.weekName}}</text><text class="week-status {{item.statusText === '休' ? 'rest' : ''}}">{{item.statusText}}</text></view>
|
||||
<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 class="week-card card">
|
||||
<view class="week-card-head">
|
||||
<view class="week-card-title">
|
||||
<text class="week-title">本周安排</text>
|
||||
<text class="week-range">{{weekRange}}</text>
|
||||
</view>
|
||||
<text class="week-summary">共 {{weekTotalCount}} 单 · 待分配 {{weekUnassignedTotal}}</text>
|
||||
</view>
|
||||
<view class="week-legend">
|
||||
<view wx:for="{{weekLegend}}" wx:key="artistId" class="week-legend-item">
|
||||
<view class="week-legend-dot" style="background: {{item.color}};"></view>
|
||||
<text class="week-legend-name">{{item.name}}</text>
|
||||
</view>
|
||||
<text wx:if="{{!weekLegend.length}}" class="week-legend-empty">暂无美甲师单量</text>
|
||||
</view>
|
||||
<view class="week-list">
|
||||
<view wx:for="{{weekDays}}" wx:key="date" class="week-row {{item.date === todayText ? 'today' : ''}}" data-date="{{item.date}}" bindtap="selectWeekDate" aria-label="查看{{item.date}}日程">
|
||||
<view class="week-row-date">
|
||||
<text class="week-row-name">{{item.weekName}}</text>
|
||||
<text class="week-row-day">{{item.day}}</text>
|
||||
<text class="week-row-suffix">日</text>
|
||||
</view>
|
||||
<text class="week-row-status {{item.statusText === '休' ? 'rest' : ''}}">{{item.statusText}}</text>
|
||||
<view class="week-track {{item.totalCount === 0 ? 'empty' : ''}}">
|
||||
<view wx:for="{{item.artistCounts}}" wx:for-item="count" wx:for-index="countIndex" wx:key="artistId" class="week-segment" style="width: {{count.width}}rpx; background: {{count.color}};">
|
||||
<text class="week-segment-text">{{count.artistName || count.shortName}}{{count.count}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="week-row-tail">
|
||||
<text class="week-row-total">{{item.totalCount}}单</text>
|
||||
<text wx:if="{{item.unassignedCount > 0}}" class="week-row-pending">待分配 {{item.unassignedCount}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -555,77 +555,187 @@
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
.week-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12rpx; }
|
||||
.week-head-title { color: #17211f; font-size: 25rpx; font-weight: 600; }
|
||||
.week-head-range { color: #71807a; font-size: 20rpx; }
|
||||
|
||||
.week-strip {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(7, minmax(0, 1fr));
|
||||
gap: 6rpx;
|
||||
width: 100%;
|
||||
.week-card {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.week-day-card {
|
||||
.week-card-head {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 12rpx;
|
||||
}
|
||||
|
||||
.week-card-title {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
min-height: 104rpx;
|
||||
margin: 0;
|
||||
padding: 8rpx 4rpx;
|
||||
align-items: center;
|
||||
align-items: baseline;
|
||||
gap: 10rpx;
|
||||
}
|
||||
|
||||
.week-day-card.active {
|
||||
background: #e5f4ed;
|
||||
border-color: #cfe4d9;
|
||||
}
|
||||
|
||||
.week-name,
|
||||
.week-total {
|
||||
color: #8f877e;
|
||||
font-size: 18rpx;
|
||||
}
|
||||
|
||||
.week-card-head { display:flex; width:100%; align-items:center; justify-content:space-between; gap:2rpx; }
|
||||
.week-status { color:#247b63; font-size:17rpx; font-weight:800; }
|
||||
.week-status.rest { color:#a08a78; }
|
||||
|
||||
.week-unassigned-count {
|
||||
display: inline-flex;
|
||||
align-self: flex-start;
|
||||
margin-top: 4rpx;
|
||||
padding: 2rpx 4rpx;
|
||||
border-radius: 6rpx;
|
||||
background: #fff1dc;
|
||||
color: #a56b24;
|
||||
font-size: 15rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.week-date {
|
||||
margin: 3rpx 0;
|
||||
.week-title {
|
||||
color: #17211f;
|
||||
font-size: 24rpx;
|
||||
font-size: 28rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.week-bars {
|
||||
.week-range {
|
||||
color: #71807a;
|
||||
font-size: 20rpx;
|
||||
}
|
||||
|
||||
.week-summary {
|
||||
flex: none;
|
||||
color: #71807a;
|
||||
font-size: 20rpx;
|
||||
}
|
||||
|
||||
.week-legend {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8rpx 18rpx;
|
||||
margin-top: 12rpx;
|
||||
}
|
||||
|
||||
.week-legend-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8rpx;
|
||||
}
|
||||
|
||||
.week-legend-dot {
|
||||
width: 14rpx;
|
||||
height: 14rpx;
|
||||
flex: none;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.week-legend-name {
|
||||
color: #71807a;
|
||||
font-size: 20rpx;
|
||||
}
|
||||
|
||||
.week-legend-empty {
|
||||
color: #a1aca6;
|
||||
font-size: 20rpx;
|
||||
}
|
||||
|
||||
.week-list {
|
||||
margin-top: 8rpx;
|
||||
}
|
||||
.week-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8rpx;
|
||||
box-sizing: border-box;
|
||||
height: 108rpx;
|
||||
border-bottom: 1rpx solid #f0f3f1;
|
||||
}
|
||||
|
||||
.week-row:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.week-row.today {
|
||||
margin: 0 -20rpx;
|
||||
padding: 0 20rpx 0 14rpx;
|
||||
border-left: 6rpx solid #247b63;
|
||||
background: #e5f4ed;
|
||||
}
|
||||
|
||||
.week-row-date {
|
||||
display: flex;
|
||||
width: 92rpx;
|
||||
flex: none;
|
||||
align-items: baseline;
|
||||
gap: 4rpx;
|
||||
}
|
||||
|
||||
.week-row-name {
|
||||
color: #71807a;
|
||||
font-size: 20rpx;
|
||||
}
|
||||
|
||||
.week-row-day {
|
||||
color: #17211f;
|
||||
font-size: 30rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.week-row-suffix {
|
||||
color: #71807a;
|
||||
font-size: 16rpx;
|
||||
}
|
||||
|
||||
.week-row-status {
|
||||
width: 40rpx;
|
||||
flex: none;
|
||||
color: #247b63;
|
||||
font-size: 18rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.week-row-status.rest {
|
||||
color: #a1aca6;
|
||||
}
|
||||
|
||||
.week-track {
|
||||
display: flex;
|
||||
width: 396rpx;
|
||||
height: 28rpx;
|
||||
flex: none;
|
||||
gap: 4rpx;
|
||||
box-sizing: border-box;
|
||||
overflow: hidden;
|
||||
border-radius: 14rpx;
|
||||
background: #eef3f0;
|
||||
}
|
||||
|
||||
.week-segment {
|
||||
display: flex;
|
||||
height: 28rpx;
|
||||
flex: none;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
border-radius: 14rpx;
|
||||
}
|
||||
|
||||
.week-segment-text {
|
||||
box-sizing: border-box;
|
||||
max-width: 100%;
|
||||
padding: 0 6rpx;
|
||||
overflow: hidden;
|
||||
color: #ffffff;
|
||||
font-size: 18rpx;
|
||||
line-height: 28rpx;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.week-row-tail {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
gap: 3rpx;
|
||||
width: 90%;
|
||||
margin-top: 3rpx;
|
||||
min-height: 10rpx;
|
||||
align-items: flex-end;
|
||||
gap: 2rpx;
|
||||
}
|
||||
|
||||
.week-bars.empty {
|
||||
min-height: 10rpx;
|
||||
.week-row-total {
|
||||
color: #17211f;
|
||||
font-size: 20rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.week-bar {
|
||||
height: 5rpx;
|
||||
border-radius: 999rpx;
|
||||
.week-row-pending {
|
||||
padding: 2rpx 8rpx;
|
||||
border-radius: 8rpx;
|
||||
background: #fff1dc;
|
||||
color: #8b5e24;
|
||||
font-size: 16rpx;
|
||||
font-weight: 700;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.week-grid {
|
||||
|
||||
Reference in New Issue
Block a user