功能:支持待分配预约与首次排班引导
This commit is contained in:
+43
-17
@@ -67,6 +67,8 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
private static final int MONTH_AVAILABLE_MINUTES = 90;
|
||||
private static final String RESERVATION_PENDING_QUOTE = "PENDING_QUOTE";
|
||||
private static final String RESERVATION_CONFIRMED = "CONFIRMED";
|
||||
private static final String RESERVATION_UNASSIGNED = "UNASSIGNED";
|
||||
private static final String ASSIGNMENT_ASSIGNED = "ASSIGNED";
|
||||
private static final String PRODUCT_SOURCE_TYPE_MANAGER_APPOINTMENT = "MANAGER_APPOINTMENT";
|
||||
private static final String ENCODED_UNSET_PASSWORD = "$2a$10$EixZaYVK1fsbw1ZfbX3OXePaWxn96p36WQoeG6Lruj3vjPGga31lW";
|
||||
private static final List<String> ACTIVE_RESERVATION_STATUS = List.of("LOCKED", RESERVATION_PENDING_QUOTE, RESERVATION_CONFIRMED);
|
||||
@@ -169,7 +171,7 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
Long shopId = requirePlanningShopId(currentUser);
|
||||
requireAppointmentDuration(dto.getDurationMinutes());
|
||||
ProductDO product = resolveAppointmentProduct(dto, shopId);
|
||||
UserDO artist = requireActiveArtist(dto.getArtistId(), shopId);
|
||||
UserDO artist = dto.getArtistId() == null ? null : requireActiveArtist(dto.getArtistId(), shopId);
|
||||
UserDO customer = resolveCustomer(shopId, dto);
|
||||
|
||||
int quantity = dto.getQuantity() == null || dto.getQuantity() <= 0 ? 1 : dto.getQuantity();
|
||||
@@ -204,21 +206,23 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
item.setProductId(product.getId());
|
||||
item.setQuantity(quantity);
|
||||
item.setPrice(unitPrice);
|
||||
item.setArtistId(artist.getId());
|
||||
item.setArtistId(artist == null ? null : artist.getId());
|
||||
item.setAppointmentTime(startTime);
|
||||
item.setIsDelete(0);
|
||||
orderItemMapper.insert(item);
|
||||
|
||||
appointmentCapacityService.reserveConfirmedOrThrow(
|
||||
order.getId(),
|
||||
item.getId(),
|
||||
shopId,
|
||||
artist.getId(),
|
||||
product.getTitle(),
|
||||
startTime,
|
||||
endTime,
|
||||
trimToNull(dto.getClientRequestId())
|
||||
);
|
||||
if (artist != null) {
|
||||
appointmentCapacityService.reserveConfirmedOrThrow(
|
||||
order.getId(),
|
||||
item.getId(),
|
||||
shopId,
|
||||
artist.getId(),
|
||||
product.getTitle(),
|
||||
startTime,
|
||||
endTime,
|
||||
trimToNull(dto.getClientRequestId())
|
||||
);
|
||||
}
|
||||
|
||||
return getAppointment(currentUser, item.getId());
|
||||
}
|
||||
@@ -291,6 +295,9 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
}
|
||||
OrderDO order = requireAccessibleOrder(currentUser, orderId);
|
||||
int targetStatus = dto.getStatus();
|
||||
if (targetStatus != OrderStatus.CANCELLED.getCode() && hasUnassignedOrderItem(orderId)) {
|
||||
throw new RuntimeException("请先分配员工");
|
||||
}
|
||||
if (targetStatus == OrderStatus.PENDING_SERVICE.getCode()) {
|
||||
if (!Integer.valueOf(OrderStatus.PENDING_SERVICE.getCode()).equals(order.getStatus())) {
|
||||
orderMapper.updateStatusIfCurrent(order.getId(), order.getStatus(), OrderStatus.PENDING_SERVICE.getCode());
|
||||
@@ -508,8 +515,10 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
? reservation.getProductTitle()
|
||||
: product == null ? "预约作品" : product.getTitle());
|
||||
vo.setArtistId(artistId);
|
||||
vo.setArtistName(artist == null ? "未分配" : artist.getName());
|
||||
vo.setArtistColor(artist == null ? ARTIST_COLORS.get(0) : artist.getColor());
|
||||
boolean unassigned = artistId == null;
|
||||
vo.setArtistName(unassigned ? "待分配" : artist.getName());
|
||||
vo.setArtistColor(unassigned ? "#D59A52" : artist.getColor());
|
||||
vo.setAssignmentStatus(unassigned ? RESERVATION_UNASSIGNED : ASSIGNMENT_ASSIGNED);
|
||||
vo.setDate(start == null ? null : start.toLocalDate().toString());
|
||||
vo.setStartTime(start == null ? null : DATE_TIME_FORMATTER.format(start));
|
||||
vo.setEndTime(end == null ? null : DATE_TIME_FORMATTER.format(end));
|
||||
@@ -517,7 +526,7 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
vo.setDurationMinutes(start == null || end == null ? durationMinutes : Math.toIntExact(Duration.between(start, end).toMinutes()));
|
||||
vo.setStatus(order == null ? null : order.getStatus());
|
||||
vo.setStatusText(statusText(order == null ? null : order.getStatus()));
|
||||
String occupancyStatus = resolveOccupancyStatus(reservation, order);
|
||||
String occupancyStatus = unassigned ? RESERVATION_UNASSIGNED : resolveOccupancyStatus(reservation, order);
|
||||
vo.setOccupancyStatus(occupancyStatus);
|
||||
vo.setCanEdit(canEditAppointment(order, occupancyStatus));
|
||||
vo.setCanCancel(canCancelAppointment(order, occupancyStatus));
|
||||
@@ -575,12 +584,16 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
artistCounts.add(countVO);
|
||||
}
|
||||
int total = dayAppointments.size();
|
||||
int unassignedCount = Math.toIntExact(dayAppointments.stream()
|
||||
.filter(appointment -> appointment.getArtistId() == null)
|
||||
.count());
|
||||
boolean hasWorkingSchedule = workingArtistCount > 0;
|
||||
boolean allFull = workingArtistCount > 0 && fullWorkingArtistCount == workingArtistCount;
|
||||
|
||||
PlanningDaySummaryVO summary = new PlanningDaySummaryVO();
|
||||
summary.setDate(date);
|
||||
summary.setTotalCount(total);
|
||||
summary.setUnassignedCount(unassignedCount);
|
||||
summary.setArtistCounts(artistCounts);
|
||||
summary.setDayStatus(PlanningCalendarSupport.resolveDayStatus(total, hasWorkingSchedule, allFull));
|
||||
summaries.add(summary);
|
||||
@@ -883,14 +896,18 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
|
||||
private Boolean canEditAppointment(OrderDO order, String occupancyStatus) {
|
||||
return order != null
|
||||
&& (RESERVATION_PENDING_QUOTE.equals(occupancyStatus) || RESERVATION_CONFIRMED.equals(occupancyStatus))
|
||||
&& (RESERVATION_PENDING_QUOTE.equals(occupancyStatus)
|
||||
|| RESERVATION_CONFIRMED.equals(occupancyStatus)
|
||||
|| RESERVATION_UNASSIGNED.equals(occupancyStatus))
|
||||
&& !Integer.valueOf(OrderStatus.COMPLETED.getCode()).equals(order.getStatus())
|
||||
&& !Integer.valueOf(OrderStatus.CANCELLED.getCode()).equals(order.getStatus());
|
||||
}
|
||||
|
||||
private Boolean canCancelAppointment(OrderDO order, String occupancyStatus) {
|
||||
return order != null
|
||||
&& (RESERVATION_PENDING_QUOTE.equals(occupancyStatus) || RESERVATION_CONFIRMED.equals(occupancyStatus))
|
||||
&& (RESERVATION_PENDING_QUOTE.equals(occupancyStatus)
|
||||
|| RESERVATION_CONFIRMED.equals(occupancyStatus)
|
||||
|| RESERVATION_UNASSIGNED.equals(occupancyStatus))
|
||||
&& !Integer.valueOf(OrderStatus.COMPLETED.getCode()).equals(order.getStatus())
|
||||
&& !Integer.valueOf(OrderStatus.CANCELLED.getCode()).equals(order.getStatus());
|
||||
}
|
||||
@@ -905,6 +922,15 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean hasUnassignedOrderItem(Long orderId) {
|
||||
QueryWrapper<OrderItemDO> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("order_id", orderId)
|
||||
.eq("is_delete", 0)
|
||||
.isNull("artist_id")
|
||||
.last("LIMIT 1");
|
||||
return orderItemMapper.selectCount(wrapper) > 0;
|
||||
}
|
||||
|
||||
private <T> List<T> safeList(List<T> list) {
|
||||
return list == null ? List.of() : list;
|
||||
}
|
||||
|
||||
+1
@@ -17,6 +17,7 @@ public class PlanningAppointmentVO {
|
||||
private Long artistId;
|
||||
private String artistName;
|
||||
private String artistColor;
|
||||
private String assignmentStatus;
|
||||
private String date;
|
||||
private String startTime;
|
||||
private String endTime;
|
||||
|
||||
+1
@@ -8,6 +8,7 @@ import java.util.List;
|
||||
public class PlanningDaySummaryVO {
|
||||
private String date;
|
||||
private Integer totalCount;
|
||||
private Integer unassignedCount;
|
||||
private List<PlanningArtistCountVO> artistCounts;
|
||||
private String dayStatus;
|
||||
}
|
||||
|
||||
+153
@@ -0,0 +1,153 @@
|
||||
package com.xiaowang.jacyucloudsalon.core.modules.planning.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.artist.mapper.ArtistScheduleExceptionMapper;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.artist.mapper.ArtistScheduleMapper;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.artist.mapper.NailArtistInfoMapper;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.order.entity.OrderDO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.order.entity.OrderItemDO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.order.mapper.OrderItemMapper;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.order.mapper.OrderMapper;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.order.service.OrderService;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.order.support.OrderStatus;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningAppointmentStatusDTO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningAppointmentCreateDTO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.planning.mapper.AppointmentReservationMapper;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.planning.service.AppointmentCapacityService;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.product.mapper.ProductMapper;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.product.entity.ProductDO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.security.support.AdminScopeHelper;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.shop.mapper.ShopMapper;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.shop.entity.ShopDO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.user.entity.UserDO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.user.mapper.UserMapper;
|
||||
import com.xiaowang.jacyucloudsalon.core.support.id.TimeOrderedSnowflakeIdGenerator;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class PlanningServiceImplTest {
|
||||
|
||||
@Mock private AdminScopeHelper adminScopeHelper;
|
||||
@Mock private UserMapper userMapper;
|
||||
@Mock private NailArtistInfoMapper nailArtistInfoMapper;
|
||||
@Mock private ArtistScheduleMapper artistScheduleMapper;
|
||||
@Mock private ArtistScheduleExceptionMapper artistScheduleExceptionMapper;
|
||||
@Mock private AppointmentReservationMapper appointmentReservationMapper;
|
||||
@Mock private OrderMapper orderMapper;
|
||||
@Mock private OrderItemMapper orderItemMapper;
|
||||
@Mock private ProductMapper productMapper;
|
||||
@Mock private ShopMapper shopMapper;
|
||||
@Mock private AppointmentCapacityService appointmentCapacityService;
|
||||
@Mock private OrderService orderService;
|
||||
@Mock private TimeOrderedSnowflakeIdGenerator snowflakeIdGenerator;
|
||||
|
||||
private PlanningServiceImpl service;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
service = new PlanningServiceImpl(adminScopeHelper, userMapper, nailArtistInfoMapper, artistScheduleMapper,
|
||||
artistScheduleExceptionMapper, appointmentReservationMapper, orderMapper, orderItemMapper,
|
||||
productMapper, shopMapper, appointmentCapacityService, orderService, snowflakeIdGenerator);
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsCompletingUnassignedAppointment() {
|
||||
UserDO operator = new UserDO();
|
||||
OrderDO order = order(11L, OrderStatus.PENDING_SERVICE.getCode());
|
||||
when(orderMapper.selectById(11L)).thenReturn(order);
|
||||
when(orderItemMapper.selectCount(any(Wrapper.class))).thenReturn(1L);
|
||||
PlanningAppointmentStatusDTO dto = new PlanningAppointmentStatusDTO();
|
||||
dto.setStatus(OrderStatus.COMPLETED.getCode());
|
||||
|
||||
RuntimeException error = assertThrows(RuntimeException.class, () -> service.updateStatus(operator, 11L, dto));
|
||||
|
||||
assertEquals("请先分配员工", error.getMessage());
|
||||
verify(orderService, never()).processOrder(11L, OrderStatus.COMPLETED.getCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void allowsCancellingUnassignedAppointment() {
|
||||
UserDO operator = new UserDO();
|
||||
OrderDO order = order(12L, OrderStatus.PENDING_SERVICE.getCode());
|
||||
when(orderMapper.selectById(12L)).thenReturn(order);
|
||||
PlanningAppointmentStatusDTO dto = new PlanningAppointmentStatusDTO();
|
||||
dto.setStatus(OrderStatus.CANCELLED.getCode());
|
||||
|
||||
service.updateStatus(operator, 12L, dto);
|
||||
|
||||
verify(orderService).processOrder(12L, OrderStatus.CANCELLED.getCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void createsUnassignedAppointmentWithoutReservation() {
|
||||
service = spy(service);
|
||||
UserDO operator = new UserDO();
|
||||
operator.setType(2);
|
||||
UserDO customer = new UserDO();
|
||||
customer.setId(31L);
|
||||
ProductDO product = new ProductDO();
|
||||
product.setId(41L);
|
||||
product.setShopId(21L);
|
||||
product.setTitle("纯色美甲");
|
||||
product.setPrice(java.math.BigDecimal.valueOf(99));
|
||||
product.setIsDelete(0);
|
||||
ShopDO shop = new ShopDO();
|
||||
shop.setId(21L);
|
||||
shop.setBusinessHours("10:00-22:00");
|
||||
when(adminScopeHelper.resolveShopScope(operator, null)).thenReturn(21L);
|
||||
when(productMapper.selectById(41L)).thenReturn(product);
|
||||
when(userMapper.selectById(31L)).thenReturn(customer);
|
||||
when(shopMapper.selectById(21L)).thenReturn(shop);
|
||||
when(snowflakeIdGenerator.nextIdString()).thenReturn("10001");
|
||||
doAnswer(invocation -> {
|
||||
OrderDO value = invocation.getArgument(0);
|
||||
value.setId(51L);
|
||||
return 1;
|
||||
}).when(orderMapper).insert(any(OrderDO.class));
|
||||
doAnswer(invocation -> {
|
||||
OrderItemDO value = invocation.getArgument(0);
|
||||
value.setId(61L);
|
||||
return 1;
|
||||
}).when(orderItemMapper).insert(any(OrderItemDO.class));
|
||||
doReturn(new com.xiaowang.jacyucloudsalon.core.modules.planning.vo.PlanningAppointmentVO())
|
||||
.when(service).getAppointment(operator, 61L);
|
||||
PlanningAppointmentCreateDTO dto = new PlanningAppointmentCreateDTO();
|
||||
dto.setCustomerUserId(31L);
|
||||
dto.setProductId(41L);
|
||||
dto.setAppointmentDate("2026-10-13");
|
||||
dto.setAppointmentTime("14:00");
|
||||
dto.setDurationMinutes(60);
|
||||
|
||||
service.createAppointment(operator, dto);
|
||||
|
||||
ArgumentCaptor<OrderItemDO> itemCaptor = ArgumentCaptor.forClass(OrderItemDO.class);
|
||||
verify(orderItemMapper).insert(itemCaptor.capture());
|
||||
assertEquals(null, itemCaptor.getValue().getArtistId());
|
||||
verify(appointmentCapacityService, never()).reserveConfirmedOrThrow(
|
||||
any(), any(), any(), any(), any(), any(), any(), any());
|
||||
}
|
||||
|
||||
private OrderDO order(Long id, int status) {
|
||||
OrderDO order = new OrderDO();
|
||||
order.setId(id);
|
||||
order.setShopId(21L);
|
||||
order.setStatus(status);
|
||||
order.setIsDelete(0);
|
||||
return order;
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ Page({
|
||||
appointment: {},
|
||||
avatarText: '',
|
||||
timeText: '',
|
||||
isUnassigned: false,
|
||||
loadError: ''
|
||||
},
|
||||
|
||||
@@ -32,6 +33,7 @@ Page({
|
||||
applyAppointment(appointment) {
|
||||
this.setData({
|
||||
appointment,
|
||||
isUnassigned: appointment.assignmentStatus === 'UNASSIGNED' || !appointment.artistId,
|
||||
avatarText: String(appointment.customerName || '客').slice(0, 1),
|
||||
timeText: `${(appointment.startTime || '').slice(0, 16)} - ${(appointment.endTime || '').slice(11, 16)}`,
|
||||
loadError: ''
|
||||
@@ -39,6 +41,10 @@ Page({
|
||||
},
|
||||
|
||||
async updateStatus(status) {
|
||||
if (status !== 3 && this.data.isUnassigned) {
|
||||
wx.showToast({ title: '请先分配员工', icon: 'none' })
|
||||
return
|
||||
}
|
||||
try {
|
||||
await planningApi.updateStatus(this.data.appointment.orderId, status)
|
||||
markPlanningRefresh()
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
</view>
|
||||
<view class="detail-actions">
|
||||
<text class="tag">{{appointment.statusText}}</text>
|
||||
<button class="small-action" bindtap="goTransfer">改派</button>
|
||||
<button class="small-action" bindtap="goTransfer">{{isUnassigned ? '分配员工' : '改派'}}</button>
|
||||
</view>
|
||||
</view>
|
||||
<view class="detail-grid">
|
||||
@@ -25,7 +25,7 @@
|
||||
</view>
|
||||
<view>
|
||||
<text class="label">美甲师</text>
|
||||
<text class="value">{{appointment.artistName}}</text>
|
||||
<text class="value">{{isUnassigned ? '待分配' : appointment.artistName}}</text>
|
||||
</view>
|
||||
<view>
|
||||
<text class="label">时间</text>
|
||||
@@ -44,8 +44,8 @@
|
||||
</view>
|
||||
|
||||
<view wx:if="{{!loadError}}" class="fixed-bottom action-row">
|
||||
<button class="secondary-btn" bindtap="confirm">确认</button>
|
||||
<button class="primary-btn" bindtap="complete">完成</button>
|
||||
<button class="secondary-btn" disabled="{{isUnassigned}}" bindtap="confirm">{{isUnassigned ? '待分配' : '确认'}}</button>
|
||||
<button class="primary-btn" disabled="{{isUnassigned}}" bindtap="complete">完成</button>
|
||||
<button class="danger-btn" bindtap="cancel">取消</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -170,6 +170,24 @@ function buildAvailableTimeGroups(calendar, form, durationMinutes) {
|
||||
.filter(group => group.times.length > 0)
|
||||
}
|
||||
|
||||
function buildUnassignedTimeGroups(durationMinutes) {
|
||||
const groupMap = {
|
||||
morning: { key: 'morning', title: '上午', times: [] },
|
||||
afternoon: { key: 'afternoon', title: '下午', times: [] },
|
||||
evening: { key: 'evening', title: '晚上', times: [] }
|
||||
}
|
||||
const businessStart = dateUtil.minutesOfDay('10:00')
|
||||
const businessEnd = dateUtil.minutesOfDay('22:00')
|
||||
for (let minute = businessStart; minute + durationMinutes <= businessEnd; minute += TIME_SLOT_MINUTES) {
|
||||
const period = getTimePeriod(minute)
|
||||
groupMap[period.key].times.push({
|
||||
value: dateUtil.timeFromMinutes(minute),
|
||||
rangeText: buildTimeRangeLabel(minute, durationMinutes)
|
||||
})
|
||||
}
|
||||
return Object.keys(groupMap).map(key => groupMap[key]).filter(group => group.times.length > 0)
|
||||
}
|
||||
|
||||
function flattenTimeGroups(groups) {
|
||||
return (groups || []).reduce((list, group) => list.concat(group.times || []), [])
|
||||
}
|
||||
@@ -611,9 +629,13 @@ Page({
|
||||
|
||||
filterArtistItems(artists, keywordValue) {
|
||||
const keyword = String(keywordValue || '').trim().toLowerCase()
|
||||
return (artists || [])
|
||||
const items = (artists || [])
|
||||
.filter(item => !keyword || String(item.name || '').toLowerCase().includes(keyword))
|
||||
.map(buildArtistSelectorItem)
|
||||
if (!keyword || '暂不分配'.includes(keyword)) {
|
||||
items.unshift({ id: '__unassigned__', title: '暂不分配', subtitle: '先记录预约,后续再分配员工', badge: '待分配' })
|
||||
}
|
||||
return items
|
||||
},
|
||||
|
||||
openArtistSheet() {
|
||||
@@ -641,6 +663,17 @@ Page({
|
||||
|
||||
selectArtist(event) {
|
||||
const selectedArtist = event.detail.item || {}
|
||||
if (selectedArtist.id === '__unassigned__') {
|
||||
this.setData({
|
||||
selectedArtist: {},
|
||||
'form.artistId': '',
|
||||
artistSheetVisible: false,
|
||||
conflictTip: '',
|
||||
conflictLevel: 'free'
|
||||
})
|
||||
this.refreshAvailableTimes()
|
||||
return
|
||||
}
|
||||
this.setData({
|
||||
selectedArtist,
|
||||
'form.artistId': selectedArtist.id,
|
||||
@@ -654,7 +687,7 @@ Page({
|
||||
addEmployeeFromSelector() {
|
||||
this.setData({ artistSheetVisible: false })
|
||||
wx.navigateTo({
|
||||
url: '/pages/employee-create/index?picker=1',
|
||||
url: `/pages/employee-create/index?picker=1&date=${encodeURIComponent(this.data.form.appointmentDate || '')}&time=${encodeURIComponent(this.data.form.appointmentTime || '')}&durationMinutes=${encodeURIComponent(this.data.form.durationMinutes || '')}`,
|
||||
success: result => {
|
||||
result.eventChannel.on('employeeCreated', employee => this.handleEmployeeCreated(employee))
|
||||
}
|
||||
@@ -662,15 +695,34 @@ Page({
|
||||
},
|
||||
|
||||
async handleEmployeeCreated(employee) {
|
||||
await this.loadArtists(employee.id, employee)
|
||||
this.setData({ 'form.appointmentTime': '' })
|
||||
const originalTime = this.data.form.appointmentTime
|
||||
await this.loadArtists(employee.autoSelect === false ? '' : employee.id, employee)
|
||||
if (employee.autoSelect === false) {
|
||||
this.setData({ selectedArtist: {}, 'form.artistId': '' })
|
||||
await this.refreshAvailableTimes()
|
||||
return
|
||||
}
|
||||
if (employee.scheduleSaved && originalTime) {
|
||||
const availability = await this.checkAvailability()
|
||||
if (!availability.ok) {
|
||||
this.setData({
|
||||
selectedArtist: {},
|
||||
'form.artistId': '',
|
||||
'form.appointmentTime': originalTime,
|
||||
conflictTip: `${availability.tip || '新员工当前排班无法承接'},预约已保持待分配`,
|
||||
conflictLevel: 'danger'
|
||||
})
|
||||
}
|
||||
} else {
|
||||
this.setData({ 'form.appointmentTime': '' })
|
||||
}
|
||||
await this.refreshAvailableTimes()
|
||||
this.checkAvailability()
|
||||
if (this.data.form.artistId) this.checkAvailability()
|
||||
},
|
||||
|
||||
canOpenTimeSheet() {
|
||||
const form = this.data.form
|
||||
return Boolean(form.appointmentDate && form.artistId && normalizeDuration(form.durationMinutes))
|
||||
return Boolean(form.appointmentDate && normalizeDuration(form.durationMinutes))
|
||||
},
|
||||
|
||||
async refreshAvailableTimes() {
|
||||
@@ -678,11 +730,11 @@ Page({
|
||||
const durationMinutes = normalizeDuration(form.durationMinutes)
|
||||
const requestSeq = (this._availableTimeRequestSeq || 0) + 1
|
||||
this._availableTimeRequestSeq = requestSeq
|
||||
if (!form.appointmentDate || !form.artistId || !durationMinutes) {
|
||||
if (!form.appointmentDate || !durationMinutes) {
|
||||
const patch = {
|
||||
availableTimeGroups: [],
|
||||
timeError: '',
|
||||
timeSelectTip: '请先选择美甲师并填写时长'
|
||||
timeSelectTip: '请先填写预约日期和时长'
|
||||
}
|
||||
if (form.appointmentTime) {
|
||||
patch['form.appointmentTime'] = ''
|
||||
@@ -690,6 +742,16 @@ Page({
|
||||
this.setData(patch)
|
||||
return
|
||||
}
|
||||
if (!form.artistId) {
|
||||
const availableTimeGroups = buildUnassignedTimeGroups(durationMinutes)
|
||||
this.setData({
|
||||
availableTimeGroups,
|
||||
timeError: '',
|
||||
timeLoading: false,
|
||||
timeSelectTip: '请选择预约时间,员工可稍后分配'
|
||||
})
|
||||
return
|
||||
}
|
||||
this.setData({
|
||||
timeLoading: true,
|
||||
timeError: '',
|
||||
@@ -732,7 +794,7 @@ Page({
|
||||
|
||||
async openTimeSheet() {
|
||||
if (!this.canOpenTimeSheet()) {
|
||||
wx.showToast({ title: '请先选择美甲师并填写时长', icon: 'none' })
|
||||
wx.showToast({ title: '请先填写预约日期和时长', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.setData({ timeSheetVisible: true })
|
||||
@@ -754,7 +816,7 @@ Page({
|
||||
|
||||
async checkAvailability() {
|
||||
const form = this.data.form
|
||||
if (!form.appointmentDate || !form.appointmentTime || !form.artistId) {
|
||||
if (!form.appointmentDate || !form.appointmentTime) {
|
||||
this.setData({ conflictTip: '', conflictLevel: 'free' })
|
||||
return { ok: true }
|
||||
}
|
||||
@@ -770,6 +832,11 @@ Page({
|
||||
this.setData({ conflictTip: tip, conflictLevel: 'danger' })
|
||||
return { ok: false, tip }
|
||||
}
|
||||
if (!form.artistId) {
|
||||
const tip = '预约将保存为待分配,当前不会占用员工时间'
|
||||
this.setData({ conflictTip: tip, conflictLevel: 'free' })
|
||||
return { ok: true, tip }
|
||||
}
|
||||
try {
|
||||
const calendar = await planningApi.calendar({
|
||||
startDate: form.appointmentDate,
|
||||
@@ -815,7 +882,7 @@ Page({
|
||||
const form = this.data.form
|
||||
const hasManualProduct = String(form.manualProductTitle || '').trim() && String(form.manualProductPrice || '').trim()
|
||||
const durationMinutes = normalizeDuration(form.durationMinutes)
|
||||
if (!form.customerName || !form.phone || (!form.productId && !hasManualProduct) || !form.artistId) {
|
||||
if (!form.customerName || !form.phone || (!form.productId && !hasManualProduct) || !form.appointmentDate || !form.appointmentTime) {
|
||||
wx.showToast({ title: '请补全预约信息', icon: 'none' })
|
||||
return
|
||||
}
|
||||
@@ -832,12 +899,25 @@ Page({
|
||||
wx.showToast({ title: availability.tip || '该时段已被预约', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!form.artistId) {
|
||||
const result = await new Promise(resolve => {
|
||||
wx.showModal({
|
||||
title: '保存为待分配预约',
|
||||
content: '当前未指定员工,预约会正常保存,但不会占用员工时间。可以稍后在预约详情中分配。',
|
||||
cancelText: '返回选择',
|
||||
confirmText: '继续保存',
|
||||
success: resolve,
|
||||
fail: () => resolve({ confirm: false })
|
||||
})
|
||||
})
|
||||
if (!result.confirm) return
|
||||
}
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
const payload = {
|
||||
...form,
|
||||
customerUserId: form.customerUserId ? String(form.customerUserId) : undefined,
|
||||
artistId: String(form.artistId),
|
||||
artistId: form.artistId ? String(form.artistId) : undefined,
|
||||
durationMinutes,
|
||||
clientRequestId: buildClientRequestId('manager-appointment')
|
||||
}
|
||||
|
||||
@@ -30,9 +30,9 @@
|
||||
<text class="unit">分钟</text>
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label required">指定员工</text>
|
||||
<text class="field-label">员工(可稍后分配)</text>
|
||||
<view class="field-value reference-value" bindtap="openArtistSheet">
|
||||
<text>{{selectedArtist.name || '请选择员工'}}</text>
|
||||
<text>{{selectedArtist.name || '暂不分配'}}</text>
|
||||
<text class="reference-arrow">›</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -41,7 +41,7 @@
|
||||
<view class="field-value time-value {{form.appointmentTime ? '' : 'placeholder'}}" bindtap="openTimeSheet">
|
||||
<view>
|
||||
<text>{{form.appointmentTime || timeSelectTip}}</text>
|
||||
<text wx:if="{{form.appointmentTime}}" class="time-range">{{form.appointmentDate}} · {{selectedArtist.name}} · {{form.durationMinutes}}分钟</text>
|
||||
<text wx:if="{{form.appointmentTime}}" class="time-range">{{form.appointmentDate}} · {{selectedArtist.name || '待分配'}} · {{form.durationMinutes}}分钟</text>
|
||||
</view>
|
||||
<text class="time-arrow">›</text>
|
||||
</view>
|
||||
@@ -54,7 +54,7 @@
|
||||
|
||||
<view class="capacity-tip card">
|
||||
<text class="tip-title">容量校验</text>
|
||||
<text class="tip-text">提交预约时会校验营业时间、美甲师休息和同时间段容量,冲突会直接拦截。</text>
|
||||
<text class="tip-text">已指定员工时会校验排班和冲突;暂不分配时只校验营业时间,后续分配时再完整校验。</text>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{draftSavedAtText}}" class="draft-tip card">
|
||||
@@ -183,13 +183,13 @@
|
||||
<view class="modal-head">
|
||||
<view>
|
||||
<text class="modal-title">选择预约时间</text>
|
||||
<text class="modal-subtitle">{{form.appointmentDate}} · {{selectedArtist.name}} · {{form.durationMinutes}}分钟</text>
|
||||
<text class="modal-subtitle">{{form.appointmentDate}} · {{selectedArtist.name || '待分配'}} · {{form.durationMinutes}}分钟</text>
|
||||
</view>
|
||||
<view class="modal-close" bindtap="closeTimeSheet">×</view>
|
||||
</view>
|
||||
<view wx:if="{{timeLoading}}" class="time-empty">正在计算可约时间...</view>
|
||||
<view wx:elif="{{timeError}}" class="time-empty">{{timeError}}</view>
|
||||
<view wx:elif="{{availableTimeGroups.length === 0}}" class="time-empty">当前美甲师当天暂无可约时间</view>
|
||||
<view wx:elif="{{availableTimeGroups.length === 0}}" class="time-empty">当前没有可选时间</view>
|
||||
<scroll-view wx:else class="time-list" scroll-y>
|
||||
<view wx:for="{{availableTimeGroups}}" wx:key="key" class="time-group">
|
||||
<text class="time-group-title">{{item.title}}</text>
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
const assert = require('assert')
|
||||
const planningApi = require('../../api/planning')
|
||||
|
||||
let redirectedTo = ''
|
||||
global.wx = {
|
||||
getAccountInfoSync: () => ({ miniProgram: { envVersion: 'develop' } }),
|
||||
getDeviceInfo: () => ({ platform: 'devtools' }),
|
||||
removeStorageSync: () => {},
|
||||
setStorageSync: () => {},
|
||||
showToast: () => {},
|
||||
showModal: ({ success }) => success({ confirm: true }),
|
||||
redirectTo: ({ url }) => { redirectedTo = url }
|
||||
}
|
||||
global.getApp = () => ({ globalData: {} })
|
||||
global.getCurrentPages = () => []
|
||||
|
||||
let definition
|
||||
global.Page = value => { definition = value }
|
||||
require('./index')
|
||||
|
||||
function createPage() {
|
||||
return {
|
||||
...definition,
|
||||
data: JSON.parse(JSON.stringify(definition.data)),
|
||||
setData(values) {
|
||||
Object.entries(values).forEach(([key, value]) => {
|
||||
const parts = key.split('.')
|
||||
let target = this.data
|
||||
for (let index = 0; index < parts.length - 1; index += 1) target = target[parts[index]]
|
||||
target[parts[parts.length - 1]] = value
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function run() {
|
||||
const page = createPage()
|
||||
Object.assign(page.data.form, {
|
||||
customerUserId: '31',
|
||||
customerName: '测试客户',
|
||||
phone: '13800138000',
|
||||
productId: '41',
|
||||
appointmentDate: '2026-10-13',
|
||||
appointmentTime: '14:00',
|
||||
durationMinutes: '60',
|
||||
artistId: ''
|
||||
})
|
||||
|
||||
await page.refreshAvailableTimes()
|
||||
assert.strictEqual(page.data.availableTimeGroups.length > 0, true)
|
||||
assert.strictEqual(page.data.timeSelectTip, '请选择预约时间,员工可稍后分配')
|
||||
const availability = await page.checkAvailability()
|
||||
assert.strictEqual(availability.ok, true)
|
||||
assert.strictEqual(page.data.conflictTip.includes('待分配'), true)
|
||||
|
||||
let submittedPayload
|
||||
planningApi.createAppointment = async payload => {
|
||||
submittedPayload = payload
|
||||
return { orderItemId: 61 }
|
||||
}
|
||||
await page.submit()
|
||||
|
||||
assert.strictEqual(submittedPayload.artistId, undefined)
|
||||
assert.strictEqual(submittedPayload.appointmentTime, '14:00')
|
||||
assert.strictEqual(redirectedTo, '/pages/appointment-detail/index?id=61')
|
||||
}
|
||||
|
||||
run().catch(error => {
|
||||
console.error(error)
|
||||
process.exitCode = 1
|
||||
})
|
||||
@@ -1,4 +1,5 @@
|
||||
const assert = require('assert')
|
||||
const planningApi = require('../../api/planning')
|
||||
|
||||
global.wx = {
|
||||
getAccountInfoSync: () => ({ miniProgram: { envVersion: 'develop' } }),
|
||||
@@ -18,12 +19,33 @@ const page = {
|
||||
setData(values) { Object.assign(this.data, values) }
|
||||
}
|
||||
|
||||
page.data.artists = [{ id: 1, name: '小周' }, { id: 2, name: '小李' }]
|
||||
page.onArtistSearch({ detail: { value: '周' } })
|
||||
assert.deepStrictEqual(page.data.artistItems.map(item => item.id), [1])
|
||||
assert.strictEqual(page.data.artistItems[0].avatar, '/assets/images/default-user-avatar.png')
|
||||
async function run() {
|
||||
page.data.artists = [{ id: 1, name: '小周' }, { id: 2, name: '小李' }]
|
||||
page.onArtistSearch({ detail: { value: '周' } })
|
||||
assert.deepStrictEqual(page.data.artistItems.map(item => item.id), [1])
|
||||
assert.strictEqual(page.data.artistItems[0].avatar, '/assets/images/default-user-avatar.png')
|
||||
|
||||
page.selectArtist({ detail: { item: page.data.artistItems[0] } })
|
||||
assert.strictEqual(page.data.selectedArtistId, 1)
|
||||
assert.strictEqual(page.data.selectedArtist.name, '小周')
|
||||
assert.strictEqual(page.data.artistSheetVisible, false)
|
||||
page.selectArtist({ detail: { item: page.data.artistItems[0] } })
|
||||
assert.strictEqual(page.data.selectedArtistId, 1)
|
||||
assert.strictEqual(page.data.selectedArtist.name, '小周')
|
||||
assert.strictEqual(page.data.artistSheetVisible, false)
|
||||
|
||||
page.data.id = '81'
|
||||
planningApi.appointment = async () => ({
|
||||
date: '2026-10-16',
|
||||
startTime: '2026-10-16 15:30:00',
|
||||
durationMinutes: 90,
|
||||
artistId: null,
|
||||
assignmentStatus: 'UNASSIGNED'
|
||||
})
|
||||
assert.strictEqual(await page.loadAppointment(), true)
|
||||
assert.strictEqual(page.data.date, '2026-10-16')
|
||||
assert.strictEqual(page.data.time, '15:30')
|
||||
assert.strictEqual(page.data.durationMinutes, 90)
|
||||
assert.strictEqual(page.data.isUnassigned, true)
|
||||
}
|
||||
|
||||
run().catch(error => {
|
||||
console.error(error)
|
||||
process.exitCode = 1
|
||||
})
|
||||
|
||||
@@ -13,15 +13,38 @@ Page({
|
||||
artistKeyword: '',
|
||||
date: dateUtil.formatDate(new Date()),
|
||||
time: '13:00',
|
||||
durationMinutes: '',
|
||||
isUnassigned: false,
|
||||
loadError: '',
|
||||
loading: false
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
async onLoad(options) {
|
||||
this.setData({
|
||||
id: options.id || ''
|
||||
})
|
||||
this.loadArtists()
|
||||
const loaded = await this.loadAppointment()
|
||||
if (!loaded) return
|
||||
await this.loadArtists()
|
||||
},
|
||||
|
||||
async loadAppointment() {
|
||||
if (!this.data.id) return false
|
||||
try {
|
||||
const appointment = await planningApi.appointment(this.data.id)
|
||||
const startTime = String(appointment.startTime || '')
|
||||
this.setData({
|
||||
date: appointment.date || startTime.slice(0, 10) || this.data.date,
|
||||
time: startTime.slice(11, 16) || this.data.time,
|
||||
durationMinutes: appointment.durationMinutes || '',
|
||||
isUnassigned: appointment.assignmentStatus === 'UNASSIGNED' || !appointment.artistId,
|
||||
loadError: ''
|
||||
})
|
||||
return true
|
||||
} catch (error) {
|
||||
this.setData({ loadError: error.message || '预约详情加载失败' })
|
||||
return false
|
||||
}
|
||||
},
|
||||
|
||||
async loadArtists(preferredArtistId, fallbackEmployee) {
|
||||
@@ -96,9 +119,11 @@ Page({
|
||||
addEmployeeFromSelector() {
|
||||
this.setData({ artistSheetVisible: false })
|
||||
wx.navigateTo({
|
||||
url: '/pages/employee-create/index?picker=1',
|
||||
url: `/pages/employee-create/index?picker=1&date=${encodeURIComponent(this.data.date || '')}&time=${encodeURIComponent(this.data.time || '')}&durationMinutes=${encodeURIComponent(this.data.durationMinutes || '')}`,
|
||||
success: result => {
|
||||
result.eventChannel.on('employeeCreated', employee => this.loadArtists(employee.id, employee))
|
||||
result.eventChannel.on('employeeCreated', employee => {
|
||||
this.loadArtists(employee.autoSelect === false ? '' : employee.id, employee)
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
@@ -122,10 +147,11 @@ Page({
|
||||
await planningApi.moveAppointment(this.data.id, {
|
||||
artistId: Number(this.data.selectedArtistId),
|
||||
appointmentDate: this.data.date,
|
||||
appointmentTime: this.data.time
|
||||
appointmentTime: this.data.time,
|
||||
durationMinutes: Number(this.data.durationMinutes) || undefined
|
||||
})
|
||||
markPlanningRefresh()
|
||||
wx.showToast({ title: '已改派' })
|
||||
wx.showToast({ title: this.data.isUnassigned ? '已分配' : '已改派' })
|
||||
setTimeout(() => wx.navigateBack(), 500)
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '改派失败', icon: 'none' })
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<view class="page no-tab">
|
||||
<view class="card form-card section">
|
||||
<view class="field">
|
||||
<text class="field-label required">改派员工</text>
|
||||
<text class="field-label required">{{isUnassigned ? '分配员工' : '改派员工'}}</text>
|
||||
<view class="field-value transfer-reference" bindtap="openArtistSheet">
|
||||
<view>
|
||||
<text>{{selectedArtist.name || '请选择员工'}}</text>
|
||||
@@ -11,13 +11,13 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label required">新日期</text>
|
||||
<text class="field-label required">预约日期</text>
|
||||
<picker mode="date" value="{{date}}" bindchange="onDateChange">
|
||||
<view class="field-value">{{date}}</view>
|
||||
</picker>
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label required">新时间</text>
|
||||
<text class="field-label required">预约时间</text>
|
||||
<picker mode="time" value="{{time}}" start="10:00" end="22:00" bindchange="onTimeChange">
|
||||
<view class="field-value">{{time}}</view>
|
||||
</picker>
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
<entity-selector-sheet
|
||||
visible="{{artistSheetVisible}}"
|
||||
title="选择改派员工"
|
||||
title="{{isUnassigned ? '选择分配员工' : '选择改派员工'}}"
|
||||
keyword="{{artistKeyword}}"
|
||||
placeholder="搜索员工姓名"
|
||||
items="{{artistItems}}"
|
||||
@@ -43,6 +43,6 @@
|
||||
/>
|
||||
|
||||
<view class="fixed-bottom">
|
||||
<button class="primary-btn" loading="{{loading}}" bindtap="submit">确认改派</button>
|
||||
<button class="primary-btn" loading="{{loading}}" bindtap="submit">{{isUnassigned ? '确认分配' : '确认改派'}}</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -6,6 +6,9 @@ const DEFAULT_EMPLOYEE_PASSWORD = 'Fingertip@123'
|
||||
Page({
|
||||
data: {
|
||||
pickerMode: false,
|
||||
appointmentContext: { date: '', time: '', durationMinutes: '' },
|
||||
onboardingVisible: false,
|
||||
createdEmployee: null,
|
||||
form: {
|
||||
nickname: '',
|
||||
phone: '',
|
||||
@@ -20,7 +23,14 @@ Page({
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
this.setData({ pickerMode: options && options.picker === '1' })
|
||||
this.setData({
|
||||
pickerMode: options && options.picker === '1',
|
||||
appointmentContext: {
|
||||
date: options.date || '',
|
||||
time: options.time || '',
|
||||
durationMinutes: options.durationMinutes || ''
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
onInput(event) {
|
||||
@@ -54,6 +64,9 @@ Page({
|
||||
this.setData({ 'form.avatar': '', 'form.avatarUrl': '' })
|
||||
},
|
||||
|
||||
stopTouchMove() {
|
||||
},
|
||||
|
||||
async submit() {
|
||||
const form = this.data.form
|
||||
const nickname = String(form.nickname || '').trim()
|
||||
@@ -83,14 +96,48 @@ Page({
|
||||
})
|
||||
const id = result && typeof result === 'object' ? (result.id || result.userId) : result
|
||||
const employee = { id, name: nickname, title: nickname, avatar: form.avatar || '' }
|
||||
const eventChannel = this.getOpenerEventChannel && this.getOpenerEventChannel()
|
||||
if (eventChannel && eventChannel.emit) eventChannel.emit('employeeCreated', employee)
|
||||
wx.showToast({ title: '员工已新增', icon: 'success' })
|
||||
setTimeout(() => wx.navigateBack(), 450)
|
||||
this.setData({ createdEmployee: employee, onboardingVisible: true })
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '新增失败', icon: 'none' })
|
||||
} finally {
|
||||
this.setData({ creating: false })
|
||||
}
|
||||
},
|
||||
|
||||
setupFirstSchedule() {
|
||||
const employee = this.data.createdEmployee
|
||||
if (!employee || !employee.id) return
|
||||
const context = this.data.appointmentContext
|
||||
const query = [
|
||||
`id=${encodeURIComponent(employee.id)}`,
|
||||
'onboarding=1',
|
||||
`source=${this.data.pickerMode ? 'appointment' : 'employees'}`,
|
||||
`date=${encodeURIComponent(context.date || '')}`,
|
||||
`time=${encodeURIComponent(context.time || '')}`,
|
||||
`durationMinutes=${encodeURIComponent(context.durationMinutes || '')}`
|
||||
]
|
||||
wx.navigateTo({
|
||||
url: `/pages/schedule-setting/index?${query.join('&')}`,
|
||||
success: result => {
|
||||
result.eventChannel.on('scheduleSaved', () => {
|
||||
setTimeout(() => this.finishCreated(true, true), 250)
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
skipFirstSchedule() {
|
||||
this.finishCreated(!this.data.pickerMode, false)
|
||||
},
|
||||
|
||||
finishCreated(autoSelect, scheduleSaved) {
|
||||
const employee = this.data.createdEmployee
|
||||
const eventChannel = this.getOpenerEventChannel && this.getOpenerEventChannel()
|
||||
if (eventChannel && eventChannel.emit) {
|
||||
eventChannel.emit('employeeCreated', { ...employee, autoSelect, scheduleSaved })
|
||||
}
|
||||
this.setData({ onboardingVisible: false })
|
||||
wx.showToast({ title: scheduleSaved ? '排班已保存' : '员工已新增', icon: 'success' })
|
||||
setTimeout(() => wx.navigateBack(), 300)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -2,11 +2,13 @@ const assert = require('assert')
|
||||
const employeesApi = require('../../api/employees')
|
||||
|
||||
let navigatedBack = false
|
||||
let navigatedTo = ''
|
||||
global.wx = {
|
||||
getAccountInfoSync: () => ({ miniProgram: { envVersion: 'develop' } }),
|
||||
getDeviceInfo: () => ({ platform: 'devtools' }),
|
||||
showToast: () => {},
|
||||
navigateBack: () => { navigatedBack = true }
|
||||
navigateBack: () => { navigatedBack = true },
|
||||
navigateTo: options => { navigatedTo = options.url }
|
||||
}
|
||||
global.setTimeout = callback => { callback(); return 1 }
|
||||
|
||||
@@ -41,9 +43,19 @@ async function run() {
|
||||
})
|
||||
employeesApi.createUser = async () => 88
|
||||
await page.submit()
|
||||
assert.strictEqual(page.data.onboardingVisible, true)
|
||||
assert.strictEqual(emitted, undefined)
|
||||
page.data.pickerMode = true
|
||||
page.skipFirstSchedule()
|
||||
assert.strictEqual(emitted.name, 'employeeCreated')
|
||||
assert.deepStrictEqual(emitted.value, { id: 88, name: '小周', title: '小周', avatar: '' })
|
||||
assert.deepStrictEqual(emitted.value, { id: 88, name: '小周', title: '小周', avatar: '', autoSelect: false, scheduleSaved: false })
|
||||
assert.strictEqual(navigatedBack, true)
|
||||
|
||||
page.data.onboardingVisible = true
|
||||
page.data.createdEmployee = { id: 88, name: '小周' }
|
||||
page.data.appointmentContext = { date: '2026-10-12', time: '14:00', durationMinutes: '60' }
|
||||
page.setupFirstSchedule()
|
||||
assert.strictEqual(navigatedTo.includes('/pages/schedule-setting/index?id=88&onboarding=1&source=appointment'), true)
|
||||
}
|
||||
|
||||
run().catch(error => {
|
||||
|
||||
@@ -41,4 +41,14 @@
|
||||
<view class="fixed-bottom">
|
||||
<button class="primary-btn" loading="{{creating}}" disabled="{{avatarUploading || creating}}" bindtap="submit">保存员工</button>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{onboardingVisible}}" class="onboarding-mask" catchtouchmove="stopTouchMove">
|
||||
<view class="onboarding-card">
|
||||
<view class="onboarding-icon">✓</view>
|
||||
<text class="onboarding-title">员工已创建</text>
|
||||
<text class="onboarding-desc">{{pickerMode ? '设置常规排班后,可继续把当前预约分配给该员工。' : '为新员工设置首个常规排班,之后即可正常承接预约。'}}</text>
|
||||
<button class="primary-btn onboarding-primary" bindtap="setupFirstSchedule">{{pickerMode ? '设置排班并分配' : '立即设置排班'}}</button>
|
||||
<button class="onboarding-skip" bindtap="skipFirstSchedule">{{pickerMode ? '暂不设置' : '稍后设置'}}</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -79,3 +79,43 @@
|
||||
.create-form .field-label {
|
||||
width: 176rpx;
|
||||
}
|
||||
|
||||
.onboarding-mask {
|
||||
position: fixed;
|
||||
z-index: 50;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 44rpx;
|
||||
background: rgba(34, 39, 36, 0.58);
|
||||
}
|
||||
|
||||
.onboarding-card {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 42rpx 34rpx 28rpx;
|
||||
border-radius: 28rpx;
|
||||
background: #fffdf8;
|
||||
}
|
||||
|
||||
.onboarding-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 82rpx;
|
||||
height: 82rpx;
|
||||
border-radius: 50%;
|
||||
background: #e5eee9;
|
||||
color: #39705d;
|
||||
font-size: 38rpx;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.onboarding-title { margin-top: 22rpx; color: #29241f; font-size: 32rpx; font-weight: 900; }
|
||||
.onboarding-desc { margin-top: 12rpx; color: #837b72; font-size: 23rpx; line-height: 1.7; text-align: center; }
|
||||
.onboarding-primary { width: 100%; margin-top: 30rpx; }
|
||||
.onboarding-skip { margin-top: 12rpx; background: transparent; color: #7e776f; font-size: 23rpx; }
|
||||
|
||||
@@ -84,6 +84,9 @@ Page({
|
||||
dayTotal: 0,
|
||||
freeArtistCount: 0,
|
||||
pendingCount: 0,
|
||||
unassignedCount: 0,
|
||||
rangeUnassignedCount: 0,
|
||||
nearestUnassignedDate: '',
|
||||
canCreateAppointment: true,
|
||||
loading: false,
|
||||
calendarError: '',
|
||||
@@ -327,7 +330,10 @@ Page({
|
||||
hours: [],
|
||||
dayTotal: 0,
|
||||
freeArtistCount: 0,
|
||||
pendingCount: 0
|
||||
pendingCount: 0,
|
||||
unassignedCount: 0,
|
||||
rangeUnassignedCount: 0,
|
||||
nearestUnassignedDate: ''
|
||||
})
|
||||
},
|
||||
|
||||
@@ -362,6 +368,8 @@ Page({
|
||||
businessEndTime: snapshot.businessEndTime,
|
||||
artists: snapshot.artists,
|
||||
calendarError: '',
|
||||
rangeUnassignedCount: snapshot.appointments.filter(item => !item.artistId).length,
|
||||
nearestUnassignedDate: this.findNearestUnassignedDate(snapshot.appointments),
|
||||
...this.buildViewState(snapshot)
|
||||
})
|
||||
},
|
||||
@@ -411,11 +419,16 @@ Page({
|
||||
}))
|
||||
return dateUtil.monthGrid(this.data.currentDateText).map(day => {
|
||||
const summary = summaryMap[day.date] || {}
|
||||
const artistCounts = this.normalizeArtistCounts(summary.artistCounts || artistTemplate, calendar)
|
||||
const unassignedCount = Number(summary.unassignedCount || 0)
|
||||
const artistCounts = this.withUnassignedCount(
|
||||
this.normalizeArtistCounts(summary.artistCounts || artistTemplate, calendar),
|
||||
unassignedCount
|
||||
)
|
||||
return {
|
||||
...day,
|
||||
isPast: day.date < todayText,
|
||||
totalCount: summary.totalCount || 0,
|
||||
unassignedCount,
|
||||
dayStatus: summary.dayStatus || 'free',
|
||||
artistCounts,
|
||||
expandedBlocks: this.data.monthDisplayMode === 'blocks' ? this.buildExpandedBlocks(artistCounts) : [],
|
||||
@@ -431,12 +444,17 @@ 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 || [], calendar).filter(count => count.count > 0)
|
||||
const unassignedCount = Number(summary.unassignedCount || 0)
|
||||
const artistCounts = this.withUnassignedCount(
|
||||
this.normalizeArtistCounts(summary.artistCounts || [], calendar),
|
||||
unassignedCount
|
||||
).filter(count => count.count > 0)
|
||||
return {
|
||||
date,
|
||||
weekName: `周${label}`,
|
||||
day: target.getDate(),
|
||||
totalCount: summary.totalCount || 0,
|
||||
unassignedCount,
|
||||
artistCounts: artistCounts.map(count => ({
|
||||
...count,
|
||||
width: Math.max(12, Math.min(100, count.count * 22)),
|
||||
@@ -463,7 +481,7 @@ Page({
|
||||
? (calendar.artists || []).filter(item => String(item.id) === String(this.data.selectedArtistId))
|
||||
: (calendar.artists || [])
|
||||
const dayAppointments = (calendar.appointments || []).filter(item => resolveAppointmentDate(item) === this.data.currentDateText)
|
||||
const lanes = filteredArtists.map(artist => {
|
||||
const employeeLanes = filteredArtists.map(artist => {
|
||||
const blocks = dayAppointments
|
||||
.filter(item => String(item.artistId) === String(artist.id))
|
||||
.map(item => {
|
||||
@@ -475,8 +493,27 @@ Page({
|
||||
timeText: resolveAppointmentTimeText(item)
|
||||
}
|
||||
})
|
||||
return { ...artist, blocks }
|
||||
return { ...artist, artistId: artist.id, blocks }
|
||||
})
|
||||
const unassignedBlocks = dayAppointments
|
||||
.filter(item => !item.artistId)
|
||||
.map(item => {
|
||||
const itemStart = resolveAppointmentStartMinute(item)
|
||||
return {
|
||||
...item,
|
||||
top: Math.max(0, itemStart - startMinute) + laneHeaderHeight,
|
||||
height: Math.max(64, item.durationMinutes || 60),
|
||||
timeText: resolveAppointmentTimeText(item)
|
||||
}
|
||||
})
|
||||
const lanes = this.data.selectedArtistId ? employeeLanes : [{
|
||||
id: '__unassigned__',
|
||||
artistId: '__unassigned__',
|
||||
name: '待分配',
|
||||
color: '#D59A52',
|
||||
blocks: unassignedBlocks,
|
||||
emptyText: '暂无待分配'
|
||||
}, ...employeeLanes]
|
||||
const pendingCount = dayAppointments.filter(item => item.status === 0).length
|
||||
return {
|
||||
dayLanes: lanes,
|
||||
@@ -486,11 +523,48 @@ Page({
|
||||
laneItemWidth: 248,
|
||||
laneWidth: Math.max(720, lanes.length * 248),
|
||||
dayTotal: dayAppointments.length,
|
||||
freeArtistCount: lanes.filter(item => item.blocks.length === 0).length,
|
||||
pendingCount
|
||||
freeArtistCount: employeeLanes.filter(item => item.blocks.length === 0).length,
|
||||
pendingCount,
|
||||
unassignedCount: unassignedBlocks.length
|
||||
}
|
||||
},
|
||||
|
||||
withUnassignedCount(artistCounts, unassignedCount) {
|
||||
if (!unassignedCount) return artistCounts
|
||||
return [{
|
||||
artistId: '__unassigned__',
|
||||
artistName: '待分配',
|
||||
shortName: '待',
|
||||
color: '#D59A52',
|
||||
count: unassignedCount,
|
||||
status: 'pending'
|
||||
}, ...(artistCounts || [])]
|
||||
},
|
||||
|
||||
findNearestUnassignedDate(appointments) {
|
||||
const dates = (appointments || [])
|
||||
.filter(item => !item.artistId)
|
||||
.map(resolveAppointmentDate)
|
||||
.filter(Boolean)
|
||||
.sort()
|
||||
if (!dates.length) return ''
|
||||
const today = dateUtil.formatDate(new Date())
|
||||
return dates.find(date => date >= today) || dates[0]
|
||||
},
|
||||
|
||||
openNearestUnassigned() {
|
||||
if (!this.data.nearestUnassignedDate) return
|
||||
const target = this.data.nearestUnassignedDate
|
||||
this.setData({
|
||||
viewMode: 'day',
|
||||
currentDate: toLocalDate(target),
|
||||
currentDateText: target,
|
||||
selectedArtistId: '',
|
||||
selectedArtistName: '全部员工'
|
||||
})
|
||||
this.loadCalendar()
|
||||
},
|
||||
|
||||
summaryMap(calendar) {
|
||||
return (calendar.daySummaries || []).reduce((map, item) => {
|
||||
map[item.date] = item
|
||||
|
||||
@@ -60,10 +60,21 @@ async function run() {
|
||||
page.data.monthDisplayMode = 'count'
|
||||
const monthDays = definition.buildMonthDays.call(page, {
|
||||
artists: [{ id: 1, name: '员工', shortName: '员', color: '#000' }],
|
||||
daySummaries: []
|
||||
daySummaries: [{ date: dateUtil.formatDate(dateUtil.startOfMonth(page.data.currentDateText)), totalCount: 2, unassignedCount: 1, artistCounts: [] }]
|
||||
})
|
||||
assert.strictEqual(monthDays.length, 42)
|
||||
assert.strictEqual(monthDays.every(item => item.expandedBlocks.length === 0 && item.rowBlocks.length === 0), true)
|
||||
assert.strictEqual(monthDays.some(item => item.artistCounts.some(count => count.artistId === '__unassigned__' && count.count === 1)), true)
|
||||
|
||||
const dayPage = createPage({ currentDateText: '2026-10-12', selectedArtistId: '' })
|
||||
const dayState = dayPage.buildDayView({
|
||||
businessStartTime: '10:00',
|
||||
businessEndTime: '22:00',
|
||||
artists: [{ id: 1, name: '员工', color: '#000' }],
|
||||
appointments: [{ orderItemId: 8, date: '2026-10-12', startTime: '2026-10-12 14:00:00', durationMinutes: 60, artistId: null }]
|
||||
})
|
||||
assert.strictEqual(dayState.dayLanes[0].artistId, '__unassigned__')
|
||||
assert.strictEqual(dayState.dayLanes[0].blocks.length, 1)
|
||||
assert.strictEqual(dayState.unassignedCount, 1)
|
||||
|
||||
const requestPage = createPage({ viewMode: 'day', currentDateText: '2026-10-11' })
|
||||
let calendarRequests = 0
|
||||
|
||||
@@ -28,6 +28,11 @@
|
||||
<text class="chip-count">{{item.rangeCount || 0}}</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<view wx:if="{{!selectedArtistId && rangeUnassignedCount > 0}}" class="unassigned-notice" bindtap="openNearestUnassigned">
|
||||
<view class="chip-dot unassigned-dot"></view>
|
||||
<text>有 {{rangeUnassignedCount}} 个预约待分配员工</text>
|
||||
<text class="unassigned-link">立即处理 ›</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{profilePromptVisible}}" class="profile-prompt-mask">
|
||||
@@ -65,6 +70,10 @@
|
||||
<text class="summary-value">{{pendingCount}}</text>
|
||||
<text class="summary-label">待确认</text>
|
||||
</view>
|
||||
<view class="summary-item card unassigned-summary">
|
||||
<text class="summary-value">{{unassignedCount}}</text>
|
||||
<text class="summary-label">待分配</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<scroll-view class="day-board card" scroll-y>
|
||||
@@ -84,12 +93,12 @@
|
||||
<text class="block-meta">{{block.timeText}} · {{block.productTitle}}</text>
|
||||
<text class="block-status">{{block.statusText}}</text>
|
||||
<view class="block-actions" catchtap="stopTap">
|
||||
<text wx:if="{{block.status === 0}}" data-id="{{block.orderItemId}}" data-status="1" catchtap="quickUpdateStatus">确认</text>
|
||||
<text data-id="{{block.orderItemId}}" catchtap="quickTransfer">改派</text>
|
||||
<text wx:if="{{block.status === 0 && block.assignmentStatus !== 'UNASSIGNED'}}" data-id="{{block.orderItemId}}" data-status="1" catchtap="quickUpdateStatus">确认</text>
|
||||
<text data-id="{{block.orderItemId}}" catchtap="quickTransfer">{{block.assignmentStatus === 'UNASSIGNED' ? '分配' : '改派'}}</text>
|
||||
<text data-id="{{block.orderItemId}}" catchtap="quickCancel">取消</text>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:if="{{item.blocks.length === 0}}" class="lane-empty">全天可约</view>
|
||||
<view wx:if="{{item.blocks.length === 0}}" class="lane-empty">{{item.emptyText || '全天可约'}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
@@ -236,12 +236,38 @@
|
||||
color: #9a9288;
|
||||
}
|
||||
|
||||
.unassigned-notice {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-top: 14rpx;
|
||||
padding: 14rpx 16rpx;
|
||||
border-radius: 12rpx;
|
||||
background: #fff4e5;
|
||||
color: #8b5e24;
|
||||
font-size: 22rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.unassigned-dot {
|
||||
flex: none;
|
||||
background: #d59a52;
|
||||
}
|
||||
|
||||
.unassigned-link {
|
||||
margin-left: auto;
|
||||
color: #a56b24;
|
||||
}
|
||||
|
||||
.day-summary {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 12rpx;
|
||||
}
|
||||
|
||||
.unassigned-summary .summary-value {
|
||||
color: #c57d27;
|
||||
}
|
||||
|
||||
.summary-item {
|
||||
padding: 16rpx;
|
||||
}
|
||||
|
||||
@@ -68,6 +68,9 @@ function buildExceptionSummary(item) {
|
||||
Page({
|
||||
data: {
|
||||
artistId: '',
|
||||
onboarding: false,
|
||||
onboardingSource: '',
|
||||
appointmentContextText: '',
|
||||
presets: PRESETS,
|
||||
presetOptions: buildPresetOptions('DOUBLE_REST'),
|
||||
weekdays: WEEKDAYS,
|
||||
@@ -95,7 +98,13 @@ Page({
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
this.setData({ artistId: options.id || '' })
|
||||
const contextParts = [options.date, options.time, options.durationMinutes ? `${options.durationMinutes}分钟` : ''].filter(Boolean)
|
||||
this.setData({
|
||||
artistId: options.id || '',
|
||||
onboarding: options.onboarding === '1',
|
||||
onboardingSource: options.source || '',
|
||||
appointmentContextText: contextParts.join(' · ')
|
||||
})
|
||||
this.loadRule()
|
||||
},
|
||||
|
||||
@@ -235,7 +244,13 @@ Page({
|
||||
})
|
||||
markPlanningRefresh()
|
||||
wx.showToast({ title: '排班规则已保存', icon: 'success' })
|
||||
await this.loadRule()
|
||||
if (this.data.onboarding) {
|
||||
const eventChannel = this.getOpenerEventChannel && this.getOpenerEventChannel()
|
||||
if (eventChannel && eventChannel.emit) eventChannel.emit('scheduleSaved', { artistId: this.data.artistId })
|
||||
setTimeout(() => wx.navigateBack(), 250)
|
||||
} else {
|
||||
await this.loadRule()
|
||||
}
|
||||
} catch (error) {
|
||||
const message = error.message || '保存失败'
|
||||
wx.showModal({ title: '排班保存失败', content: message, showCancel: false, confirmText: '知道了' })
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
const assert = require('assert')
|
||||
const employeesApi = require('../../api/employees')
|
||||
|
||||
let navigatedBack = false
|
||||
global.wx = {
|
||||
getAccountInfoSync: () => ({ miniProgram: { envVersion: 'develop' } }),
|
||||
getDeviceInfo: () => ({ platform: 'devtools' }),
|
||||
setStorageSync: () => {},
|
||||
showToast: () => {},
|
||||
showModal: () => {},
|
||||
navigateBack: () => { navigatedBack = true }
|
||||
}
|
||||
global.getApp = () => ({ globalData: {} })
|
||||
global.getCurrentPages = () => []
|
||||
global.setTimeout = callback => { callback(); return 1 }
|
||||
|
||||
let definition
|
||||
global.Page = value => { definition = value }
|
||||
require('./index')
|
||||
|
||||
let emitted
|
||||
const page = {
|
||||
...definition,
|
||||
data: JSON.parse(JSON.stringify(definition.data)),
|
||||
getOpenerEventChannel: () => ({ emit: (name, value) => { emitted = { name, value } } }),
|
||||
setData(values) {
|
||||
Object.entries(values).forEach(([key, value]) => {
|
||||
const parts = key.split('.')
|
||||
let target = this.data
|
||||
for (let index = 0; index < parts.length - 1; index += 1) target = target[parts[index]]
|
||||
target[parts[parts.length - 1]] = value
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
async function run() {
|
||||
page.data.artistId = '88'
|
||||
page.data.onboarding = true
|
||||
page.data.onboardingSource = 'appointment'
|
||||
employeesApi.saveScheduleRule = async payload => {
|
||||
assert.strictEqual(payload.artistId, '88')
|
||||
assert.deepStrictEqual(payload.workDays, [1, 2, 3, 4, 5])
|
||||
}
|
||||
|
||||
await page.save()
|
||||
|
||||
assert.deepStrictEqual(emitted, { name: 'scheduleSaved', value: { artistId: '88' } })
|
||||
assert.strictEqual(navigatedBack, true)
|
||||
}
|
||||
|
||||
run().catch(error => {
|
||||
console.error(error)
|
||||
process.exitCode = 1
|
||||
})
|
||||
@@ -1,4 +1,8 @@
|
||||
<view class="page no-tab">
|
||||
<view wx:if="{{onboarding}}" class="onboarding-context card">
|
||||
<text class="onboarding-context-title">首次排班设置</text>
|
||||
<text class="onboarding-context-desc">{{appointmentContextText ? '待承接预约:' + appointmentContextText : '保存常规排班后,员工即可开始承接预约。'}}</text>
|
||||
</view>
|
||||
<view class="section">
|
||||
<view class="section-title">常规排班</view>
|
||||
<view class="card rule-card">
|
||||
@@ -28,7 +32,7 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="section">
|
||||
<view wx:if="{{!onboarding}}" class="section">
|
||||
<view class="section-title">特殊日期</view>
|
||||
<view class="card rule-card">
|
||||
<view class="field">
|
||||
@@ -63,6 +67,6 @@
|
||||
</view>
|
||||
|
||||
<view class="fixed-bottom">
|
||||
<button class="primary-btn" loading="{{saving}}" bindtap="save">保存排班规则</button>
|
||||
<button class="primary-btn" loading="{{saving}}" bindtap="save">{{onboarding && onboardingSource === 'appointment' ? '保存排班并继续分配' : '保存排班规则'}}</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -2,6 +2,19 @@
|
||||
padding: 20rpx 24rpx;
|
||||
}
|
||||
|
||||
.onboarding-context {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8rpx;
|
||||
margin-bottom: 20rpx;
|
||||
padding: 22rpx 24rpx;
|
||||
border-left: 8rpx solid #d59a52;
|
||||
background: #fff7ea;
|
||||
}
|
||||
|
||||
.onboarding-context-title { color: #70481c; font-size: 27rpx; font-weight: 900; }
|
||||
.onboarding-context-desc { color: #8d673b; font-size: 22rpx; line-height: 1.6; }
|
||||
|
||||
.preset-grid,
|
||||
.weekday-grid {
|
||||
display: flex;
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# Salon 待分配预约与新员工排班引导实施计划
|
||||
|
||||
## 目标
|
||||
|
||||
在不新增数据库字段的前提下,让预约可以先保存为待分配状态,并在后续分配员工时执行完整排班与冲突校验;同时为新员工补充首次排班引导。
|
||||
|
||||
## 实施步骤
|
||||
|
||||
1. 调整 Salon Core 规划模型与服务:员工可空、待分配状态、日汇总待分配数量、未分配预约状态操作限制。
|
||||
2. 补充后端测试,覆盖无员工创建、无占用记录、首次分配和未分配状态拦截。
|
||||
3. 调整小程序新增预约表单:员工非必填、可清除选择、无员工时使用普通时间列表并在提交前确认。
|
||||
4. 调整规划月周日视图与预约详情:显示橙色待分配标识、虚拟泳道和分配员工入口。
|
||||
5. 调整员工创建与排班设置页:创建成功后引导首次排班,并通过事件通道返回预约表单继续分配。
|
||||
6. 增加小程序状态测试,更新项目变更记录。
|
||||
7. 运行后端测试与编译、小程序全量测试、静态差异检查及 GitNexus 变更检测,最后创建中文提交。
|
||||
|
||||
## 验收重点
|
||||
|
||||
- 未选择员工也能创建正式预约,且不会创建员工占用记录。
|
||||
- 待分配预约在月、周、日视图和详情中均有明确状态。
|
||||
- 待分配预约不能确认或完成,分配失败不会丢失预约资料。
|
||||
- 新员工可立即进入首次排班;预约来源保存排班后能回填并重新校验。
|
||||
- 现有已分配预约、员工筛选、改派、取消和普通排班流程保持兼容。
|
||||
@@ -169,3 +169,13 @@
|
||||
- 新增来源检查工作流:`.gitea/workflows/environment-promotion-guard.yml`。
|
||||
- 当前环境分支存在未晋级业务差异,首次启用按已确认的一次性安全引导执行;只向 `sit`、`prod` 写入检查工作流,不携带业务改动。
|
||||
|
||||
# 2026-10-12 Salon 待分配预约与新员工首次排班引导
|
||||
|
||||
- 新增预约允许暂不选择员工,客户、作品、日期、时间和时长仍为必填;待分配预约只校验门店营业时间,不创建员工时段占用。
|
||||
- 规划接口补充 `assignmentStatus` 和每日 `unassignedCount`,月、周视图增加橙色待分配标识,日视图最左侧增加待分配虚拟泳道;具体员工筛选不混入待分配预约。
|
||||
- 预约详情在未分配时展示“分配员工”,后端和小程序同时阻止确认或完成,取消仍保持可用;后续继续复用改派接口完成首次分配和容量校验。
|
||||
- 员工创建成功后增加首次排班引导:员工列表可立即设置排班,预约来源可“设置排班并分配”或保持待分配;首次模式隐藏特殊日期并通过事件通道回填预约。
|
||||
- 修复复用改派页时默认使用“今天 13:00”的历史问题:页面现在先读取原预约日期、时间和时长,避免分配员工时意外改变预约时间。
|
||||
- 本次现有字段已支持员工为空,未修改冻结初始化 SQL、版本 SQL、Nacos、后台管理或 ArtList。
|
||||
- GitNexus 已执行关键符号影响分析,但当前索引无法识别相关 Java/小程序页面方法并返回 `UNKNOWN`;本次以静态调用链、Core 测试与编译、小程序全量状态测试替代验证。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user