Merge pull request 'Dev合并到sit' (#63) from dev into sit
Reviewed-on: http://wcy111.top:3000/xiaowang/JayuCloud/pulls/63
This commit was merged in pull request #63.
This commit is contained in:
+1
-1
@@ -53,7 +53,7 @@ public class OperationsAnalyticsServiceImpl implements OperationsAnalyticsServic
|
||||
vo.setCartCount(0L);
|
||||
vo.setOrderCount((long) orders.size());
|
||||
vo.setPaidOrderCount(orders.stream().filter(order -> "PAID".equals(order.getPaymentStatus())).count());
|
||||
vo.setCompletedOrderCount(orders.stream().filter(order -> Integer.valueOf(2).equals(order.getStatus())).count());
|
||||
vo.setCompletedOrderCount(orders.stream().filter(order -> Integer.valueOf(2).equals(order.getStatus()) || Integer.valueOf(4).equals(order.getStatus())).count());
|
||||
vo.setReviewCount(userGrowthRecordMapper.selectCount(new LambdaQueryWrapper<UserGrowthRecordDO>()
|
||||
.eq(UserGrowthRecordDO::getSourceType, "REVIEW")));
|
||||
vo.setRebookCount(userGrowthRecordMapper.selectCount(new LambdaQueryWrapper<UserGrowthRecordDO>()
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ public class WorkbenchServiceImpl implements WorkbenchService {
|
||||
vo.setLowStockItemCount(countLowStock(shopId));
|
||||
vo.setScheduleReminderCount(countMissingSchedules(shopId, artistId, todayStart.toLocalDate()));
|
||||
vo.setTodayServiceCount(countTodayServices(artistId, todayStart, tomorrowStart));
|
||||
vo.setCompletedServiceCount(orders.stream().filter(order -> Integer.valueOf(2).equals(order.getStatus())).count());
|
||||
vo.setCompletedServiceCount(orders.stream().filter(order -> Integer.valueOf(2).equals(order.getStatus()) || Integer.valueOf(4).equals(order.getStatus())).count());
|
||||
vo.setServiceAmount(orders.stream()
|
||||
.map(order -> order.getActualAmount() == null ? BigDecimal.ZERO : order.getActualAmount())
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
|
||||
+10
@@ -18,6 +18,7 @@ import com.xiaowang.jacyucloudsalon.core.modules.manager.dto.ManagerCustomerCrea
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningAppointmentCreateDTO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningAppointmentMoveDTO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningAppointmentStatusDTO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningBackfillOrderCreateDTO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.planning.service.PlanningService;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.planning.vo.PlanningAppointmentVO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.planning.vo.PlanningCalendarVO;
|
||||
@@ -89,6 +90,15 @@ public class AdminManagerController {
|
||||
return Result.success(planningService.createAppointment(currentUser, dto));
|
||||
}
|
||||
|
||||
@PostMapping("/planning/backfill-orders")
|
||||
@RequirePermission("order:process")
|
||||
@OperationGuard(action = "manager-planning-create-backfill-order", ttlSeconds = 10, message = "补单创建处理中,请勿重复提交")
|
||||
public Result<PlanningAppointmentVO> createBackfillOrder(HttpServletRequest request,
|
||||
@RequestBody PlanningBackfillOrderCreateDTO dto) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(planningService.createBackfillOrder(currentUser, dto));
|
||||
}
|
||||
|
||||
@GetMapping("/planning/appointments/{orderItemId}")
|
||||
@RequirePermission("order:view")
|
||||
public Result<PlanningAppointmentVO> appointment(HttpServletRequest request,
|
||||
|
||||
+3
@@ -54,7 +54,10 @@ public class OrderDO extends BaseEntity {
|
||||
private String paymentOrderNo;
|
||||
private String refundStatus;
|
||||
private String customerRemark;
|
||||
private String customerNameSnapshot;
|
||||
private String customerPhoneSnapshot;
|
||||
private String quoteStatus;
|
||||
private String orderSource;
|
||||
private Integer quoteUserConfirmed;
|
||||
private Integer quoteShopConfirmed;
|
||||
private LocalDateTime quoteExpireTime;
|
||||
|
||||
+1
@@ -44,6 +44,7 @@ public class OrderItemDO extends BaseEntity {
|
||||
* Field `appointmentTime` (LocalDateTime): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
|
||||
*/
|
||||
private LocalDateTime appointmentTime;
|
||||
private java.time.LocalDate serviceDate;
|
||||
|
||||
/**
|
||||
* Field `createTime` (LocalDateTime): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
|
||||
|
||||
+19
-1
@@ -1519,7 +1519,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
*/
|
||||
throw new RuntimeException("订单不存在");
|
||||
}
|
||||
if (status != 2 && status != 3) {
|
||||
if (status != 2 && status != 3 && status != 4) {
|
||||
/**
|
||||
* Run business method `RuntimeException`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
@@ -1528,7 +1528,13 @@ public class OrderServiceImpl implements OrderService {
|
||||
throw new RuntimeException("无效的订单状态");
|
||||
}
|
||||
OrderStatus targetStatus = OrderStatus.requireKnown(status);
|
||||
if (status == OrderStatus.IN_SERVICE.getCode()
|
||||
&& !"HISTORICAL_BACKFILL".equals(order.getOrderSource())) {
|
||||
throw new RuntimeException("普通预约不能进入服务中状态");
|
||||
}
|
||||
if (!Integer.valueOf(OrderStatus.PENDING_SERVICE.getCode()).equals(order.getStatus())
|
||||
&& !(Integer.valueOf(OrderStatus.IN_SERVICE.getCode()).equals(order.getStatus())
|
||||
&& (status == OrderStatus.COMPLETED.getCode() || status == OrderStatus.CANCELLED.getCode()))
|
||||
&& !(Integer.valueOf(OrderStatus.PRICE_CONFIRMING.getCode()).equals(order.getStatus())
|
||||
&& Integer.valueOf(OrderStatus.CANCELLED.getCode()).equals(status))) {
|
||||
/**
|
||||
@@ -3278,6 +3284,9 @@ public class OrderServiceImpl implements OrderService {
|
||||
if (Integer.valueOf(3).equals(status)) {
|
||||
return "已取消";
|
||||
}
|
||||
if (Integer.valueOf(4).equals(status)) {
|
||||
return "服务中";
|
||||
}
|
||||
return "未知状态";
|
||||
}
|
||||
|
||||
@@ -3327,6 +3336,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
orderVO.setCustomerNickname(resolveCustomerNickname(customer));
|
||||
orderVO.setCustomerPhoneMasked(maskPhone(customer == null ? null : customer.getPhone()));
|
||||
orderVO.setStatus(order.getStatus());
|
||||
orderVO.setOrderSource(order.getOrderSource());
|
||||
|
||||
switch (order.getStatus()) {
|
||||
case 0:
|
||||
@@ -3341,6 +3351,9 @@ public class OrderServiceImpl implements OrderService {
|
||||
case 3:
|
||||
orderVO.setStatusText("已取消");
|
||||
break;
|
||||
case 4:
|
||||
orderVO.setStatusText("服务中");
|
||||
break;
|
||||
default:
|
||||
orderVO.setStatusText("未知状态");
|
||||
}
|
||||
@@ -3395,6 +3408,8 @@ public class OrderServiceImpl implements OrderService {
|
||||
itemVO.setPrice(displayPrice);
|
||||
itemVO.setTotalPrice(displayPrice.multiply(BigDecimal.valueOf(item.getQuantity())));
|
||||
itemVO.setAppointmentTime(formatAppointmentTime(item.getAppointmentTime()));
|
||||
itemVO.setServiceDate(item.getServiceDate() == null ? null : item.getServiceDate().toString());
|
||||
itemVO.setHistoricalBackfill("HISTORICAL_BACKFILL".equals(order.getOrderSource()));
|
||||
String occupancyStatus = resolveOrderItemOccupancyStatus(order);
|
||||
itemVO.setOccupancyStatus(occupancyStatus);
|
||||
itemVO.setCanEdit(canEditOrderItem(order));
|
||||
@@ -3453,6 +3468,9 @@ public class OrderServiceImpl implements OrderService {
|
||||
if (Integer.valueOf(OrderStatus.COMPLETED.getCode()).equals(order.getStatus())) {
|
||||
return "COMPLETED";
|
||||
}
|
||||
if (Integer.valueOf(OrderStatus.IN_SERVICE.getCode()).equals(order.getStatus())) {
|
||||
return "HISTORICAL_BACKFILL";
|
||||
}
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -19,7 +19,10 @@ public final class OrderStateMachine {
|
||||
if (from == OrderStatus.PRICE_CONFIRMING) {
|
||||
return to == OrderStatus.PENDING_SERVICE || to == OrderStatus.CANCELLED;
|
||||
}
|
||||
return from == OrderStatus.PENDING_SERVICE
|
||||
if (from == OrderStatus.PENDING_SERVICE) {
|
||||
return to == OrderStatus.COMPLETED || to == OrderStatus.CANCELLED;
|
||||
}
|
||||
return from == OrderStatus.IN_SERVICE
|
||||
&& (to == OrderStatus.COMPLETED || to == OrderStatus.CANCELLED);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -10,7 +10,8 @@ public enum OrderStatus {
|
||||
PRICE_CONFIRMING(0),
|
||||
PENDING_SERVICE(1),
|
||||
COMPLETED(2),
|
||||
CANCELLED(3);
|
||||
CANCELLED(3),
|
||||
IN_SERVICE(4);
|
||||
|
||||
/**
|
||||
* Purpose: code supports OrderStatus.java by holding or executing the code business role.
|
||||
|
||||
+2
@@ -57,6 +57,8 @@ public class OrderItemVO {
|
||||
* Field `appointmentTime` (String): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
|
||||
*/
|
||||
private String appointmentTime;
|
||||
private String serviceDate;
|
||||
private Boolean historicalBackfill;
|
||||
private String occupancyStatus;
|
||||
private Boolean canEdit;
|
||||
private Boolean canCancel;
|
||||
|
||||
+1
@@ -66,6 +66,7 @@ public class OrderVO {
|
||||
private String refundStatus;
|
||||
private String customerRemark;
|
||||
private String quoteStatus;
|
||||
private String orderSource;
|
||||
private String quoteStatusText;
|
||||
private Boolean quoteUserConfirmed;
|
||||
private Boolean quoteShopConfirmed;
|
||||
|
||||
+10
@@ -4,6 +4,7 @@ import com.xiaowang.jacyucloudsalon.core.annotation.OperationGuard;
|
||||
import com.xiaowang.jacyucloudsalon.core.annotation.RequirePermission;
|
||||
import com.xiaowang.jacyucloudsalon.core.common.Result;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningAppointmentCreateDTO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningBackfillOrderCreateDTO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningAppointmentMoveDTO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningAppointmentStatusDTO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.user.entity.UserDO;
|
||||
@@ -53,6 +54,15 @@ public class AdminPlanningController {
|
||||
return Result.success(planningService.createAppointment(currentUser, dto));
|
||||
}
|
||||
|
||||
@PostMapping("/backfill-orders")
|
||||
@RequirePermission("order:process")
|
||||
@OperationGuard(action = "admin-planning-create-backfill-order", ttlSeconds = 10, message = "补单创建处理中,请勿重复提交")
|
||||
public Result<PlanningAppointmentVO> createBackfillOrder(HttpServletRequest request,
|
||||
@RequestBody PlanningBackfillOrderCreateDTO dto) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
return Result.success(planningService.createBackfillOrder(currentUser, dto));
|
||||
}
|
||||
|
||||
@GetMapping("/appointments/{orderItemId}")
|
||||
@RequirePermission("order:view")
|
||||
public Result<PlanningAppointmentVO> appointment(HttpServletRequest request,
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.xiaowang.jacyucloudsalon.core.modules.planning.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class PlanningBackfillOrderCreateDTO {
|
||||
private Long productId;
|
||||
private String manualProductTitle;
|
||||
private BigDecimal manualProductPrice;
|
||||
private Long customerUserId;
|
||||
private String customerName;
|
||||
private String phone;
|
||||
private String serviceDate;
|
||||
private String serviceTime;
|
||||
private Long artistId;
|
||||
private BigDecimal amount;
|
||||
private Integer status;
|
||||
private String remark;
|
||||
}
|
||||
+3
@@ -1,6 +1,7 @@
|
||||
package com.xiaowang.jacyucloudsalon.core.modules.planning.service;
|
||||
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningAppointmentCreateDTO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningBackfillOrderCreateDTO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningAppointmentMoveDTO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningAppointmentStatusDTO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.user.entity.UserDO;
|
||||
@@ -17,6 +18,8 @@ public interface PlanningService {
|
||||
|
||||
PlanningAppointmentVO createAppointment(UserDO currentUser, PlanningAppointmentCreateDTO dto);
|
||||
|
||||
PlanningAppointmentVO createBackfillOrder(UserDO currentUser, PlanningBackfillOrderCreateDTO dto);
|
||||
|
||||
PlanningAppointmentVO getAppointment(UserDO currentUser, Long orderItemId);
|
||||
|
||||
PlanningAppointmentVO moveAppointment(UserDO currentUser, Long orderItemId, PlanningAppointmentMoveDTO dto);
|
||||
|
||||
+113
-25
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningAppointmentCreateDTO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningAppointmentMoveDTO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningAppointmentStatusDTO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningBackfillOrderCreateDTO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.planning.entity.AppointmentReservationDO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.artist.entity.ArtistScheduleDO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.artist.entity.ArtistScheduleExceptionDO;
|
||||
@@ -67,6 +68,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 +172,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();
|
||||
@@ -196,6 +199,7 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
order.setPayAmount(amount);
|
||||
order.setPaidAmount(BigDecimal.ZERO);
|
||||
order.setStatus(OrderStatus.PENDING_SERVICE.getCode());
|
||||
order.setOrderSource("NORMAL_APPOINTMENT");
|
||||
order.setIsDelete(0);
|
||||
orderMapper.insert(order);
|
||||
|
||||
@@ -204,25 +208,77 @@ 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());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public PlanningAppointmentVO createBackfillOrder(UserDO currentUser, PlanningBackfillOrderCreateDTO dto) {
|
||||
if (dto == null) throw new RuntimeException("补单信息不能为空");
|
||||
if (Integer.valueOf(3).equals(currentUser.getType())) throw new RuntimeException("美甲师账号不能创建补单");
|
||||
Long shopId = requirePlanningShopId(currentUser);
|
||||
if (!hasText(dto.getServiceDate())) throw new RuntimeException("服务日期不能为空");
|
||||
LocalDate serviceDate;
|
||||
try { serviceDate = LocalDate.parse(dto.getServiceDate()); }
|
||||
catch (DateTimeParseException ex) { throw new RuntimeException("服务日期格式不正确"); }
|
||||
UserDO artist = requireActiveArtist(dto.getArtistId(), shopId);
|
||||
ProductDO product;
|
||||
if (dto.getProductId() != null) product = requireActiveProduct(dto.getProductId(), shopId);
|
||||
else {
|
||||
String title = trimToNull(dto.getManualProductTitle());
|
||||
if (!hasText(title)) throw new RuntimeException("请选择项目或填写项目名称");
|
||||
BigDecimal price = dto.getManualProductPrice() == null ? dto.getAmount() : dto.getManualProductPrice();
|
||||
if (price == null || price.compareTo(BigDecimal.ZERO) < 0) throw new RuntimeException("项目金额不能小于0");
|
||||
product = new ProductDO(); product.setShopId(shopId); product.setTitle(title); product.setPrice(price);
|
||||
product.setSourceType(PRODUCT_SOURCE_TYPE_MANAGER_APPOINTMENT); product.setFrontVisible(0);
|
||||
product.setLikeCount(0); product.setCollectCount(0); product.setIsDelete(0); productMapper.insert(product);
|
||||
}
|
||||
if (dto.getAmount() == null || dto.getAmount().compareTo(BigDecimal.ZERO) < 0) throw new RuntimeException("金额不能为空且不能小于0");
|
||||
int status = dto.getStatus() == null ? OrderStatus.COMPLETED.getCode() : dto.getStatus();
|
||||
if (status != OrderStatus.IN_SERVICE.getCode() && status != OrderStatus.COMPLETED.getCode()) throw new RuntimeException("补单状态只能为服务中或已完成");
|
||||
UserDO customer = null;
|
||||
if (dto.getCustomerUserId() != null) {
|
||||
customer = userMapper.selectById(dto.getCustomerUserId());
|
||||
if (customer == null || Integer.valueOf(1).equals(customer.getIsDelete())) throw new RuntimeException("客户不存在");
|
||||
}
|
||||
LocalDateTime appointmentTime = null;
|
||||
if (hasText(dto.getServiceTime())) {
|
||||
try { appointmentTime = LocalDateTime.of(serviceDate, LocalTime.parse(dto.getServiceTime())); }
|
||||
catch (DateTimeParseException ex) { throw new RuntimeException("服务时间格式不正确"); }
|
||||
}
|
||||
OrderDO order = new OrderDO(); order.setOrderNo("ORD" + snowflakeIdGenerator.nextIdString());
|
||||
order.setUserId(customer == null ? null : customer.getId()); order.setShopId(shopId);
|
||||
order.setTotalAmount(dto.getAmount()); order.setActualAmount(dto.getAmount()); order.setPayAmount(dto.getAmount());
|
||||
order.setPaidAmount(dto.getAmount()); order.setPaymentStatus("PAID"); order.setQuoteStatus("CONFIRMED");
|
||||
order.setQuoteUserConfirmed(1); order.setQuoteShopConfirmed(1); order.setQuoteConfirmedTime(LocalDateTime.now());
|
||||
order.setStatus(status); order.setOrderSource("HISTORICAL_BACKFILL"); order.setCustomerRemark(trimToNull(dto.getRemark()));
|
||||
order.setCustomerNameSnapshot(trimToNull(dto.getCustomerName()));
|
||||
order.setCustomerPhoneSnapshot(trimToNull(dto.getPhone()));
|
||||
order.setIsDelete(0); orderMapper.insert(order);
|
||||
OrderItemDO item = new OrderItemDO(); item.setOrderId(order.getId()); item.setProductId(product.getId());
|
||||
item.setQuantity(1); item.setPrice(dto.getAmount()); item.setArtistId(artist.getId()); item.setServiceDate(serviceDate);
|
||||
item.setAppointmentTime(appointmentTime); item.setIsDelete(0); orderItemMapper.insert(item);
|
||||
return getAppointment(currentUser, item.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlanningAppointmentVO getAppointment(UserDO currentUser, Long orderItemId) {
|
||||
if (orderItemId == null) {
|
||||
@@ -237,7 +293,7 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
AppointmentReservationDO reservation = findActiveReservation(orderItemId);
|
||||
Map<Long, PlanningArtistVO> artistMap = listArtists(order.getShopId(), item.getArtistId()).stream()
|
||||
.collect(Collectors.toMap(PlanningArtistVO::getId, Function.identity(), (a, b) -> a));
|
||||
Map<Long, UserDO> customerMap = loadUsers(Set.of(order.getUserId()));
|
||||
Map<Long, UserDO> customerMap = order.getUserId() == null ? Map.of() : loadUsers(Set.of(order.getUserId()));
|
||||
return toAppointmentVO(reservation, item, order, product, customerMap.get(order.getUserId()), artistMap);
|
||||
}
|
||||
|
||||
@@ -291,6 +347,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());
|
||||
@@ -399,9 +458,9 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
|
||||
QueryWrapper<OrderItemDO> itemWrapper = new QueryWrapper<>();
|
||||
itemWrapper.eq("is_delete", 0)
|
||||
.isNotNull("appointment_time")
|
||||
.ge("appointment_time", rangeStart)
|
||||
.lt("appointment_time", rangeEnd)
|
||||
.and(wrapper -> wrapper
|
||||
.and(q -> q.isNotNull("appointment_time").ge("appointment_time", rangeStart).lt("appointment_time", rangeEnd))
|
||||
.or(q -> q.isNotNull("service_date").ge("service_date", rangeStart.toLocalDate()).lt("service_date", rangeEnd.toLocalDate())))
|
||||
.orderByAsc("appointment_time");
|
||||
if (artistId != null && artistId > 0) {
|
||||
itemWrapper.eq("artist_id", artistId);
|
||||
@@ -501,24 +560,28 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
vo.setOrderNo(order == null ? null : order.getOrderNo());
|
||||
vo.setOrderItemId(item == null ? reservation == null ? null : reservation.getOrderItemId() : item.getId());
|
||||
vo.setCustomerId(customer == null ? order == null ? null : order.getUserId() : customer.getId());
|
||||
vo.setCustomerName(customer == null ? "到店客户" : firstNonBlank(customer.getNickname(), customer.getAccount(), "到店客户"));
|
||||
vo.setCustomerPhone(customer == null ? null : firstNonBlank(customer.getContactPhone(), customer.getPhone(), ""));
|
||||
vo.setCustomerName(customer == null ? firstNonBlank(order == null ? null : order.getCustomerNameSnapshot(), "散客") : firstNonBlank(customer.getNickname(), customer.getAccount(), "到店客户"));
|
||||
vo.setCustomerPhone(customer == null ? order == null ? null : order.getCustomerPhoneSnapshot() : firstNonBlank(customer.getContactPhone(), customer.getPhone(), ""));
|
||||
vo.setProductId(product == null ? item == null ? null : item.getProductId() : product.getId());
|
||||
vo.setProductTitle(reservation != null && hasText(reservation.getProductTitle())
|
||||
? 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());
|
||||
vo.setDate(start == null ? null : start.toLocalDate().toString());
|
||||
boolean unassigned = artistId == null;
|
||||
vo.setArtistName(unassigned ? "待分配" : artist == null ? "美甲师" : artist.getName());
|
||||
vo.setArtistColor(unassigned ? "#D59A52" : artist == null ? "#7BA7C7" : artist.getColor());
|
||||
vo.setAssignmentStatus(unassigned ? RESERVATION_UNASSIGNED : ASSIGNMENT_ASSIGNED);
|
||||
vo.setHistoricalBackfill(order != null && "HISTORICAL_BACKFILL".equals(order.getOrderSource()));
|
||||
LocalDate serviceDate = item == null ? null : item.getServiceDate();
|
||||
vo.setDate(start == null ? serviceDate == null ? null : serviceDate.toString() : start.toLocalDate().toString());
|
||||
vo.setStartTime(start == null ? null : DATE_TIME_FORMATTER.format(start));
|
||||
vo.setEndTime(end == null ? null : DATE_TIME_FORMATTER.format(end));
|
||||
vo.setStartMinute(start == null ? null : start.toLocalTime().toSecondOfDay() / 60);
|
||||
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);
|
||||
vo.setOccupancyStatus(occupancyStatus);
|
||||
String occupancyStatus = unassigned ? RESERVATION_UNASSIGNED : resolveOccupancyStatus(reservation, order);
|
||||
vo.setOccupancyStatus(Boolean.TRUE.equals(vo.getHistoricalBackfill()) ? "HISTORICAL_BACKFILL" : occupancyStatus);
|
||||
vo.setCanEdit(canEditAppointment(order, occupancyStatus));
|
||||
vo.setCanCancel(canCancelAppointment(order, occupancyStatus));
|
||||
vo.setConflictReason(resolveAppointmentConflictReason(occupancyStatus));
|
||||
@@ -575,12 +638,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);
|
||||
@@ -853,12 +920,18 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
if (Integer.valueOf(OrderStatus.COMPLETED.getCode()).equals(status)) {
|
||||
return "已完成";
|
||||
}
|
||||
if (Integer.valueOf(OrderStatus.IN_SERVICE.getCode()).equals(status)) {
|
||||
return "服务中";
|
||||
}
|
||||
if (Integer.valueOf(OrderStatus.CANCELLED.getCode()).equals(status)) {
|
||||
return "已取消";
|
||||
}
|
||||
if (Integer.valueOf(OrderStatus.PRICE_CONFIRMING.getCode()).equals(status)) {
|
||||
return "待确认";
|
||||
}
|
||||
if (Integer.valueOf(OrderStatus.IN_SERVICE.getCode()).equals(status)) {
|
||||
return "服务中";
|
||||
}
|
||||
return "未知";
|
||||
}
|
||||
|
||||
@@ -883,14 +956,20 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
|
||||
private Boolean canEditAppointment(OrderDO order, String occupancyStatus) {
|
||||
return order != null
|
||||
&& (RESERVATION_PENDING_QUOTE.equals(occupancyStatus) || RESERVATION_CONFIRMED.equals(occupancyStatus))
|
||||
&& !"HISTORICAL_BACKFILL".equals(order.getOrderSource())
|
||||
&& (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))
|
||||
&& (!"HISTORICAL_BACKFILL".equals(order.getOrderSource()) || Integer.valueOf(OrderStatus.IN_SERVICE.getCode()).equals(order.getStatus()))
|
||||
&& (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 +984,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;
|
||||
}
|
||||
|
||||
+2
@@ -17,6 +17,8 @@ public class PlanningAppointmentVO {
|
||||
private Long artistId;
|
||||
private String artistName;
|
||||
private String artistColor;
|
||||
private String assignmentStatus;
|
||||
private Boolean historicalBackfill;
|
||||
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;
|
||||
}
|
||||
|
||||
+8
-2
@@ -2,8 +2,9 @@ package com.xiaowang.jacyucloudsalon.core.modules.registration.controller;
|
||||
|
||||
import com.xiaowang.jacyucloudsalon.core.common.Result;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.registration.dto.WorkbenchRegistrationRejectDTO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.registration.entity.WorkbenchRegistrationApplicationDO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.registration.service.WorkbenchRegistrationService;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.registration.vo.WorkbenchRegistrationReviewSummaryVO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.registration.vo.WorkbenchRegistrationReviewVO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.user.entity.UserDO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.user.mapper.UserMapper;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -28,12 +29,17 @@ public class AdminWorkbenchRegistrationController {
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
public Result<List<WorkbenchRegistrationApplicationDO>> list(HttpServletRequest request) {
|
||||
public Result<List<WorkbenchRegistrationReviewVO>> list(HttpServletRequest request) {
|
||||
Long userId = requireUserId(request);
|
||||
UserDO user = userMapper.selectById(userId);
|
||||
return Result.success(registrationService.listForReviewer(userId, isPlatformAdmin(user)));
|
||||
}
|
||||
|
||||
@GetMapping("/summary")
|
||||
public Result<WorkbenchRegistrationReviewSummaryVO> summary(HttpServletRequest request) {
|
||||
return Result.success(registrationService.getReviewSummary(requireUserId(request)));
|
||||
}
|
||||
|
||||
@PostMapping("/{id}/approve")
|
||||
public Result<Boolean> approve(HttpServletRequest request, @PathVariable Long id) {
|
||||
Long userId = requireUserId(request);
|
||||
|
||||
+5
@@ -2,6 +2,11 @@ package com.xiaowang.jacyucloudsalon.core.modules.registration.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.registration.entity.WorkbenchRegistrationApplicationDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
public interface WorkbenchRegistrationApplicationMapper extends BaseMapper<WorkbenchRegistrationApplicationDO> {
|
||||
|
||||
@Select("SELECT * FROM t_workbench_registration_application WHERE id = #{id} AND is_delete = 0 FOR UPDATE")
|
||||
WorkbenchRegistrationApplicationDO selectByIdForUpdate(@Param("id") Long id);
|
||||
}
|
||||
|
||||
+4
-2
@@ -1,7 +1,8 @@
|
||||
package com.xiaowang.jacyucloudsalon.core.modules.registration.service;
|
||||
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.registration.dto.WorkbenchRegistrationRequestDTO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.registration.entity.WorkbenchRegistrationApplicationDO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.registration.vo.WorkbenchRegistrationReviewSummaryVO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.registration.vo.WorkbenchRegistrationReviewVO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.registration.vo.WorkbenchRegistrationStatusVO;
|
||||
|
||||
import java.util.List;
|
||||
@@ -10,7 +11,8 @@ public interface WorkbenchRegistrationService {
|
||||
WorkbenchRegistrationStatusVO register(WorkbenchRegistrationRequestDTO request);
|
||||
WorkbenchRegistrationStatusVO getStatus(Long userId);
|
||||
WorkbenchRegistrationStatusVO resubmit(WorkbenchRegistrationRequestDTO request);
|
||||
List<WorkbenchRegistrationApplicationDO> listForReviewer(Long reviewerId, boolean platformAdmin);
|
||||
List<WorkbenchRegistrationReviewVO> listForReviewer(Long reviewerId, boolean platformAdmin);
|
||||
WorkbenchRegistrationReviewSummaryVO getReviewSummary(Long reviewerId);
|
||||
boolean approve(Long reviewerId, boolean platformAdmin, Long applicationId);
|
||||
boolean reject(Long reviewerId, boolean platformAdmin, Long applicationId, String reason);
|
||||
}
|
||||
|
||||
+73
-10
@@ -7,6 +7,8 @@ import com.xiaowang.jacyucloudsalon.core.modules.registration.entity.WorkbenchRe
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.registration.entity.WorkbenchRegistrationStatus;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.registration.mapper.WorkbenchRegistrationApplicationMapper;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.registration.service.WorkbenchRegistrationService;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.registration.vo.WorkbenchRegistrationReviewSummaryVO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.registration.vo.WorkbenchRegistrationReviewVO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.registration.vo.WorkbenchRegistrationStatusVO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.integration.service.WechatMiniAuthService;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.integration.dto.WechatMiniRegistrationTicket;
|
||||
@@ -18,13 +20,19 @@ import com.xiaowang.jacyucloudsalon.core.modules.shop.mapper.UserShopBindingMapp
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.user.entity.UserDO;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.user.mapper.UserMapper;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.user.service.UserService;
|
||||
import com.xiaowang.jacyucloudsalon.core.modules.system.service.SystemParameterConfigService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationService {
|
||||
@@ -35,6 +43,7 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe
|
||||
private final UserShopBindingSupport userShopBindingSupport;
|
||||
private final UserShopBindingMapper userShopBindingMapper;
|
||||
private final WechatMiniAuthService wechatMiniAuthService;
|
||||
private final SystemParameterConfigService systemParameterConfigService;
|
||||
|
||||
public WorkbenchRegistrationServiceImpl(
|
||||
WorkbenchRegistrationApplicationMapper applicationMapper,
|
||||
@@ -43,7 +52,8 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe
|
||||
UserService userService,
|
||||
UserShopBindingSupport userShopBindingSupport,
|
||||
UserShopBindingMapper userShopBindingMapper,
|
||||
WechatMiniAuthService wechatMiniAuthService
|
||||
WechatMiniAuthService wechatMiniAuthService,
|
||||
SystemParameterConfigService systemParameterConfigService
|
||||
) {
|
||||
this.applicationMapper = applicationMapper;
|
||||
this.userMapper = userMapper;
|
||||
@@ -52,6 +62,7 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe
|
||||
this.userShopBindingSupport = userShopBindingSupport;
|
||||
this.userShopBindingMapper = userShopBindingMapper;
|
||||
this.wechatMiniAuthService = wechatMiniAuthService;
|
||||
this.systemParameterConfigService = systemParameterConfigService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -158,13 +169,38 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WorkbenchRegistrationApplicationDO> listForReviewer(Long reviewerId, boolean platformAdmin) {
|
||||
public List<WorkbenchRegistrationReviewVO> listForReviewer(Long reviewerId, boolean platformAdmin) {
|
||||
List<WorkbenchRegistrationApplicationDO> applications;
|
||||
if (platformAdmin) {
|
||||
return applicationMapper.selectList(Wrappers.lambdaQuery(WorkbenchRegistrationApplicationDO.class).eq(WorkbenchRegistrationApplicationDO::getStatus, WorkbenchRegistrationStatus.PENDING_ADMIN).eq(WorkbenchRegistrationApplicationDO::getIsDelete, 0).orderByAsc(WorkbenchRegistrationApplicationDO::getCreateTime));
|
||||
applications = applicationMapper.selectList(Wrappers.lambdaQuery(WorkbenchRegistrationApplicationDO.class).eq(WorkbenchRegistrationApplicationDO::getStatus, WorkbenchRegistrationStatus.PENDING_ADMIN).eq(WorkbenchRegistrationApplicationDO::getIsDelete, 0).orderByAsc(WorkbenchRegistrationApplicationDO::getCreateTime));
|
||||
} else {
|
||||
UserDO reviewer = requireManager(reviewerId);
|
||||
applications = applicationMapper.selectList(Wrappers.lambdaQuery(WorkbenchRegistrationApplicationDO.class).eq(WorkbenchRegistrationApplicationDO::getStatus, WorkbenchRegistrationStatus.PENDING_MANAGER).eq(WorkbenchRegistrationApplicationDO::getShopId, reviewer.getShopId()).eq(WorkbenchRegistrationApplicationDO::getIsDelete, 0).orderByAsc(WorkbenchRegistrationApplicationDO::getCreateTime));
|
||||
}
|
||||
UserDO reviewer = userMapper.selectById(reviewerId);
|
||||
require(reviewer != null && Integer.valueOf(2).equals(reviewer.getType()), "仅店长可以审核店员申请");
|
||||
return applicationMapper.selectList(Wrappers.lambdaQuery(WorkbenchRegistrationApplicationDO.class).eq(WorkbenchRegistrationApplicationDO::getStatus, WorkbenchRegistrationStatus.PENDING_MANAGER).eq(WorkbenchRegistrationApplicationDO::getShopId, reviewer.getShopId()).eq(WorkbenchRegistrationApplicationDO::getIsDelete, 0).orderByAsc(WorkbenchRegistrationApplicationDO::getCreateTime));
|
||||
List<Long> applicantIds = applications.stream()
|
||||
.map(WorkbenchRegistrationApplicationDO::getUserId)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
Map<Long, UserDO> applicants = applicantIds.isEmpty()
|
||||
? Map.of()
|
||||
: userMapper.selectBatchIds(applicantIds).stream()
|
||||
.collect(Collectors.toMap(UserDO::getId, Function.identity()));
|
||||
return applications.stream()
|
||||
.map(application -> toReviewVO(application, applicants.get(application.getUserId())))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorkbenchRegistrationReviewSummaryVO getReviewSummary(Long reviewerId) {
|
||||
UserDO reviewer = requireManager(reviewerId);
|
||||
Long pendingCount = applicationMapper.selectCount(Wrappers.lambdaQuery(WorkbenchRegistrationApplicationDO.class)
|
||||
.eq(WorkbenchRegistrationApplicationDO::getStatus, WorkbenchRegistrationStatus.PENDING_MANAGER)
|
||||
.eq(WorkbenchRegistrationApplicationDO::getShopId, reviewer.getShopId())
|
||||
.eq(WorkbenchRegistrationApplicationDO::getIsDelete, 0));
|
||||
boolean noticeEnabled = "true".equalsIgnoreCase(systemParameterConfigService.getEnabledValue(
|
||||
"WORKBENCH", "MANAGER_REGISTRATION_REVIEW_NOTICE"));
|
||||
return new WorkbenchRegistrationReviewSummaryVO(pendingCount == null ? 0L : pendingCount, noticeEnabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -204,14 +240,16 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe
|
||||
}
|
||||
|
||||
private WorkbenchRegistrationApplicationDO loadReviewable(Long reviewerId, boolean platformAdmin, Long applicationId) {
|
||||
WorkbenchRegistrationApplicationDO application = applicationMapper.selectById(applicationId);
|
||||
require(application != null && WorkbenchRegistrationStatus.REJECTED.equals(application.getStatus()) == false, "审核申请不存在或已处理");
|
||||
WorkbenchRegistrationApplicationDO application = applicationMapper.selectByIdForUpdate(applicationId);
|
||||
require(application != null, "审核申请不存在或已处理");
|
||||
if (platformAdmin) {
|
||||
require(WorkbenchRegistrationStatus.PENDING_ADMIN.equals(application.getStatus()), "管理员只能审核店长申请");
|
||||
require(WorkbenchRegistrationRole.MANAGER.equals(application.getRoleType()), "管理员只能审核店长申请");
|
||||
} else {
|
||||
UserDO reviewer = userMapper.selectById(reviewerId);
|
||||
require(reviewer != null && Integer.valueOf(2).equals(reviewer.getType()) && reviewer.getShopId().equals(application.getShopId()), "无权审核该店铺申请");
|
||||
UserDO reviewer = requireManager(reviewerId);
|
||||
require(Objects.equals(reviewer.getShopId(), application.getShopId()), "无权审核该店铺申请");
|
||||
require(WorkbenchRegistrationStatus.PENDING_MANAGER.equals(application.getStatus()), "店长只能审核店员申请");
|
||||
require(WorkbenchRegistrationRole.STAFF.equals(application.getRoleType()), "店长只能审核店员申请");
|
||||
}
|
||||
return application;
|
||||
}
|
||||
@@ -224,6 +262,31 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe
|
||||
return new WorkbenchRegistrationStatusVO(application.getId(), application.getApplicationNo(), application.getRoleType(), application.getStatus(), application.getRejectReason(), application.getShopId(), application.getShopName());
|
||||
}
|
||||
|
||||
private WorkbenchRegistrationReviewVO toReviewVO(WorkbenchRegistrationApplicationDO application, UserDO applicant) {
|
||||
WorkbenchRegistrationReviewVO review = new WorkbenchRegistrationReviewVO();
|
||||
BeanUtils.copyProperties(application, review);
|
||||
if (applicant != null) {
|
||||
review.setApplicantNickname(applicant.getNickname());
|
||||
review.setApplicantAvatar(applicant.getAvatar());
|
||||
review.setApplicantMaskedPhone(maskPhone(applicant.getPhone()));
|
||||
}
|
||||
return review;
|
||||
}
|
||||
|
||||
private UserDO requireManager(Long reviewerId) {
|
||||
UserDO reviewer = userMapper.selectById(reviewerId);
|
||||
require(reviewer != null && Integer.valueOf(2).equals(reviewer.getType()) && reviewer.getShopId() != null,
|
||||
"仅店长可以审核店员申请");
|
||||
return reviewer;
|
||||
}
|
||||
|
||||
private String maskPhone(String phone) {
|
||||
if (!StringUtils.hasText(phone) || phone.length() < 7) {
|
||||
return "";
|
||||
}
|
||||
return phone.substring(0, 3) + "****" + phone.substring(phone.length() - 4);
|
||||
}
|
||||
|
||||
private String requireText(String value, String message) {
|
||||
require(StringUtils.hasText(value), message);
|
||||
return value.trim();
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.xiaowang.jacyucloudsalon.core.modules.registration.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class WorkbenchRegistrationReviewSummaryVO {
|
||||
private final long pendingCount;
|
||||
private final boolean noticeEnabled;
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.xiaowang.jacyucloudsalon.core.modules.registration.vo;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class WorkbenchRegistrationReviewVO {
|
||||
private Long id;
|
||||
private String applicationNo;
|
||||
private Long userId;
|
||||
private String roleType;
|
||||
private Long shopId;
|
||||
private String shopName;
|
||||
private String shopAddress;
|
||||
private String status;
|
||||
private Long reviewerId;
|
||||
private LocalDateTime reviewedAt;
|
||||
private String rejectReason;
|
||||
private LocalDateTime createTime;
|
||||
private LocalDateTime updateTime;
|
||||
private String applicantNickname;
|
||||
private String applicantAvatar;
|
||||
private String applicantMaskedPhone;
|
||||
}
|
||||
+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;
|
||||
}
|
||||
}
|
||||
+5
@@ -27,5 +27,10 @@ class WorkbenchRegistrationControllerMappingTest {
|
||||
GetMapping listMapping = listMethod.getAnnotation(GetMapping.class);
|
||||
assertNotNull(listMapping);
|
||||
assertEquals("/list", Arrays.stream(listMapping.value()).findFirst().orElse(""));
|
||||
|
||||
Method summaryMethod = AdminWorkbenchRegistrationController.class.getMethod("summary", javax.servlet.http.HttpServletRequest.class);
|
||||
GetMapping summaryMapping = summaryMethod.getAnnotation(GetMapping.class);
|
||||
assertNotNull(summaryMapping);
|
||||
assertEquals("/summary", Arrays.stream(summaryMapping.value()).findFirst().orElse(""));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1983,6 +1983,10 @@ export interface WorkbenchRegistrationApplication {
|
||||
status: 'PENDING_ADMIN' | 'PENDING_MANAGER' | 'APPROVED' | 'REJECTED'
|
||||
rejectReason?: string
|
||||
createTime?: string
|
||||
updateTime?: string
|
||||
applicantNickname?: string
|
||||
applicantAvatar?: string
|
||||
applicantMaskedPhone?: string
|
||||
}
|
||||
|
||||
export const adminWorkbenchRegistrationApi = {
|
||||
|
||||
@@ -34,7 +34,7 @@ const formatMoney = (value?: number | string) => {
|
||||
const formatDateTime = (value?: string) => value ? String(value).replace('T', ' ').slice(0, 16) : '--'
|
||||
const isQuoteStatus = (status?: unknown) => Number(status) === 0
|
||||
const isQuoteConfirming = computed(() => isQuoteStatus(order.value?.status))
|
||||
const statusClass = (status?: number) => isQuoteStatus(status) ? 'quote' : status === 2 ? 'done' : status === 3 ? 'cancelled' : 'pending'
|
||||
const statusClass = (status?: number) => isQuoteStatus(status) ? 'quote' : status === 2 ? 'done' : status === 3 ? 'cancelled' : status === 4 ? 'in-service' : 'pending'
|
||||
const isOrderPaid = (target: any) => String(target?.paymentStatus || '').toUpperCase() === 'PAID'
|
||||
const canPreparePayment = computed(() => !isQuoteConfirming.value && Number(order.value?.status) === 1 && !isOrderPaid(order.value))
|
||||
const canMockPay = computed(() => !isQuoteConfirming.value && Number(order.value?.status) === 1 && String(order.value?.paymentStatus || '').toUpperCase() === 'PAYING')
|
||||
|
||||
@@ -31,7 +31,7 @@ const nodes = computed(() => {
|
||||
{ key: 'created', title: '订单创建', desc: formatTime(current.createTime), done: true, active: false },
|
||||
{ key: 'appointment', title: '预约确认', desc: formatTime(firstAppointment.value), done: Boolean(firstAppointment.value), active: status === 1 },
|
||||
{ key: 'artist', title: '服务安排', desc: latestChangeText.value, done: changes.value.length > 0 || items.value.some((item: any) => item.artistName), active: changes.value.some(item => item.status === 'PENDING') },
|
||||
{ key: 'service', title: status === 3 ? '订单取消' : '服务完成', desc: formatTime(current.completeTime || current.cancelTime || current.updateTime), done: status === 2 || status === 3, active: status === 2 || status === 3 },
|
||||
{ key: 'service', title: status === 3 ? '订单取消' : status === 4 ? '服务中' : '服务完成', desc: formatTime(current.completeTime || current.cancelTime || current.updateTime), done: status === 2 || status === 3, active: status === 2 || status === 3 || status === 4 },
|
||||
{ key: 'after-sale', title: '售后/评价', desc: afterSales.value.length ? `${afterSales.value.length} 条售后` : (reviews.value.length ? `${reviews.value.length} 条评价` : '暂无记录'), done: afterSales.value.length > 0 || reviews.value.length > 0, active: afterSales.value.some(item => item.status === 'PENDING') || reviews.value.some(item => !item.rating) }
|
||||
]
|
||||
})
|
||||
|
||||
@@ -108,6 +108,22 @@
|
||||
>
|
||||
取消订单
|
||||
</a-button>
|
||||
<a-button
|
||||
v-if="record.status === 4 && canProcessOrders"
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="process(record.id, 2)"
|
||||
>
|
||||
完成补单
|
||||
</a-button>
|
||||
<a-button
|
||||
v-if="record.status === 4 && canProcessOrders && !isArtist"
|
||||
danger
|
||||
size="small"
|
||||
@click="process(record.id, 3)"
|
||||
>
|
||||
取消补单
|
||||
</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
@@ -175,6 +191,8 @@
|
||||
>
|
||||
取消
|
||||
</a-button>
|
||||
<a-button v-if="item.status === 4 && canProcessOrders" size="small" type="primary" @click="process(item.id, 2)">完成补单</a-button>
|
||||
<a-button v-if="item.status === 4 && canProcessOrders && !isArtist" size="small" danger @click="process(item.id, 3)">取消补单</a-button>
|
||||
</div>
|
||||
</article>
|
||||
</template>
|
||||
@@ -195,6 +213,7 @@
|
||||
<a-descriptions-item label="实付金额">{{ formatMoney(currentOrder.actualAmount) }}</a-descriptions-item>
|
||||
<a-descriptions-item label="优惠券">{{ currentOrder.couponName || '无' }}</a-descriptions-item>
|
||||
<a-descriptions-item label="订单状态">{{ orderStatusText(currentOrder) }}</a-descriptions-item>
|
||||
<a-descriptions-item label="订单来源">{{ currentOrder.orderSource === 'HISTORICAL_BACKFILL' ? '历史补单' : '正常订单' }}</a-descriptions-item>
|
||||
<a-descriptions-item label="创建时间" :span="isMobile ? 1 : 2">{{ currentOrder.createTime }}</a-descriptions-item>
|
||||
</a-descriptions>
|
||||
|
||||
@@ -496,7 +515,8 @@ const statusOptions = [
|
||||
{ label: '待报价', value: '0' },
|
||||
{ label: '待完成', value: '1' },
|
||||
{ label: '已完成', value: '2' },
|
||||
{ label: '已取消', value: '3' }
|
||||
{ label: '已取消', value: '3' },
|
||||
{ label: '服务中', value: '4' }
|
||||
]
|
||||
|
||||
const activeFilterCount = computed(() => [
|
||||
@@ -623,6 +643,7 @@ const statusColor = (status: number) => {
|
||||
if (normalized === 1) return 'orange'
|
||||
if (normalized === 2) return 'green'
|
||||
if (normalized === 3) return 'red'
|
||||
if (normalized === 4) return 'processing'
|
||||
return 'default'
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,20 @@
|
||||
<a-button type="primary" :loading="saving" @click="save">保存默认密码</a-button>
|
||||
</a-form>
|
||||
</a-card>
|
||||
<a-card title="店长员工审核提醒" :loading="loading">
|
||||
<a-alert
|
||||
message="控制店长登录小程序后的待审核弹窗"
|
||||
description="关闭后只是不再主动弹窗,员工页面中的审核入口和待审核数量仍然保留。"
|
||||
show-icon
|
||||
type="info"
|
||||
/>
|
||||
<a-form class="settings-form" layout="vertical">
|
||||
<a-form-item label="登录提醒">
|
||||
<a-switch v-model:checked="reviewNoticeEnabled" checked-children="显示" un-checked-children="隐藏" />
|
||||
</a-form-item>
|
||||
<a-button type="primary" :loading="savingReviewNotice" @click="saveReviewNotice">保存审核提醒设置</a-button>
|
||||
</a-form>
|
||||
</a-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -38,7 +52,9 @@ import { adminSystemParameterConfigApi, type SystemParameterConfigVO } from '@/a
|
||||
const loading = ref(false)
|
||||
const saving = ref(false)
|
||||
const savingSmsProvider = ref(false)
|
||||
const savingReviewNotice = ref(false)
|
||||
const enabled = ref(true)
|
||||
const reviewNoticeEnabled = ref(true)
|
||||
const form = reactive<SystemParameterConfigVO>({
|
||||
configGroup: 'USER',
|
||||
configKey: 'DEFAULT_PASSWORD',
|
||||
@@ -55,13 +71,22 @@ const smsProviderForm = reactive<SystemParameterConfigVO>({
|
||||
configGroup: 'SMS', configKey: 'SMS_PROVIDER', configName: '短信供应商', configValue: 'SPUG', enabled: 1,
|
||||
remark: '全局切换短信供应商时同步验证码模板和 MessageHub 通道'
|
||||
})
|
||||
const reviewNoticeForm = reactive<SystemParameterConfigVO>({
|
||||
configGroup: 'WORKBENCH',
|
||||
configKey: 'MANAGER_REGISTRATION_REVIEW_NOTICE',
|
||||
configName: '店长员工审核提醒',
|
||||
configValue: 'true',
|
||||
enabled: 1,
|
||||
remark: '控制店长登录小程序后是否显式提示当前门店的待审核员工申请'
|
||||
})
|
||||
|
||||
const load = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const [configs, smsConfigs] = await Promise.all([
|
||||
const [configs, smsConfigs, workbenchConfigs] = await Promise.all([
|
||||
adminSystemParameterConfigApi.listConfigs('USER'),
|
||||
adminSystemParameterConfigApi.listConfigs('SMS')
|
||||
adminSystemParameterConfigApi.listConfigs('SMS'),
|
||||
adminSystemParameterConfigApi.listConfigs('WORKBENCH')
|
||||
])
|
||||
const config = configs.find(item => item.configKey === 'DEFAULT_PASSWORD')
|
||||
if (config) {
|
||||
@@ -70,6 +95,11 @@ const load = async () => {
|
||||
}
|
||||
const smsProvider = smsConfigs.find(item => item.configKey === 'SMS_PROVIDER')
|
||||
if (smsProvider) Object.assign(smsProviderForm, smsProvider)
|
||||
const reviewNotice = workbenchConfigs.find(item => item.configKey === 'MANAGER_REGISTRATION_REVIEW_NOTICE')
|
||||
if (reviewNotice) {
|
||||
Object.assign(reviewNoticeForm, reviewNotice)
|
||||
reviewNoticeEnabled.value = reviewNotice.enabled === 1 && String(reviewNotice.configValue).toLowerCase() === 'true'
|
||||
}
|
||||
} catch (error) {
|
||||
message.error(error instanceof Error ? error.message : '默认密码加载失败')
|
||||
} finally {
|
||||
@@ -113,6 +143,23 @@ const save = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const saveReviewNotice = async () => {
|
||||
savingReviewNotice.value = true
|
||||
try {
|
||||
await adminSystemParameterConfigApi.saveConfig({
|
||||
...reviewNoticeForm,
|
||||
configValue: 'true',
|
||||
enabled: reviewNoticeEnabled.value ? 1 : 0
|
||||
})
|
||||
message.success(reviewNoticeEnabled.value ? '店长员工审核提醒已开启' : '店长员工审核提醒已关闭')
|
||||
await load()
|
||||
} catch (error) {
|
||||
message.error(error instanceof Error ? error.message : '审核提醒设置保存失败')
|
||||
} finally {
|
||||
savingReviewNotice.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void load()
|
||||
})
|
||||
|
||||
@@ -66,5 +66,32 @@ module.exports = {
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
},
|
||||
|
||||
reviewSummary() {
|
||||
return request({
|
||||
url: '/user/workbench/registration/summary'
|
||||
})
|
||||
},
|
||||
|
||||
reviewApplications() {
|
||||
return request({
|
||||
url: '/user/workbench/registration/list'
|
||||
})
|
||||
},
|
||||
|
||||
approveApplication(id) {
|
||||
return request({
|
||||
url: `/user/workbench/registration/${id}/approve`,
|
||||
method: 'POST'
|
||||
})
|
||||
},
|
||||
|
||||
rejectApplication(id, reason) {
|
||||
return request({
|
||||
url: `/user/workbench/registration/${id}/reject`,
|
||||
method: 'POST',
|
||||
data: { reason }
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,14 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
createBackfillOrder(data) {
|
||||
return request({
|
||||
url: '/manager/planning/backfill-orders',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
},
|
||||
|
||||
appointment(orderItemId) {
|
||||
return request({
|
||||
url: `/manager/planning/appointments/${orderItemId}`
|
||||
|
||||
@@ -27,6 +27,8 @@ function reset(preference) {
|
||||
navigations.length = 0
|
||||
appDefinition.globalData.userInfo = null
|
||||
appDefinition.globalData.wechatLoginState = null
|
||||
appDefinition.globalData.reviewNoticeShown = true
|
||||
appDefinition.globalData.openEmployeeReview = true
|
||||
codeSequence = 0
|
||||
}
|
||||
|
||||
@@ -40,6 +42,8 @@ async function run() {
|
||||
assert.strictEqual(appDefinition.globalData.userInfo.id, 1)
|
||||
assert.strictEqual(statusCalled, false)
|
||||
assert.strictEqual(codeSequence, 1)
|
||||
assert.strictEqual(appDefinition.globalData.reviewNoticeShown, false)
|
||||
assert.strictEqual(appDefinition.globalData.openEmployeeReview, false)
|
||||
|
||||
reset({ rememberMe: false })
|
||||
let quickLoginCalled = false
|
||||
@@ -66,6 +70,7 @@ async function run() {
|
||||
appDefinition.logoutDevice()
|
||||
assert.strictEqual(storage[LOGIN_PREFERENCE_KEY], undefined)
|
||||
assert.strictEqual(appDefinition.globalData.userInfo, null)
|
||||
assert.strictEqual(appDefinition.globalData.reviewNoticeShown, false)
|
||||
}
|
||||
|
||||
run().catch(error => {
|
||||
|
||||
+13
-3
@@ -9,7 +9,9 @@ App({
|
||||
shopName: BRAND_CONFIG.defaultShopName,
|
||||
userInfo: null,
|
||||
planningNeedRefresh: false,
|
||||
wechatLoginState: null
|
||||
wechatLoginState: null,
|
||||
reviewNoticeShown: false,
|
||||
openEmployeeReview: false
|
||||
},
|
||||
|
||||
onLaunch() {
|
||||
@@ -55,7 +57,7 @@ App({
|
||||
})
|
||||
this.publishWechatLoginState(result)
|
||||
if (result.status === 'SUCCESS' && result.accessToken) {
|
||||
this.setSession(result)
|
||||
this.setSession(result, true)
|
||||
wx.reLaunch({ url: '/pages/planning/index' })
|
||||
return
|
||||
}
|
||||
@@ -96,7 +98,11 @@ App({
|
||||
}
|
||||
},
|
||||
|
||||
setSession(session) {
|
||||
setSession(session, newLoginSession = false) {
|
||||
if (newLoginSession) {
|
||||
this.globalData.reviewNoticeShown = false
|
||||
this.globalData.openEmployeeReview = false
|
||||
}
|
||||
auth.setSession(session)
|
||||
this.bootstrapSession()
|
||||
},
|
||||
@@ -105,6 +111,8 @@ App({
|
||||
auth.clearSession()
|
||||
profileCache.invalidate()
|
||||
this.globalData.userInfo = null
|
||||
this.globalData.reviewNoticeShown = false
|
||||
this.globalData.openEmployeeReview = false
|
||||
},
|
||||
|
||||
logoutDevice() {
|
||||
@@ -112,5 +120,7 @@ App({
|
||||
profileCache.invalidate()
|
||||
this.globalData.userInfo = null
|
||||
this.globalData.wechatLoginState = null
|
||||
this.globalData.reviewNoticeShown = false
|
||||
this.globalData.openEmployeeReview = false
|
||||
}
|
||||
})
|
||||
|
||||
@@ -5,11 +5,13 @@
|
||||
"pages/register/index",
|
||||
"pages/planning/index",
|
||||
"pages/appointment-form/index",
|
||||
"pages/backfill-order/index",
|
||||
"pages/appointment-detail/index",
|
||||
"pages/artist-transfer/index",
|
||||
"pages/customers/index",
|
||||
"pages/customer-detail/index",
|
||||
"pages/employees/index",
|
||||
"pages/employee-create/index",
|
||||
"pages/employee-detail/index",
|
||||
"pages/schedule-setting/index",
|
||||
"pages/leave-management/index",
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 9.0 KiB |
@@ -0,0 +1,41 @@
|
||||
Component({
|
||||
properties: {
|
||||
visible: { type: Boolean, value: false },
|
||||
title: { type: String, value: '请选择' },
|
||||
keyword: { type: String, value: '' },
|
||||
placeholder: { type: String, value: '搜索' },
|
||||
items: { type: Array, value: [] },
|
||||
selectedId: { type: null, value: '' },
|
||||
loading: { type: Boolean, value: false },
|
||||
errorText: { type: String, value: '' },
|
||||
emptyText: { type: String, value: '暂无可选内容' },
|
||||
actionText: { type: String, value: '' },
|
||||
showSearch: { type: Boolean, value: true }
|
||||
},
|
||||
|
||||
methods: {
|
||||
close() {
|
||||
this.triggerEvent('close')
|
||||
},
|
||||
|
||||
stopEvent() {
|
||||
},
|
||||
|
||||
onSearch(event) {
|
||||
this.triggerEvent('search', { value: event.detail.value })
|
||||
},
|
||||
|
||||
selectItem(event) {
|
||||
const item = this.data.items[Number(event.currentTarget.dataset.index)]
|
||||
if (item) this.triggerEvent('select', { item })
|
||||
},
|
||||
|
||||
retry() {
|
||||
this.triggerEvent('retry')
|
||||
},
|
||||
|
||||
action() {
|
||||
this.triggerEvent('action')
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"component": true
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
const assert = require('assert')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
let definition
|
||||
global.Component = value => { definition = value }
|
||||
require('./index')
|
||||
|
||||
const events = []
|
||||
const component = {
|
||||
data: {
|
||||
items: [{ id: 7, title: '小周' }]
|
||||
},
|
||||
triggerEvent(name, detail) {
|
||||
events.push({ name, detail })
|
||||
}
|
||||
}
|
||||
Object.assign(component, definition.methods)
|
||||
|
||||
component.onSearch({ detail: { value: '周' } })
|
||||
component.selectItem({ currentTarget: { dataset: { index: 0 } } })
|
||||
component.retry()
|
||||
component.action()
|
||||
component.close()
|
||||
|
||||
assert.deepStrictEqual(events.map(item => item.name), ['search', 'select', 'retry', 'action', 'close'])
|
||||
assert.strictEqual(events[0].detail.value, '周')
|
||||
assert.strictEqual(events[1].detail.item.id, 7)
|
||||
|
||||
const wxml = fs.readFileSync(path.join(__dirname, 'index.wxml'), 'utf8')
|
||||
const wxss = fs.readFileSync(path.join(__dirname, 'index.wxss'), 'utf8')
|
||||
assert.match(wxml, /class="selector-mask"[^>]*catchtouchmove="stopEvent"/)
|
||||
assert.match(wxml, /<scroll-view class="selector-scroll" scroll-y/)
|
||||
assert.doesNotMatch(wxml, /selector-scroll[^>]*catchtouchmove/)
|
||||
assert.match(wxss, /\.selector-sheet\s*\{[^}]*height:\s*88vh;[^}]*flex-direction:\s*column;[^}]*overflow:\s*hidden;/s)
|
||||
assert.match(wxss, /\.selector-scroll\s*\{[^}]*min-height:\s*0;[^}]*flex:\s*1;/s)
|
||||
@@ -0,0 +1,44 @@
|
||||
<view wx:if="{{visible}}" class="selector-mask" bindtap="close" catchtouchmove="stopEvent">
|
||||
<view class="selector-sheet" catchtap="stopEvent">
|
||||
<view class="selector-handle"></view>
|
||||
<view class="selector-head">
|
||||
<text class="selector-title">{{title}}</text>
|
||||
<button class="selector-close" bindtap="close" aria-label="关闭"></button>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{showSearch}}" class="selector-search-wrap">
|
||||
<text class="selector-search-icon"></text>
|
||||
<input class="selector-search" value="{{keyword}}" bindinput="onSearch" placeholder="{{placeholder}}" confirm-type="search" />
|
||||
</view>
|
||||
|
||||
<scroll-view class="selector-scroll" scroll-y enhanced show-scrollbar="{{false}}">
|
||||
<view wx:if="{{loading}}" class="selector-state">
|
||||
<view class="selector-loading-dot"></view>
|
||||
<text>正在加载...</text>
|
||||
</view>
|
||||
<view wx:elif="{{errorText}}" class="selector-state selector-error">
|
||||
<text>{{errorText}}</text>
|
||||
<button class="selector-retry" bindtap="retry">重新加载</button>
|
||||
</view>
|
||||
<view wx:elif="{{items.length === 0}}" class="selector-state">{{emptyText}}</view>
|
||||
<view wx:else class="selector-list">
|
||||
<view wx:for="{{items}}" wx:key="id" class="selector-item {{selectedId == item.id ? 'selected' : ''}}" data-index="{{index}}" bindtap="selectItem">
|
||||
<image wx:if="{{item.avatar}}" class="selector-avatar" src="{{item.avatar}}" mode="aspectFill"></image>
|
||||
<view class="selector-copy {{item.avatar ? '' : 'without-avatar'}}">
|
||||
<view class="selector-title-row">
|
||||
<text class="selector-item-title">{{item.title}}</text>
|
||||
<text wx:if="{{item.badge}}" class="selector-badge">{{item.badge}}</text>
|
||||
</view>
|
||||
<text wx:if="{{item.subtitle}}" class="selector-subtitle">{{item.subtitle}}</text>
|
||||
<text wx:if="{{item.meta}}" class="selector-meta">{{item.meta}}</text>
|
||||
</view>
|
||||
<view class="selector-check">{{selectedId == item.id ? '✓' : '›'}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<view wx:if="{{actionText}}" class="selector-footer">
|
||||
<button class="selector-action" bindtap="action">{{actionText}}</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,289 @@
|
||||
.selector-mask,
|
||||
.selector-sheet,
|
||||
.selector-head,
|
||||
.selector-search-wrap,
|
||||
.selector-scroll,
|
||||
.selector-list,
|
||||
.selector-item,
|
||||
.selector-copy,
|
||||
.selector-footer,
|
||||
.selector-close,
|
||||
.selector-retry,
|
||||
.selector-action,
|
||||
.selector-search {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.selector-close,
|
||||
.selector-retry,
|
||||
.selector-action {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.selector-close::after,
|
||||
.selector-retry::after,
|
||||
.selector-action::after {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.selector-mask {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 120;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
background: rgba(25, 22, 18, 0.5);
|
||||
animation: selectorMaskIn 180ms ease both;
|
||||
}
|
||||
|
||||
.selector-sheet {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
height: 88vh;
|
||||
max-height: 88vh;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
border-radius: 34rpx 34rpx 0 0;
|
||||
background: #fffdf8;
|
||||
box-shadow: 0 -20rpx 48rpx rgba(44, 35, 27, 0.18);
|
||||
animation: selectorSheetUp 220ms ease both;
|
||||
}
|
||||
|
||||
.selector-handle {
|
||||
width: 72rpx;
|
||||
height: 7rpx;
|
||||
margin: 14rpx auto 2rpx;
|
||||
border-radius: 999rpx;
|
||||
background: #ddd6cd;
|
||||
}
|
||||
|
||||
.selector-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
min-height: 92rpx;
|
||||
padding: 0 28rpx;
|
||||
}
|
||||
|
||||
.selector-title {
|
||||
color: #29241f;
|
||||
font-size: 34rpx;
|
||||
font-weight: 900;
|
||||
letter-spacing: 1rpx;
|
||||
}
|
||||
|
||||
.selector-close {
|
||||
position: relative;
|
||||
width: 52rpx;
|
||||
min-width: 52rpx;
|
||||
height: 52rpx;
|
||||
min-height: 52rpx;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 1rpx solid #e6dfd6;
|
||||
border-radius: 50%;
|
||||
background: #f8f4ee;
|
||||
}
|
||||
|
||||
.selector-close::before,
|
||||
.selector-close::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 24rpx;
|
||||
left: 14rpx;
|
||||
width: 22rpx;
|
||||
height: 3rpx;
|
||||
border-radius: 999rpx;
|
||||
background: #665e56;
|
||||
}
|
||||
|
||||
.selector-close::before { transform: rotate(45deg); }
|
||||
.selector-close::after { transform: rotate(-45deg); }
|
||||
|
||||
.selector-search-wrap {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-height: 80rpx;
|
||||
margin: 0 28rpx 18rpx;
|
||||
padding: 0 22rpx;
|
||||
border: 1rpx solid #e7e0d7;
|
||||
border-radius: 22rpx;
|
||||
background: #f7f3ed;
|
||||
}
|
||||
|
||||
.selector-search-icon {
|
||||
position: relative;
|
||||
width: 26rpx;
|
||||
height: 26rpx;
|
||||
margin-right: 18rpx;
|
||||
border: 3rpx solid #8e877f;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.selector-search-icon::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
right: -9rpx;
|
||||
bottom: -6rpx;
|
||||
width: 12rpx;
|
||||
height: 3rpx;
|
||||
border-radius: 999rpx;
|
||||
background: #8e877f;
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
|
||||
.selector-search {
|
||||
height: 78rpx;
|
||||
flex: 1;
|
||||
color: #29241f;
|
||||
font-size: 27rpx;
|
||||
}
|
||||
|
||||
.selector-scroll {
|
||||
height: 0;
|
||||
min-height: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.selector-list {
|
||||
padding: 0 28rpx 24rpx;
|
||||
}
|
||||
|
||||
.selector-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-height: 112rpx;
|
||||
margin-bottom: 14rpx;
|
||||
padding: 20rpx;
|
||||
border: 1rpx solid #ece5dc;
|
||||
border-radius: 24rpx;
|
||||
background: #fff;
|
||||
transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
|
||||
}
|
||||
|
||||
.selector-item:active { transform: scale(0.99); }
|
||||
.selector-item.selected { border-color: #8eafa3; background: #f0f6f3; }
|
||||
|
||||
.selector-avatar {
|
||||
width: 76rpx;
|
||||
height: 76rpx;
|
||||
flex: 0 0 auto;
|
||||
border-radius: 50%;
|
||||
background: #eee9e2;
|
||||
}
|
||||
|
||||
.selector-copy {
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
margin-left: 18rpx;
|
||||
}
|
||||
|
||||
.selector-copy.without-avatar { margin-left: 2rpx; }
|
||||
|
||||
.selector-title-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
}
|
||||
|
||||
.selector-item-title {
|
||||
overflow: hidden;
|
||||
color: #2b2621;
|
||||
font-size: 28rpx;
|
||||
font-weight: 800;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.selector-badge {
|
||||
flex: 0 0 auto;
|
||||
padding: 5rpx 12rpx;
|
||||
border-radius: 999rpx;
|
||||
background: #e7f0ec;
|
||||
color: #55786d;
|
||||
font-size: 19rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.selector-subtitle,
|
||||
.selector-meta {
|
||||
display: block;
|
||||
margin-top: 7rpx;
|
||||
overflow: hidden;
|
||||
color: #7f7870;
|
||||
font-size: 23rpx;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.selector-meta { color: #a19990; font-size: 21rpx; }
|
||||
|
||||
.selector-check {
|
||||
width: 52rpx;
|
||||
color: #8c857d;
|
||||
font-size: 32rpx;
|
||||
font-weight: 800;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.selector-item.selected .selector-check { color: #2f6f62; }
|
||||
|
||||
.selector-state {
|
||||
display: flex;
|
||||
min-height: 360rpx;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 40rpx 48rpx;
|
||||
color: #9a9289;
|
||||
font-size: 25rpx;
|
||||
line-height: 1.6;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.selector-error { color: #a8554e; }
|
||||
|
||||
.selector-retry {
|
||||
min-width: 180rpx;
|
||||
height: 64rpx;
|
||||
margin-top: 22rpx;
|
||||
padding: 0 28rpx;
|
||||
border: 1rpx solid #d8d1c8;
|
||||
border-radius: 999rpx;
|
||||
background: #fff;
|
||||
color: #514b44;
|
||||
font-size: 23rpx;
|
||||
font-weight: 800;
|
||||
line-height: 64rpx;
|
||||
}
|
||||
|
||||
.selector-loading-dot {
|
||||
width: 20rpx;
|
||||
height: 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
border-radius: 50%;
|
||||
background: #6f8f83;
|
||||
box-shadow: -30rpx 0 #c9d8d2, 30rpx 0 #9eb9af;
|
||||
}
|
||||
|
||||
.selector-footer {
|
||||
padding: 16rpx 28rpx calc(18rpx + env(safe-area-inset-bottom));
|
||||
border-top: 1rpx solid #eee7de;
|
||||
background: #fffdf8;
|
||||
}
|
||||
|
||||
.selector-action {
|
||||
width: 100%;
|
||||
height: 78rpx;
|
||||
border: 1rpx solid #cbdad4;
|
||||
border-radius: 22rpx;
|
||||
background: #edf4f1;
|
||||
color: #2f6f62;
|
||||
font-size: 26rpx;
|
||||
font-weight: 900;
|
||||
line-height: 78rpx;
|
||||
}
|
||||
|
||||
@keyframes selectorMaskIn { from { opacity: 0; } to { opacity: 1; } }
|
||||
@keyframes selectorSheetUp { from { transform: translateY(48rpx); } to { transform: translateY(0); } }
|
||||
@@ -0,0 +1,37 @@
|
||||
const assert = require('assert')
|
||||
|
||||
const requests = []
|
||||
const storage = {}
|
||||
global.wx = {
|
||||
getAccountInfoSync: () => ({ miniProgram: { envVersion: 'develop' } }),
|
||||
getDeviceInfo: () => ({ platform: 'devtools' }),
|
||||
getStorageSync: key => storage[key] || '',
|
||||
setStorageSync: (key, value) => { storage[key] = value },
|
||||
removeStorageSync: key => { delete storage[key] },
|
||||
request: options => {
|
||||
requests.push(options)
|
||||
options.success({ statusCode: 200, data: { code: 200, data: {} } })
|
||||
}
|
||||
}
|
||||
global.getApp = () => ({ clearSession: () => {}, goLogin: () => {} })
|
||||
|
||||
const employeesApi = require('./api/employees')
|
||||
|
||||
async function run() {
|
||||
await employeesApi.reviewSummary()
|
||||
await employeesApi.reviewApplications()
|
||||
await employeesApi.approveApplication(12)
|
||||
await employeesApi.rejectApplication(12, '资料不完整')
|
||||
|
||||
assert.deepStrictEqual(requests.map(item => [item.method || 'GET', item.url, item.data]), [
|
||||
['GET', 'http://127.0.0.1:80/api/admin/user/workbench/registration/summary', undefined],
|
||||
['GET', 'http://127.0.0.1:80/api/admin/user/workbench/registration/list', undefined],
|
||||
['POST', 'http://127.0.0.1:80/api/admin/user/workbench/registration/12/approve', undefined],
|
||||
['POST', 'http://127.0.0.1:80/api/admin/user/workbench/registration/12/reject', { reason: '资料不完整' }]
|
||||
])
|
||||
}
|
||||
|
||||
run().catch(error => {
|
||||
console.error(error)
|
||||
process.exitCode = 1
|
||||
})
|
||||
@@ -7,6 +7,7 @@ Page({
|
||||
appointment: {},
|
||||
avatarText: '',
|
||||
timeText: '',
|
||||
isUnassigned: false,
|
||||
loadError: ''
|
||||
},
|
||||
|
||||
@@ -32,13 +33,18 @@ 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)}`,
|
||||
timeText: appointment.historicalBackfill && !appointment.startTime ? '时间未记录' : `${(appointment.startTime || '').slice(0, 16)} - ${(appointment.endTime || '').slice(11, 16)}`,
|
||||
loadError: ''
|
||||
})
|
||||
},
|
||||
|
||||
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()
|
||||
@@ -50,6 +56,7 @@ Page({
|
||||
},
|
||||
|
||||
confirm() {
|
||||
if (this.data.appointment.historicalBackfill) return
|
||||
this.updateStatus(1)
|
||||
},
|
||||
|
||||
@@ -62,6 +69,7 @@ Page({
|
||||
},
|
||||
|
||||
goTransfer() {
|
||||
if (this.data.appointment.historicalBackfill) return
|
||||
wx.navigateTo({ url: `/pages/artist-transfer/index?id=${this.data.id}` })
|
||||
},
|
||||
|
||||
|
||||
@@ -14,8 +14,9 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="detail-actions">
|
||||
<text class="tag">{{appointment.statusText}}</text>
|
||||
<button class="small-action" bindtap="goTransfer">改派</button>
|
||||
<text wx:if="{{appointment.historicalBackfill}}" class="tag">历史补单 · {{appointment.statusText}}</text>
|
||||
<text wx:else class="tag">{{appointment.statusText}}</text>
|
||||
<button wx:if="{{!appointment.historicalBackfill}}" class="small-action" bindtap="goTransfer">{{isUnassigned ? '分配员工' : '改派'}}</button>
|
||||
</view>
|
||||
</view>
|
||||
<view class="detail-grid">
|
||||
@@ -25,7 +26,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 +45,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 wx:if="{{!appointment.historicalBackfill}}" class="secondary-btn" disabled="{{isUnassigned}}" bindtap="confirm">{{isUnassigned ? '待分配' : '确认'}}</button>
|
||||
<button class="primary-btn" disabled="{{isUnassigned}}" bindtap="complete">{{appointment.historicalBackfill ? '完成补单' : '完成'}}</button>
|
||||
<button class="danger-btn" bindtap="cancel">取消</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
const assert = require('assert')
|
||||
|
||||
global.wx = {
|
||||
getAccountInfoSync: () => ({ miniProgram: { envVersion: 'develop' } }),
|
||||
getDeviceInfo: () => ({ platform: 'devtools' }),
|
||||
getStorageSync: () => '',
|
||||
setStorageSync: () => {},
|
||||
removeStorageSync: () => {},
|
||||
showToast: () => {},
|
||||
navigateTo: () => {}
|
||||
}
|
||||
global.getApp = () => ({ globalData: { userInfo: { type: 2, id: 1, shopId: 2 } } })
|
||||
|
||||
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()
|
||||
page.selectCustomer({ detail: { item: { id: 18, name: '小周', phone: '13800138000' } } })
|
||||
assert.strictEqual(page.data.form.customerUserId, 18)
|
||||
assert.strictEqual(page.data.form.customerName, '小周')
|
||||
assert.strictEqual(page.data.form.phone, '13800138000')
|
||||
assert.strictEqual(page.data.customerSheetVisible, false)
|
||||
|
||||
page.data.form.customerUserId = 18
|
||||
page.data.manualCustomerForm = { name: '新客户', phone: '13900139000' }
|
||||
page.useManualCustomer()
|
||||
assert.strictEqual(page.data.form.customerUserId, '')
|
||||
assert.strictEqual(page.data.form.customerName, '新客户')
|
||||
assert.strictEqual(page.data.form.phone, '13900139000')
|
||||
|
||||
page.data.artists = [{ id: 1, name: '小周' }, { id: 2, name: '小李' }]
|
||||
page.onArtistSearch({ detail: { value: '李' } })
|
||||
assert.deepStrictEqual(page.data.artistSelectorItems.map(item => item.id), [2])
|
||||
|
||||
page.refreshAvailableTimes = async () => {}
|
||||
page.checkAvailability = () => {}
|
||||
page.selectArtist({ detail: { item: { id: 2, name: '小李' } } })
|
||||
assert.strictEqual(page.data.form.artistId, 2)
|
||||
assert.strictEqual(page.data.selectedArtist.name, '小李')
|
||||
assert.strictEqual(page.data.artistSheetVisible, false)
|
||||
}
|
||||
|
||||
run().catch(error => {
|
||||
console.error(error)
|
||||
process.exitCode = 1
|
||||
})
|
||||
@@ -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 || []), [])
|
||||
}
|
||||
@@ -231,6 +249,25 @@ function normalizeCustomer(customer) {
|
||||
}
|
||||
}
|
||||
|
||||
function buildCustomerSelectorItem(customer) {
|
||||
return {
|
||||
...customer,
|
||||
title: customer.displayName,
|
||||
subtitle: customer.displayPhone,
|
||||
badge: '已有客户'
|
||||
}
|
||||
}
|
||||
|
||||
function buildArtistSelectorItem(artist) {
|
||||
return {
|
||||
...artist,
|
||||
title: artist.name || '未命名员工',
|
||||
subtitle: artist.statusText || '可用于指定预约',
|
||||
meta: artist.workStartTime && artist.workEndTime ? `${artist.workStartTime.slice(0, 5)}-${artist.workEndTime.slice(0, 5)}` : '',
|
||||
avatar: artist.avatar || artist.avatarUrl || '/assets/images/default-user-avatar.png'
|
||||
}
|
||||
}
|
||||
|
||||
Page({
|
||||
data: {
|
||||
form: {
|
||||
@@ -253,12 +290,19 @@ Page({
|
||||
remark: ''
|
||||
},
|
||||
customerOptions: [],
|
||||
customerDropdownVisible: false,
|
||||
customerSheetVisible: false,
|
||||
customerKeyword: '',
|
||||
customerLoading: false,
|
||||
customerError: '',
|
||||
manualCustomerVisible: false,
|
||||
manualCustomerForm: { name: '', phone: '' },
|
||||
products: [],
|
||||
filteredProducts: [],
|
||||
artists: [],
|
||||
artistSelectorItems: [],
|
||||
artistSheetVisible: false,
|
||||
artistKeyword: '',
|
||||
artistError: '',
|
||||
selectedProduct: {},
|
||||
selectedArtist: {},
|
||||
productModalVisible: false,
|
||||
@@ -298,7 +342,6 @@ Page({
|
||||
return
|
||||
}
|
||||
this.loadOptions()
|
||||
this.searchCustomers()
|
||||
},
|
||||
|
||||
async loadOptions() {
|
||||
@@ -319,21 +362,37 @@ Page({
|
||||
this.checkAvailability()
|
||||
},
|
||||
|
||||
async loadArtists() {
|
||||
async loadArtists(preferredArtistId, fallbackEmployee) {
|
||||
try {
|
||||
const calendar = await planningApi.calendar({
|
||||
startDate: this.data.form.appointmentDate,
|
||||
endDate: this.data.form.appointmentDate
|
||||
})
|
||||
const artists = getCalendarArtists(calendar)
|
||||
const selectedArtist = this.data.form.artistId ? findArtist(artists, this.data.form.artistId) : {}
|
||||
this.setData({ artists, selectedArtist })
|
||||
let artists = getCalendarArtists(calendar)
|
||||
const requestedId = preferredArtistId || this.data.form.artistId
|
||||
if (fallbackEmployee && requestedId && !findArtist(artists, requestedId).id) {
|
||||
artists = artists.concat({
|
||||
id: requestedId,
|
||||
name: fallbackEmployee.name || fallbackEmployee.title,
|
||||
avatar: fallbackEmployee.avatar || ''
|
||||
})
|
||||
}
|
||||
const selectedArtist = requestedId ? findArtist(artists, requestedId) : {}
|
||||
this.setData({
|
||||
artists,
|
||||
artistSelectorItems: this.filterArtistItems(artists, this.data.artistKeyword),
|
||||
selectedArtist,
|
||||
artistError: '',
|
||||
'form.artistId': selectedArtist.id || ''
|
||||
})
|
||||
this.refreshProductCards()
|
||||
} catch (error) {
|
||||
this.setData({
|
||||
artists: [],
|
||||
artistSelectorItems: [],
|
||||
selectedArtist: {},
|
||||
'form.artistId': '',
|
||||
artistError: error.message || '员工列表加载失败',
|
||||
conflictTip: error.message || '美甲师列表加载失败',
|
||||
conflictLevel: 'danger'
|
||||
})
|
||||
@@ -345,44 +404,40 @@ Page({
|
||||
const patch = {
|
||||
[`form.${field}`]: event.detail.value
|
||||
}
|
||||
if (field === 'customerName' || field === 'phone') {
|
||||
patch['form.customerUserId'] = ''
|
||||
patch.customerDropdownVisible = true
|
||||
}
|
||||
this.setData(patch)
|
||||
if (field === 'customerName' || field === 'phone') {
|
||||
this.scheduleCustomerSearch(field)
|
||||
}
|
||||
if (field === 'durationMinutes') {
|
||||
this.refreshAvailableTimes()
|
||||
this.checkAvailability()
|
||||
}
|
||||
},
|
||||
|
||||
onCustomerFocus(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
this.setData({ customerDropdownVisible: true })
|
||||
this.searchCustomers(field)
|
||||
openCustomerSheet() {
|
||||
this.setData({ customerSheetVisible: true })
|
||||
this.searchCustomers(this.data.customerKeyword)
|
||||
},
|
||||
|
||||
scheduleCustomerSearch(field) {
|
||||
closeCustomerSheet() {
|
||||
this.setData({ customerSheetVisible: false })
|
||||
},
|
||||
|
||||
onCustomerSearch(event) {
|
||||
const keyword = event.detail.value
|
||||
this.setData({ customerKeyword: keyword })
|
||||
clearTimeout(this._customerTimer)
|
||||
this._customerTimer = setTimeout(() => this.searchCustomers(field), 250)
|
||||
this._customerTimer = setTimeout(() => this.searchCustomers(keyword), 250)
|
||||
},
|
||||
|
||||
async searchCustomers(preferredField) {
|
||||
async searchCustomers(keywordValue) {
|
||||
if (!this.data.canCreateAppointment) {
|
||||
return
|
||||
}
|
||||
const form = this.data.form
|
||||
const sourceValue = preferredField === 'phone' ? form.phone : form.customerName || form.phone
|
||||
const keyword = String(sourceValue || '').trim()
|
||||
const keyword = String(keywordValue === undefined ? this.data.customerKeyword : keywordValue || '').trim()
|
||||
this.setData({ customerLoading: true })
|
||||
try {
|
||||
const data = await customersApi.list({ keyword, page: 1, size: 20 })
|
||||
const list = data.list || data || []
|
||||
this.setData({
|
||||
customerOptions: list.map(normalizeCustomer),
|
||||
customerOptions: list.map(normalizeCustomer).map(buildCustomerSelectorItem),
|
||||
customerError: ''
|
||||
})
|
||||
} catch (error) {
|
||||
@@ -395,8 +450,12 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
retryCustomerSearch() {
|
||||
this.searchCustomers(this.data.customerKeyword)
|
||||
},
|
||||
|
||||
selectCustomer(event) {
|
||||
const customer = this.data.customerOptions.find(item => String(item.id) === String(event.currentTarget.dataset.id))
|
||||
const customer = event.detail.item
|
||||
if (!customer) {
|
||||
return
|
||||
}
|
||||
@@ -404,14 +463,48 @@ Page({
|
||||
'form.customerUserId': customer.id,
|
||||
'form.customerName': customer.name,
|
||||
'form.phone': customer.phone,
|
||||
customerDropdownVisible: false
|
||||
customerSheetVisible: false,
|
||||
customerKeyword: ''
|
||||
})
|
||||
},
|
||||
|
||||
hideCustomerDropdown() {
|
||||
setTimeout(() => {
|
||||
this.setData({ customerDropdownVisible: false })
|
||||
}, 180)
|
||||
openManualCustomer() {
|
||||
this.setData({
|
||||
customerSheetVisible: false,
|
||||
manualCustomerVisible: true,
|
||||
manualCustomerForm: {
|
||||
name: this.data.form.customerName || '',
|
||||
phone: this.data.form.phone || ''
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
closeManualCustomer() {
|
||||
this.setData({ manualCustomerVisible: false })
|
||||
},
|
||||
|
||||
onManualCustomerInput(event) {
|
||||
this.setData({ [`manualCustomerForm.${event.currentTarget.dataset.field}`]: event.detail.value })
|
||||
},
|
||||
|
||||
useManualCustomer() {
|
||||
const name = String(this.data.manualCustomerForm.name || '').trim()
|
||||
const phone = String(this.data.manualCustomerForm.phone || '').trim()
|
||||
if (!name) {
|
||||
wx.showToast({ title: '请输入客户姓名', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!/^1[3-9]\d{9}$/.test(phone)) {
|
||||
wx.showToast({ title: '请输入正确手机号', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.setData({
|
||||
'form.customerUserId': '',
|
||||
'form.customerName': name,
|
||||
'form.phone': phone,
|
||||
manualCustomerVisible: false,
|
||||
customerKeyword: ''
|
||||
})
|
||||
},
|
||||
|
||||
onUnload() {
|
||||
@@ -454,6 +547,9 @@ Page({
|
||||
stopTap() {
|
||||
},
|
||||
|
||||
stopTouchMove() {
|
||||
},
|
||||
|
||||
onProductSearch(event) {
|
||||
this.setData({ productKeyword: event.detail.value })
|
||||
this.refreshProductCards()
|
||||
@@ -531,20 +627,102 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
onArtistChange(event) {
|
||||
const selectedArtist = this.data.artists[Number(event.detail.value)] || {}
|
||||
filterArtistItems(artists, keywordValue) {
|
||||
const keyword = String(keywordValue || '').trim().toLowerCase()
|
||||
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() {
|
||||
this.setData({
|
||||
artistSheetVisible: true,
|
||||
artistSelectorItems: this.filterArtistItems(this.data.artists, this.data.artistKeyword)
|
||||
})
|
||||
},
|
||||
|
||||
closeArtistSheet() {
|
||||
this.setData({ artistSheetVisible: false })
|
||||
},
|
||||
|
||||
retryArtists() {
|
||||
this.loadArtists()
|
||||
},
|
||||
|
||||
onArtistSearch(event) {
|
||||
const artistKeyword = event.detail.value
|
||||
this.setData({
|
||||
artistKeyword,
|
||||
artistSelectorItems: this.filterArtistItems(this.data.artists, artistKeyword)
|
||||
})
|
||||
},
|
||||
|
||||
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,
|
||||
'form.appointmentTime': ''
|
||||
'form.appointmentTime': '',
|
||||
artistSheetVisible: false
|
||||
})
|
||||
this.refreshAvailableTimes()
|
||||
this.checkAvailability()
|
||||
},
|
||||
|
||||
addEmployeeFromSelector() {
|
||||
this.setData({ artistSheetVisible: false })
|
||||
wx.navigateTo({
|
||||
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))
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
async handleEmployeeCreated(employee) {
|
||||
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()
|
||||
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() {
|
||||
@@ -552,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'] = ''
|
||||
@@ -564,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: '',
|
||||
@@ -606,7 +794,7 @@ Page({
|
||||
|
||||
async openTimeSheet() {
|
||||
if (!this.canOpenTimeSheet()) {
|
||||
wx.showToast({ title: '请先选择美甲师并填写时长', icon: 'none' })
|
||||
wx.showToast({ title: '请先填写预约日期和时长', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.setData({ timeSheetVisible: true })
|
||||
@@ -628,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 }
|
||||
}
|
||||
@@ -644,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,
|
||||
@@ -689,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
|
||||
}
|
||||
@@ -706,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')
|
||||
}
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
{
|
||||
"navigationBarTitleText": "新建预约"
|
||||
"navigationBarTitleText": "新建预约",
|
||||
"usingComponents": {
|
||||
"entity-selector-sheet": "/components/entity-selector-sheet/index"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,14 @@
|
||||
<view class="page no-tab">
|
||||
<view class="card form-card">
|
||||
<view class="customer-select">
|
||||
<view class="field">
|
||||
<text class="field-label required">客户姓名</text>
|
||||
<input value="{{form.customerName}}" data-field="customerName" bindinput="onInput" bindfocus="onCustomerFocus" bindblur="hideCustomerDropdown" placeholder="搜索或输入客户姓名" />
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label required">手机号</text>
|
||||
<input value="{{form.phone}}" data-field="phone" bindinput="onInput" bindfocus="onCustomerFocus" bindblur="hideCustomerDropdown" maxlength="11" type="number" placeholder="搜索或输入手机号" />
|
||||
</view>
|
||||
<view wx:if="{{customerDropdownVisible}}" class="customer-dropdown">
|
||||
<view wx:if="{{customerLoading}}" class="customer-option muted-option">正在搜索客户...</view>
|
||||
<view wx:elif="{{customerError}}" class="customer-option muted-option">{{customerError}},可继续手动输入</view>
|
||||
<view wx:else>
|
||||
<view wx:for="{{customerOptions}}" wx:key="id" class="customer-option" data-id="{{item.id}}" bindtap="selectCustomer">
|
||||
<view class="customer-copy">
|
||||
<text class="customer-name">{{item.displayName}}</text>
|
||||
<text class="customer-phone">{{item.displayPhone}}</text>
|
||||
</view>
|
||||
<text class="customer-select-tag">选择</text>
|
||||
</view>
|
||||
<view wx:if="{{customerOptions.length === 0}}" class="customer-option muted-option">暂无匹配客户,可继续手动输入</view>
|
||||
<view class="field customer-field" bindtap="openCustomerSheet">
|
||||
<text class="field-label required">客户</text>
|
||||
<view class="reference-card {{form.customerName ? 'filled' : ''}}">
|
||||
<view class="reference-copy">
|
||||
<text class="reference-title">{{form.customerName || '请选择客户'}}</text>
|
||||
<text class="reference-subtitle">{{form.phone || '搜索已有客户或手动录入'}}</text>
|
||||
</view>
|
||||
<text wx:if="{{form.customerUserId}}" class="reference-badge">已有</text>
|
||||
<text class="reference-arrow">›</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="field">
|
||||
@@ -43,17 +30,18 @@
|
||||
<text class="unit">分钟</text>
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label required">指定员工</text>
|
||||
<picker range="{{artists}}" range-key="name" bindchange="onArtistChange">
|
||||
<view class="field-value">{{selectedArtist.name || '请选择美甲师'}}</view>
|
||||
</picker>
|
||||
<text class="field-label">员工(可稍后分配)</text>
|
||||
<view class="field-value reference-value" bindtap="openArtistSheet">
|
||||
<text>{{selectedArtist.name || '暂不分配'}}</text>
|
||||
<text class="reference-arrow">›</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label required">预约时间</text>
|
||||
<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>
|
||||
@@ -66,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">
|
||||
@@ -79,7 +67,66 @@
|
||||
<text class="tip-text">{{conflictTip}}</text>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{productModalVisible}}" class="modal-mask" bindtap="closeProductModal">
|
||||
<entity-selector-sheet
|
||||
visible="{{customerSheetVisible}}"
|
||||
title="选择客户"
|
||||
keyword="{{customerKeyword}}"
|
||||
placeholder="搜索客户姓名或手机号"
|
||||
items="{{customerOptions}}"
|
||||
selected-id="{{form.customerUserId}}"
|
||||
loading="{{customerLoading}}"
|
||||
error-text="{{customerError}}"
|
||||
empty-text="暂无匹配客户,可手动录入"
|
||||
action-text="手动录入客户"
|
||||
bind:search="onCustomerSearch"
|
||||
bind:select="selectCustomer"
|
||||
bind:retry="retryCustomerSearch"
|
||||
bind:action="openManualCustomer"
|
||||
bind:close="closeCustomerSheet"
|
||||
/>
|
||||
|
||||
<entity-selector-sheet
|
||||
visible="{{artistSheetVisible}}"
|
||||
title="选择员工"
|
||||
keyword="{{artistKeyword}}"
|
||||
placeholder="搜索员工姓名"
|
||||
items="{{artistSelectorItems}}"
|
||||
selected-id="{{form.artistId}}"
|
||||
loading="{{false}}"
|
||||
error-text="{{artistError}}"
|
||||
empty-text="暂无匹配员工"
|
||||
action-text="快速新增员工"
|
||||
bind:search="onArtistSearch"
|
||||
bind:select="selectArtist"
|
||||
bind:retry="retryArtists"
|
||||
bind:action="addEmployeeFromSelector"
|
||||
bind:close="closeArtistSheet"
|
||||
/>
|
||||
|
||||
<view wx:if="{{manualCustomerVisible}}" class="modal-mask" bindtap="closeManualCustomer" catchtouchmove="stopTouchMove">
|
||||
<view class="manual-customer-sheet" catchtap="stopTap">
|
||||
<view class="modal-head">
|
||||
<view>
|
||||
<text class="modal-title">手动录入客户</text>
|
||||
<text class="modal-subtitle">录入后将直接带回本次预约</text>
|
||||
</view>
|
||||
<view class="modal-close" bindtap="closeManualCustomer">×</view>
|
||||
</view>
|
||||
<view class="manual-customer-form">
|
||||
<view class="manual-customer-field">
|
||||
<text class="required-label">客户姓名</text>
|
||||
<input value="{{manualCustomerForm.name}}" data-field="name" bindinput="onManualCustomerInput" placeholder="请输入客户姓名" />
|
||||
</view>
|
||||
<view class="manual-customer-field">
|
||||
<text class="required-label">手机号</text>
|
||||
<input value="{{manualCustomerForm.phone}}" data-field="phone" bindinput="onManualCustomerInput" type="number" maxlength="11" placeholder="请输入手机号" />
|
||||
</view>
|
||||
</view>
|
||||
<button class="primary-btn manual-customer-submit" bindtap="useManualCustomer">使用该客户</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{productModalVisible}}" class="modal-mask" bindtap="closeProductModal" catchtouchmove="stopTouchMove">
|
||||
<view class="product-modal" catchtap="stopTap">
|
||||
<view class="modal-head">
|
||||
<view>
|
||||
@@ -88,44 +135,46 @@
|
||||
<view class="modal-close" bindtap="closeProductModal">×</view>
|
||||
</view>
|
||||
<input class="product-search" value="{{productKeyword}}" bindinput="onProductSearch" placeholder="搜索作品、标签、美甲师" />
|
||||
<scroll-view class="product-list" scroll-y>
|
||||
<view wx:if="{{productError}}" class="product-empty">{{productError}}</view>
|
||||
<view wx:for="{{filteredProducts}}" wx:key="id" class="product-option {{form.productId == item.id ? 'active' : ''}}" data-id="{{item.id}}" bindtap="selectProduct">
|
||||
<image wx:if="{{item.coverImage}}" class="product-cover" src="{{item.coverImage}}" mode="aspectFill"></image>
|
||||
<view wx:else class="product-cover placeholder">图</view>
|
||||
<view class="product-info">
|
||||
<view class="product-title-row">
|
||||
<text class="product-title">{{item.title}}</text>
|
||||
<text class="product-price">{{item.priceText}}</text>
|
||||
</view>
|
||||
<text class="product-meta">{{item.artistText}} · {{item.durationText || '时长待定'}}</text>
|
||||
<view class="tag-row">
|
||||
<text wx:for="{{item.tagList}}" wx:for-item="tag" wx:key="*this" class="tag-pill">{{tag}}</text>
|
||||
<scroll-view class="product-modal-scroll" scroll-y enhanced show-scrollbar="{{false}}">
|
||||
<view class="product-list">
|
||||
<view wx:if="{{productError}}" class="product-empty">{{productError}}</view>
|
||||
<view wx:for="{{filteredProducts}}" wx:key="id" class="product-option {{form.productId == item.id ? 'active' : ''}}" data-id="{{item.id}}" bindtap="selectProduct">
|
||||
<image wx:if="{{item.coverImage}}" class="product-cover" src="{{item.coverImage}}" mode="aspectFill"></image>
|
||||
<view wx:else class="product-cover placeholder">图</view>
|
||||
<view class="product-info">
|
||||
<view class="product-title-row">
|
||||
<text class="product-title">{{item.title}}</text>
|
||||
<text class="product-price">{{item.priceText}}</text>
|
||||
</view>
|
||||
<text class="product-meta">{{item.artistText}} · {{item.durationText || '时长待定'}}</text>
|
||||
<view class="tag-row">
|
||||
<text wx:for="{{item.tagList}}" wx:for-item="tag" wx:key="*this" class="tag-pill">{{tag}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:if="{{!productError && filteredProducts.length === 0}}" class="product-empty">暂无匹配作品</view>
|
||||
</view>
|
||||
<view class="manual-panel">
|
||||
<text class="manual-title required-label">手动新增预约作品</text>
|
||||
<view class="manual-grid">
|
||||
<input value="{{form.manualProductTitle}}" data-field="manualProductTitle" bindinput="onInput" placeholder="作品名称" />
|
||||
<input value="{{form.manualProductPrice}}" data-field="manualProductPrice" bindinput="onInput" type="digit" placeholder="价格" />
|
||||
</view>
|
||||
<textarea class="manual-textarea" value="{{form.manualProductDescription}}" data-field="manualProductDescription" bindinput="onInput" placeholder="作品描述(选填)" />
|
||||
<view class="manual-grid single">
|
||||
<input value="{{form.manualProductTags}}" data-field="manualProductTags" bindinput="onInput" placeholder="标签,多个用逗号分隔(选填)" />
|
||||
<input value="{{form.manualProductTargetAudience}}" data-field="manualProductTargetAudience" bindinput="onInput" placeholder="适合人群(选填)" />
|
||||
<input value="{{form.manualProductPrecautions}}" data-field="manualProductPrecautions" bindinput="onInput" placeholder="注意事项(选填)" />
|
||||
</view>
|
||||
<view class="manual-image-row">
|
||||
<image wx:if="{{form.manualProductImageUrl}}" class="manual-image" src="{{form.manualProductImageUrl}}" mode="aspectFill"></image>
|
||||
<view wx:else class="manual-image placeholder">图</view>
|
||||
<button class="secondary-btn image-btn" loading="{{manualImageUploading}}" bindtap="chooseManualProductImage">上传图片</button>
|
||||
<button wx:if="{{form.manualProductImageUrl}}" class="text-btn image-remove" bindtap="removeManualProductImage">移除</button>
|
||||
</view>
|
||||
<button class="secondary-btn manual-btn" bindtap="useManualProduct">使用手动预约作品</button>
|
||||
</view>
|
||||
<view wx:if="{{!productError && filteredProducts.length === 0}}" class="product-empty">暂无匹配作品</view>
|
||||
</scroll-view>
|
||||
<view class="manual-panel">
|
||||
<text class="manual-title required-label">手动新增预约作品</text>
|
||||
<view class="manual-grid">
|
||||
<input value="{{form.manualProductTitle}}" data-field="manualProductTitle" bindinput="onInput" placeholder="作品名称" />
|
||||
<input value="{{form.manualProductPrice}}" data-field="manualProductPrice" bindinput="onInput" type="digit" placeholder="价格" />
|
||||
</view>
|
||||
<textarea class="manual-textarea" value="{{form.manualProductDescription}}" data-field="manualProductDescription" bindinput="onInput" placeholder="作品描述(选填)" />
|
||||
<view class="manual-grid single">
|
||||
<input value="{{form.manualProductTags}}" data-field="manualProductTags" bindinput="onInput" placeholder="标签,多个用逗号分隔(选填)" />
|
||||
<input value="{{form.manualProductTargetAudience}}" data-field="manualProductTargetAudience" bindinput="onInput" placeholder="适合人群(选填)" />
|
||||
<input value="{{form.manualProductPrecautions}}" data-field="manualProductPrecautions" bindinput="onInput" placeholder="注意事项(选填)" />
|
||||
</view>
|
||||
<view class="manual-image-row">
|
||||
<image wx:if="{{form.manualProductImageUrl}}" class="manual-image" src="{{form.manualProductImageUrl}}" mode="aspectFill"></image>
|
||||
<view wx:else class="manual-image placeholder">图</view>
|
||||
<button class="secondary-btn image-btn" loading="{{manualImageUploading}}" bindtap="chooseManualProductImage">上传图片</button>
|
||||
<button wx:if="{{form.manualProductImageUrl}}" class="text-btn image-remove" bindtap="removeManualProductImage">移除</button>
|
||||
</view>
|
||||
<button class="secondary-btn manual-btn" bindtap="useManualProduct">使用手动预约作品</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -134,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>
|
||||
|
||||
@@ -3,75 +3,81 @@
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.customer-select {
|
||||
position: relative;
|
||||
.customer-field {
|
||||
align-items: stretch;
|
||||
padding: 18rpx 0;
|
||||
}
|
||||
|
||||
.customer-dropdown {
|
||||
position: absolute;
|
||||
top: 214rpx;
|
||||
right: 0;
|
||||
left: 180rpx;
|
||||
z-index: 30;
|
||||
max-height: 360rpx;
|
||||
overflow-y: auto;
|
||||
border: 1rpx solid #e5ded4;
|
||||
border-radius: 18rpx;
|
||||
background: #fffdf8;
|
||||
box-shadow: 0 18rpx 40rpx rgba(58, 48, 34, 0.14);
|
||||
}
|
||||
|
||||
.customer-option {
|
||||
.customer-field > .field-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16rpx;
|
||||
min-height: 76rpx;
|
||||
padding: 0 20rpx;
|
||||
border-bottom: 1rpx solid #f0e9df;
|
||||
}
|
||||
|
||||
.customer-option:last-child {
|
||||
border-bottom: 0;
|
||||
.reference-card,
|
||||
.reference-value {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
}
|
||||
|
||||
.customer-copy {
|
||||
.reference-card {
|
||||
min-height: 78rpx;
|
||||
padding: 13rpx 16rpx;
|
||||
border: 1rpx solid #e7e0d7;
|
||||
border-radius: 18rpx;
|
||||
background: #f8f4ee;
|
||||
}
|
||||
|
||||
.reference-copy {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
gap: 6rpx;
|
||||
}
|
||||
|
||||
.customer-name {
|
||||
min-width: 0;
|
||||
.reference-title,
|
||||
.reference-subtitle {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
color: #2a2521;
|
||||
font-size: 26rpx;
|
||||
font-weight: 800;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.customer-phone {
|
||||
color: #8c8177;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.customer-select-tag {
|
||||
flex: 0 0 auto;
|
||||
padding: 4rpx 12rpx;
|
||||
border-radius: 999rpx;
|
||||
background: #e5eee9;
|
||||
color: #55786d;
|
||||
font-size: 22rpx;
|
||||
.reference-title {
|
||||
color: #817a72;
|
||||
font-size: 27rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.muted-option {
|
||||
justify-content: center;
|
||||
color: #9a9288;
|
||||
font-size: 24rpx;
|
||||
.reference-card.filled .reference-title { color: #29241f; }
|
||||
|
||||
.reference-subtitle {
|
||||
margin-top: 6rpx;
|
||||
color: #9a9289;
|
||||
font-size: 21rpx;
|
||||
}
|
||||
|
||||
.reference-badge {
|
||||
flex: 0 0 auto;
|
||||
padding: 5rpx 11rpx;
|
||||
border-radius: 999rpx;
|
||||
background: #e7f0ec;
|
||||
color: #55786d;
|
||||
font-size: 19rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.reference-value {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.reference-arrow {
|
||||
flex: 0 0 auto;
|
||||
color: #a99f95;
|
||||
font-size: 38rpx;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.product-value {
|
||||
@@ -208,14 +214,62 @@
|
||||
}
|
||||
|
||||
.product-modal {
|
||||
display: flex;
|
||||
box-sizing: border-box;
|
||||
height: 88vh;
|
||||
width: 100%;
|
||||
max-height: 88vh;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
padding: 28rpx 28rpx calc(28rpx + env(safe-area-inset-bottom));
|
||||
border-radius: 28rpx 28rpx 0 0;
|
||||
background: #fffaf4;
|
||||
box-shadow: 0 -18rpx 40rpx rgba(41, 31, 23, 0.16);
|
||||
}
|
||||
|
||||
.manual-customer-sheet {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
height: 88vh;
|
||||
max-height: 88vh;
|
||||
flex-direction: column;
|
||||
padding: 28rpx 28rpx calc(28rpx + env(safe-area-inset-bottom));
|
||||
border-radius: 34rpx 34rpx 0 0;
|
||||
background: #fffaf4;
|
||||
box-shadow: 0 -18rpx 40rpx rgba(41, 31, 23, 0.16);
|
||||
}
|
||||
|
||||
.manual-customer-form {
|
||||
flex: 1;
|
||||
padding-top: 12rpx;
|
||||
}
|
||||
|
||||
.manual-customer-field {
|
||||
margin-bottom: 20rpx;
|
||||
padding: 20rpx 22rpx;
|
||||
border: 1rpx solid #e7e0d7;
|
||||
border-radius: 20rpx;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.manual-customer-field text {
|
||||
display: block;
|
||||
margin-bottom: 10rpx;
|
||||
color: #625c55;
|
||||
font-size: 24rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.manual-customer-field input {
|
||||
height: 64rpx;
|
||||
color: #29241f;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.manual-customer-submit {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.time-modal {
|
||||
width: 100%;
|
||||
max-height: 82vh;
|
||||
@@ -293,9 +347,16 @@
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.product-list {
|
||||
max-height: 440rpx;
|
||||
.product-modal-scroll {
|
||||
flex: 1;
|
||||
height: 0;
|
||||
min-height: 0;
|
||||
margin-top: 20rpx;
|
||||
padding-right: 2rpx;
|
||||
}
|
||||
|
||||
.product-list {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.product-option {
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
const assert = require('assert')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const wxml = fs.readFileSync(path.join(__dirname, 'index.wxml'), 'utf8')
|
||||
const wxss = fs.readFileSync(path.join(__dirname, 'index.wxss'), 'utf8')
|
||||
const pageScript = fs.readFileSync(path.join(__dirname, 'index.js'), 'utf8')
|
||||
|
||||
assert.match(wxml, /class="modal-mask" bindtap="closeProductModal" catchtouchmove="stopTouchMove"/)
|
||||
assert.match(wxml, /<scroll-view class="product-modal-scroll" scroll-y/)
|
||||
assert.match(wxml, /<view class="product-list">/)
|
||||
assert.match(wxss, /\.product-modal\s*\{[^}]*height:\s*88vh;[^}]*flex-direction:\s*column;[^}]*overflow:\s*hidden;/s)
|
||||
assert.match(wxss, /\.product-modal-scroll\s*\{[^}]*flex:\s*1;[^}]*height:\s*0;[^}]*min-height:\s*0;/s)
|
||||
assert.match(pageScript, /stopTouchMove\(\)\s*\{\s*\}/)
|
||||
@@ -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
|
||||
})
|
||||
@@ -0,0 +1,51 @@
|
||||
const assert = require('assert')
|
||||
const planningApi = require('../../api/planning')
|
||||
|
||||
global.wx = {
|
||||
getAccountInfoSync: () => ({ miniProgram: { envVersion: 'develop' } }),
|
||||
getDeviceInfo: () => ({ platform: 'devtools' }),
|
||||
showToast: () => {},
|
||||
navigateTo: () => {},
|
||||
navigateBack: () => {}
|
||||
}
|
||||
|
||||
let definition
|
||||
global.Page = value => { definition = value }
|
||||
require('./index')
|
||||
|
||||
const page = {
|
||||
...definition,
|
||||
data: JSON.parse(JSON.stringify(definition.data)),
|
||||
setData(values) { Object.assign(this.data, values) }
|
||||
}
|
||||
|
||||
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.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
|
||||
})
|
||||
@@ -6,52 +6,131 @@ Page({
|
||||
data: {
|
||||
id: '',
|
||||
artists: [],
|
||||
artistItems: [],
|
||||
selectedArtistId: '',
|
||||
selectedArtist: {},
|
||||
artistSheetVisible: false,
|
||||
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 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) {
|
||||
try {
|
||||
const calendar = await planningApi.calendar({
|
||||
startDate: this.data.date,
|
||||
endDate: this.data.date
|
||||
})
|
||||
const artists = Array.isArray(calendar.artists) ? calendar.artists : []
|
||||
let artists = Array.isArray(calendar.artists) ? calendar.artists : []
|
||||
if (fallbackEmployee && preferredArtistId && !artists.some(item => String(item.id) === String(preferredArtistId))) {
|
||||
artists = artists.concat({ id: preferredArtistId, name: fallbackEmployee.name || fallbackEmployee.title, avatar: fallbackEmployee.avatar || '' })
|
||||
}
|
||||
const selectedArtistId = preferredArtistId || this.data.selectedArtistId
|
||||
const selectedArtist = artists.find(item => String(item.id) === String(selectedArtistId)) || {}
|
||||
this.setData({
|
||||
artists: artists.map(item => ({
|
||||
...item,
|
||||
availableStatus: 'free',
|
||||
availableText: '可选择'
|
||||
})),
|
||||
selectedArtistId: '',
|
||||
artistItems: this.filterArtistItems(artists, this.data.artistKeyword),
|
||||
selectedArtistId: selectedArtist.id || '',
|
||||
selectedArtist,
|
||||
loadError: ''
|
||||
})
|
||||
} catch (error) {
|
||||
this.setData({
|
||||
artists: [],
|
||||
artistItems: [],
|
||||
selectedArtistId: '',
|
||||
selectedArtist: {},
|
||||
loadError: error.message || '美甲师列表加载失败'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
filterArtistItems(artists, keywordValue) {
|
||||
const keyword = String(keywordValue || '').trim().toLowerCase()
|
||||
return (artists || [])
|
||||
.filter(item => !keyword || String(item.name || '').toLowerCase().includes(keyword))
|
||||
.map(item => ({
|
||||
...item,
|
||||
title: item.name || '未命名员工',
|
||||
subtitle: item.statusText || '可用于改派',
|
||||
meta: item.workStartTime && item.workEndTime ? `${item.workStartTime.slice(0, 5)}-${item.workEndTime.slice(0, 5)}` : '',
|
||||
avatar: item.avatar || item.avatarUrl || '/assets/images/default-user-avatar.png'
|
||||
}))
|
||||
},
|
||||
|
||||
openArtistSheet() {
|
||||
this.setData({ artistSheetVisible: true, artistItems: this.filterArtistItems(this.data.artists, this.data.artistKeyword) })
|
||||
},
|
||||
|
||||
closeArtistSheet() {
|
||||
this.setData({ artistSheetVisible: false })
|
||||
},
|
||||
|
||||
onArtistSearch(event) {
|
||||
const artistKeyword = event.detail.value
|
||||
this.setData({ artistKeyword, artistItems: this.filterArtistItems(this.data.artists, artistKeyword) })
|
||||
},
|
||||
|
||||
selectArtist(event) {
|
||||
this.setData({ selectedArtistId: event.currentTarget.dataset.id })
|
||||
const selectedArtist = event.detail.item || {}
|
||||
this.setData({ selectedArtistId: selectedArtist.id, selectedArtist, artistSheetVisible: false })
|
||||
},
|
||||
|
||||
retryArtists() {
|
||||
this.loadArtists()
|
||||
},
|
||||
|
||||
addEmployeeFromSelector() {
|
||||
this.setData({ artistSheetVisible: false })
|
||||
wx.navigateTo({
|
||||
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.autoSelect === false ? '' : employee.id, employee)
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
async onDateChange(event) {
|
||||
this.setData({ date: event.detail.value })
|
||||
await this.loadArtists()
|
||||
await this.loadArtists(this.data.selectedArtistId)
|
||||
},
|
||||
|
||||
onTimeChange(event) {
|
||||
@@ -68,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,3 +1,6 @@
|
||||
{
|
||||
"navigationBarTitleText": "改派员工"
|
||||
"navigationBarTitleText": "改派员工",
|
||||
"usingComponents": {
|
||||
"entity-selector-sheet": "/components/entity-selector-sheet/index"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,40 +1,48 @@
|
||||
<view class="page no-tab">
|
||||
<view class="list">
|
||||
<view wx:if="{{loadError}}" class="empty card">
|
||||
<text>{{loadError}}</text>
|
||||
<button class="secondary-btn retry-btn" bindtap="loadArtists">重试</button>
|
||||
</view>
|
||||
<view wx:elif="{{artists.length === 0}}" class="empty card">暂无可选美甲师</view>
|
||||
<view wx:for="{{artists}}" wx:key="id" class="card transfer-card {{selectedArtistId == item.id ? 'active' : ''}}" data-id="{{item.id}}" bindtap="selectArtist">
|
||||
<view class="row between">
|
||||
<view class="row">
|
||||
<view class="chip-dot large" style="background: {{item.color}};"></view>
|
||||
<view>
|
||||
<text class="artist-name">{{item.name}}</text>
|
||||
<text class="artist-status">{{item.statusText}}</text>
|
||||
</view>
|
||||
<view class="card form-card section">
|
||||
<view class="field">
|
||||
<text class="field-label required">{{isUnassigned ? '分配员工' : '改派员工'}}</text>
|
||||
<view class="field-value transfer-reference" bindtap="openArtistSheet">
|
||||
<view>
|
||||
<text>{{selectedArtist.name || '请选择员工'}}</text>
|
||||
<text wx:if="{{loadError}}" class="transfer-error">{{loadError}}</text>
|
||||
</view>
|
||||
<text class="tag {{item.availableStatus}}">{{item.availableText}}</text>
|
||||
<text class="transfer-arrow">›</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{!loadError}}" class="card form-card section">
|
||||
<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>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{!loadError}}" class="fixed-bottom">
|
||||
<button class="primary-btn" loading="{{loading}}" bindtap="submit">确认改派</button>
|
||||
<entity-selector-sheet
|
||||
visible="{{artistSheetVisible}}"
|
||||
title="{{isUnassigned ? '选择分配员工' : '选择改派员工'}}"
|
||||
keyword="{{artistKeyword}}"
|
||||
placeholder="搜索员工姓名"
|
||||
items="{{artistItems}}"
|
||||
selected-id="{{selectedArtistId}}"
|
||||
loading="{{false}}"
|
||||
error-text="{{loadError}}"
|
||||
empty-text="暂无可选员工"
|
||||
action-text="快速新增员工"
|
||||
bind:search="onArtistSearch"
|
||||
bind:select="selectArtist"
|
||||
bind:retry="retryArtists"
|
||||
bind:action="addEmployeeFromSelector"
|
||||
bind:close="closeArtistSheet"
|
||||
/>
|
||||
|
||||
<view class="fixed-bottom">
|
||||
<button class="primary-btn" loading="{{loading}}" bindtap="submit">{{isUnassigned ? '确认分配' : '确认改派'}}</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -1,52 +1,29 @@
|
||||
.transfer-card {
|
||||
padding: 24rpx;
|
||||
.transfer-reference {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.retry-btn {
|
||||
width: 180rpx;
|
||||
min-width: 180rpx;
|
||||
max-width: 180rpx;
|
||||
margin: 24rpx auto 0;
|
||||
.transfer-reference > view {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.transfer-card.active {
|
||||
outline: 3rpx solid #8fb89a;
|
||||
}
|
||||
|
||||
.chip-dot.large {
|
||||
width: 24rpx;
|
||||
height: 24rpx;
|
||||
margin-right: 16rpx;
|
||||
}
|
||||
|
||||
.artist-name,
|
||||
.artist-status {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.artist-name {
|
||||
color: #25211d;
|
||||
font-size: 30rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.artist-status {
|
||||
.transfer-error {
|
||||
margin-top: 6rpx;
|
||||
color: #948c83;
|
||||
font-size: 22rpx;
|
||||
overflow: hidden;
|
||||
color: #a8554e;
|
||||
font-size: 21rpx;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.tag.free {
|
||||
background: #e5eee9;
|
||||
color: #55786d;
|
||||
}
|
||||
|
||||
.tag.busy {
|
||||
background: #fbedd7;
|
||||
color: #a5722a;
|
||||
}
|
||||
|
||||
.tag.full {
|
||||
background: #f8e2e6;
|
||||
color: #b06070;
|
||||
.transfer-arrow {
|
||||
flex: 0 0 auto;
|
||||
color: #a99f95;
|
||||
font-size: 38rpx;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
const planningApi = require('../../api/planning')
|
||||
const employeesApi = require('../../api/employees')
|
||||
const productsApi = require('../../api/products')
|
||||
const customersApi = require('../../api/customers')
|
||||
const dateUtil = require('../../utils/date')
|
||||
|
||||
Page({
|
||||
data: { form: { serviceDate: dateUtil.formatDate(new Date()), manualProductTitle: '', amount: '', customerName: '', phone: '', serviceTime: '', status: 4, remark: '', artistId: '', productId: '', customerUserId: '' }, artists: [], artistOptions: [], allProductOptions: [], productOptions: [], customerOptions: [], allCustomerOptions: [], productSelectorVisible: false, artistSelectorVisible: false, customerSelectorVisible: false, loadingProducts: false, loadingArtists: false, loadingCustomers: false, productKeyword: '', artistKeyword: '', customerKeyword: '', productError: '', artistError: '', customerError: '', selectedArtistName: '', selectedProductTitle: '', submitting: false },
|
||||
onLoad() { this.loadArtists(); this.loadProducts(); this.loadCustomers() },
|
||||
async loadArtists() {
|
||||
try {
|
||||
const result = await employeesApi.list({ page: 1, size: 100 })
|
||||
const list = result.list || result || []
|
||||
const normalized = list.map(item => ({ ...item, name: item.name || item.nickname || item.account || `员工${item.id}` }))
|
||||
this.setData({ artists: normalized, artistOptions: normalized.map(item => ({ id: item.id, title: item.name, subtitle: item.phone || '' })), selectedArtistName: '', 'form.artistId': '' })
|
||||
} catch (error) { wx.showToast({ title: error.message || '员工加载失败', icon: 'none' }) }
|
||||
},
|
||||
async loadProducts() { this.setData({ loadingProducts: true }); try { const result = await productsApi.list({ page: 1, size: 100 }); const list = result.list || result || []; const options = list.map(item => ({ id: item.id, title: item.title, price: item.price, subtitle: item.price == null ? '' : `¥${item.price}` })); this.setData({ allProductOptions: options, productOptions: options, productError: '' }) } catch (error) { this.setData({ productError: error.message || '项目加载失败' }) } finally { this.setData({ loadingProducts: false }) } },
|
||||
async loadCustomers() { this.setData({ loadingCustomers: true }); try { const result = await customersApi.list({ page: 1, size: 30 }); const list = result.list || result || []; const options = list.map(item => ({ id: item.id, title: item.nickname || item.name || item.account, subtitle: item.phone || item.contactPhone || '' })); this.setData({ allCustomerOptions: options, customerOptions: options, customerError: '' }) } catch (error) { this.setData({ customerError: error.message || '客户加载失败' }) } finally { this.setData({ loadingCustomers: false }) } },
|
||||
openProductSelector() { this.setData({ productSelectorVisible: true }) },
|
||||
closeProductSelector() { this.setData({ productSelectorVisible: false }) },
|
||||
openArtistSelector() { this.setData({ artistSelectorVisible: true }) },
|
||||
closeArtistSelector() { this.setData({ artistSelectorVisible: false }) },
|
||||
openCustomerSelector() { this.setData({ customerSelectorVisible: true }) },
|
||||
closeCustomerSelector() { this.setData({ customerSelectorVisible: false }) },
|
||||
searchProducts(e) { const keyword = String(e.detail.value || '').toLowerCase(); this.setData({ productKeyword: keyword, productOptions: this.data.allProductOptions.filter(item => !keyword || String(item.title).toLowerCase().includes(keyword)) }) },
|
||||
searchArtists(e) { const keyword = String(e.detail.value || '').toLowerCase(); this.setData({ artistKeyword: keyword, artistOptions: this.data.artists.map(item => ({ id: item.id, title: item.name, subtitle: item.phone || '' })).filter(item => !keyword || item.title.toLowerCase().includes(keyword)) }) },
|
||||
searchCustomers(e) { const keyword = String(e.detail.value || '').toLowerCase(); this.setData({ customerKeyword: keyword, customerOptions: this.data.allCustomerOptions.filter(item => !keyword || String(item.title).toLowerCase().includes(keyword) || String(item.subtitle).includes(keyword)) }) },
|
||||
selectProduct(e) { const item = e.detail.item; this.setData({ 'form.productId': item.id, selectedProductTitle: item.title, 'form.manualProductTitle': '', 'form.amount': item.price == null ? this.data.form.amount : String(item.price), productSelectorVisible: false }) },
|
||||
selectArtist(e) { const item = e.detail.item; this.setData({ 'form.artistId': item.id, selectedArtistName: item.title, artistSelectorVisible: false }) },
|
||||
selectCustomer(e) { const item = e.detail.item; this.setData({ 'form.customerUserId': item.id, 'form.customerName': item.title, 'form.phone': item.subtitle, customerSelectorVisible: false }) },
|
||||
useWalkIn() { this.setData({ 'form.customerUserId': '', 'form.customerName': '', 'form.phone': '', customerSelectorVisible: false }) },
|
||||
onCustomerNameInput(e) { this.setData({ 'form.customerName': e.detail.value, 'form.customerUserId': '' }) },
|
||||
onProductNameInput(e) { this.setData({ 'form.manualProductTitle': e.detail.value, 'form.productId': '', selectedProductTitle: '' }) },
|
||||
onInput(e) { this.setData({ [`form.${e.currentTarget.dataset.field}`]: e.detail.value }) },
|
||||
onDateChange(e) { this.setData({ 'form.serviceDate': e.detail.value }) },
|
||||
onTimeChange(e) { this.setData({ 'form.serviceTime': e.detail.value }) },
|
||||
onArtistChange(e) { const index = Number(e.detail.value); const item = this.data.artists[index] || {}; this.setData({ artistIndex: index, selectedArtistName: item.name || item.nickname || '', 'form.artistId': item.id }) },
|
||||
selectStatus(e) { this.setData({ 'form.status': Number(e.currentTarget.dataset.status) }) },
|
||||
async submit() {
|
||||
const form = this.data.form
|
||||
if (!form.serviceDate || (!form.productId && !form.manualProductTitle) || !form.amount || !form.artistId) { wx.showToast({ title: '请填写项目、金额、日期和员工', icon: 'none' }); return }
|
||||
if (form.phone && !/^1[3-9]\d{9}$/.test(form.phone)) { wx.showToast({ title: '手机号格式不正确', icon: 'none' }); return }
|
||||
this.setData({ submitting: true })
|
||||
try { await planningApi.createBackfillOrder(form); wx.showToast({ title: '补单已保存', icon: 'success' }); const app = getApp(); app.globalData.planningNeedRefresh = true; setTimeout(() => wx.navigateBack(), 500) }
|
||||
catch (error) { wx.showToast({ title: error.message || '保存失败', icon: 'none' }) }
|
||||
finally { this.setData({ submitting: false }) }
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"navigationBarTitleText": "补录历史订单",
|
||||
"usingComponents": { "entity-selector-sheet": "/components/entity-selector-sheet/index" }
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<view class="page no-tab">
|
||||
<view class="card form-card">
|
||||
<view class="page-hint">历史补单不校验员工排班,也不会占用预约时段。</view>
|
||||
<view class="field"><text class="field-label required">服务日期</text><picker mode="date" value="{{form.serviceDate}}" bindchange="onDateChange"><view class="field-value">{{form.serviceDate}}</view></picker></view>
|
||||
<view class="field"><text class="field-label required">项目</text><view class="field-value" bindtap="openProductSelector">{{selectedProductTitle || form.manualProductTitle || '选择已有项目或手动填写'}}</view><input value="{{form.manualProductTitle}}" bindinput="onProductNameInput" placeholder="手动录入项目名称(选填)" /></view>
|
||||
<view class="field"><text class="field-label required">金额</text><input type="digit" value="{{form.amount}}" data-field="amount" bindinput="onInput" placeholder="请输入实际金额" /></view>
|
||||
<view class="field"><text class="field-label required">员工</text><view class="field-value" bindtap="openArtistSelector">{{selectedArtistName || '请选择员工'}}</view></view>
|
||||
<view class="field"><text class="field-label">客户</text><view class="field-value" bindtap="openCustomerSelector">{{form.customerName || '请选择客户(可选)'}}</view><input value="{{form.customerName}}" data-field="customerName" bindinput="onCustomerNameInput" placeholder="或填写散客姓名" /></view>
|
||||
<view class="field"><text class="field-label">手机号</text><input type="number" maxlength="11" value="{{form.phone}}" data-field="phone" bindinput="onInput" placeholder="选填" /></view>
|
||||
<view class="field"><text class="field-label">服务时间</text><picker mode="time" value="{{form.serviceTime}}" bindchange="onTimeChange"><view class="field-value">{{form.serviceTime || '时间未记录'}}</view></picker></view>
|
||||
<view class="field"><text class="field-label">状态</text><view class="status-segment"><view class="status-option {{form.status == 4 ? 'active' : ''}}" data-status="4" bindtap="selectStatus">服务中</view><view class="status-option {{form.status == 2 ? 'active' : ''}}" data-status="2" bindtap="selectStatus">已完成</view></view></view>
|
||||
<view class="field textarea-field"><text class="field-label">备注</text><textarea value="{{form.remark}}" data-field="remark" bindinput="onInput" placeholder="补单备注(选填)" /></view>
|
||||
</view>
|
||||
<view class="card submit-tip">提交后订单会直接进入所选状态,不创建预约占用。</view>
|
||||
<button class="primary-btn" loading="{{submitting}}" disabled="{{submitting}}" bindtap="submit">保存历史补单</button>
|
||||
<entity-selector-sheet visible="{{productSelectorVisible}}" title="选择项目" keyword="{{productKeyword}}" placeholder="搜索项目名称" items="{{productOptions}}" selected-id="{{form.productId}}" loading="{{loadingProducts}}" error-text="{{productError}}" empty-text="暂无项目,可直接手动录入" bind:search="searchProducts" bind:select="selectProduct" bind:retry="loadProducts" bind:close="closeProductSelector" />
|
||||
<entity-selector-sheet visible="{{artistSelectorVisible}}" title="选择员工" keyword="{{artistKeyword}}" placeholder="搜索员工姓名" items="{{artistOptions}}" selected-id="{{form.artistId}}" loading="{{loadingArtists}}" error-text="{{artistError}}" empty-text="暂无可选员工" bind:search="searchArtists" bind:select="selectArtist" bind:retry="loadArtists" bind:close="closeArtistSelector" />
|
||||
<entity-selector-sheet visible="{{customerSelectorVisible}}" title="选择客户" keyword="{{customerKeyword}}" placeholder="搜索客户姓名或手机号" items="{{customerOptions}}" selected-id="{{form.customerUserId}}" loading="{{loadingCustomers}}" error-text="{{customerError}}" empty-text="暂无客户,可留空记为散客" action-text="按散客记录" bind:search="searchCustomers" bind:select="selectCustomer" bind:retry="loadCustomers" bind:action="useWalkIn" bind:close="closeCustomerSelector" />
|
||||
</view>
|
||||
@@ -0,0 +1 @@
|
||||
.page{padding:24rpx;background:#f7f5f1;min-height:100vh;box-sizing:border-box}.form-card{padding:28rpx}.page-hint,.submit-tip{font-size:26rpx;color:#8b8177;line-height:1.6}.field{padding:24rpx 0;border-bottom:1rpx solid #eee7df}.field-label{display:block;color:#4d463f;font-size:28rpx;margin-bottom:14rpx}.required:after{content:' *';color:#c9795d}.field-value,input,textarea{font-size:30rpx;color:#2d2925}.field-value{min-height:42rpx;color:#6f665d}.status-segment{display:flex;gap:16rpx}.status-option{flex:1;text-align:center;padding:18rpx;border:1rpx solid #ddd4ca;border-radius:12rpx;color:#756b61}.status-option.active{background:#4f766d;color:#fff;border-color:#4f766d}.submit-tip{margin:22rpx 0;padding:22rpx}.primary-btn{margin-top:28rpx;background:#4f766d;color:#fff;border-radius:14rpx}
|
||||
@@ -0,0 +1,143 @@
|
||||
const employeesApi = require('../../api/employees')
|
||||
const { chooseImageFilePath, uploadObjectFile } = require('../../utils/upload')
|
||||
|
||||
const DEFAULT_EMPLOYEE_PASSWORD = 'Fingertip@123'
|
||||
|
||||
Page({
|
||||
data: {
|
||||
pickerMode: false,
|
||||
appointmentContext: { date: '', time: '', durationMinutes: '' },
|
||||
onboardingVisible: false,
|
||||
createdEmployee: null,
|
||||
form: {
|
||||
nickname: '',
|
||||
phone: '',
|
||||
account: '',
|
||||
password: DEFAULT_EMPLOYEE_PASSWORD,
|
||||
wechatId: '',
|
||||
avatar: '',
|
||||
avatarUrl: ''
|
||||
},
|
||||
avatarUploading: false,
|
||||
creating: false
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
this.setData({
|
||||
pickerMode: options && options.picker === '1',
|
||||
appointmentContext: {
|
||||
date: options.date || '',
|
||||
time: options.time || '',
|
||||
durationMinutes: options.durationMinutes || ''
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
onInput(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
const value = event.detail.value
|
||||
const updates = { [`form.${field}`]: value }
|
||||
if (field === 'phone' && !this.data.form.account) updates['form.account'] = value
|
||||
this.setData(updates)
|
||||
},
|
||||
|
||||
async chooseAvatar() {
|
||||
if (this.data.avatarUploading || this.data.creating) return
|
||||
try {
|
||||
const filePath = await chooseImageFilePath()
|
||||
if (!filePath) return
|
||||
this.setData({ avatarUploading: true })
|
||||
const uploadResult = await uploadObjectFile(filePath)
|
||||
const avatarUrl = uploadResult.fileUrl || uploadResult.primaryUrl || filePath
|
||||
this.setData({
|
||||
'form.avatar': avatarUrl,
|
||||
'form.avatarUrl': avatarUrl
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '头像上传失败', icon: 'none' })
|
||||
} finally {
|
||||
this.setData({ avatarUploading: false })
|
||||
}
|
||||
},
|
||||
|
||||
removeAvatar() {
|
||||
this.setData({ 'form.avatar': '', 'form.avatarUrl': '' })
|
||||
},
|
||||
|
||||
stopTouchMove() {
|
||||
},
|
||||
|
||||
async submit() {
|
||||
const form = this.data.form
|
||||
const nickname = String(form.nickname || '').trim()
|
||||
const phone = String(form.phone || '').trim()
|
||||
const account = String(form.account || '').trim()
|
||||
const password = String(form.password || '').trim()
|
||||
const wechatId = String(form.wechatId || '').trim()
|
||||
if (!nickname || !phone || !account || !password || !wechatId) {
|
||||
wx.showToast({ title: '请补全员工信息', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!/^1[3-9]\d{9}$/.test(phone)) {
|
||||
wx.showToast({ title: '请输入正确手机号', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.setData({ creating: true })
|
||||
try {
|
||||
const result = await employeesApi.createUser({
|
||||
nickname,
|
||||
phone,
|
||||
contactPhone: phone,
|
||||
account,
|
||||
password,
|
||||
wechatId,
|
||||
avatar: form.avatar || undefined,
|
||||
type: 3
|
||||
})
|
||||
const id = result && typeof result === 'object' ? (result.id || result.userId) : result
|
||||
const employee = { id, name: nickname, title: nickname, avatar: form.avatar || '' }
|
||||
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)
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"navigationBarTitleText": "新增员工"
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
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 },
|
||||
navigateTo: options => { navigatedTo = options.url }
|
||||
}
|
||||
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.onInput({ currentTarget: { dataset: { field: 'phone' } }, detail: { value: '13800138000' } })
|
||||
assert.strictEqual(page.data.form.account, '13800138000')
|
||||
Object.assign(page.data.form, {
|
||||
nickname: '小周',
|
||||
phone: '13800138000',
|
||||
account: '13800138000',
|
||||
password: 'Fingertip@123',
|
||||
wechatId: 'wx_zhou'
|
||||
})
|
||||
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: '', 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 => {
|
||||
console.error(error)
|
||||
process.exitCode = 1
|
||||
})
|
||||
@@ -0,0 +1,54 @@
|
||||
<view class="page no-tab employee-create-page">
|
||||
<view class="create-intro">
|
||||
<text class="create-title">录入员工账号</text>
|
||||
<text class="create-subtitle">{{pickerMode ? '保存后自动选择该员工' : '保存后即可用于预约指定和员工管理'}}</text>
|
||||
</view>
|
||||
|
||||
<view class="card avatar-card" bindtap="chooseAvatar">
|
||||
<image wx:if="{{form.avatarUrl}}" class="avatar-preview" src="{{form.avatarUrl}}" mode="aspectFill"></image>
|
||||
<image wx:else class="avatar-preview" src="/assets/images/default-user-avatar.png" mode="aspectFit"></image>
|
||||
<view class="avatar-copy">
|
||||
<text class="avatar-title">员工头像</text>
|
||||
<text class="avatar-tip">点击选择图片,可稍后补充</text>
|
||||
</view>
|
||||
<text class="avatar-action">{{avatarUploading ? '上传中' : '更换'}}</text>
|
||||
</view>
|
||||
<button wx:if="{{form.avatarUrl}}" class="remove-avatar" catchtap="removeAvatar">移除当前头像</button>
|
||||
|
||||
<view class="card form-card create-form">
|
||||
<view class="field">
|
||||
<text class="field-label required">姓名</text>
|
||||
<input value="{{form.nickname}}" data-field="nickname" bindinput="onInput" placeholder="请输入员工姓名" />
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label required">手机号</text>
|
||||
<input value="{{form.phone}}" data-field="phone" bindinput="onInput" type="number" maxlength="11" placeholder="请输入手机号" />
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label required">登录账号</text>
|
||||
<input value="{{form.account}}" data-field="account" bindinput="onInput" placeholder="默认跟随手机号" />
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label required">初始密码</text>
|
||||
<input value="{{form.password}}" data-field="password" bindinput="onInput" password placeholder="请输入初始密码" />
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label required">微信号</text>
|
||||
<input value="{{form.wechatId}}" data-field="wechatId" bindinput="onInput" placeholder="请输入微信号" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<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>
|
||||
@@ -0,0 +1,121 @@
|
||||
.employee-create-page {
|
||||
padding-top: 28rpx;
|
||||
}
|
||||
|
||||
.create-intro {
|
||||
margin: 0 6rpx 24rpx;
|
||||
}
|
||||
|
||||
.create-title,
|
||||
.create-subtitle,
|
||||
.avatar-title,
|
||||
.avatar-tip {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.create-title {
|
||||
color: #29241f;
|
||||
font-size: 38rpx;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.create-subtitle {
|
||||
margin-top: 10rpx;
|
||||
color: #8b837b;
|
||||
font-size: 23rpx;
|
||||
}
|
||||
|
||||
.avatar-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 24rpx;
|
||||
}
|
||||
|
||||
.avatar-preview {
|
||||
width: 96rpx;
|
||||
height: 96rpx;
|
||||
flex: 0 0 auto;
|
||||
border-radius: 50%;
|
||||
background: #eee9e2;
|
||||
}
|
||||
|
||||
.avatar-copy {
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
|
||||
.avatar-title {
|
||||
color: #302a25;
|
||||
font-size: 28rpx;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.avatar-tip {
|
||||
margin-top: 8rpx;
|
||||
color: #948c83;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
.avatar-action {
|
||||
color: #2f6f62;
|
||||
font-size: 24rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.remove-avatar {
|
||||
width: auto;
|
||||
min-height: 58rpx;
|
||||
margin: 8rpx 8rpx 10rpx auto;
|
||||
padding: 0 12rpx;
|
||||
color: #a8554e;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
.create-form {
|
||||
margin-top: 22rpx;
|
||||
}
|
||||
|
||||
.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; }
|
||||
@@ -1,10 +1,8 @@
|
||||
const employeesApi = require('../../api/employees')
|
||||
const planningApi = require('../../api/planning')
|
||||
const dateUtil = require('../../utils/date')
|
||||
const { chooseImageFilePath, uploadObjectFile } = require('../../utils/upload')
|
||||
|
||||
const EMPLOYEE_COLORS = ['#7AA9C2', '#8EB99B', '#BDA7D8', '#D7B17D', '#D98D8D']
|
||||
const DEFAULT_EMPLOYEE_PASSWORD = 'Fingertip@123'
|
||||
|
||||
function buildScheduleSummary(item) {
|
||||
const mode = item.scheduleModeSummary || item.scheduleMode || '未设置'
|
||||
@@ -12,26 +10,121 @@ function buildScheduleSummary(item) {
|
||||
return time ? `${mode} ${time}` : mode
|
||||
}
|
||||
|
||||
function formatApplicationTime(value) {
|
||||
if (!value) return ''
|
||||
return String(value).replace('T', ' ').slice(0, 16)
|
||||
}
|
||||
|
||||
function confirmModal(options) {
|
||||
return new Promise(resolve => {
|
||||
wx.showModal({ ...options, success: resolve, fail: () => resolve({ confirm: false }) })
|
||||
})
|
||||
}
|
||||
|
||||
Page({
|
||||
data: {
|
||||
employees: [],
|
||||
loadError: '',
|
||||
createModalVisible: false,
|
||||
creating: false,
|
||||
createForm: {
|
||||
nickname: '',
|
||||
phone: '',
|
||||
account: '',
|
||||
password: DEFAULT_EMPLOYEE_PASSWORD,
|
||||
wechatId: '',
|
||||
avatar: '',
|
||||
avatarUrl: ''
|
||||
},
|
||||
avatarUploading: false
|
||||
isManager: false,
|
||||
reviewExpanded: false,
|
||||
reviewApplications: [],
|
||||
reviewPendingCount: 0,
|
||||
reviewLoading: false,
|
||||
reviewError: '',
|
||||
reviewingId: ''
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
const userInfo = getApp().globalData.userInfo || {}
|
||||
this.setData({ isManager: Number(userInfo.type) === 2 })
|
||||
this.loadEmployees()
|
||||
if (Number(userInfo.type) === 2) this.loadReviewSummary()
|
||||
},
|
||||
|
||||
onShow() {
|
||||
const app = getApp()
|
||||
if (!this.data.isManager || !app.globalData.openEmployeeReview) return
|
||||
app.globalData.openEmployeeReview = false
|
||||
this.setData({ reviewExpanded: true })
|
||||
return this.loadReviewApplications()
|
||||
},
|
||||
|
||||
async loadReviewSummary() {
|
||||
if (!this.data.isManager) return
|
||||
try {
|
||||
const summary = await employeesApi.reviewSummary()
|
||||
this.setData({ reviewPendingCount: Number(summary.pendingCount || 0) })
|
||||
} catch (error) {
|
||||
// 审核摘要失败不影响员工列表。
|
||||
}
|
||||
},
|
||||
|
||||
toggleReview() {
|
||||
if (!this.data.isManager) return
|
||||
const reviewExpanded = !this.data.reviewExpanded
|
||||
this.setData({ reviewExpanded })
|
||||
if (reviewExpanded) this.loadReviewApplications()
|
||||
},
|
||||
|
||||
async loadReviewApplications() {
|
||||
if (!this.data.isManager || this.data.reviewLoading) return
|
||||
this.setData({ reviewLoading: true, reviewError: '' })
|
||||
try {
|
||||
const data = await employeesApi.reviewApplications()
|
||||
const applications = (Array.isArray(data) ? data : []).map(item => ({
|
||||
...item,
|
||||
applicantNickname: item.applicantNickname || '待审核员工',
|
||||
applicantAvatar: item.applicantAvatar || '',
|
||||
applicantMaskedPhone: item.applicantMaskedPhone || '',
|
||||
applicationTimeText: formatApplicationTime(item.createTime)
|
||||
}))
|
||||
this.setData({ reviewApplications: applications, reviewPendingCount: applications.length })
|
||||
} catch (error) {
|
||||
this.setData({ reviewError: error.message || '审核申请加载失败' })
|
||||
} finally {
|
||||
this.setData({ reviewLoading: false })
|
||||
}
|
||||
},
|
||||
|
||||
async approveApplication(event) {
|
||||
const id = event.currentTarget.dataset.id
|
||||
if (!id || this.data.reviewingId) return
|
||||
const result = await confirmModal({ title: '通过员工申请', content: '确认允许该员工加入当前门店吗?' })
|
||||
if (!result.confirm) return
|
||||
await this.submitReview(id, () => employeesApi.approveApplication(id), '申请已通过')
|
||||
},
|
||||
|
||||
async rejectApplication(event) {
|
||||
const id = event.currentTarget.dataset.id
|
||||
if (!id || this.data.reviewingId) return
|
||||
const result = await confirmModal({
|
||||
title: '驳回员工申请',
|
||||
content: '',
|
||||
editable: true,
|
||||
placeholderText: '请输入驳回原因',
|
||||
confirmText: '确认驳回'
|
||||
})
|
||||
if (!result.confirm) return
|
||||
const reason = String(result.content || '').trim()
|
||||
if (!reason) {
|
||||
wx.showToast({ title: '请输入驳回原因', icon: 'none' })
|
||||
return
|
||||
}
|
||||
await this.submitReview(id, () => employeesApi.rejectApplication(id, reason), '申请已驳回')
|
||||
},
|
||||
|
||||
async submitReview(id, action, successMessage) {
|
||||
this.setData({ reviewingId: String(id) })
|
||||
try {
|
||||
await action()
|
||||
wx.showToast({ title: successMessage, icon: 'success' })
|
||||
await Promise.all([this.loadReviewApplications(), this.loadEmployees()])
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '申请状态已变化,请刷新重试', icon: 'none' })
|
||||
await this.loadReviewApplications()
|
||||
} finally {
|
||||
this.setData({ reviewingId: '' })
|
||||
}
|
||||
},
|
||||
|
||||
async loadEmployees() {
|
||||
@@ -81,110 +174,11 @@ Page({
|
||||
},
|
||||
|
||||
addEmployee() {
|
||||
this.setData({ createModalVisible: true })
|
||||
},
|
||||
|
||||
closeCreateModal() {
|
||||
if (this.data.creating) {
|
||||
return
|
||||
}
|
||||
this.setData({ createModalVisible: false })
|
||||
},
|
||||
|
||||
stopTap() {
|
||||
},
|
||||
|
||||
onCreateInput(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
const value = event.detail.value
|
||||
const updates = {
|
||||
[`createForm.${field}`]: value
|
||||
}
|
||||
if (field === 'phone' && !this.data.createForm.account) {
|
||||
updates['createForm.account'] = value
|
||||
}
|
||||
this.setData(updates)
|
||||
},
|
||||
|
||||
resetCreateForm() {
|
||||
this.setData({
|
||||
createForm: {
|
||||
nickname: '',
|
||||
phone: '',
|
||||
account: '',
|
||||
password: DEFAULT_EMPLOYEE_PASSWORD,
|
||||
wechatId: '',
|
||||
avatar: '',
|
||||
avatarUrl: ''
|
||||
wx.navigateTo({
|
||||
url: '/pages/employee-create/index',
|
||||
success: result => {
|
||||
result.eventChannel.on('employeeCreated', () => this.loadEmployees())
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
async chooseEmployeeAvatar() {
|
||||
if (this.data.avatarUploading || this.data.creating) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
const filePath = await chooseImageFilePath()
|
||||
if (!filePath) {
|
||||
return
|
||||
}
|
||||
this.setData({ avatarUploading: true })
|
||||
const uploadResult = await uploadObjectFile(filePath)
|
||||
const avatarUrl = uploadResult.fileUrl || uploadResult.primaryUrl || filePath
|
||||
this.setData({
|
||||
'createForm.avatar': avatarUrl,
|
||||
'createForm.avatarUrl': avatarUrl
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '头像上传失败', icon: 'none' })
|
||||
} finally {
|
||||
this.setData({ avatarUploading: false })
|
||||
}
|
||||
},
|
||||
|
||||
removeEmployeeAvatar() {
|
||||
this.setData({
|
||||
'createForm.avatar': '',
|
||||
'createForm.avatarUrl': ''
|
||||
})
|
||||
},
|
||||
|
||||
async submitEmployee() {
|
||||
const form = this.data.createForm
|
||||
const nickname = String(form.nickname || '').trim()
|
||||
const phone = String(form.phone || '').trim()
|
||||
const account = String(form.account || '').trim()
|
||||
const password = String(form.password || '').trim()
|
||||
const wechatId = String(form.wechatId || '').trim()
|
||||
if (!nickname || !phone || !account || !password || !wechatId) {
|
||||
wx.showToast({ title: '请补全美甲师信息', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!/^1[3-9]\d{9}$/.test(phone)) {
|
||||
wx.showToast({ title: '请输入正确手机号', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.setData({ creating: true })
|
||||
try {
|
||||
await employeesApi.createUser({
|
||||
nickname,
|
||||
phone,
|
||||
contactPhone: phone,
|
||||
account,
|
||||
password,
|
||||
wechatId,
|
||||
avatar: form.avatar || undefined,
|
||||
type: 3
|
||||
})
|
||||
wx.showToast({ title: '美甲师已新增', icon: 'success' })
|
||||
this.resetCreateForm()
|
||||
this.setData({ createModalVisible: false })
|
||||
await this.loadEmployees()
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '新增失败', icon: 'none' })
|
||||
} finally {
|
||||
this.setData({ creating: false })
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
const assert = require('assert')
|
||||
|
||||
global.wx = {
|
||||
getAccountInfoSync: () => ({ miniProgram: { envVersion: 'develop' } }),
|
||||
getDeviceInfo: () => ({ platform: 'devtools' }),
|
||||
getStorageSync: () => '',
|
||||
setStorageSync: () => {},
|
||||
removeStorageSync: () => {}
|
||||
}
|
||||
|
||||
const appMock = {
|
||||
globalData: {
|
||||
userInfo: { type: 2 },
|
||||
openEmployeeReview: true
|
||||
}
|
||||
}
|
||||
global.getApp = () => appMock
|
||||
|
||||
let definition
|
||||
global.Page = value => { definition = value }
|
||||
require('./index')
|
||||
|
||||
function createPage() {
|
||||
return {
|
||||
...definition,
|
||||
data: { ...definition.data, isManager: true },
|
||||
setData(values) { Object.assign(this.data, values) }
|
||||
}
|
||||
}
|
||||
|
||||
async function run() {
|
||||
const employeesApi = require('../../api/employees')
|
||||
employeesApi.reviewApplications = async () => [{
|
||||
id: 12,
|
||||
applicationNo: 'SALON-001',
|
||||
applicantNickname: '小周',
|
||||
createTime: '2026-10-12T10:30:00'
|
||||
}]
|
||||
|
||||
const page = createPage()
|
||||
await page.onShow()
|
||||
|
||||
assert.strictEqual(appMock.globalData.openEmployeeReview, false)
|
||||
assert.strictEqual(page.data.reviewExpanded, true)
|
||||
assert.strictEqual(page.data.reviewPendingCount, 1)
|
||||
assert.strictEqual(page.data.reviewApplications[0].applicationTimeText, '2026-10-12 10:30')
|
||||
}
|
||||
|
||||
run().catch(error => {
|
||||
console.error(error)
|
||||
process.exitCode = 1
|
||||
})
|
||||
@@ -1,9 +1,40 @@
|
||||
<view class="page">
|
||||
<view class="list-heading">
|
||||
<text>美甲师</text>
|
||||
<button wx:if="{{isManager}}" class="compact-btn review-toggle {{reviewExpanded ? 'is-open' : ''}}" bindtap="toggleReview">
|
||||
审核<text wx:if="{{reviewPendingCount > 0}}" class="review-badge">{{reviewPendingCount}}</text>
|
||||
</button>
|
||||
<button class="compact-btn" bindtap="addEmployee">新增</button>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{isManager && reviewExpanded}}" class="review-panel card">
|
||||
<view class="review-panel-head">
|
||||
<view><text class="review-title">员工申请审核</text><text class="review-subtitle">仅显示当前门店待处理申请</text></view>
|
||||
<text class="review-count">{{reviewPendingCount}} 项</text>
|
||||
</view>
|
||||
<view wx:if="{{reviewLoading}}" class="review-state">正在加载申请…</view>
|
||||
<view wx:elif="{{reviewError}}" class="review-state review-error">
|
||||
<text>{{reviewError}}</text>
|
||||
<button class="secondary-btn review-retry" bindtap="loadReviewApplications">重试</button>
|
||||
</view>
|
||||
<view wx:elif="{{reviewApplications.length === 0}}" class="review-state">暂无待审核员工申请</view>
|
||||
<view wx:else class="review-list">
|
||||
<view wx:for="{{reviewApplications}}" wx:key="id" class="review-item">
|
||||
<image class="review-avatar" src="{{item.applicantAvatar || '/assets/images/default-user-avatar.png'}}" mode="aspectFill"></image>
|
||||
<view class="review-info">
|
||||
<text class="review-name">{{item.applicantNickname}}</text>
|
||||
<text wx:if="{{item.applicantMaskedPhone}}" class="review-meta">{{item.applicantMaskedPhone}}</text>
|
||||
<text class="review-meta">{{item.shopName || '当前门店'}} · {{item.applicationTimeText}}</text>
|
||||
<text class="review-number">申请编号 {{item.applicationNo}}</text>
|
||||
</view>
|
||||
<view class="review-actions">
|
||||
<button class="review-action reject" data-id="{{item.id}}" disabled="{{reviewingId}}" bindtap="rejectApplication">驳回</button>
|
||||
<button class="review-action approve" data-id="{{item.id}}" loading="{{reviewingId == item.id}}" disabled="{{reviewingId}}" bindtap="approveApplication">通过</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="list">
|
||||
<view wx:if="{{loadError}}" class="empty card">
|
||||
<text>{{loadError}}</text>
|
||||
@@ -26,45 +57,4 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{createModalVisible}}" class="modal-mask" bindtap="closeCreateModal">
|
||||
<view class="employee-modal" catchtap="stopTap">
|
||||
<view class="modal-head">
|
||||
<view>
|
||||
<text class="modal-title">新增美甲师</text>
|
||||
</view>
|
||||
<view class="modal-close" bindtap="closeCreateModal">×</view>
|
||||
</view>
|
||||
<view class="avatar-upload">
|
||||
<view wx:if="{{createForm.avatarUrl}}" class="avatar-preview image-avatar">
|
||||
<image src="{{createForm.avatarUrl}}" mode="aspectFill"></image>
|
||||
</view>
|
||||
<view wx:else class="avatar-preview">头像</view>
|
||||
<button class="secondary-btn avatar-btn" loading="{{avatarUploading}}" bindtap="chooseEmployeeAvatar">上传头像</button>
|
||||
<button wx:if="{{createForm.avatarUrl}}" class="text-btn avatar-remove" bindtap="removeEmployeeAvatar">移除</button>
|
||||
</view>
|
||||
<view class="form-grid">
|
||||
<view class="modal-field">
|
||||
<text class="required-label">姓名</text>
|
||||
<input value="{{createForm.nickname}}" data-field="nickname" bindinput="onCreateInput" placeholder="请输入姓名" />
|
||||
</view>
|
||||
<view class="modal-field">
|
||||
<text class="required-label">手机号</text>
|
||||
<input value="{{createForm.phone}}" data-field="phone" bindinput="onCreateInput" type="number" maxlength="11" placeholder="请输入手机号" />
|
||||
</view>
|
||||
<view class="modal-field">
|
||||
<text class="required-label">登录账号</text>
|
||||
<input value="{{createForm.account}}" data-field="account" bindinput="onCreateInput" placeholder="请输入账号" />
|
||||
</view>
|
||||
<view class="modal-field">
|
||||
<text class="required-label">初始密码</text>
|
||||
<input value="{{createForm.password}}" data-field="password" bindinput="onCreateInput" password placeholder="请输入密码" />
|
||||
</view>
|
||||
<view class="modal-field">
|
||||
<text class="required-label">微信号</text>
|
||||
<input value="{{createForm.wechatId}}" data-field="wechatId" bindinput="onCreateInput" placeholder="请输入微信号" />
|
||||
</view>
|
||||
</view>
|
||||
<button class="primary-btn modal-submit" loading="{{creating}}" bindtap="submitEmployee">保存美甲师</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.list-heading text {
|
||||
.list-heading > text {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,173 @@
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.list-heading .review-toggle {
|
||||
position: relative;
|
||||
margin-right: 12rpx;
|
||||
margin-left: 0;
|
||||
border-color: #c9d8d2;
|
||||
background: #eef5f2;
|
||||
color: #2f6f62;
|
||||
}
|
||||
|
||||
.list-heading .review-toggle.is-open {
|
||||
background: #2f6f62;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.review-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 30rpx;
|
||||
height: 30rpx;
|
||||
margin-left: 8rpx;
|
||||
padding: 0 7rpx;
|
||||
border-radius: 999rpx;
|
||||
background: #d9685f;
|
||||
color: #fff;
|
||||
font-size: 19rpx;
|
||||
line-height: 30rpx;
|
||||
}
|
||||
|
||||
.review-panel {
|
||||
margin-bottom: 22rpx;
|
||||
padding: 22rpx;
|
||||
border: 1rpx solid #dce8e3;
|
||||
background: #f8fcfa;
|
||||
}
|
||||
|
||||
.review-panel-head,
|
||||
.review-item,
|
||||
.review-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.review-panel-head {
|
||||
justify-content: space-between;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.review-title,
|
||||
.review-subtitle,
|
||||
.review-name,
|
||||
.review-meta,
|
||||
.review-number {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.review-title {
|
||||
color: #25211d;
|
||||
font-size: 28rpx;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.review-subtitle {
|
||||
margin-top: 4rpx;
|
||||
color: #8b847c;
|
||||
font-size: 21rpx;
|
||||
}
|
||||
|
||||
.review-count {
|
||||
color: #2f6f62;
|
||||
font-size: 23rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.review-list {
|
||||
display: grid;
|
||||
gap: 14rpx;
|
||||
}
|
||||
|
||||
.review-item {
|
||||
gap: 14rpx;
|
||||
padding: 18rpx;
|
||||
border-radius: 20rpx;
|
||||
background: #fff;
|
||||
box-shadow: 0 5rpx 18rpx rgba(47, 111, 98, 0.07);
|
||||
}
|
||||
|
||||
.review-avatar {
|
||||
flex: 0 0 auto;
|
||||
width: 72rpx;
|
||||
height: 72rpx;
|
||||
border-radius: 50%;
|
||||
background: #eee9e1;
|
||||
}
|
||||
|
||||
.review-info {
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.review-name {
|
||||
color: #28231f;
|
||||
font-size: 27rpx;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.review-meta,
|
||||
.review-number {
|
||||
margin-top: 4rpx;
|
||||
overflow: hidden;
|
||||
color: #817a72;
|
||||
font-size: 20rpx;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.review-number {
|
||||
color: #aaa198;
|
||||
font-size: 18rpx;
|
||||
}
|
||||
|
||||
.review-actions {
|
||||
flex: 0 0 auto;
|
||||
gap: 8rpx;
|
||||
}
|
||||
|
||||
.review-action {
|
||||
width: auto;
|
||||
min-width: 82rpx;
|
||||
height: 54rpx;
|
||||
margin: 0;
|
||||
padding: 0 15rpx;
|
||||
border-radius: 999rpx;
|
||||
font-size: 21rpx;
|
||||
font-weight: 800;
|
||||
line-height: 54rpx;
|
||||
}
|
||||
|
||||
.review-action.reject {
|
||||
border: 1rpx solid #e7c7c2;
|
||||
background: #fff5f3;
|
||||
color: #a8554e;
|
||||
}
|
||||
|
||||
.review-action.approve {
|
||||
border: 1rpx solid #2f6f62;
|
||||
background: #2f6f62;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.review-state {
|
||||
padding: 34rpx 12rpx;
|
||||
color: #8c857d;
|
||||
font-size: 23rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.review-state.review-error {
|
||||
color: #a8554e;
|
||||
}
|
||||
|
||||
.review-retry {
|
||||
width: 150rpx;
|
||||
min-width: 150rpx;
|
||||
margin: 16rpx auto 0;
|
||||
}
|
||||
|
||||
.employee-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -97,148 +264,6 @@
|
||||
margin: 24rpx auto 0;
|
||||
}
|
||||
|
||||
.modal-mask {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 80;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: center;
|
||||
background: rgba(18, 15, 12, 0.48);
|
||||
animation: maskIn 180ms ease both;
|
||||
}
|
||||
|
||||
.employee-modal {
|
||||
width: 100%;
|
||||
padding: 28rpx 28rpx calc(28rpx + env(safe-area-inset-bottom));
|
||||
border-radius: 28rpx 28rpx 0 0;
|
||||
background: #fffaf4;
|
||||
box-shadow: 0 -18rpx 40rpx rgba(41, 31, 23, 0.16);
|
||||
animation: modalUp 220ms ease both;
|
||||
}
|
||||
|
||||
.modal-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
color: #27211d;
|
||||
font-size: 34rpx;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.modal-close {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 48rpx;
|
||||
min-width: 48rpx;
|
||||
height: 48rpx;
|
||||
border-radius: 50%;
|
||||
border: 1rpx solid #e4d8ca;
|
||||
background: #fffaf4;
|
||||
color: transparent;
|
||||
font-size: 0;
|
||||
line-height: 0;
|
||||
}
|
||||
|
||||
.modal-close::before,
|
||||
.modal-close::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
width: 22rpx;
|
||||
height: 3rpx;
|
||||
border-radius: 999rpx;
|
||||
background: #61554c;
|
||||
}
|
||||
|
||||
.modal-close::before {
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
|
||||
.modal-close::after {
|
||||
transform: rotate(-45deg);
|
||||
}
|
||||
|
||||
.avatar-upload {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
margin-bottom: 18rpx;
|
||||
padding: 18rpx;
|
||||
border-radius: 18rpx;
|
||||
background: #f7efe7;
|
||||
}
|
||||
|
||||
.avatar-preview {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex: 0 0 auto;
|
||||
width: 92rpx;
|
||||
height: 92rpx;
|
||||
overflow: hidden;
|
||||
border-radius: 50%;
|
||||
background: #6f8f83;
|
||||
color: #fff;
|
||||
font-size: 24rpx;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.avatar-preview image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.avatar-btn {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
.avatar-remove {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.form-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.modal-field {
|
||||
padding: 16rpx 18rpx;
|
||||
border-radius: 18rpx;
|
||||
background: #f7efe7;
|
||||
}
|
||||
|
||||
.modal-field text {
|
||||
display: block;
|
||||
margin-bottom: 8rpx;
|
||||
color: #6c5f54;
|
||||
font-size: 24rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.modal-field input {
|
||||
height: 58rpx;
|
||||
color: #2c2722;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.modal-submit {
|
||||
margin-top: 22rpx;
|
||||
}
|
||||
|
||||
@keyframes cardIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
@@ -250,20 +275,3 @@
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes maskIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes modalUp {
|
||||
from {
|
||||
transform: translateY(40rpx);
|
||||
}
|
||||
to {
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ Page({
|
||||
},
|
||||
|
||||
finishLogin(result) {
|
||||
getApp().setSession(result)
|
||||
getApp().setSession(result, true)
|
||||
auth.setLoginPreference(this.data.rememberMe ? {
|
||||
rememberMe: true,
|
||||
preferredShopId: result.userInfo && result.userInfo.shopId,
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
const assert = require('assert')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const pageDirectory = __dirname
|
||||
const projectDirectory = path.resolve(pageDirectory, '../..')
|
||||
const template = fs.readFileSync(path.join(pageDirectory, 'index.wxml'), 'utf8')
|
||||
const styles = fs.readFileSync(path.join(pageDirectory, 'index.wxss'), 'utf8')
|
||||
const defaultAvatar = path.join(projectDirectory, 'assets/images/default-user-avatar.png')
|
||||
|
||||
assert.strictEqual(fs.existsSync(defaultAvatar), true)
|
||||
assert.match(template, /profileForm\.avatar \|\| '\/assets\/images\/default-user-avatar\.png'/)
|
||||
assert.match(template, /open-type="chooseAvatar"/)
|
||||
assert.match(template, /点击更换/)
|
||||
assert.match(styles, /\.wechat-avatar\s*\{[\s\S]*?width:\s*144rpx;[\s\S]*?height:\s*144rpx;[\s\S]*?border-radius:\s*50%;/)
|
||||
assert.doesNotMatch(template, /wx:else>选择头像/)
|
||||
@@ -5,6 +5,7 @@ const auth = require('../../utils/auth')
|
||||
const { uploadProfileImage } = require('../../utils/upload')
|
||||
const { normalizeAvatar } = require('../../utils/profile-card')
|
||||
const profileCache = require('../../utils/profile-cache')
|
||||
const employeesApi = require('../../api/employees')
|
||||
|
||||
function canCreateAppointment() {
|
||||
const app = getApp()
|
||||
@@ -50,9 +51,9 @@ Page({
|
||||
data: {
|
||||
viewMode: 'month',
|
||||
viewModes: [
|
||||
{ value: 'day', label: '日' },
|
||||
{ value: 'month', label: '月' },
|
||||
{ value: 'week', label: '周' },
|
||||
{ value: 'month', label: '月' }
|
||||
{ value: 'day', label: '日' }
|
||||
],
|
||||
monthDisplayMode: 'count',
|
||||
monthDisplayModes: [
|
||||
@@ -83,6 +84,10 @@ Page({
|
||||
dayTotal: 0,
|
||||
freeArtistCount: 0,
|
||||
pendingCount: 0,
|
||||
unassignedCount: 0,
|
||||
historicalBackfillItems: [],
|
||||
rangeUnassignedCount: 0,
|
||||
nearestUnassignedDate: '',
|
||||
canCreateAppointment: true,
|
||||
loading: false,
|
||||
calendarError: '',
|
||||
@@ -110,6 +115,7 @@ Page({
|
||||
},
|
||||
|
||||
async refreshAccountPrompts() {
|
||||
let shouldShowProfilePrompt = false
|
||||
try {
|
||||
const profile = await profileCache.getProfile()
|
||||
const session = auth.getSession()
|
||||
@@ -119,14 +125,47 @@ Page({
|
||||
const missingNickname = !String(profile.nickname || '').trim() || String(profile.nickname).startsWith('微信用户')
|
||||
const avatar = normalizeAvatar(profile.avatar)
|
||||
const skipped = wx.getStorageSync(auth.PROFILE_PROMPT_SKIPPED_KEY) === '1'
|
||||
shouldShowProfilePrompt = !skipped && (missingNickname || !avatar)
|
||||
this.setData({
|
||||
phoneBannerVisible: Number(profile.phoneVerified) !== 1 && dismissed !== today,
|
||||
profilePromptVisible: !skipped && (missingNickname || !avatar),
|
||||
profilePromptVisible: false,
|
||||
profileForm: { nickname: missingNickname ? '' : profile.nickname, avatar }
|
||||
})
|
||||
} catch (error) {
|
||||
// 资料提醒失败不影响规划数据。
|
||||
}
|
||||
const navigatedToReview = await this.showEmployeeReviewNotice()
|
||||
if (!navigatedToReview) {
|
||||
this.setData({ profilePromptVisible: shouldShowProfilePrompt })
|
||||
}
|
||||
},
|
||||
|
||||
async showEmployeeReviewNotice() {
|
||||
const app = getApp()
|
||||
const userInfo = app.globalData.userInfo || {}
|
||||
if (Number(userInfo.type) !== 2 || app.globalData.reviewNoticeShown) return false
|
||||
let summary
|
||||
try {
|
||||
summary = await employeesApi.reviewSummary()
|
||||
} catch (error) {
|
||||
return false
|
||||
}
|
||||
if (!summary.noticeEnabled || Number(summary.pendingCount || 0) <= 0) return false
|
||||
app.globalData.reviewNoticeShown = true
|
||||
const result = await new Promise(resolve => {
|
||||
wx.showModal({
|
||||
title: '有员工申请待审核',
|
||||
content: `当前有 ${summary.pendingCount} 条员工加入申请,是否立即处理?`,
|
||||
cancelText: '稍后处理',
|
||||
confirmText: '立即审核',
|
||||
success: resolve,
|
||||
fail: () => resolve({ confirm: false })
|
||||
})
|
||||
})
|
||||
if (!result.confirm) return false
|
||||
app.globalData.openEmployeeReview = true
|
||||
wx.switchTab({ url: '/pages/employees/index' })
|
||||
return true
|
||||
},
|
||||
|
||||
openAccountSettings() { wx.navigateTo({ url: '/pages/account-settings/index' }) },
|
||||
@@ -199,14 +238,17 @@ Page({
|
||||
this.loadCalendar()
|
||||
},
|
||||
|
||||
selectDate(event) {
|
||||
const currentDate = dateUtil.formatDate(event.currentTarget.dataset.date)
|
||||
this.setData({
|
||||
currentDate,
|
||||
currentDateText: currentDate,
|
||||
viewMode: this.data.viewMode === 'month' ? 'day' : this.data.viewMode
|
||||
})
|
||||
this.prepareView()
|
||||
quickCreateAppointment(event) {
|
||||
if (!this.data.canCreateAppointment) {
|
||||
wx.showToast({ title: '当前账号仅支持查看预约', icon: 'none' })
|
||||
return
|
||||
}
|
||||
const appointmentDate = dateUtil.formatDate(event.currentTarget.dataset.date)
|
||||
if (appointmentDate < dateUtil.formatDate(new Date())) {
|
||||
wx.showToast({ title: '不能为历史日期新增预约', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.openAppointmentForm(appointmentDate)
|
||||
},
|
||||
|
||||
prevRange() {
|
||||
@@ -289,7 +331,10 @@ Page({
|
||||
hours: [],
|
||||
dayTotal: 0,
|
||||
freeArtistCount: 0,
|
||||
pendingCount: 0
|
||||
pendingCount: 0,
|
||||
unassignedCount: 0,
|
||||
rangeUnassignedCount: 0,
|
||||
nearestUnassignedDate: ''
|
||||
})
|
||||
},
|
||||
|
||||
@@ -324,6 +369,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)
|
||||
})
|
||||
},
|
||||
@@ -373,11 +420,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) : [],
|
||||
@@ -393,12 +445,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)),
|
||||
@@ -425,9 +482,11 @@ 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 historicalBackfillItems = dayAppointments.filter(item => item.historicalBackfill)
|
||||
const employeeLanes = filteredArtists.map(artist => {
|
||||
const blocks = dayAppointments
|
||||
.filter(item => String(item.artistId) === String(artist.id))
|
||||
.filter(item => item.startTime)
|
||||
.map(item => {
|
||||
const itemStart = resolveAppointmentStartMinute(item)
|
||||
return {
|
||||
@@ -437,8 +496,28 @@ Page({
|
||||
timeText: resolveAppointmentTimeText(item)
|
||||
}
|
||||
})
|
||||
return { ...artist, blocks }
|
||||
return { ...artist, artistId: artist.id, blocks }
|
||||
})
|
||||
const unassignedBlocks = dayAppointments
|
||||
.filter(item => !item.artistId)
|
||||
.filter(item => item.startTime)
|
||||
.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,
|
||||
@@ -448,11 +527,49 @@ 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.every(block => block.historicalBackfill)).length,
|
||||
pendingCount,
|
||||
unassignedCount: unassignedBlocks.length,
|
||||
historicalBackfillItems
|
||||
}
|
||||
},
|
||||
|
||||
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
|
||||
@@ -510,9 +627,23 @@ Page({
|
||||
wx.showToast({ title: '当前账号仅支持查看预约', icon: 'none' })
|
||||
return
|
||||
}
|
||||
wx.navigateTo({
|
||||
url: `/pages/appointment-form/index?date=${this.data.currentDateText}&artistId=${this.data.selectedArtistId || ''}`
|
||||
})
|
||||
this.openAppointmentForm(this.data.currentDateText)
|
||||
},
|
||||
|
||||
openBackfillOrder() {
|
||||
if (!this.data.canCreateAppointment) {
|
||||
wx.showToast({ title: '当前账号仅支持查看预约', icon: 'none' })
|
||||
return
|
||||
}
|
||||
wx.navigateTo({ url: '/pages/backfill-order/index' })
|
||||
},
|
||||
|
||||
openAppointmentForm(appointmentDate) {
|
||||
const query = [`date=${encodeURIComponent(appointmentDate)}`]
|
||||
if (this.data.selectedArtistId) {
|
||||
query.push(`artistId=${encodeURIComponent(this.data.selectedArtistId)}`)
|
||||
}
|
||||
wx.navigateTo({ url: `/pages/appointment-form/index?${query.join('&')}` })
|
||||
},
|
||||
|
||||
openAppointment(event) {
|
||||
@@ -529,7 +660,7 @@ Page({
|
||||
if (!appointment) return
|
||||
try {
|
||||
await planningApi.updateStatus(appointment.orderId, Number(event.currentTarget.dataset.status))
|
||||
wx.showToast({ title: '预约已确认', icon: 'success' })
|
||||
wx.showToast({ title: Number(event.currentTarget.dataset.status) === 2 ? '补单已完成' : '预约已确认', icon: 'success' })
|
||||
this.loadCalendar()
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '预约状态更新失败', icon: 'none' })
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const assert = require('assert')
|
||||
const planningApi = require('../../api/planning')
|
||||
const dateUtil = require('../../utils/date')
|
||||
|
||||
global.wx = {
|
||||
getAccountInfoSync: () => ({ miniProgram: { envVersion: 'develop' } }),
|
||||
@@ -7,9 +8,13 @@ global.wx = {
|
||||
getStorageSync: () => '',
|
||||
setStorageSync: () => {},
|
||||
removeStorageSync: () => {},
|
||||
showToast: () => {}
|
||||
showToast: () => {},
|
||||
showModal: ({ success }) => success({ confirm: false }),
|
||||
switchTab: () => {},
|
||||
navigateTo: () => {}
|
||||
}
|
||||
global.getApp = () => ({ globalData: { userInfo: {} } })
|
||||
const appMock = { globalData: { userInfo: {} } }
|
||||
global.getApp = () => appMock
|
||||
|
||||
let definition
|
||||
global.Page = value => { definition = value }
|
||||
@@ -38,6 +43,9 @@ function createPage(data = {}) {
|
||||
}
|
||||
|
||||
async function run() {
|
||||
assert.deepStrictEqual(definition.data.viewModes.map(item => item.value), ['month', 'week', 'day'])
|
||||
assert.strictEqual(definition.data.viewMode, 'month')
|
||||
|
||||
const page = createPage({ viewMode: 'week' })
|
||||
let monthBuilds = 0
|
||||
let weekBuilds = 0
|
||||
@@ -52,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
|
||||
@@ -69,6 +88,49 @@ async function run() {
|
||||
assert.strictEqual(calendarRequests, 1)
|
||||
resolveCalendar({ artists: [], appointments: [], daySummaries: [] })
|
||||
await Promise.all([requestOne, requestTwo])
|
||||
|
||||
const employeesApi = require('../../api/employees')
|
||||
const noticePage = createPage()
|
||||
appMock.globalData.userInfo = { type: 2 }
|
||||
appMock.globalData.reviewNoticeShown = false
|
||||
employeesApi.reviewSummary = async () => ({ pendingCount: 2, noticeEnabled: true })
|
||||
let switched = false
|
||||
global.wx.showModal = ({ success }) => success({ confirm: true })
|
||||
global.wx.switchTab = ({ url }) => { switched = url === '/pages/employees/index' }
|
||||
assert.strictEqual(await noticePage.showEmployeeReviewNotice(), true)
|
||||
assert.strictEqual(switched, true)
|
||||
assert.strictEqual(appMock.globalData.reviewNoticeShown, true)
|
||||
assert.strictEqual(appMock.globalData.openEmployeeReview, true)
|
||||
|
||||
const navigations = []
|
||||
const toasts = []
|
||||
global.wx.navigateTo = options => navigations.push(options.url)
|
||||
global.wx.showToast = options => toasts.push(options.title)
|
||||
|
||||
const quickCreatePage = createPage({ canCreateAppointment: true, selectedArtistId: '88' })
|
||||
const today = dateUtil.formatDate(new Date())
|
||||
quickCreatePage.quickCreateAppointment({ currentTarget: { dataset: { date: today } } })
|
||||
assert.strictEqual(navigations.pop(), `/pages/appointment-form/index?date=${today}&artistId=88`)
|
||||
|
||||
quickCreatePage.quickCreateAppointment({ currentTarget: { dataset: { date: '2099-12-31' } } })
|
||||
assert.strictEqual(navigations.pop(), '/pages/appointment-form/index?date=2099-12-31&artistId=88')
|
||||
|
||||
quickCreatePage.data.selectedArtistId = ''
|
||||
quickCreatePage.quickCreateAppointment({ currentTarget: { dataset: { date: '2099-11-30' } } })
|
||||
assert.strictEqual(navigations.pop(), '/pages/appointment-form/index?date=2099-11-30')
|
||||
|
||||
quickCreatePage.quickCreateAppointment({ currentTarget: { dataset: { date: '2000-01-01' } } })
|
||||
assert.strictEqual(navigations.length, 0)
|
||||
assert.strictEqual(toasts.pop(), '不能为历史日期新增预约')
|
||||
|
||||
const readonlyPage = createPage({ canCreateAppointment: false, selectedArtistId: '88' })
|
||||
readonlyPage.quickCreateAppointment({ currentTarget: { dataset: { date: '2099-12-31' } } })
|
||||
assert.strictEqual(navigations.length, 0)
|
||||
assert.strictEqual(toasts.pop(), '当前账号仅支持查看预约')
|
||||
|
||||
const fabPage = createPage({ canCreateAppointment: true, currentDateText: '2026-10-12', selectedArtistId: '99' })
|
||||
fabPage.createAppointment()
|
||||
assert.strictEqual(navigations.pop(), '/pages/appointment-form/index?date=2026-10-12&artistId=99')
|
||||
}
|
||||
|
||||
run().catch(error => {
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
<view class="segmented">
|
||||
<view wx:for="{{viewModes}}" wx:key="value" class="segment {{viewMode === item.value ? 'active' : ''}}" data-mode="{{item.value}}" bindtap="switchView">{{item.label}}</view>
|
||||
</view>
|
||||
<button wx:if="{{canCreateAppointment}}" class="backfill-entry" bindtap="openBackfillOrder">补录历史订单</button>
|
||||
<scroll-view class="artist-filter" scroll-x enable-flex>
|
||||
<view class="artist-chip {{!selectedArtistId ? 'active' : ''}}" data-id="" bindtap="selectArtist">全部员工</view>
|
||||
<view wx:for="{{artists}}" wx:key="id" class="artist-chip {{selectedArtistId == item.id ? 'active' : ''}}" data-id="{{item.id}}" bindtap="selectArtist">
|
||||
@@ -28,12 +29,20 @@
|
||||
<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">
|
||||
<view class="profile-prompt">
|
||||
<text class="profile-prompt-title">完善你的工作名片</text><text class="profile-prompt-desc">头像和昵称会用于门店协作展示,可暂时跳过。</text>
|
||||
<button class="wechat-avatar" open-type="chooseAvatar" bindchooseavatar="chooseWechatAvatar"><image wx:if="{{profileForm.avatar}}" src="{{profileForm.avatar}}" mode="aspectFill"></image><text wx:else>选择头像</text></button>
|
||||
<button class="wechat-avatar" open-type="chooseAvatar" bindchooseavatar="chooseWechatAvatar" disabled="{{profileSaving}}">
|
||||
<image class="wechat-avatar-image {{profileForm.avatar ? 'is-real' : 'is-default'}}" src="{{profileForm.avatar || '/assets/images/default-user-avatar.png'}}" mode="aspectFill"></image>
|
||||
<view class="wechat-avatar-hint">{{profileSaving ? '上传中' : '点击更换'}}</view>
|
||||
</button>
|
||||
<input class="wechat-nickname" type="nickname" value="{{profileForm.nickname}}" bindinput="onNicknameInput" placeholder="填写微信昵称" />
|
||||
<button class="profile-save" loading="{{profileSaving}}" bindtap="saveWechatProfile">保存资料</button><button class="profile-skip" bindtap="skipProfilePrompt">暂时跳过</button>
|
||||
</view>
|
||||
@@ -49,6 +58,13 @@
|
||||
|
||||
<block wx:if="{{!calendarError}}">
|
||||
<view wx:if="{{viewMode === 'day'}}" class="section">
|
||||
<view wx:if="{{historicalBackfillItems.length}}" class="card historical-backfill-card">
|
||||
<view class="section-title">历史补单</view>
|
||||
<view wx:for="{{historicalBackfillItems}}" wx:key="orderItemId" class="historical-backfill-row" data-id="{{item.orderItemId}}" bindtap="openAppointment">
|
||||
<view><text>{{item.customerName || '散客'}} · {{item.productTitle}}</text><text class="muted">{{item.artistName}} · {{item.startTime || '时间未记录'}}</text></view>
|
||||
<text>{{item.statusText}} · ¥{{item.amount}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="day-summary">
|
||||
<view class="summary-item card">
|
||||
<text class="summary-value">{{dayTotal}}</text>
|
||||
@@ -62,6 +78,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>
|
||||
@@ -81,12 +101,13 @@
|
||||
<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 data-id="{{block.orderItemId}}" catchtap="quickCancel">取消</text>
|
||||
<text wx:if="{{!block.historicalBackfill && block.status === 0 && block.assignmentStatus !== 'UNASSIGNED'}}" data-id="{{block.orderItemId}}" data-status="1" catchtap="quickUpdateStatus">确认</text>
|
||||
<text wx:if="{{!block.historicalBackfill}}" data-id="{{block.orderItemId}}" catchtap="quickTransfer">{{block.assignmentStatus === 'UNASSIGNED' ? '分配' : '改派'}}</text>
|
||||
<text wx:if="{{!block.historicalBackfill || block.status === 4}}" data-id="{{block.orderItemId}}" catchtap="quickCancel">取消</text>
|
||||
<text wx:if="{{block.historicalBackfill && block.status === 4}}" data-id="{{block.orderItemId}}" data-status="2" catchtap="quickUpdateStatus">完成</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>
|
||||
@@ -96,7 +117,7 @@
|
||||
|
||||
<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' : ''}}" data-date="{{item.date}}" bindtap="quickCreateAppointment">
|
||||
<text class="week-name">{{item.weekName}}</text>
|
||||
<text class="week-date">{{item.day}}</text>
|
||||
<text class="week-total">{{item.totalCount}}单</text>
|
||||
@@ -137,7 +158,7 @@
|
||||
<text wx:for="{{weekLabels}}" wx:key="*this">{{item}}</text>
|
||||
</view>
|
||||
<view class="month-grid">
|
||||
<view wx:for="{{monthDays}}" wx:key="date" class="month-cell {{item.isCurrentMonth ? '' : 'out-month'}} {{item.date === currentDateText ? 'selected' : ''}}" data-date="{{item.date}}" bindtap="selectDate">
|
||||
<view wx:for="{{monthDays}}" wx:key="date" class="month-cell {{item.isCurrentMonth ? '' : 'out-month'}} {{item.date === currentDateText ? 'selected' : ''}}" data-date="{{item.date}}" bindtap="quickCreateAppointment">
|
||||
<view class="month-cell-head">
|
||||
<text class="month-day">{{item.day}}</text>
|
||||
<text wx:if="{{!item.isPast && item.dayStatus === 'full'}}" class="day-mark full">满</text>
|
||||
|
||||
@@ -2,7 +2,55 @@
|
||||
padding-top: 18rpx;
|
||||
}
|
||||
|
||||
.phone-banner { display:flex; align-items:center; margin-bottom:18rpx; padding:16rpx 18rpx; border-radius:14rpx; background:#fff2d8; color:#815f2b; overflow:hidden; }.phone-banner-track { display:flex; flex:1; width:0; gap:50rpx; white-space:nowrap; animation:phoneBannerScroll 10s linear infinite; font-size:22rpx; }.phone-banner-close { position:relative; z-index:2; margin-left:18rpx; padding:6rpx; background:#fff2d8; font-size:32rpx; }.profile-prompt-mask { position:fixed; z-index:30; inset:0; display:flex; align-items:center; justify-content:center; padding:40rpx; background:rgba(25,41,33,.55); }.profile-prompt { box-sizing:border-box; display:flex; width:100%; flex-direction:column; align-items:center; padding:36rpx; border-radius:24rpx; background:#fff; }.profile-prompt-title { color:#30483c; font-size:32rpx; font-weight:800; }.profile-prompt-desc { margin-top:10rpx; color:#89988f; font-size:22rpx; text-align:center; }.wechat-avatar { display:flex; align-items:center; justify-content:center; width:128rpx; height:128rpx; margin-top:28rpx; padding:0; border-radius:50%; background:#e6f0e9; color:#416c56; font-size:22rpx; overflow:hidden; }.wechat-avatar image { width:100%; height:100%; }.wechat-nickname { box-sizing:border-box; width:100%; height:80rpx; margin-top:24rpx; padding:0 22rpx; border:1rpx solid #dce8df; border-radius:13rpx; background:#f7faf8; }.profile-save { width:100%; height:80rpx; margin-top:22rpx; border-radius:14rpx; background:#35634d; color:#fff; line-height:80rpx; }.profile-skip { margin-top:12rpx; background:transparent; color:#7e8e85; font-size:23rpx; }
|
||||
.phone-banner { display:flex; align-items:center; margin-bottom:18rpx; padding:16rpx 18rpx; border-radius:14rpx; background:#fff2d8; color:#815f2b; overflow:hidden; }.phone-banner-track { display:flex; flex:1; width:0; gap:50rpx; white-space:nowrap; animation:phoneBannerScroll 10s linear infinite; font-size:22rpx; }.phone-banner-close { position:relative; z-index:2; margin-left:18rpx; padding:6rpx; background:#fff2d8; font-size:32rpx; }.profile-prompt-mask { position:fixed; z-index:30; inset:0; display:flex; align-items:center; justify-content:center; padding:40rpx; background:rgba(25,41,33,.55); }.profile-prompt { box-sizing:border-box; display:flex; width:100%; flex-direction:column; align-items:center; padding:36rpx; border-radius:24rpx; background:#fff; }.profile-prompt-title { color:#30483c; font-size:32rpx; font-weight:800; }.profile-prompt-desc { margin-top:10rpx; color:#89988f; font-size:22rpx; text-align:center; }.wechat-nickname { box-sizing:border-box; width:100%; height:80rpx; margin-top:24rpx; padding:0 22rpx; border:1rpx solid #dce8df; border-radius:13rpx; background:#f7faf8; }.profile-save { width:100%; height:80rpx; margin-top:22rpx; border-radius:14rpx; background:#35634d; color:#fff; line-height:80rpx; }.profile-skip { margin-top:12rpx; background:transparent; color:#7e8e85; font-size:23rpx; }
|
||||
|
||||
.wechat-avatar {
|
||||
position: relative;
|
||||
display: block;
|
||||
flex: none;
|
||||
width: 144rpx;
|
||||
min-width: 144rpx;
|
||||
max-width: 144rpx;
|
||||
height: 144rpx;
|
||||
min-height: 144rpx;
|
||||
max-height: 144rpx;
|
||||
margin-top: 28rpx;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
border: 2rpx solid #d8dfdb;
|
||||
border-radius: 50%;
|
||||
background: #f3f4f3;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.wechat-avatar[disabled] {
|
||||
opacity: 0.78;
|
||||
}
|
||||
|
||||
.wechat-avatar-image {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.wechat-avatar-image.is-default {
|
||||
box-sizing: border-box;
|
||||
padding: 12rpx;
|
||||
}
|
||||
|
||||
.wechat-avatar-hint {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
height: 38rpx;
|
||||
background: rgba(22, 27, 25, 0.68);
|
||||
color: #fff;
|
||||
font-size: 19rpx;
|
||||
font-weight: 600;
|
||||
line-height: 38rpx;
|
||||
text-align: center;
|
||||
}
|
||||
@keyframes phoneBannerScroll { from { transform:translateX(0); } to { transform:translateX(-48%); } }
|
||||
|
||||
.today-btn {
|
||||
@@ -188,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;
|
||||
}
|
||||
@@ -695,3 +769,6 @@
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
.backfill-entry{margin:18rpx 0 0;background:#f1ebe4;color:#4f766d;border:1rpx solid #d9cfc3;font-size:25rpx;line-height:68rpx;height:68rpx;border-radius:12rpx}
|
||||
.historical-backfill-card{margin:20rpx 0;padding:22rpx}.historical-backfill-row{display:flex;justify-content:space-between;align-items:center;padding:18rpx 0;border-top:1rpx solid #eee7df;font-size:26rpx}.historical-backfill-row .muted{display:block;color:#92887e;font-size:22rpx;margin-top:8rpx}
|
||||
|
||||
@@ -8,7 +8,11 @@ Page({
|
||||
registrationTicket: '',
|
||||
applicationId: '',
|
||||
shopOptions: [],
|
||||
shopIndex: 0,
|
||||
shopSelectorItems: [],
|
||||
shopSheetVisible: false,
|
||||
shopKeyword: '',
|
||||
shopLoading: false,
|
||||
shopError: '',
|
||||
selectedShopName: '',
|
||||
loading: false,
|
||||
ticketInvalid: false
|
||||
@@ -21,17 +25,26 @@ Page({
|
||||
applicationId: options && options.applicationId ? options.applicationId : '',
|
||||
ticketInvalid: !registrationTicket
|
||||
})
|
||||
await this.loadShops()
|
||||
},
|
||||
|
||||
async loadShops() {
|
||||
this.setData({ shopLoading: true, shopError: '' })
|
||||
try {
|
||||
const shops = await authApi.getAvailableRegistrationShops()
|
||||
const shopOptions = (Array.isArray(shops) ? shops : []).map(item => ({
|
||||
id: item.id,
|
||||
name: item.shopName || item.name,
|
||||
address: item.address || ''
|
||||
}))
|
||||
this.setData({
|
||||
shopOptions: (Array.isArray(shops) ? shops : []).map(item => ({
|
||||
id: item.id,
|
||||
name: item.shopName || item.name,
|
||||
address: item.address || ''
|
||||
}))
|
||||
shopOptions,
|
||||
shopSelectorItems: this.filterShops(shopOptions, this.data.shopKeyword)
|
||||
})
|
||||
} catch (error) {
|
||||
this.setData({ shopOptions: [] })
|
||||
this.setData({ shopOptions: [], shopSelectorItems: [], shopError: error.message || '门店列表加载失败' })
|
||||
} finally {
|
||||
this.setData({ shopLoading: false })
|
||||
}
|
||||
},
|
||||
|
||||
@@ -39,10 +52,30 @@ Page({
|
||||
selectRole(event) { this.setData({ role: event.currentTarget.dataset.role }) },
|
||||
continueFromRole() { if (!this.data.ticketInvalid) this.setData({ step: 2 }) },
|
||||
|
||||
filterShops(shops, keywordValue) {
|
||||
const keyword = String(keywordValue || '').trim().toLowerCase()
|
||||
return (shops || [])
|
||||
.filter(item => !keyword || [item.name, item.address].some(value => String(value || '').toLowerCase().includes(keyword)))
|
||||
.map(item => ({ ...item, title: item.name || '未命名门店', subtitle: item.address || '暂无地址' }))
|
||||
},
|
||||
|
||||
openShopSheet() {
|
||||
this.setData({ shopSheetVisible: true, shopSelectorItems: this.filterShops(this.data.shopOptions, this.data.shopKeyword) })
|
||||
if (this.data.shopError) this.loadShops()
|
||||
},
|
||||
|
||||
closeShopSheet() {
|
||||
this.setData({ shopSheetVisible: false })
|
||||
},
|
||||
|
||||
onShopSearch(event) {
|
||||
const shopKeyword = event.detail.value
|
||||
this.setData({ shopKeyword, shopSelectorItems: this.filterShops(this.data.shopOptions, shopKeyword) })
|
||||
},
|
||||
|
||||
selectShop(event) {
|
||||
const index = Number(event.detail.value)
|
||||
const shop = this.data.shopOptions[index]
|
||||
if (shop) this.setData({ shopIndex: index, selectedShopName: shop.name, 'form.shopId': shop.id })
|
||||
const shop = event.detail.item
|
||||
if (shop) this.setData({ selectedShopName: shop.name, 'form.shopId': shop.id, shopSheetVisible: false })
|
||||
},
|
||||
|
||||
goBackStep() { this.setData({ step: 1 }) },
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
{
|
||||
"navigationBarTitleText": "注册"
|
||||
"navigationBarTitleText": "注册",
|
||||
"usingComponents": {
|
||||
"entity-selector-sheet": "/components/entity-selector-sheet/index"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
<view class="progress-row"><view class="progress-step {{step >= 1 ? 'active' : ''}}"><text>1</text><label>选择身份</label></view><view class="progress-line {{step >= 2 ? 'active' : ''}}"></view><view class="progress-step {{step >= 2 ? 'active' : ''}}"><text>2</text><label>门店资料</label></view><view class="progress-line {{step >= 3 ? 'active' : ''}}"></view><view class="progress-step {{step >= 3 ? 'active' : ''}}"><text>3</text><label>等待审核</label></view></view>
|
||||
<view wx:if="{{ticketInvalid}}" class="card result-card"><view class="result-icon">!</view><view class="section-title">申请入口已失效</view><view class="section-desc">请返回登录页重新点击微信快捷登录,获取新的申请凭证。</view><button class="primary-btn" bindtap="back">返回登录</button></view>
|
||||
<view wx:elif="{{step === 1}}" class="card form-card"><view class="section-title">选择工作身份</view><view class="section-desc">无需手机号和密码,审核人会根据你的身份处理申请</view><view class="role-list"><view class="role-option {{role === 'manager' ? 'selected' : ''}}" data-role="manager" bindtap="selectRole"><view class="role-icon">店</view><view class="role-copy"><text class="role-title">店长</text><text class="role-desc">创建并负责一家 Salon 门店</text></view><text class="role-mark">{{role === 'manager' ? '✓' : '○'}}</text></view><view class="role-option {{role === 'staff' ? 'selected' : ''}}" data-role="staff" bindtap="selectRole"><view class="role-icon">员</view><view class="role-copy"><text class="role-title">店员</text><text class="role-desc">加入已有门店协同工作</text></view><text class="role-mark">{{role === 'staff' ? '✓' : '○'}}</text></view></view><button class="primary-btn" bindtap="continueFromRole">继续</button></view>
|
||||
<view wx:elif="{{step === 2}}" class="card form-card"><view class="section-title">{{role === 'manager' ? '完善店铺资料' : '选择要加入的店铺'}}</view><view class="section-desc">{{role === 'manager' ? '提交后由平台管理员审核' : '提交后由对应店长审核'}}</view><view wx:if="{{role === 'manager'}}" class="field"><text class="field-label">店铺名称</text><input value="{{form.shopName}}" data-field="shopName" bindinput="onInput" placeholder="请输入店铺名称" /></view><view wx:if="{{role === 'manager'}}" class="field"><text class="field-label">店铺地址</text><input value="{{form.shopAddress}}" data-field="shopAddress" bindinput="onInput" placeholder="请输入门店地址" /></view><view wx:if="{{role === 'staff'}}" class="field"><text class="field-label">选择店铺</text><picker range="{{shopOptions}}" range-key="name" value="{{shopIndex}}" bindchange="selectShop"><view class="picker-value {{selectedShopName ? 'filled' : ''}}">{{selectedShopName || '请选择要加入的店铺'}}</view></picker></view><view wx:if="{{role === 'staff'}}" class="notice">审核通过前不会获得门店业务权限</view><button class="primary-btn" loading="{{loading}}" bindtap="submit">提交审核</button><view class="back-entry" bindtap="goBackStep">返回上一步</view></view>
|
||||
<view wx:elif="{{step === 2}}" class="card form-card"><view class="section-title">{{role === 'manager' ? '完善店铺资料' : '选择要加入的店铺'}}</view><view class="section-desc">{{role === 'manager' ? '提交后由平台管理员审核' : '提交后由对应店长审核'}}</view><view wx:if="{{role === 'manager'}}" class="field"><text class="field-label">店铺名称</text><input value="{{form.shopName}}" data-field="shopName" bindinput="onInput" placeholder="请输入店铺名称" /></view><view wx:if="{{role === 'manager'}}" class="field"><text class="field-label">店铺地址</text><input value="{{form.shopAddress}}" data-field="shopAddress" bindinput="onInput" placeholder="请输入门店地址" /></view><view wx:if="{{role === 'staff'}}" class="field"><text class="field-label">选择店铺</text><view class="picker-value {{selectedShopName ? 'filled' : ''}}" bindtap="openShopSheet"><text>{{selectedShopName || '请选择要加入的店铺'}}</text><text class="picker-arrow">›</text></view></view><view wx:if="{{role === 'staff'}}" class="notice">审核通过前不会获得门店业务权限</view><button class="primary-btn" loading="{{loading}}" bindtap="submit">提交审核</button><view class="back-entry" bindtap="goBackStep">返回上一步</view></view>
|
||||
<view wx:elif="{{step === 3}}" class="card result-card"><view class="result-icon">✓</view><view class="section-title">申请已提交</view><view class="section-desc">{{role === 'manager' ? '平台管理员审核通过后,即可使用快捷登录。' : '店长审核通过后,即可使用快捷登录。'}}</view><view class="result-status">当前状态:<text>等待审核</text></view><button class="primary-btn" bindtap="back">返回登录</button></view>
|
||||
<entity-selector-sheet visible="{{shopSheetVisible}}" title="选择门店" keyword="{{shopKeyword}}" placeholder="搜索门店名称或地址" items="{{shopSelectorItems}}" selected-id="{{form.shopId}}" loading="{{shopLoading}}" error-text="{{shopError}}" empty-text="暂无匹配门店" bind:search="onShopSearch" bind:select="selectShop" bind:retry="loadShops" bind:close="closeShopSheet" />
|
||||
<view class="safe-note">OpenID 仅用于识别你的微信身份,不会在页面中展示。</view>
|
||||
</view>
|
||||
|
||||
@@ -114,11 +114,18 @@
|
||||
.picker-value {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
color: #a0ada4;
|
||||
}
|
||||
|
||||
.picker-value.filled { color: #2e4a3d; }
|
||||
|
||||
.picker-arrow {
|
||||
color: #8fa096;
|
||||
font-size: 36rpx;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.code-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
const assert = require('assert')
|
||||
|
||||
global.wx = {
|
||||
getAccountInfoSync: () => ({ miniProgram: { envVersion: 'develop' } }),
|
||||
getDeviceInfo: () => ({ platform: 'devtools' }),
|
||||
showToast: () => {},
|
||||
reLaunch: () => {}
|
||||
}
|
||||
|
||||
let definition
|
||||
global.Page = value => { definition = value }
|
||||
require('./index')
|
||||
|
||||
const page = {
|
||||
...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
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const shops = [
|
||||
{ id: 1, name: '甲屿一店', address: '滨江路' },
|
||||
{ id: 2, name: '甲屿二店', address: '湖滨路' }
|
||||
]
|
||||
assert.deepStrictEqual(page.filterShops(shops, '湖滨').map(item => item.id), [2])
|
||||
page.selectShop({ detail: { item: { ...shops[1], title: shops[1].name } } })
|
||||
assert.strictEqual(page.data.form.shopId, 2)
|
||||
assert.strictEqual(page.data.selectedShopName, '甲屿二店')
|
||||
assert.strictEqual(page.data.shopSheetVisible, false)
|
||||
@@ -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;
|
||||
|
||||
@@ -336,14 +336,18 @@ create table t_order
|
||||
id bigint unsigned auto_increment comment '订单主键索引'
|
||||
primary key,
|
||||
order_no varchar(50) not null comment '订单编号',
|
||||
user_id bigint unsigned not null comment '关联用户表主键',
|
||||
user_id bigint unsigned null comment '关联用户表主键,历史补单可为空',
|
||||
shop_id bigint unsigned null comment '所属店铺ID',
|
||||
total_amount decimal(10, 2) not null comment '订单总金额',
|
||||
actual_amount decimal(10, 2) not null comment '实际支付金额',
|
||||
coupon_id bigint unsigned default 0 null comment '使用的优惠券ID',
|
||||
user_coupon_id bigint unsigned null comment '用户券ID',
|
||||
coupon_source_type varchar(32) null comment '优惠来源类型',
|
||||
status tinyint unsigned default 1 not null comment '订单状态:1-待使用,2-已完成,3-已取消',
|
||||
customer_remark varchar(500) null comment '用户询价预约备注',
|
||||
customer_name_snapshot varchar(100) null comment '补单客户名称快照',
|
||||
customer_phone_snapshot varchar(32) null comment '补单客户手机号快照',
|
||||
order_source varchar(32) default 'NORMAL_APPOINTMENT' not null comment '订单来源:NORMAL_APPOINTMENT/HISTORICAL_BACKFILL',
|
||||
status tinyint unsigned default 1 not null comment '订单状态:0-价格确认中,1-待服务,2-已完成,3-已取消,4-服务中',
|
||||
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
|
||||
update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
|
||||
is_delete tinyint unsigned default 0 null comment '逻辑删除:0-未删,1-已删',
|
||||
@@ -360,6 +364,10 @@ create index idx_user_id
|
||||
on t_order (user_id)
|
||||
comment '按用户查询订单的索引';
|
||||
|
||||
create index idx_order_source_status_delete
|
||||
on t_order (order_source, status, is_delete)
|
||||
comment '按订单来源和状态查询的索引';
|
||||
|
||||
-- auto-generated definition
|
||||
create table t_order_item
|
||||
(
|
||||
@@ -371,6 +379,7 @@ create table t_order_item
|
||||
price decimal(10, 2) not null comment '商品单价',
|
||||
artist_id bigint unsigned null comment '关联美甲师ID',
|
||||
appointment_time datetime null comment '预约开始时间',
|
||||
service_date date null comment '业务服务日期,历史补单无具体时间时使用',
|
||||
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
|
||||
update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
|
||||
is_delete tinyint unsigned default 0 null comment '逻辑删除:0-未删,1-已删'
|
||||
@@ -381,6 +390,10 @@ create index idx_order_id
|
||||
on t_order_item (order_id)
|
||||
comment '按订单查询商品的索引';
|
||||
|
||||
create index idx_order_item_artist_service_date
|
||||
on t_order_item (artist_id, service_date, is_delete)
|
||||
comment '按员工和业务服务日期查询的索引';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS t_order_artist_review
|
||||
(
|
||||
id bigint unsigned auto_increment comment '评价任务ID'
|
||||
@@ -1050,8 +1063,22 @@ CALL sp_add_index_if_not_exists('t_balance_change_detail', 'idx_balance_detail_o
|
||||
CALL sp_add_column_if_not_exists('t_order', 'shop_id', 'bigint unsigned NULL COMMENT ''所属店铺ID''');
|
||||
CALL sp_add_column_if_not_exists('t_order', 'user_coupon_id', 'bigint unsigned NULL COMMENT ''用户券ID''');
|
||||
|
||||
SET @sql = (SELECT IF(COUNT(*) = 0,
|
||||
'ALTER TABLE t_order MODIFY COLUMN user_id BIGINT UNSIGNED NULL COMMENT ''关联用户表主键,历史补单可为空''',
|
||||
'SELECT 1') FROM information_schema.columns
|
||||
WHERE table_schema = DATABASE() AND table_name = 't_order' AND column_name = 'user_id' AND is_nullable = 'YES');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
CALL sp_add_column_if_not_exists('t_order', 'customer_remark', 'varchar(500) NULL COMMENT ''用户询价预约备注''');
|
||||
CALL sp_add_column_if_not_exists('t_order', 'customer_name_snapshot', 'varchar(100) NULL COMMENT ''补单客户名称快照''');
|
||||
CALL sp_add_column_if_not_exists('t_order', 'customer_phone_snapshot', 'varchar(32) NULL COMMENT ''补单客户手机号快照''');
|
||||
CALL sp_add_column_if_not_exists('t_order', 'order_source', 'varchar(32) NOT NULL DEFAULT ''NORMAL_APPOINTMENT'' COMMENT ''订单来源:NORMAL_APPOINTMENT/HISTORICAL_BACKFILL''');
|
||||
|
||||
CALL sp_add_column_if_not_exists('t_order_item', 'appointment_time', 'datetime NULL COMMENT ''预约开始时间''');
|
||||
CALL sp_add_column_if_not_exists('t_order_item', 'service_date', 'date NULL COMMENT ''业务服务日期,历史补单无具体时间时使用''');
|
||||
CALL sp_add_index_if_not_exists('t_order_item', 'idx_t_order_item_artist_appointment_time', '(`artist_id`, `appointment_time`)');
|
||||
CALL sp_add_index_if_not_exists('t_order', 'idx_order_source_status_delete', '(`order_source`, `status`, `is_delete`)');
|
||||
CALL sp_add_index_if_not_exists('t_order_item', 'idx_order_item_artist_service_date', '(`artist_id`, `service_date`, `is_delete`)');
|
||||
|
||||
SET @drop_old_tag_unique_sql = (
|
||||
SELECT IF(
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
USE jayucloud_salon;
|
||||
|
||||
START TRANSACTION;
|
||||
|
||||
INSERT INTO t_system_parameter_config (
|
||||
id,
|
||||
config_group,
|
||||
config_key,
|
||||
config_name,
|
||||
config_value,
|
||||
enabled,
|
||||
remark,
|
||||
create_time,
|
||||
update_time,
|
||||
is_delete
|
||||
)
|
||||
VALUES (
|
||||
313931273555139020,
|
||||
'WORKBENCH',
|
||||
'MANAGER_REGISTRATION_REVIEW_NOTICE',
|
||||
'店长员工审核提醒',
|
||||
'true',
|
||||
1,
|
||||
'控制店长登录小程序后是否显式提示当前门店的待审核员工申请',
|
||||
NOW(),
|
||||
NOW(),
|
||||
0
|
||||
)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
config_name = VALUES(config_name),
|
||||
remark = VALUES(remark),
|
||||
is_delete = 0,
|
||||
update_time = NOW();
|
||||
|
||||
COMMIT;
|
||||
@@ -0,0 +1,5 @@
|
||||
# 历史补单与服务中状态
|
||||
|
||||
历史补单使用订单来源 `HISTORICAL_BACKFILL`,状态 `4` 表示服务中。补单必须归属员工,可不填写客户和具体服务时间;没有具体时间时仅按 `service_date` 参与规划日期统计,不创建预约占用,也不执行排班冲突校验。
|
||||
|
||||
数据库字段和索引已融合到 `docs/scripts/sql/init/jayucloud-salon.sql`,初始化脚本可重复执行,不连接或清理已有业务数据。
|
||||
@@ -0,0 +1,23 @@
|
||||
# Salon 待分配预约与新员工排班引导实施计划
|
||||
|
||||
## 目标
|
||||
|
||||
在不新增数据库字段的前提下,让预约可以先保存为待分配状态,并在后续分配员工时执行完整排班与冲突校验;同时为新员工补充首次排班引导。
|
||||
|
||||
## 实施步骤
|
||||
|
||||
1. 调整 Salon Core 规划模型与服务:员工可空、待分配状态、日汇总待分配数量、未分配预约状态操作限制。
|
||||
2. 补充后端测试,覆盖无员工创建、无占用记录、首次分配和未分配状态拦截。
|
||||
3. 调整小程序新增预约表单:员工非必填、可清除选择、无员工时使用普通时间列表并在提交前确认。
|
||||
4. 调整规划月周日视图与预约详情:显示橙色待分配标识、虚拟泳道和分配员工入口。
|
||||
5. 调整员工创建与排班设置页:创建成功后引导首次排班,并通过事件通道返回预约表单继续分配。
|
||||
6. 增加小程序状态测试,更新项目变更记录。
|
||||
7. 运行后端测试与编译、小程序全量测试、静态差异检查及 GitNexus 变更检测,最后创建中文提交。
|
||||
|
||||
## 验收重点
|
||||
|
||||
- 未选择员工也能创建正式预约,且不会创建员工占用记录。
|
||||
- 待分配预约在月、周、日视图和详情中均有明确状态。
|
||||
- 待分配预约不能确认或完成,分配失败不会丢失预约资料。
|
||||
- 新员工可立即进入首次排班;预约来源保存排班后能回填并重新校验。
|
||||
- 现有已分配预约、员工筛选、改派、取消和普通排班流程保持兼容。
|
||||
@@ -0,0 +1,53 @@
|
||||
# Salon 小程序业务引用字段底部选择页设计
|
||||
|
||||
## 背景与问题
|
||||
|
||||
新增预约中的客户搜索以内嵌下拉列表呈现,员工和注册门店仍使用原生 picker,改派页面则直接铺开全部员工卡片。相同的“引用已有业务数据”操作分散在多个页面,搜索、加载失败、空状态和滚动处理不一致;员工新增还嵌在员工列表弹窗中,无法从预约选择流程快速创建并回填。
|
||||
|
||||
## 设计目标
|
||||
|
||||
- 客户、员工和门店统一使用约 88% 屏高的底部选择页。
|
||||
- 标题、搜索和底部操作固定,列表区域独立滚动,遮罩阻止主页面滚动穿透。
|
||||
- 选择结果自动回填原表单;请求失败只影响弹层,不清空已有表单。
|
||||
- 日期、时间和固定枚举继续使用微信原生 picker。
|
||||
- 作品保留现有富内容弹层,但高度、滚动和防穿透规则与公共选择页一致。
|
||||
|
||||
## 组件边界
|
||||
|
||||
`entity-selector-sheet` 只负责通用展示和交互状态,接收标准化的 `id`、`title`、`subtitle`、`meta`、`avatar`、`badge` 数据,并向页面发送 `search`、`select`、`retry`、`action`、`close` 事件。数据请求、过滤、业务校验和表单回填仍由页面负责,避免公共组件耦合客户、员工或门店接口。
|
||||
|
||||
## 页面交互
|
||||
|
||||
### 新增预约
|
||||
|
||||
- 客户姓名和手机号合并为客户卡片。客户弹层默认搜索已有客户,底部“手动录入客户”切换到同高度的姓名、手机号表单。
|
||||
- 选择已有客户时保留 `customerUserId`;手动录入时清空该 ID,继续复用后端现有客户解析能力。
|
||||
- 指定员工改用员工选择弹层,按姓名本地搜索,并提供“快速新增员工”。
|
||||
- 快速新增成功后通过事件通道回传员工 ID 和展示信息,刷新员工数据并自动选中。
|
||||
|
||||
### 改派与注册
|
||||
|
||||
- 改派页面将平铺员工卡片收敛为员工选择字段,复用员工搜索和快速新增能力。
|
||||
- 店员注册将门店 picker 改为门店选择弹层,按名称或地址搜索,只允许选择已有门店。
|
||||
|
||||
### 员工创建
|
||||
|
||||
- 员工页原新增弹窗迁移到独立 `employee-create` 页面。
|
||||
- 普通入口创建成功后刷新员工列表;选择器入口创建成功后额外自动回填原业务表单。
|
||||
|
||||
## 异常与状态
|
||||
|
||||
- 加载中、空列表和请求错误均在弹层列表区域展示;错误状态提供重新加载。
|
||||
- 搜索结果为空时仍保留客户手动录入或员工快速新增入口。
|
||||
- 关闭弹层只清理可见状态,不修改已经填写的预约、改派或注册数据。
|
||||
- 员工无真实头像时使用项目内黑白默认人物头像,不使用昵称首字。
|
||||
|
||||
## 验证
|
||||
|
||||
- 覆盖公共组件事件、独立滚动和防穿透结构。
|
||||
- 覆盖已有客户与手动客户回填、员工搜索与选择、门店名称/地址搜索、员工创建事件回传。
|
||||
- 运行 Salon 小程序全部 Node 测试、JavaScript/JSON 静态检查、Git 差异检查和 GitNexus 变更检测。
|
||||
|
||||
## 约束
|
||||
|
||||
本次仅修改 `JC-Salon-WeChat` 和项目文档,不修改后端、SQL、Nacos、后台管理或 ArtList。GitNexus 对 `normalizeCustomer` 的 CRITICAL 结果属于同名符号跨项目误关联,因此不修改该函数,新增独立选择器映射函数规避影响。
|
||||
@@ -0,0 +1,99 @@
|
||||
# Salon 待分配预约与新员工排班引导设计
|
||||
|
||||
## 背景
|
||||
|
||||
门店可能在没有可选员工或暂时无法确认服务人员时,需要先记录客户预约。当前新增预约强制要求员工,并立即校验该员工排班与时段容量;新建员工成功后也没有首个排班引导,导致新员工无法直接承接预约。
|
||||
|
||||
## 目标
|
||||
|
||||
- 新增预约允许不选择员工,但客户、作品、日期、时间和时长仍然必填。
|
||||
- 未选员工时保存为正式的“待分配预约”,不创建临时员工账号。
|
||||
- 待分配预约只校验门店营业时间,不校验员工排班或空闲状态,也不占用任何员工容量。
|
||||
- 后续分配员工时再完整校验员工归属、排班覆盖和预约冲突。
|
||||
- 新员工创建成功后提供首次排班引导,从预约场景进入时可保存排班并继续完成员工分配。
|
||||
|
||||
## 数据与后端行为
|
||||
|
||||
### 创建待分配预约
|
||||
|
||||
- `POST /admin/planning/appointments` 的 `artistId` 改为可选,其他现有请求字段保持不变。
|
||||
- 有 `artistId` 时保持现有逻辑:校验有效员工、排班、营业时间和容量,并创建预约占用记录。
|
||||
- 无 `artistId` 时:
|
||||
- `t_order_item.artist_id` 保存为 `NULL`;
|
||||
- 仍保存 `appointment_time`、客户、作品、时长和订单信息;
|
||||
- 不创建 `t_appointment_reservation` 记录;
|
||||
- 只执行门店营业时间校验;
|
||||
- 返回 `artistId = null`、`artistName = 待分配`、`assignmentStatus = UNASSIGNED`。
|
||||
- 已分配预约返回 `assignmentStatus = ASSIGNED`。状态由 `artistId` 是否为空派生,不新增数据库字段。
|
||||
- 待分配预约仍是正式待服务订单,可查看和取消;未分配前禁止确认服务或完成订单,并返回“请先分配员工”。
|
||||
|
||||
### 分配员工
|
||||
|
||||
- 继续复用现有改派接口,不新增重复接口。
|
||||
- 当原 `artistId` 为空时,接口执行首次分配:校验目标员工属于当前门店且启用、排班覆盖预约时段、容量和冲突;通过后创建正式预约占用并更新订单项员工。
|
||||
- 校验失败时事务回滚,预约继续保持待分配,原日期、时间和其他资料不变。
|
||||
- 已有员工时仍按现有改派逻辑处理。
|
||||
|
||||
现有 `t_order_item.artist_id` 已允许为空,预约占用表仍保持 `artist_id NOT NULL`,因此无需数据库变更 SQL。
|
||||
|
||||
## 小程序交互
|
||||
|
||||
### 新增预约
|
||||
|
||||
- “指定员工”改为非必填,字段文案显示“员工(可稍后分配)”。
|
||||
- 员工选择弹层增加“暂不分配”操作;清除已选员工后,预约时间改为普通必填时间选择,不请求员工可约时段。
|
||||
- 未选员工提交时提示“预约将保存为待分配,当前不会占用员工时间”,确认后直接创建。
|
||||
- 已选员工时继续使用现有可约时间、冲突和容量校验。
|
||||
|
||||
### 规划页与详情
|
||||
|
||||
- 全部门工筛选状态下,日视图最左侧增加橙色“待分配”虚拟泳道,展示对应预约卡片;该泳道不进入员工筛选列表和员工统计。
|
||||
- 月、周视图将待分配数量加入日期总数,并增加独立橙色计数标识,点击预约仍进入详情。
|
||||
- 选择具体员工筛选时不展示待分配预约。
|
||||
- 规划页顶部增加待分配数量提示,点击切到日视图并定位最近存在待分配预约的日期;没有待分配项时不显示。
|
||||
- 预约详情将未分配状态明确展示为“待分配”,操作按钮显示“分配员工”;完成或确认服务按钮在未分配时禁用并提示先分配。
|
||||
|
||||
## 新员工首次排班引导
|
||||
|
||||
### 员工列表入口
|
||||
|
||||
- 员工创建成功后显示引导弹窗,主操作“立即设置排班”,次操作“稍后设置”。
|
||||
- 立即设置进入现有排班设置页的首次排班模式;稍后设置返回员工列表并刷新数据。
|
||||
|
||||
### 预约选择器入口
|
||||
|
||||
- 创建成功后显示“设置排班并分配 / 暂不设置”。
|
||||
- “设置排班并分配”进入首次排班模式,并携带新员工 ID、当前预约日期、时间和时长。
|
||||
- 排班页顶部展示待承接预约时间,只展示常规排班设置,隐藏特殊日期区域;保存按钮为“保存排班并继续分配”。
|
||||
- 保存成功后回到预约表单,刷新员工列表、自动选中新员工并重新计算可约时间:
|
||||
- 排班覆盖且无冲突时保留当前时间,可直接提交;
|
||||
- 排班不覆盖或产生冲突时不自动分配,显示具体原因,预约仍可按待分配方式保存。
|
||||
- “暂不设置”返回预约表单,不自动选择无排班员工;当前预约保持待分配。
|
||||
|
||||
### 事件回传
|
||||
|
||||
- 员工创建页通过事件通道回传员工资料及来源场景。
|
||||
- 首次排班页保存成功后回传 `scheduleSaved + employee`,来源预约页负责刷新、选择和校验;普通员工列表来源只刷新列表。
|
||||
- 页面返回、保存失败或用户跳过均不得清空已填写的预约表单。
|
||||
|
||||
## 异常与兼容
|
||||
|
||||
- 待分配预约没有容量占用,因此同一时段可以存在多个待分配项;真正分配时以当时排班和容量为准。
|
||||
- 员工被停用、排班变化或时段已满时,分配失败并保留待分配状态。
|
||||
- 取消待分配预约不执行占用释放;已分配预约继续沿用现有释放逻辑。
|
||||
- 现有已分配预约、改派、预约详情和规划员工筛选保持兼容。
|
||||
- 不创建“临时员工”,避免污染员工数量、排班、绩效和订单统计。
|
||||
|
||||
## 测试与验收
|
||||
|
||||
- 后端覆盖有员工和无员工两种创建路径;无员工时不创建预约占用,只校验营业时间。
|
||||
- 待分配预约可查询、展示和取消,但不能确认服务或完成。
|
||||
- 首次分配成功会创建占用并更新员工;冲突、无排班、非本店员工失败时保持待分配。
|
||||
- 月、周、日视图均能看到待分配数量和预约,具体员工筛选不混入待分配项。
|
||||
- 新增预约未选员工时仍强制校验日期、时间和时长。
|
||||
- 两种员工创建来源均验证立即设置与稍后设置;预约来源保存排班后正确回填或保留待分配。
|
||||
- 完成 Core 单元测试与 Maven 编译、小程序全部测试、GitNexus 影响分析与提交前变更检测。
|
||||
|
||||
## 范围约束
|
||||
|
||||
本次修改 Salon Core、Salon 小程序和项目文档;不修改冻结初始化 SQL、Nacos、后台管理和 ArtList。由于现有字段空值能力足够,不新增版本 SQL。
|
||||
@@ -0,0 +1,28 @@
|
||||
# Salon 资料弹窗默认头像优化设计
|
||||
|
||||
## 目标
|
||||
|
||||
优化规划页首次资料完善弹窗中的头像选择区域:头像入口必须为圆形,并在用户尚未设置真实头像时显示统一的黑白人物轮廓,不再显示椭圆按钮、昵称首字或纯文字占位。
|
||||
|
||||
## 方案
|
||||
|
||||
- 将头像入口固定为圆形,图片使用 `aspectFill` 覆盖整个区域。
|
||||
- 新增本地 PNG 黑白人物轮廓默认头像资源,避免依赖网络外链、首字生成和 SVG 兼容差异。
|
||||
- `profileForm.avatar` 继续只保存真实头像地址;默认头像仅作为模板展示资源,保存时仍要求用户选择真实头像。
|
||||
- 圆形头像底部覆盖半透明“点击更换”提示,真实头像和默认头像下均可识别入口用途。
|
||||
- 上传期间禁止重复选择并显示“上传中”,上传失败后保留选择前状态。
|
||||
|
||||
## 验收
|
||||
|
||||
- 无真实头像时显示圆形黑白人物头像。
|
||||
- 有真实头像时圆形区域完整回显当前头像。
|
||||
- 点击头像仍能调用微信 `chooseAvatar`,成功后立即更新预览。
|
||||
- 默认图片地址不会作为用户头像提交。
|
||||
- 小程序页面测试、JavaScript 语法检查和差异检查通过。
|
||||
|
||||
## 实施清单
|
||||
|
||||
1. 增加本地默认人物头像资源。
|
||||
2. 调整规划页弹窗 WXML 与 WXSS。
|
||||
3. 补充默认头像与真实头像状态测试。
|
||||
4. 运行全量小程序测试并提交。
|
||||
@@ -0,0 +1,35 @@
|
||||
# 店长员工审核与登录提醒设计
|
||||
|
||||
## 目标
|
||||
|
||||
店长可在小程序员工页直接处理当前门店的员工注册申请。存在待审核申请时,系统根据后台动态参数,在每次成功登录会话中最多提醒一次,并提供直达审核区域的入口。
|
||||
|
||||
## 交互与数据流
|
||||
|
||||
1. 店长进入员工页时获取待审核摘要,并在“审核”按钮显示数量角标。
|
||||
2. 点击“审核”后在当前页面展开申请列表;通过操作需要确认,驳回操作必须填写原因。
|
||||
3. 登录进入规划页后获取审核摘要。开关开启且数量大于零时优先显示审核提醒。
|
||||
4. 点击“立即审核”切换到员工 Tab 并自动展开申请列表;点击“稍后处理”后本会话不再提醒,再继续处理资料完善弹窗。
|
||||
5. 摘要、列表或提醒请求失败不阻断员工列表、登录及规划页数据。
|
||||
|
||||
## 权限与一致性
|
||||
|
||||
- 只有 `type=2` 的店长可以读取本门店 `PENDING_MANAGER` 申请和执行审核。
|
||||
- 平台管理员继续通过原后台入口处理 `PENDING_ADMIN` 店长申请。
|
||||
- 审核事务使用数据库行锁串行处理同一申请,避免重复通过、驳回或权限同步。
|
||||
- 列表接口返回展示 VO,补充申请人的昵称、头像和脱敏手机号,不暴露 OpenID。
|
||||
|
||||
## 动态参数
|
||||
|
||||
参数 `WORKBENCH / MANAGER_REGISTRATION_REVIEW_NOTICE` 存储于 `t_system_parameter_config`。`config_value=true` 且 `enabled=1` 时显示登录提醒;停用只隐藏提醒,不关闭审核功能。
|
||||
|
||||
## 验收重点
|
||||
|
||||
- 店长仅能查看和审核本门店员工申请。
|
||||
- 通过后员工账号及门店关系启用,列表和角标同步减少;驳回原因不能为空。
|
||||
- 自动登录、手动登录和多门店确认登录均建立新的提醒会话。
|
||||
- 审核提醒与资料完善弹窗不重叠,审核提醒优先。
|
||||
|
||||
## 实施验证记录
|
||||
|
||||
当前 Codex 会话未提供 GitNexus `impact` 与 `detect_changes` 工具,因此无法执行图谱级影响分析和提交前变更检测。实施中改用静态调用链检索、Git 差异范围检查、Core 编译与单元测试、小程序测试、后台单元测试与生产构建进行替代验证。
|
||||
@@ -0,0 +1,22 @@
|
||||
# 规划页日期快速新增预约设计
|
||||
|
||||
## 目标
|
||||
|
||||
规划页视图入口按“月、周、日”排列。月视图和周视图中的日期点击统一改为快速新增预约,减少先进入日视图再点击新增的操作步骤。
|
||||
|
||||
## 交互
|
||||
|
||||
- 默认保持月视图,日视图仍可通过顶部“日”按钮进入。
|
||||
- 点击月历或周视图中的今天、未来日期,直接进入新增预约页并预填所点日期。
|
||||
- 当前筛选具体员工时一并传递员工 ID;“全部员工”状态下不预选员工。
|
||||
- 历史日期禁止新增并显示明确提示;只读员工优先提示无新增权限。
|
||||
- 月历中跨月显示的未来日期与本月日期行为一致。
|
||||
- 右下角“+”按钮继续按当前规划日期和员工筛选条件进入新增预约。
|
||||
|
||||
## 技术边界
|
||||
|
||||
复用新增预约页已有的 `date`、`artistId` 查询参数,不修改后端接口、数据库、Nacos、后台管理或 ArtList。
|
||||
|
||||
## 验证
|
||||
|
||||
覆盖视图顺序、默认视图、月周快速新增、员工参数、全部员工、历史日期、只读权限、跨月未来日期和原“+”按钮行为。当前会话未提供 GitNexus `impact` 与 `detect_changes` 工具,使用静态引用检查、小程序测试和 Git 差异检查替代。
|
||||
@@ -0,0 +1,16 @@
|
||||
# 预约作品弹层滚动修复设计
|
||||
|
||||
## 问题
|
||||
|
||||
预约作品弹层只有最大高度,内部作品列表没有确定的可滚动高度;遮罩层也未拦截纵向触摸,导致滑动作品弹层时底层预约页面滚动。
|
||||
|
||||
## 方案
|
||||
|
||||
- 将作品弹层设置为固定视口高度的纵向弹性布局,并隐藏弹层自身溢出。
|
||||
- 标题和搜索框保持固定,将作品列表及手动新增区域放入同一个纵向 `scroll-view`。
|
||||
- 遮罩层拦截 `touchmove`,阻止手势穿透到底层页面。
|
||||
- 保留点击遮罩关闭、作品选择、搜索和手动新增的原有业务行为。
|
||||
|
||||
## 验证
|
||||
|
||||
增加弹层结构测试,检查滚动容器、固定高度布局和触摸拦截;运行全部小程序测试。当前会话未提供 GitNexus `impact` 与 `detect_changes` 工具,因此使用静态引用检查、结构测试和 Git 差异检查替代。
|
||||
@@ -0,0 +1,17 @@
|
||||
# Salon 历史补单与服务中状态设计
|
||||
|
||||
## 目标
|
||||
|
||||
通过独立补单入口记录已经发生或正在服务中的业务,不改变普通预约的历史日期限制、排班校验和预约占用逻辑。
|
||||
|
||||
## 状态与数据
|
||||
|
||||
订单新增 `IN_SERVICE(4)`,仅 `HISTORICAL_BACKFILL` 来源允许创建为该状态。补单必须有项目、金额、服务日期和员工;客户、手机号、具体服务时间和备注可为空。服务日期写入订单项 `service_date`,具体时间存在时才写入 `appointment_time`。
|
||||
|
||||
## 展示与流转
|
||||
|
||||
规划页提供独立“补录历史订单”入口。没有具体时间的补单显示在日视图“历史补单”区域,不进入时间轴;有时间的记录可展示但不产生排班容量占用。服务中补单可完成或取消,已完成补单不再进入普通预约流程。
|
||||
|
||||
## 兼容与验证
|
||||
|
||||
普通预约接口和状态流转保持原规则。数据库字段和索引统一写入 `docs/scripts/sql/init/jayucloud-salon.sql`,脚本可重复执行;后端编译通过,客户端脚本执行语法检查。
|
||||
@@ -1,5 +1,14 @@
|
||||
# 项目变更记录
|
||||
|
||||
## 2026-10-12 Salon 小程序业务引用字段底部选择页
|
||||
|
||||
- 新增统一的业务引用选择组件,客户、员工和门店使用约 88% 屏高的底部选择页,统一搜索、加载、错误、空状态和滚动防穿透行为。
|
||||
- 新增预约将姓名与手机号合并为客户卡片,支持选择已有客户或切换手动录入;指定员工改为可搜索选择,并支持快速新增后自动回填。
|
||||
- 改派页面收敛为员工选择字段,店员注册改为按名称或地址搜索门店;日期、时间和固定枚举继续使用微信原生 picker。
|
||||
- 员工新增从列表弹窗迁移为独立页面,删除旧弹窗状态、方法和样式,创建结果通过事件通道通知来源页面。
|
||||
- 问题根因是业务引用字段分别使用内嵌下拉、原生 picker 和平铺列表,导致交互、错误状态及滚动处理不一致;本次通过标准化展示模型和页面内业务回填解决。
|
||||
- GitNexus 索引已刷新;其对通用名称 `normalizeCustomer` 的 CRITICAL 结果误关联了跨项目同名符号,因此保留原函数并新增独立映射函数规避风险。
|
||||
|
||||
## 2026-10-10 Salon 微信资料双按钮
|
||||
|
||||
- 将个人信息页“使用微信资料”折叠入口改为左右两个等宽按钮:左侧使用微信头像,右侧使用微信昵称。
|
||||
@@ -160,3 +169,19 @@
|
||||
- 新增来源检查工作流:`.gitea/workflows/environment-promotion-guard.yml`。
|
||||
- 当前环境分支存在未晋级业务差异,首次启用按已确认的一次性安全引导执行;只向 `sit`、`prod` 写入检查工作流,不携带业务改动。
|
||||
|
||||
# 2026-10-12 Salon 待分配预约与新员工首次排班引导
|
||||
|
||||
- 新增预约允许暂不选择员工,客户、作品、日期、时间和时长仍为必填;待分配预约只校验门店营业时间,不创建员工时段占用。
|
||||
- 规划接口补充 `assignmentStatus` 和每日 `unassignedCount`,月、周视图增加橙色待分配标识,日视图最左侧增加待分配虚拟泳道;具体员工筛选不混入待分配预约。
|
||||
- 预约详情在未分配时展示“分配员工”,后端和小程序同时阻止确认或完成,取消仍保持可用;后续继续复用改派接口完成首次分配和容量校验。
|
||||
- 员工创建成功后增加首次排班引导:员工列表可立即设置排班,预约来源可“设置排班并分配”或保持待分配;首次模式隐藏特殊日期并通过事件通道回填预约。
|
||||
- 修复复用改派页时默认使用“今天 13:00”的历史问题:页面现在先读取原预约日期、时间和时长,避免分配员工时意外改变预约时间。
|
||||
- 本次现有字段已支持员工为空,未修改冻结初始化 SQL、版本 SQL、Nacos、后台管理或 ArtList。
|
||||
- GitNexus 已执行关键符号影响分析,但当前索引无法识别相关 Java/小程序页面方法并返回 `UNKNOWN`;本次以静态调用链、Core 测试与编译、小程序全量状态测试替代验证。
|
||||
|
||||
## 2026-10-13 历史补单与服务中状态
|
||||
|
||||
- 新增历史补单接口与小程序独立补单页面,补单可直接进入“服务中”或“已完成”。
|
||||
- 新增 `IN_SERVICE(4)` 状态、历史补单来源和服务日期字段;无具体时间的补单仅参与日期统计,不创建预约占用。
|
||||
- 规划页增加补录入口、历史补单展示,后台订单筛选增加服务中状态。
|
||||
- 数据库字段与索引已融合到 `docs/scripts/sql/init/jayucloud-salon.sql`,初始化脚本可重复执行。
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
# 店长员工审核提醒参数说明
|
||||
|
||||
## 参数
|
||||
|
||||
- 分组:`WORKBENCH`
|
||||
- 键:`MANAGER_REGISTRATION_REVIEW_NOTICE`
|
||||
- 值:`true`
|
||||
- 启用状态:`enabled=1` 时显示登录提醒,`enabled=0` 时隐藏登录提醒。
|
||||
|
||||
该参数存储在 `t_system_parameter_config`,由后台“系统设置”页面动态管理。它只控制店长成功登录小程序后的待审核弹窗,不影响员工页面的审核入口、待审核数量及审核能力。
|
||||
|
||||
## 发布步骤
|
||||
|
||||
1. 发布后端、后台和小程序代码。
|
||||
2. 在目标 Salon 数据库执行 `docs/scripts/sql/versions/店长员工审核提醒参数_20261012.sql`。
|
||||
3. 使用平台管理员进入后台“系统设置”,确认“店长员工审核提醒”状态。
|
||||
|
||||
脚本可重复执行,重复执行不会覆盖管理员已经选择的启用或停用状态。本次仓库变更不会连接或修改任何实际数据库及 Nacos 环境。
|
||||
Reference in New Issue
Block a user