修复日程美甲师筛选消失与日视图泳道末端裁切 #109
+11
@@ -133,7 +133,9 @@ public class PlanningServiceImpl implements PlanningService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean artistFiltered = artistId != null && artistId > 0;
|
||||||
List<PlanningArtistVO> artists = listArtists(shopId, artistId);
|
List<PlanningArtistVO> artists = listArtists(shopId, artistId);
|
||||||
|
List<PlanningArtistVO> artistOptions = artistFiltered ? listArtists(shopId, null) : artists;
|
||||||
List<ArtistScheduleDO> schedules = listSchedules(shopId, start, end, artistId);
|
List<ArtistScheduleDO> schedules = listSchedules(shopId, start, end, artistId);
|
||||||
Map<Long, String> artistNames = artists.stream()
|
Map<Long, String> artistNames = artists.stream()
|
||||||
.collect(Collectors.toMap(PlanningArtistVO::getId, PlanningArtistVO::getName, (a, b) -> a));
|
.collect(Collectors.toMap(PlanningArtistVO::getId, PlanningArtistVO::getName, (a, b) -> a));
|
||||||
@@ -151,6 +153,14 @@ public class PlanningServiceImpl implements PlanningService {
|
|||||||
.filter(appointment -> appointment.getArtistId() != null)
|
.filter(appointment -> appointment.getArtistId() != null)
|
||||||
.collect(Collectors.groupingBy(PlanningAppointmentVO::getArtistId, Collectors.counting()));
|
.collect(Collectors.groupingBy(PlanningAppointmentVO::getArtistId, Collectors.counting()));
|
||||||
artists.forEach(artist -> artist.setRangeCount(countByArtist.getOrDefault(artist.getId(), 0L).intValue()));
|
artists.forEach(artist -> artist.setRangeCount(countByArtist.getOrDefault(artist.getId(), 0L).intValue()));
|
||||||
|
if (artistFiltered) {
|
||||||
|
List<PlanningAppointmentVO> rangeAppointments = listAppointments(shopId, rangeStart, rangeEnd, null, artistOptions);
|
||||||
|
Map<Long, Long> optionCountByArtist = rangeAppointments.stream()
|
||||||
|
.filter(appointment -> appointment.getArtistId() != null)
|
||||||
|
.collect(Collectors.groupingBy(PlanningAppointmentVO::getArtistId, Collectors.counting()));
|
||||||
|
artistOptions.forEach(artist -> artist.setRangeCount(
|
||||||
|
optionCountByArtist.getOrDefault(artist.getId(), 0L).intValue()));
|
||||||
|
}
|
||||||
|
|
||||||
PlanningCalendarVO vo = new PlanningCalendarVO();
|
PlanningCalendarVO vo = new PlanningCalendarVO();
|
||||||
vo.setBusinessStartTime(businessHours == null ? null : businessHours.start().toString());
|
vo.setBusinessStartTime(businessHours == null ? null : businessHours.start().toString());
|
||||||
@@ -159,6 +169,7 @@ public class PlanningServiceImpl implements PlanningService {
|
|||||||
|| shop.getDefaultAppointmentDurationMinutes() <= 0 ? DEFAULT_DURATION_MINUTES : shop.getDefaultAppointmentDurationMinutes());
|
|| shop.getDefaultAppointmentDurationMinutes() <= 0 ? DEFAULT_DURATION_MINUTES : shop.getDefaultAppointmentDurationMinutes());
|
||||||
vo.setSlotMinutes(DEFAULT_SLOT_MINUTES);
|
vo.setSlotMinutes(DEFAULT_SLOT_MINUTES);
|
||||||
vo.setArtists(artists);
|
vo.setArtists(artists);
|
||||||
|
vo.setArtistOptions(artistOptions);
|
||||||
vo.setSchedules(scheduleVos);
|
vo.setSchedules(scheduleVos);
|
||||||
vo.setAppointments(appointments);
|
vo.setAppointments(appointments);
|
||||||
vo.setDaySummaries(buildDaySummaries(start, end, artists, schedules, appointments, weeklyHours));
|
vo.setDaySummaries(buildDaySummaries(start, end, artists, schedules, appointments, weeklyHours));
|
||||||
|
|||||||
+2
@@ -11,6 +11,8 @@ public class PlanningCalendarVO {
|
|||||||
private Integer defaultAppointmentDurationMinutes;
|
private Integer defaultAppointmentDurationMinutes;
|
||||||
private Integer slotMinutes;
|
private Integer slotMinutes;
|
||||||
private List<PlanningArtistVO> artists;
|
private List<PlanningArtistVO> artists;
|
||||||
|
/** 全部美甲师选项(不受 artistId 筛选影响),供端侧筛选栏始终展示完整 chip 列表 */
|
||||||
|
private List<PlanningArtistVO> artistOptions;
|
||||||
private List<PlanningScheduleVO> schedules;
|
private List<PlanningScheduleVO> schedules;
|
||||||
private List<PlanningAppointmentVO> appointments;
|
private List<PlanningAppointmentVO> appointments;
|
||||||
private List<PlanningDaySummaryVO> daySummaries;
|
private List<PlanningDaySummaryVO> daySummaries;
|
||||||
|
|||||||
@@ -211,6 +211,7 @@ Page({
|
|||||||
laneWidth: 720,
|
laneWidth: 720,
|
||||||
laneItemWidth: 240,
|
laneItemWidth: 240,
|
||||||
laneHeaderHeight: 54,
|
laneHeaderHeight: 54,
|
||||||
|
laneEdgeSpacerWidth: 24,
|
||||||
dayTotal: 0,
|
dayTotal: 0,
|
||||||
freeArtistCount: 0,
|
freeArtistCount: 0,
|
||||||
pendingCount: 0,
|
pendingCount: 0,
|
||||||
@@ -370,10 +371,15 @@ Page({
|
|||||||
},
|
},
|
||||||
|
|
||||||
selectArtist(event) {
|
selectArtist(event) {
|
||||||
const id = event.currentTarget.dataset.id || ''
|
const id = String(event.currentTarget.dataset.id || '')
|
||||||
const artist = this.data.artists.find(item => String(item.id) === String(id))
|
const currentId = String(this.data.selectedArtistId || '')
|
||||||
|
const nextId = id && currentId === id ? '' : id
|
||||||
|
if (nextId === currentId) return
|
||||||
|
const artist = nextId
|
||||||
|
? this.data.artists.find(item => String(item.id) === nextId)
|
||||||
|
: null
|
||||||
this.setData({
|
this.setData({
|
||||||
selectedArtistId: id,
|
selectedArtistId: nextId,
|
||||||
selectedArtistName: artist ? artist.name : '全部美甲师'
|
selectedArtistName: artist ? artist.name : '全部美甲师'
|
||||||
})
|
})
|
||||||
this.loadCalendar()
|
this.loadCalendar()
|
||||||
@@ -516,14 +522,20 @@ Page({
|
|||||||
|
|
||||||
applyCalendar(calendar) {
|
applyCalendar(calendar) {
|
||||||
const businessHours = resolveBusinessHours(calendar)
|
const businessHours = resolveBusinessHours(calendar)
|
||||||
|
const artistSource = Array.isArray(calendar.artists) ? calendar.artists : []
|
||||||
|
const artistOptionSource = Array.isArray(calendar.artistOptions) && calendar.artistOptions.length
|
||||||
|
? calendar.artistOptions
|
||||||
|
: artistSource
|
||||||
|
const normalizeArtist = artist => ({
|
||||||
|
...artist,
|
||||||
|
color: resolveDisplayColor({ name: artist.name || artist.nickname, color: artist.color })
|
||||||
|
})
|
||||||
const snapshot = {
|
const snapshot = {
|
||||||
businessStartTime: businessHours ? businessHours.start : '',
|
businessStartTime: businessHours ? businessHours.start : '',
|
||||||
businessEndTime: businessHours ? businessHours.end : '',
|
businessEndTime: businessHours ? businessHours.end : '',
|
||||||
businessHoursConfigured: hasBusinessHours(calendar),
|
businessHoursConfigured: hasBusinessHours(calendar),
|
||||||
artists: (Array.isArray(calendar.artists) ? calendar.artists : []).map(artist => ({
|
artists: artistSource.map(normalizeArtist),
|
||||||
...artist,
|
artistOptions: artistOptionSource.map(normalizeArtist),
|
||||||
color: resolveDisplayColor({ name: artist.name || artist.nickname, color: artist.color })
|
|
||||||
})),
|
|
||||||
appointments: Array.isArray(calendar.appointments) ? calendar.appointments : [],
|
appointments: Array.isArray(calendar.appointments) ? calendar.appointments : [],
|
||||||
daySummaries: Array.isArray(calendar.daySummaries) ? calendar.daySummaries : []
|
daySummaries: Array.isArray(calendar.daySummaries) ? calendar.daySummaries : []
|
||||||
}
|
}
|
||||||
@@ -532,7 +544,7 @@ Page({
|
|||||||
businessStartTime: snapshot.businessStartTime,
|
businessStartTime: snapshot.businessStartTime,
|
||||||
businessEndTime: snapshot.businessEndTime,
|
businessEndTime: snapshot.businessEndTime,
|
||||||
businessHoursConfigured: snapshot.businessHoursConfigured,
|
businessHoursConfigured: snapshot.businessHoursConfigured,
|
||||||
artists: snapshot.artists,
|
artists: snapshot.artistOptions,
|
||||||
calendarError: '',
|
calendarError: '',
|
||||||
rangeUnassignedCount: snapshot.appointments.filter(item => !item.artistId).length,
|
rangeUnassignedCount: snapshot.appointments.filter(item => !item.artistId).length,
|
||||||
nearestUnassignedDate: this.findNearestUnassignedDate(snapshot.appointments),
|
nearestUnassignedDate: this.findNearestUnassignedDate(snapshot.appointments),
|
||||||
@@ -653,6 +665,7 @@ Page({
|
|||||||
|
|
||||||
buildDayView(calendar) {
|
buildDayView(calendar) {
|
||||||
const minuteScale = 2.5
|
const minuteScale = 2.5
|
||||||
|
const laneEdgeSpacerWidth = Number(this.data.laneEdgeSpacerWidth) || 0
|
||||||
const daySummary = this.summaryMap(calendar)[this.data.currentDateText] || null
|
const daySummary = this.summaryMap(calendar)[this.data.currentDateText] || null
|
||||||
const businessHours = resolveBusinessHours(calendar, this.data.currentDateText)
|
const businessHours = resolveBusinessHours(calendar, this.data.currentDateText)
|
||||||
const filteredArtists = this.data.selectedArtistId
|
const filteredArtists = this.data.selectedArtistId
|
||||||
@@ -676,7 +689,8 @@ Page({
|
|||||||
timelineViewportHeight: 320,
|
timelineViewportHeight: 320,
|
||||||
laneHeaderHeight: 54,
|
laneHeaderHeight: 54,
|
||||||
laneItemWidth: 248,
|
laneItemWidth: 248,
|
||||||
laneWidth: 720,
|
laneEdgeSpacerWidth,
|
||||||
|
laneWidth: 720 + laneEdgeSpacerWidth,
|
||||||
dayTotal: dayAppointments.length,
|
dayTotal: dayAppointments.length,
|
||||||
freeArtistCount: 0,
|
freeArtistCount: 0,
|
||||||
pendingCount,
|
pendingCount,
|
||||||
@@ -753,7 +767,8 @@ Page({
|
|||||||
timelineViewportHeight: Math.min(820, timelineHeight + laneHeaderHeight + TIMELINE_BOTTOM_SPACE),
|
timelineViewportHeight: Math.min(820, timelineHeight + laneHeaderHeight + TIMELINE_BOTTOM_SPACE),
|
||||||
laneHeaderHeight,
|
laneHeaderHeight,
|
||||||
laneItemWidth: 248,
|
laneItemWidth: 248,
|
||||||
laneWidth: Math.max(720, lanes.reduce((width, lane) => width + (lane.width || 248), 0)),
|
laneEdgeSpacerWidth,
|
||||||
|
laneWidth: Math.max(720, lanes.reduce((width, lane) => width + (lane.width || 248), 0) + laneEdgeSpacerWidth),
|
||||||
dayTotal: dayAppointments.length,
|
dayTotal: dayAppointments.length,
|
||||||
freeArtistCount: employeeLanes.filter(item => item.blocks.every(block => block.historicalBackfill)).length,
|
freeArtistCount: employeeLanes.filter(item => item.blocks.every(block => block.historicalBackfill)).length,
|
||||||
pendingCount,
|
pendingCount,
|
||||||
|
|||||||
@@ -292,6 +292,33 @@ async function run() {
|
|||||||
assert.match(planningWxml, /bindtap="selectMonthDate" aria-label="查看\{\{item\.date\}\}日程"/)
|
assert.match(planningWxml, /bindtap="selectMonthDate" aria-label="查看\{\{item\.date\}\}日程"/)
|
||||||
assert.match(planningWxml, /bindtap="selectWeekDate" aria-label="查看\{\{item\.date\}\}日程"/)
|
assert.match(planningWxml, /bindtap="selectWeekDate" aria-label="查看\{\{item\.date\}\}日程"/)
|
||||||
assert.match(planningWxss, /\.week-list\s*\{/)
|
assert.match(planningWxss, /\.week-list\s*\{/)
|
||||||
|
|
||||||
|
assert.strictEqual(definition.data.laneEdgeSpacerWidth, 24)
|
||||||
|
assert.match(planningWxml, /class="lane-edge-spacer" style="width: \{\{laneEdgeSpacerWidth\}\}rpx;"/)
|
||||||
|
assert.match(planningWxss, /\.lane-edge-spacer\s*\{[^}]*flex-shrink:\s*0;/)
|
||||||
|
assert.strictEqual(overlappingState.laneEdgeSpacerWidth, 24)
|
||||||
|
assert.strictEqual(overlappingState.laneWidth, 1016)
|
||||||
|
|
||||||
|
const filterPage = createPage()
|
||||||
|
let filterLoads = 0
|
||||||
|
filterPage.loadCalendar = () => { filterLoads += 1 }
|
||||||
|
filterPage.applyCalendar({
|
||||||
|
artists: [{ id: 1, name: '美甲师甲' }],
|
||||||
|
artistOptions: [{ id: 1, name: '美甲师甲', rangeCount: 3 }, { id: 2, name: '美甲师乙', rangeCount: 1 }],
|
||||||
|
appointments: [],
|
||||||
|
daySummaries: []
|
||||||
|
})
|
||||||
|
assert.strictEqual(filterPage.data.artists.length, 2)
|
||||||
|
assert.strictEqual(filterPage.data.artists[1].rangeCount, 1)
|
||||||
|
filterPage.selectArtist({ currentTarget: { dataset: { id: 2 } } })
|
||||||
|
assert.strictEqual(filterPage.data.selectedArtistId, '2')
|
||||||
|
assert.strictEqual(filterPage.data.artists.length, 2)
|
||||||
|
filterPage.selectArtist({ currentTarget: { dataset: { id: 2 } } })
|
||||||
|
assert.strictEqual(filterPage.data.selectedArtistId, '')
|
||||||
|
filterPage.selectArtist({ currentTarget: { dataset: { id: '' } } })
|
||||||
|
assert.strictEqual(filterPage.data.selectedArtistId, '')
|
||||||
|
assert.strictEqual(filterPage.data.selectedArtistName, '全部美甲师')
|
||||||
|
assert.strictEqual(filterLoads, 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
run().catch(error => {
|
run().catch(error => {
|
||||||
|
|||||||
@@ -125,6 +125,7 @@
|
|||||||
</view>
|
</view>
|
||||||
<view wx:if="{{item.blocks.length === 0}}" class="lane-empty">{{item.emptyText || '全天可约'}}</view>
|
<view wx:if="{{item.blocks.length === 0}}" class="lane-empty">{{item.emptyText || '全天可约'}}</view>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="lane-edge-spacer" style="width: {{laneEdgeSpacerWidth}}rpx;"></view>
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -421,6 +421,12 @@
|
|||||||
background: #ffffff;
|
background: #ffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 泳道尾部留白:仅为扩展横向滚动范围,避免最后一列被卡片圆角/边框裁切,不参与泳道排布 */
|
||||||
|
.lane-edge-spacer {
|
||||||
|
flex-shrink: 0;
|
||||||
|
align-self: stretch;
|
||||||
|
}
|
||||||
|
|
||||||
.lane-unassigned-tag {
|
.lane-unassigned-tag {
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
color: #a56b24;
|
color: #a56b24;
|
||||||
|
|||||||
Reference in New Issue
Block a user