feat: 店铺详情页重构 — 四卡片布局(月度目标/推广费/刷单费/店铺订单),筛选栏移至标题行,图标替换为Lucide

This commit is contained in:
小蟑螂
2026-04-30 15:57:32 +08:00
parent 00377bdc63
commit b063f65568
21 changed files with 1211 additions and 961 deletions
@@ -0,0 +1,12 @@
-- ================================================
-- 店铺详情菜单 SQL(需在数据库执行)
-- 父菜单:电商/店铺管理(请先查询确认父菜单ID)
-- ================================================
--
-- 步骤1:查询父菜单ID(电商/店铺管理)
-- SELECT id, name, title, parent_id FROM sys_menu WHERE name LIKE '%店铺%';
--
-- 假设父菜单 ID 为 XX,则执行以下 INSERT(将 XX 替换为实际父菜单ID)
--
-- INSERT INTO `sys_menu` (`parent_id`, `name`, `title`, `path`, `component`, `icon`, `type`, `visible`, `status`, `order`, `create_time`)
-- VALUES (XX, 'shop-details', '店铺详情', '/ecom/shop/details/:id', 'ecommerce/shop/details/index', 'file-text', 'menu', 1, 1, 200, NOW());
@@ -12,12 +12,14 @@ import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
import top.xyquan.ecomdmbbackend.common.response.ApiResponse;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.CreateShopDTO;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.ShopDetailQueryDTO;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.ShopFilterDTO;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.ShopProductPageFilterDTO;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.ShopStatisticsQueryDTO;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.UpdateShopDTO;
import top.xyquan.ecomdmbbackend.modules.ecom.overview.model.dto.ShopOverviewQueryDTO;
import top.xyquan.ecomdmbbackend.modules.ecom.product.model.vo.ProductVO;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.vo.ShopDashboardVO;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.vo.ShopOverviewVO;
import top.xyquan.ecomdmbbackend.modules.ecom.overview.model.vo.ShopOverviewStatisticsVO;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.vo.ShopVO;
@@ -115,4 +117,12 @@ public class ShopController {
ShopOverviewStatisticsVO overviewVO = shopOverviewStatisticsService.getShopOverviewStatistics(queryDTO);
return ApiResponse.success("获取店铺概览统计成功", overviewVO);
}
@Operation(summary = "获取店铺详情页看板数据", description = "获取店铺详情页的月度目标、推广费、刷单费、店铺订单等看板数据")
@PostMapping("/details")
@RequirePermission(value = "ecom:shop:read", description = "查询店铺详情", allowSuper = true)
public ApiResponse<ShopDashboardVO> getShopDetails(@Valid @RequestBody ShopDetailQueryDTO queryDTO) {
ShopDashboardVO dashboard = shopService.getShopDashboard(queryDTO);
return ApiResponse.success("获取店铺详情看板数据成功", dashboard);
}
}
@@ -0,0 +1,133 @@
package top.xyquan.ecomdmbbackend.modules.ecom.shop.model.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* 店铺详情页看板VO
*/
@Data
@Schema(description = "店铺详情页看板VO")
public class ShopDashboardVO {
/**
* 店铺基本信息
*/
@Schema(description = "店铺基本信息")
private ShopInfo shopInfo;
/**
* 月度目标看板数据
*/
@Schema(description = "月度目标看板数据")
private MonthlyTargetKpi monthlyTarget;
/**
* 推广费看板数据
*/
@Schema(description = "推广费看板数据")
private PromotionFeeKpi promotionFee;
/**
* 刷单费看板数据
*/
@Schema(description = "刷单费看板数据")
private BrushOrderKpi brushOrder;
/**
* 店铺订单看板数据
*/
@Schema(description = "店铺订单看板数据")
private ShopOrderKpi shopOrder;
/**
* 店铺基本信息
*/
@Data
@Schema(description = "店铺基本信息")
public static class ShopInfo {
@Schema(description = "店铺ID")
private Long id;
@Schema(description = "店铺名称")
private String name;
@Schema(description = "logo URL")
private String logo;
@Schema(description = "平台名称")
private String platformName;
}
/**
* 月度目标KPI
*/
@Data
@Schema(description = "月度目标KPI")
public static class MonthlyTargetKpi {
/** 年度目标总额 */
@Schema(description = "年度目标总额")
private java.math.BigDecimal totalTargetAmount;
/** 目标单量合计 */
@Schema(description = "目标单量合计")
private Integer totalOrderCount;
/** 本月目标销售额 */
@Schema(description = "本月目标销售额")
private java.math.BigDecimal thisMonthTargetAmount;
/** 本月目标单量 */
@Schema(description = "本月目标单量")
private Integer thisMonthTargetOrderCount;
/** 当前达成率 */
@Schema(description = "当前达成率(百分比)")
private java.math.BigDecimal achievementRate;
}
/**
* 推广费KPI
*/
@Data
@Schema(description = "推广费KPI")
public static class PromotionFeeKpi {
/** 累计推广费 */
@Schema(description = "累计推广费")
private java.math.BigDecimal totalFeeAmount;
/** 本月推广费 */
@Schema(description = "本月推广费")
private java.math.BigDecimal thisMonthFee;
/** 日均推广费 */
@Schema(description = "日均推广费")
private java.math.BigDecimal avgDailyFee;
}
/**
* 刷单费KPI
*/
@Data
@Schema(description = "刷单费KPI")
public static class BrushOrderKpi {
/** 累计刷单费 */
@Schema(description = "累计刷单费")
private java.math.BigDecimal totalBrushAmount;
/** 本月刷单次数 */
@Schema(description = "本月刷单次数")
private Integer thisMonthCount;
/** 平均刷单金额 */
@Schema(description = "平均刷单金额")
private java.math.BigDecimal avgAmount;
}
/**
* 店铺订单KPI
*/
@Data
@Schema(description = "店铺订单KPI")
public static class ShopOrderKpi {
/** 累计实收金额 */
@Schema(description = "累计实收金额")
private java.math.BigDecimal totalReceivedAmount;
/** 累计佣金 */
@Schema(description = "累计佣金")
private java.math.BigDecimal totalCommission;
/** 累计订单数 */
@Schema(description = "累计订单数")
private Integer totalOrderCount;
}
}
@@ -5,12 +5,14 @@ import org.springframework.web.multipart.MultipartFile;
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.CreateShopDTO;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.ShopDetailQueryDTO;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.ShopFilterDTO;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.ShopProductPageFilterDTO;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.ShopStatisticsQueryDTO;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.UpdateShopDTO;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.po.ShopPO;
import top.xyquan.ecomdmbbackend.modules.ecom.product.model.vo.ProductVO;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.vo.ShopDashboardVO;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.vo.ShopOverviewVO;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.vo.ShopVO;
import top.xyquan.ecomdmbbackend.modules.sys.file.model.vo.SysFileUploadVO;
@@ -75,4 +77,12 @@ public interface ShopService extends IService<ShopPO> {
* @return 分页结果
*/
PageResultVO<ProductVO> getShopProductPage(PageQueryDTO<ShopProductPageFilterDTO> pageQueryDTO);
/**
* 获取店铺详情页看板数据
*
* @param queryDTO 查询DTO
* @return 看板VO
*/
ShopDashboardVO getShopDashboard(ShopDetailQueryDTO queryDTO);
}
@@ -10,6 +10,8 @@ import org.springframework.transaction.annotation.Transactional;
import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
import top.xyquan.ecomdmbbackend.modules.ecom.brushorder.mapper.BrushOrderMapper;
import top.xyquan.ecomdmbbackend.modules.ecom.brushorder.model.po.BrushOrderPO;
import top.xyquan.ecomdmbbackend.modules.ecom.order.mapper.OrderMapper;
import top.xyquan.ecomdmbbackend.modules.ecom.product.mapper.ProductMapper;
import top.xyquan.ecomdmbbackend.modules.ecom.promotion.mapper.PromotionFeeMapper;
@@ -17,7 +19,11 @@ import top.xyquan.ecomdmbbackend.modules.ecom.platform.mapper.PlatformMapper;
import top.xyquan.ecomdmbbackend.modules.ecom.platform.model.po.PlatformPO;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.mapper.ShopMapper;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.mapper.ShopProductRelationMapper;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.monthlytarget.mapper.ShopMonthlyTargetMapper;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.monthlytarget.model.po.ShopMonthlyTargetPO;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.monthlytarget.model.vo.ShopMonthlyTargetVO;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.CreateShopDTO;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.ShopDetailQueryDTO;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.ShopFilterDTO;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.ShopProductPageFilterDTO;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.dto.ShopStatisticsQueryDTO;
@@ -32,6 +38,7 @@ import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.po.ShopPO;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.po.ShopProductRelationPO;
import top.xyquan.ecomdmbbackend.modules.ecom.product.model.vo.ProductSpecVO;
import top.xyquan.ecomdmbbackend.modules.ecom.product.model.vo.ProductVO;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.vo.ShopDashboardVO;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.vo.ShopOverviewVO;
import top.xyquan.ecomdmbbackend.modules.ecom.shop.model.vo.ShopVO;
import top.xyquan.ecomdmbbackend.modules.ecom.product.service.ProductSpecService;
@@ -71,12 +78,15 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopPO> implements
private final ProductSpecService productSpecService;
private final OrderStatusService orderStatusService;
private final PlatformMapper platformMapper;
private final BrushOrderMapper brushOrderMapper;
private final ShopMonthlyTargetMapper shopMonthlyTargetMapper;
public ShopServiceImpl(CurrentUserContext currentUserContext, SysFileMapper sysFileMapper, SysFileService sysFileService,
OrderMapper orderMapper, PromotionFeeMapper promotionFeeMapper,
ProductMapper productMapper,
ShopProductRelationMapper shopProductRelationMapper, ProductSpecService productSpecService,
OrderStatusService orderStatusService, PlatformMapper platformMapper) {
OrderStatusService orderStatusService, PlatformMapper platformMapper,
BrushOrderMapper brushOrderMapper, ShopMonthlyTargetMapper shopMonthlyTargetMapper) {
this.currentUserContext = currentUserContext;
this.sysFileMapper = sysFileMapper;
this.sysFileService = sysFileService;
@@ -87,6 +97,8 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopPO> implements
this.productSpecService = productSpecService;
this.orderStatusService = orderStatusService;
this.platformMapper = platformMapper;
this.brushOrderMapper = brushOrderMapper;
this.shopMonthlyTargetMapper = shopMonthlyTargetMapper;
}
/**
@@ -733,4 +745,185 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopPO> implements
BeanUtils.copyProperties(productSpec, productSpecVO);
return productSpecVO;
}
@Override
public ShopDashboardVO getShopDashboard(ShopDetailQueryDTO queryDTO) {
Long companyId = currentUserContext.getCurrentCompanyId();
Long shopId = queryDTO.getShopId();
// 验证店铺
ShopPO shop = this.getById(shopId);
if (shop == null || !shop.getCompanyId().equals(companyId)) {
throw new BusinessException("店铺不存在");
}
// 日期范围(默认当月)
LocalDate startDate = queryDTO.getStartDate() != null ? queryDTO.getStartDate() : LocalDate.now().withDayOfMonth(1);
LocalDate endDate = queryDTO.getEndDate() != null ? queryDTO.getEndDate() : LocalDate.now();
LocalDateTime startDateTime = startDate.atStartOfDay();
LocalDateTime endDateTime = endDate.atTime(23, 59, 59);
ShopDashboardVO dashboard = new ShopDashboardVO();
// 设置店铺基本信息
ShopDashboardVO.ShopInfo shopInfo = new ShopDashboardVO.ShopInfo();
shopInfo.setId(shop.getId());
shopInfo.setName(shop.getName());
shopInfo.setLogo(null); // logoImageId 冗余字段,前端按需使用
// 查询平台名称
if (shop.getPlatformId() != null) {
LambdaQueryWrapper<PlatformPO> platformWrapper = new LambdaQueryWrapper<>();
platformWrapper.eq(PlatformPO::getId, shop.getPlatformId())
.eq(PlatformPO::getCompanyId, companyId);
PlatformPO platform = platformMapper.selectOne(platformWrapper);
if (platform != null) {
shopInfo.setPlatformName(platform.getPlatformName());
}
}
dashboard.setShopInfo(shopInfo);
// 1. 月度目标
dashboard.setMonthlyTarget(buildMonthlyTargetKpi(companyId, shopId, shop, startDate, endDate));
// 2. 推广费
dashboard.setPromotionFee(buildPromotionFeeKpi(companyId, shopId, shop, startDate, endDate));
// 3. 刷单费
dashboard.setBrushOrder(buildBrushOrderKpi(companyId, shopId, shop, startDate, endDate));
// 4. 店铺订单
dashboard.setShopOrder(buildShopOrderKpi(companyId, shopId, shop, startDateTime, endDateTime));
return dashboard;
}
private ShopDashboardVO.MonthlyTargetKpi buildMonthlyTargetKpi(Long companyId, Long shopId, ShopPO shop, LocalDate startDate, LocalDate endDate) {
ShopDashboardVO.MonthlyTargetKpi kpi = new ShopDashboardVO.MonthlyTargetKpi();
// 查询所有目标记录(不限日期,取所有)
LambdaQueryWrapper<ShopMonthlyTargetPO> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(ShopMonthlyTargetPO::getCompanyId, companyId)
.eq(ShopMonthlyTargetPO::getShopId, shopId)
.orderByDesc(ShopMonthlyTargetPO::getTargetMonth);
List<ShopMonthlyTargetPO> allTargets = shopMonthlyTargetMapper.selectList(wrapper);
// 年度总额 & 目标单量合计
BigDecimal totalTargetAmount = allTargets.stream()
.map(ShopMonthlyTargetPO::getTargetAmount)
.reduce(BigDecimal.ZERO, BigDecimal::add);
int totalOrderCount = allTargets.stream()
.mapToInt(t -> t.getTargetOrderCount() != null ? t.getTargetOrderCount() : 0)
.sum();
// 本月目标
String thisMonth = startDate.withDayOfMonth(1).toString().substring(0, 7);
ShopMonthlyTargetPO thisMonthTarget = allTargets.stream()
.filter(t -> t.getTargetMonth() != null && t.getTargetMonth().toString().startsWith(thisMonth))
.findFirst().orElse(null);
kpi.setTotalTargetAmount(totalTargetAmount);
kpi.setTotalOrderCount(totalOrderCount);
kpi.setThisMonthTargetAmount(thisMonthTarget != null ? thisMonthTarget.getTargetAmount() : BigDecimal.ZERO);
kpi.setThisMonthTargetOrderCount(thisMonthTarget != null ? thisMonthTarget.getTargetOrderCount() : 0);
// 达成率 = 实际销售额 / 目标销售额(简化:查时间段内订单实收 / 目标)
LambdaQueryWrapper<OrderPO> orderWrapper = new LambdaQueryWrapper<>();
orderWrapper.eq(OrderPO::getCompanyId, companyId)
.eq(OrderPO::getShopId, shopId)
.ge(OrderPO::getOrderTime, startDate.atStartOfDay())
.le(OrderPO::getOrderTime, endDate.atTime(23, 59, 59));
List<OrderPO> periodOrders = orderMapper.selectList(orderWrapper);
BigDecimal actualSales = periodOrders.stream()
.map(o -> o.getReceivedAmount() != null ? o.getReceivedAmount() : BigDecimal.ZERO)
.reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal achievementRate = BigDecimal.ZERO;
if (thisMonthTarget != null && thisMonthTarget.getTargetAmount() != null
&& thisMonthTarget.getTargetAmount().compareTo(BigDecimal.ZERO) > 0) {
achievementRate = actualSales.divide(thisMonthTarget.getTargetAmount(), 4, RoundingMode.HALF_UP)
.multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP);
}
kpi.setAchievementRate(achievementRate);
return kpi;
}
private ShopDashboardVO.PromotionFeeKpi buildPromotionFeeKpi(Long companyId, Long shopId, ShopPO shop, LocalDate startDate, LocalDate endDate) {
ShopDashboardVO.PromotionFeeKpi kpi = new ShopDashboardVO.PromotionFeeKpi();
LambdaQueryWrapper<PromotionFeePO> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(PromotionFeePO::getCompanyId, companyId)
.eq(PromotionFeePO::getShopId, shopId)
.ge(PromotionFeePO::getFeeDate, startDate)
.le(PromotionFeePO::getFeeDate, endDate)
.orderByDesc(PromotionFeePO::getFeeDate);
List<PromotionFeePO> allFees = promotionFeeMapper.selectList(wrapper);
BigDecimal totalFeeAmount = allFees.stream()
.map(f -> f.getFeeAmount() != null ? f.getFeeAmount() : BigDecimal.ZERO)
.reduce(BigDecimal.ZERO, BigDecimal::add);
// 本月推广费
String thisMonthStr = startDate.withDayOfMonth(1).toString().substring(0, 7);
BigDecimal thisMonthFee = allFees.stream()
.filter(f -> f.getFeeDate() != null && f.getFeeDate().toString().startsWith(thisMonthStr))
.map(f -> f.getFeeAmount() != null ? f.getFeeAmount() : BigDecimal.ZERO)
.reduce(BigDecimal.ZERO, BigDecimal::add);
// 日均
long days = java.time.temporal.ChronoUnit.DAYS.between(startDate, endDate) + 1;
BigDecimal avgDailyFee = days > 0 ? totalFeeAmount.divide(BigDecimal.valueOf(days), 2, RoundingMode.HALF_UP) : BigDecimal.ZERO;
kpi.setTotalFeeAmount(totalFeeAmount);
kpi.setThisMonthFee(thisMonthFee);
kpi.setAvgDailyFee(avgDailyFee);
return kpi;
}
private ShopDashboardVO.BrushOrderKpi buildBrushOrderKpi(Long companyId, Long shopId, ShopPO shop, LocalDate startDate, LocalDate endDate) {
ShopDashboardVO.BrushOrderKpi kpi = new ShopDashboardVO.BrushOrderKpi();
LambdaQueryWrapper<BrushOrderPO> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(BrushOrderPO::getCompanyId, companyId)
.eq(BrushOrderPO::getShopId, shopId)
.ge(BrushOrderPO::getBrushTime, startDate.atStartOfDay())
.le(BrushOrderPO::getBrushTime, endDate.atTime(23, 59, 59))
.orderByDesc(BrushOrderPO::getBrushTime);
List<BrushOrderPO> allBrush = brushOrderMapper.selectList(wrapper);
BigDecimal totalBrushAmount = allBrush.stream()
.map(b -> b.getBrushAmount() != null ? b.getBrushAmount() : BigDecimal.ZERO)
.reduce(BigDecimal.ZERO, BigDecimal::add);
long thisMonthCount = allBrush.stream()
.filter(b -> b.getBrushTime() != null && b.getBrushTime().toLocalDate().getMonth().equals(startDate.getMonth()))
.count();
long brushCount = allBrush.size();
BigDecimal avgAmount = brushCount > 0 ? totalBrushAmount.divide(BigDecimal.valueOf(brushCount), 2, RoundingMode.HALF_UP) : BigDecimal.ZERO;
kpi.setTotalBrushAmount(totalBrushAmount);
kpi.setThisMonthCount((int) thisMonthCount);
kpi.setAvgAmount(avgAmount);
return kpi;
}
private ShopDashboardVO.ShopOrderKpi buildShopOrderKpi(Long companyId, Long shopId, ShopPO shop, LocalDateTime startDateTime, LocalDateTime endDateTime) {
ShopDashboardVO.ShopOrderKpi kpi = new ShopDashboardVO.ShopOrderKpi();
LambdaQueryWrapper<OrderPO> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(OrderPO::getCompanyId, companyId)
.eq(OrderPO::getShopId, shopId)
.ge(OrderPO::getOrderTime, startDateTime)
.le(OrderPO::getOrderTime, endDateTime)
.orderByDesc(OrderPO::getOrderTime);
List<OrderPO> allOrders = orderMapper.selectList(wrapper);
BigDecimal totalReceived = allOrders.stream()
.map(o -> o.getReceivedAmount() != null ? o.getReceivedAmount() : BigDecimal.ZERO)
.reduce(BigDecimal.ZERO, BigDecimal::add);
kpi.setTotalReceivedAmount(totalReceived);
kpi.setTotalCommission(BigDecimal.ZERO); // 订单表暂无佣金字段
kpi.setTotalOrderCount(allOrders.size());
return kpi;
}
}
@@ -106,3 +106,10 @@ export async function exportCompanyOverviewApi(params: {
responseType: 'blob',
});
}
/**
* 获取店铺详情看板数据
*/
export async function getShopDetailsApi(params: ShopDTO.DetailQuery) {
return requestClient.post<ShopVO.Dashboard>('/ec/shop/details', params);
}
@@ -56,4 +56,14 @@ export namespace ShopDTO {
/** 税率(默认0.04,即4%) */
taxRate?: number;
}
/** 店铺详情看板查询参数 */
export interface DetailQuery {
/** 店铺ID */
shopId: number;
/** 开始日期(不传默认为当月1号) */
startDate?: string;
/** 结束日期(不传默认为今天) */
endDate?: string;
}
}
@@ -260,4 +260,72 @@ export namespace ShopVO {
/** 各品类汇总列表 */
categories: CategoryComparison[];
}
// ========== 店铺详情看板 ==========
/** 店铺基本信息 */
export interface ShopInfo {
id: number;
name: string;
logo?: string;
platformName?: string;
}
/** 月度目标KPI */
export interface MonthlyTargetKpi {
/** 年度目标总额 */
totalTargetAmount: number;
/** 目标单量合计 */
totalOrderCount: number;
/** 本月目标销售额 */
thisMonthTargetAmount: number;
/** 本月目标单量 */
thisMonthTargetOrderCount: number;
/** 当前达成率(百分比) */
achievementRate: number;
}
/** 推广费KPI */
export interface PromotionFeeKpi {
/** 累计推广费 */
totalFeeAmount: number;
/** 本月推广费 */
thisMonthFee: number;
/** 日均推广费 */
avgDailyFee: number;
}
/** 刷单费KPI */
export interface BrushOrderKpi {
/** 累计刷单费 */
totalBrushAmount: number;
/** 本月刷单次数 */
thisMonthCount: number;
/** 平均刷单金额 */
avgAmount: number;
}
/** 店铺订单KPI */
export interface ShopOrderKpi {
/** 累计实收金额 */
totalReceivedAmount: number;
/** 累计佣金 */
totalCommission: number;
/** 累计订单数 */
totalOrderCount: number;
}
/** 店铺详情看板数据 */
export interface Dashboard {
/** 店铺基本信息 */
shopInfo: ShopInfo;
/** 月度目标看板数据 */
monthlyTarget: MonthlyTargetKpi;
/** 推广费看板数据 */
promotionFee: PromotionFeeKpi;
/** 刷单费看板数据 */
brushOrder: BrushOrderKpi;
/** 店铺订单看板数据 */
shopOrder: ShopOrderKpi;
}
}
@@ -0,0 +1,174 @@
<script lang="ts" setup>
import type { VxeGridProps } from '#/adapter/vxe-table';
import type { BrushOrderDTO, BrushOrderVO } from '#/api/ecommerce/brush-order';
import type { ShopVO } from '#/api/ecommerce/shop/types';
import type { PageQueryDTO } from '#/types/common';
import { Button, DatePicker, Popconfirm, Space } from 'ant-design-vue';
import { computed, ref } from 'vue';
import { createIconifyIcon } from '@vben/icons';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import {
deleteBrushOrderApi,
getBrushOrderPageApi,
} from '#/api/ecommerce/brush-order';
import BrushOrderFormModal from '#/views/ecommerce/brush-order/components/BrushOrderFormModal.vue';
defineOptions({ name: 'BrushOrderCard' });
const PlusIcon = createIconifyIcon('lucide:plus');
const RepeatIcon = createIconifyIcon('lucide:repeat');
const props = defineProps<{
shopId: number;
data?: ShopVO.BrushOrderKpi;
}>();
const kpi = computed(() => props.data);
const gridReloadRef = ref<(() => void) | null>(null);
const searchForm = ref({
startBrushTime: undefined as string | undefined,
endBrushTime: undefined as string | undefined,
});
const modalVisible = ref(false);
const editingData = ref<BrushOrderVO.Info | undefined>();
const gridOptions: VxeGridProps<any> = {
columns: [
{ type: 'seq', title: '序号', width: 60 },
{ field: 'productName', title: '商品名称', minWidth: 160 },
{ field: 'productSpecName', title: '规格名称', minWidth: 160 },
{
field: 'brushAmount', title: '刷单金额', width: 120,
formatter: ({ cellValue }) => `¥${Number(cellValue || 0).toLocaleString()}`,
},
{ field: 'brushTime', title: '刷单时间', minWidth: 160 },
{ field: 'remark', title: '备注', minWidth: 120 },
{
title: '操作',
width: 150,
fixed: 'right',
slots: { default: 'action' },
},
],
height: 'auto',
maxHeight: 340,
border: true,
stripe: true,
size: 'small',
pagerConfig: { enabled: true, pageSizes: [10, 20, 50] },
proxyConfig: {
ajax: {
query: async ({ page }) => {
const params: PageQueryDTO<BrushOrderDTO.Filters> = {
page: page.currentPage,
pageSize: page.pageSize,
filters: {
shopId: props.shopId || undefined,
startBrushTime: searchForm.value.startBrushTime,
endBrushTime: searchForm.value.endBrushTime,
},
};
const data = await getBrushOrderPageApi(params);
return { items: data.records, total: data.total };
},
},
},
};
const [Grid, gridApi] = useVbenVxeGrid({
gridOptions,
showSearchForm: false,
});
gridReloadRef.value = () => gridApi.reload();
function handleAdd() {
editingData.value = undefined;
modalVisible.value = true;
}
function handleEdit(row: BrushOrderVO.Info) {
editingData.value = row;
modalVisible.value = true;
}
async function handleDelete(id: number) {
await deleteBrushOrderApi(id);
gridReloadRef.value?.();
}
</script>
<template>
<div class="rounded-2xl border border-slate-200/80 bg-white/90 shadow-sm dark:border-[hsl(222.34deg_10.43%_16%)] dark:bg-[hsl(222.34deg_10.43%_12.27%)]">
<!-- 标题栏 + 筛选区(单行) -->
<div class="flex items-center justify-between gap-3 border-b border-slate-100 px-6 py-3 dark:border-[hsl(222.34deg_10.43%_16%)]">
<h3 class="flex shrink-0 items-center gap-2 text-base font-semibold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
<RepeatIcon class="h-4 w-4" />
<span>刷单费</span>
</h3>
<div class="flex items-center gap-2">
<DatePicker
v-model:value="searchForm.startBrushTime"
placeholder="开始时间"
class="!w-40"
allow-clear
show-time
@change="() => gridReloadRef?.()"
/>
<span class="text-xs text-slate-400">至</span>
<DatePicker
v-model:value="searchForm.endBrushTime"
placeholder="结束时间"
class="!w-40"
allow-clear
show-time
@change="() => gridReloadRef?.()"
/>
</div>
<Button type="primary" size="small" @click="handleAdd">
<template #icon><PlusIcon /></template>
新增记录
</Button>
</div>
<!-- KPI 指标卡 -->
<div class="grid grid-cols-3 gap-4 border-b border-slate-100 px-6 py-4 dark:border-[hsl(222.34deg_10.43%_16%)]">
<div class="text-center">
<div class="text-xs font-medium text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">累计刷单费</div>
<div class="mt-1 text-lg font-bold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">¥{{ Number(kpi?.totalBrushAmount || 0).toLocaleString() }}</div>
</div>
<div class="text-center">
<div class="text-xs font-medium text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">本月刷单次数</div>
<div class="mt-1 text-lg font-bold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">{{ kpi?.thisMonthCount ?? 0 }} 次</div>
</div>
<div class="text-center">
<div class="text-xs font-medium text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">平均刷单金额</div>
<div class="mt-1 text-lg font-bold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">¥{{ Number(kpi?.avgAmount || 0).toLocaleString() }}</div>
</div>
</div>
<div class="p-4">
<Grid>
<template #action="{ row }: { row: BrushOrderVO.Info }">
<Space>
<Button size="small" type="primary" @click="handleEdit(row)">编辑</Button>
<Popconfirm title="确定删除?" @confirm="handleDelete(row.id)">
<Button size="small" danger>删除</Button>
</Popconfirm>
</Space>
</template>
</Grid>
</div>
<BrushOrderFormModal
v-model:open="modalVisible"
:brush-order-data="editingData"
@success="gridReloadRef?.()"
/>
</div>
</template>
@@ -1,170 +0,0 @@
<script lang="ts" setup>
import type { EchartsUIType } from '@vben/plugins/echarts';
import type { ShopVO } from '#/api/ecommerce/shop/types';
import { computed, onMounted, ref, watch } from 'vue';
import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
import { Card, Statistic } from 'ant-design-vue';
interface Props {
/** 标题 */
title: string;
/** 统计数据 */
data: ShopVO.DailyStatistics;
/** 格式化函数 */
formatter?: (value: number) => string;
/** 图表类型 */
chartType?: 'bar' | 'line';
/** 图表颜色 */
color?: string;
}
defineOptions({ name: 'ChartCard' });
const props = withDefaults(defineProps<Props>(), {
chartType: 'line',
color: '#5ab1ef',
formatter: (value: number) => value.toLocaleString('zh-CN'),
});
const chartRef = ref<EchartsUIType>();
const { renderEcharts } = useEcharts(chartRef);
// 图表配置类型(使用 Record 类型,避免直接导入 echarts 类型)
type ChartOptions = Record<string, any>;
// 格式化日期:从 "2025-11-17" 提取日期部分 "17"
function formatDateToDay(dateStr: string): string {
const date = new Date(dateStr);
return date.getDate().toString();
}
// 图表配置
const chartOptions = computed<ChartOptions>(() => {
const { dailyDataList } = props.data;
// 横坐标只显示日期(日)
const dateLabels = dailyDataList.map((item) => formatDateToDay(item.date));
// 保存完整日期用于 tooltip
const fullDates = dailyDataList.map((item) => item.date);
const values = dailyDataList.map((item) => item.value);
const isLine = props.chartType === 'line';
return {
grid: {
bottom: 20,
containLabel: true,
left: '3%',
right: '3%',
top: '10%',
},
tooltip: {
axisPointer: {
lineStyle: {
color: props.color,
width: 1,
},
},
trigger: 'axis',
formatter: (params: any) => {
const param = Array.isArray(params) ? params[0] : params;
const index = param.dataIndex;
const fullDate = fullDates[index];
const value = param.value;
const formattedValue = props.formatter(value);
return `${fullDate}<br/>${props.title}: ${formattedValue}`;
},
},
xAxis: {
axisTick: {
show: false,
},
boundaryGap: !isLine,
data: dateLabels,
type: 'category',
},
yAxis: {
axisTick: {
show: false,
},
splitLine: {
lineStyle: {
type: 'dashed',
},
show: true,
},
type: 'value',
},
series: [
{
areaStyle: isLine
? {
color: {
type: 'linear',
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{
offset: 0,
color: props.color,
},
{
offset: 1,
color: `${props.color}00`, // 透明
},
],
},
}
: undefined,
data: values,
itemStyle: {
color: props.color,
},
smooth: isLine,
type: props.chartType,
...(props.chartType === 'bar' && { barMaxWidth: 60 }),
},
],
};
});
// 渲染图表
function renderChart() {
if (chartRef.value && props.data.dailyDataList.length > 0) {
renderEcharts(chartOptions.value);
}
}
// 监听数据变化
watch(
() => props.data,
() => {
renderChart();
},
{ deep: true },
);
onMounted(() => {
renderChart();
});
</script>
<template>
<Card :title="title" class="h-full">
<div class="mb-4">
<Statistic
:title="`${title}总计`"
:value="data.total"
:formatter="({ value }) => formatter(value as number)"
/>
</div>
<div class="h-64 min-h-0">
<EchartsUI ref="chartRef" />
</div>
</Card>
</template>
@@ -0,0 +1,179 @@
<script lang="ts" setup>
import type { VxeGridProps } from '#/adapter/vxe-table';
import type { ShopMonthlyTargetDTO, ShopMonthlyTargetVO } from '#/api/ecommerce/shop-monthly-target';
import type { ShopVO } from '#/api/ecommerce/shop/types';
import type { PageQueryDTO } from '#/types/common';
import { Button, DatePicker, Popconfirm, Space } from 'ant-design-vue';
import { computed, ref } from 'vue';
import { createIconifyIcon } from '@vben/icons';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import {
deleteShopMonthlyTargetApi,
getShopMonthlyTargetPageApi,
} from '#/api/ecommerce/shop-monthly-target';
import ShopMonthlyTargetFormModal from '#/views/ecommerce/shop/monthly-target/components/ShopMonthlyTargetFormModal.vue';
defineOptions({ name: 'MonthlyTargetCard' });
const PlusIcon = createIconifyIcon('lucide:plus');
const CalendarIcon = createIconifyIcon('lucide:calendar');
const props = defineProps<{
shopId: number;
data?: ShopVO.MonthlyTargetKpi;
}>();
const kpi = computed(() => props.data);
const gridReloadRef = ref<(() => void) | null>(null);
const searchForm = ref({
startTargetMonth: undefined as string | undefined,
endTargetMonth: undefined as string | undefined,
});
const modalVisible = ref(false);
const editingData = ref<ShopMonthlyTargetVO.Info | undefined>();
const gridOptions: VxeGridProps<any> = {
columns: [
{ type: 'seq', title: '序号', width: 60 },
{ field: 'targetMonth', title: '目标月份', width: 120 },
{
field: 'targetAmount', title: '目标销售额', width: 140,
formatter: ({ cellValue }) => `¥${Number(cellValue || 0).toLocaleString()}`,
},
{ field: 'targetOrderCount', title: '目标单量', width: 120 },
{ field: 'remark', title: '备注', minWidth: 140 },
{
title: '操作',
width: 120,
fixed: 'right',
slots: { default: 'action' },
},
],
height: 'auto',
maxHeight: 340,
border: true,
stripe: true,
size: 'small',
pagerConfig: { enabled: true, pageSizes: [10, 20, 50] },
proxyConfig: {
ajax: {
query: async ({ page }) => {
const params: PageQueryDTO<ShopMonthlyTargetDTO.Filters> = {
page: page.currentPage,
pageSize: page.pageSize,
filters: {
shopId: props.shopId || undefined,
startTargetMonth: searchForm.value.startTargetMonth,
endTargetMonth: searchForm.value.endTargetMonth,
},
};
const data = await getShopMonthlyTargetPageApi(params);
return { items: data.records, total: data.total };
},
},
},
};
const [Grid, gridApi] = useVbenVxeGrid({
gridOptions,
showSearchForm: false,
});
gridReloadRef.value = () => gridApi.reload();
function handleAdd() {
editingData.value = undefined;
modalVisible.value = true;
}
function handleEdit(row: ShopMonthlyTargetVO.Info) {
editingData.value = row;
modalVisible.value = true;
}
async function handleDelete(id: number) {
await deleteShopMonthlyTargetApi(id);
gridReloadRef.value?.();
}
</script>
<template>
<div class="rounded-2xl border border-slate-200/80 bg-white/90 shadow-sm dark:border-[hsl(222.34deg_10.43%_16%)] dark:bg-[hsl(222.34deg_10.43%_12.27%)]">
<!-- 标题栏 + 筛选区(单行) -->
<div class="flex items-center justify-between gap-3 border-b border-slate-100 px-6 py-3 dark:border-[hsl(222.34deg_10.43%_16%)]">
<h3 class="flex shrink-0 items-center gap-2 text-base font-semibold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
<CalendarIcon class="h-4 w-4" />
<span>月度目标</span>
</h3>
<div class="flex items-center gap-2">
<DatePicker
v-model:value="searchForm.startTargetMonth"
placeholder="开始月份"
picker="month"
class="!w-32"
allow-clear
@change="() => gridReloadRef?.()"
/>
<span class="text-xs text-slate-400">至</span>
<DatePicker
v-model:value="searchForm.endTargetMonth"
placeholder="结束月份"
picker="month"
class="!w-32"
allow-clear
@change="() => gridReloadRef?.()"
/>
</div>
<Button type="primary" size="small" @click="handleAdd">
<template #icon><PlusIcon /></template>
新增目标
</Button>
</div>
<!-- KPI 指标卡 -->
<div class="grid grid-cols-2 gap-4 border-b border-slate-100 px-6 py-4 dark:border-[hsl(222.34deg_10.43%_16%)] sm:grid-cols-4">
<div class="text-center">
<div class="text-xs font-medium text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">年度目标总额</div>
<div class="mt-1 text-lg font-bold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">¥{{ Number(kpi?.totalTargetAmount || 0).toLocaleString() }}</div>
</div>
<div class="text-center">
<div class="text-xs font-medium text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">目标单量合计</div>
<div class="mt-1 text-lg font-bold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">{{ Number(kpi?.totalOrderCount || 0).toLocaleString() }}</div>
</div>
<div class="text-center">
<div class="text-xs font-medium text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">本月目标</div>
<div class="mt-1 text-lg font-bold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">¥{{ Number(kpi?.thisMonthTargetAmount || 0).toLocaleString() }}</div>
</div>
<div class="text-center">
<div class="text-xs font-medium text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">当前达成率</div>
<div class="mt-1 text-lg font-bold text-emerald-600 dark:text-emerald-400">{{ kpi?.achievementRate ?? 0 }}%</div>
</div>
</div>
<!-- 表格 -->
<div class="p-4">
<Grid>
<template #action="{ row }: { row: ShopMonthlyTargetVO.Info }">
<Space>
<Button size="small" type="primary" @click="handleEdit(row)">编辑</Button>
<Popconfirm title="确定删除?" @confirm="handleDelete(row.id)">
<Button size="small" danger>删除</Button>
</Popconfirm>
</Space>
</template>
</Grid>
</div>
<!-- 弹窗 -->
<ShopMonthlyTargetFormModal
v-model:open="modalVisible"
:shop-monthly-target-data="editingData"
@success="gridReloadRef?.()"
/>
</div>
</template>
@@ -1,214 +0,0 @@
<script lang="ts" setup>
import type { VxeGridProps } from '#/adapter/vxe-table';
import type { ShopDTO } from '#/api/ecommerce/shop/types';
import type { PageQueryDTO } from '#/types/common';
import { computed, ref, watch } from 'vue';
import { Page } from '@vben/common-ui';
import { Image, message, Tag } from 'ant-design-vue';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { getShopProductPageApi } from '#/api/ecommerce/shop';
interface Props {
shopId: number;
}
defineOptions({ name: 'ProductsTab' });
const props = defineProps<Props>();
// 响应式数据
const loading = ref(false);
// VbenVxeGrid 表格配置
const gridOptions: VxeGridProps<any> = {
columns: [
{
type: 'seq' as const,
minWidth: 'auto',
title: '序号',
},
{
title: '主图',
width: 60,
slots: { default: 'mainImage' },
},
{
field: 'name',
title: '商品名称',
minWidth: 200,
showOverflow: 'tooltip' as const,
},
{
field: 'productCode',
title: '商品编码',
minWidth: 150,
showOverflow: 'tooltip' as const,
},
{
title: '规格数量',
minWidth: 100,
slots: { default: 'specs' },
},
{
field: 'createTime',
title: '创建时间',
minWidth: 180,
},
{
field: 'updateTime',
title: '更新时间',
minWidth: 180,
},
],
height: 'auto',
border: true,
stripe: true,
rowConfig: { isHover: true },
showOverflow: true,
size: 'small',
toolbarConfig: {
custom: true,
refresh: true,
zoom: true,
},
data: [],
pagerConfig: {
enabled: true,
pageSizes: [10, 20, 50, 100],
layouts: [
'PrevJump',
'PrevPage',
'Number',
'NextPage',
'NextJump',
'Sizes',
'FullJump',
'Total',
] as (
| 'FullJump'
| 'NextJump'
| 'NextPage'
| 'Number'
| 'PrevJump'
| 'PrevPage'
| 'Sizes'
| 'Total'
)[],
},
// 配置远程加载
proxyConfig: {
ajax: {
query: async ({ page }) => {
if (!props.shopId) {
return {
items: [],
total: 0,
};
}
try {
loading.value = true;
const params: PageQueryDTO<ShopDTO.ProductPageFilters> = {
page: page.currentPage,
pageSize: page.pageSize,
filters: {
shopId: props.shopId,
},
};
const data = await getShopProductPageApi(params);
return {
items: data.records,
total: data.total,
};
} catch (error) {
console.error('获取商品列表失败:', error);
message.error('获取商品列表失败');
return {
items: [],
total: 0,
};
} finally {
loading.value = false;
}
},
},
},
};
// 搜索表单配置
const gridReloadRef = ref<(() => void) | null>(null);
const formOptions = computed(() => ({
schema: [
{
component: 'Input',
componentProps: {
placeholder: '请输入商品名称(回车搜索)',
onPressEnter: () => gridReloadRef.value?.(),
},
fieldName: 'name',
label: '商品名称',
},
{
component: 'Input',
componentProps: {
placeholder: '请输入商品编码(回车搜索)',
onPressEnter: () => gridReloadRef.value?.(),
},
fieldName: 'productCode',
label: '商品编码',
},
],
showDefaultActions: true,
collapsed: true,
collapsedRows: 1,
}));
// 创建 VbenVxeGrid 实例
const [Grid, gridApi] = useVbenVxeGrid({
gridOptions,
formOptions: formOptions.value,
showSearchForm: true,
tableTitle: '商品列表',
});
gridReloadRef.value = () => gridApi.reload();
// 监听 shopId 变化,刷新表格
watch(
() => props.shopId,
() => {
if (props.shopId && gridApi) {
gridApi.reload();
}
},
);
</script>
<template>
<Page auto-content-height content-class="flex flex-col">
<Grid :loading="loading">
<!-- 主图列 -->
<template #mainImage="{ row }: { row: any }">
<Image
v-if="row.mainImage"
:src="row.mainImage"
:alt="row.name"
width="60"
height="60"
style="object-fit: cover; border-radius: 4px"
:preview="true"
/>
<span v-else class="text-xs text-gray-400">暂无图片</span>
</template>
<!-- 规格数量列 -->
<template #specs="{ row }: { row: any }">
<Tag :color="(row.specs?.length || 0) > 0 ? 'blue' : 'default'">
{{ row.specs?.length || 0 }} 个规格
</Tag>
</template>
</Grid>
</Page>
</template>
@@ -0,0 +1,182 @@
<script lang="ts" setup>
import type { VxeGridProps } from '#/adapter/vxe-table';
import type { PromotionFeeDTO, PromotionFeeVO } from '#/api/ecommerce/promotion-fee';
import type { ShopVO } from '#/api/ecommerce/shop/types';
import type { PageQueryDTO } from '#/types/common';
import { Button, DatePicker, Input, Popconfirm, Space } from 'ant-design-vue';
import { computed, ref } from 'vue';
import { createIconifyIcon } from '@vben/icons';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import {
deletePromotionFeeApi,
getPromotionFeePageApi,
} from '#/api/ecommerce/promotion-fee';
import PromotionFeeFormModal from '#/views/ecommerce/promotion-fee/components/PromotionFeeFormModal.vue';
defineOptions({ name: 'PromotionFeeCard' });
const PlusIcon = createIconifyIcon('lucide:plus');
const CoinsIcon = createIconifyIcon('lucide:coins');
const props = defineProps<{
shopId: number;
data?: ShopVO.PromotionFeeKpi;
}>();
const kpi = computed(() => props.data);
const gridReloadRef = ref<(() => void) | null>(null);
const searchForm = ref({
platform: undefined as string | undefined,
feeDateStart: undefined as string | undefined,
feeDateEnd: undefined as string | undefined,
});
const modalVisible = ref(false);
const editingData = ref<PromotionFeeVO.Info | undefined>();
const gridOptions: VxeGridProps<any> = {
columns: [
{ type: 'seq', title: '序号', width: 60 },
{ field: 'feeName', title: '费用名称', width: 110 },
{ field: 'campaignName', title: '活动名称', minWidth: 140 },
{ field: 'platform', title: '平台', width: 90 },
{
field: 'feeAmount', title: '费用金额', width: 130,
formatter: ({ cellValue }) => `¥${Number(cellValue || 0).toLocaleString()}`,
},
{ field: 'feeDate', title: '费用日期', width: 120 },
{ field: 'remark', title: '备注', minWidth: 120 },
{
title: '操作',
width: 150,
fixed: 'right',
slots: { default: 'action' },
},
],
height: 'auto',
maxHeight: 340,
border: true,
stripe: true,
size: 'small',
pagerConfig: { enabled: true, pageSizes: [10, 20, 50] },
proxyConfig: {
ajax: {
query: async ({ page }) => {
const params: PageQueryDTO<PromotionFeeDTO.Filters> = {
page: page.currentPage,
pageSize: page.pageSize,
filters: {
shopId: props.shopId || undefined,
platform: searchForm.value.platform,
feeDateStart: searchForm.value.feeDateStart,
feeDateEnd: searchForm.value.feeDateEnd,
},
};
const data = await getPromotionFeePageApi(params);
return { items: data.records, total: data.total };
},
},
},
};
const [Grid, gridApi] = useVbenVxeGrid({
gridOptions,
showSearchForm: false,
});
gridReloadRef.value = () => gridApi.reload();
function handleAdd() {
editingData.value = undefined;
modalVisible.value = true;
}
function handleEdit(row: PromotionFeeVO.Info) {
editingData.value = row;
modalVisible.value = true;
}
async function handleDelete(id: number) {
await deletePromotionFeeApi(id);
gridReloadRef.value?.();
}
</script>
<template>
<div class="rounded-2xl border border-slate-200/80 bg-white/90 shadow-sm dark:border-[hsl(222.34deg_10.43%_16%)] dark:bg-[hsl(222.34deg_10.43%_12.27%)]">
<!-- 标题栏 + 筛选区(单行) -->
<div class="flex items-center justify-between gap-3 border-b border-slate-100 px-6 py-3 dark:border-[hsl(222.34deg_10.43%_16%)]">
<h3 class="flex shrink-0 items-center gap-2 text-base font-semibold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
<CoinsIcon class="h-4 w-4" />
<span>推广费</span>
</h3>
<div class="flex items-center gap-2">
<Input
v-model:value="searchForm.platform"
placeholder="平台"
class="!w-24"
allow-clear
@change="() => gridReloadRef?.()"
/>
<DatePicker
v-model:value="searchForm.feeDateStart"
placeholder="开始日期"
class="!w-32"
allow-clear
@change="() => gridReloadRef?.()"
/>
<span class="text-xs text-slate-400">至</span>
<DatePicker
v-model:value="searchForm.feeDateEnd"
placeholder="结束日期"
class="!w-32"
allow-clear
@change="() => gridReloadRef?.()"
/>
</div>
<Button type="primary" size="small" @click="handleAdd">
<template #icon><PlusIcon /></template>
新增记录
</Button>
</div>
<!-- KPI 指标卡 -->
<div class="grid grid-cols-3 gap-4 border-b border-slate-100 px-6 py-4 dark:border-[hsl(222.34deg_10.43%_16%)]">
<div class="text-center">
<div class="text-xs font-medium text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">累计推广费</div>
<div class="mt-1 text-lg font-bold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">¥{{ Number(kpi?.totalFeeAmount || 0).toLocaleString() }}</div>
</div>
<div class="text-center">
<div class="text-xs font-medium text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">本月推广费</div>
<div class="mt-1 text-lg font-bold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">¥{{ Number(kpi?.thisMonthFee || 0).toLocaleString() }}</div>
</div>
<div class="text-center">
<div class="text-xs font-medium text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">日均推广费</div>
<div class="mt-1 text-lg font-bold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">¥{{ Number(kpi?.avgDailyFee || 0).toLocaleString() }}</div>
</div>
</div>
<div class="p-4">
<Grid>
<template #action="{ row }: { row: PromotionFeeVO.Info }">
<Space>
<Button size="small" type="primary" @click="handleEdit(row)">编辑</Button>
<Popconfirm title="确定删除?" @confirm="handleDelete(row.id)">
<Button size="small" danger>删除</Button>
</Popconfirm>
</Space>
</template>
</Grid>
</div>
<PromotionFeeFormModal
v-model:open="modalVisible"
:promotion-fee-data="editingData"
@success="gridReloadRef?.()"
/>
</div>
</template>
@@ -0,0 +1,167 @@
<script lang="ts" setup>
import type { VxeGridProps } from '#/adapter/vxe-table';
import type { OrderDTO, OrderVO } from '#/api/ecommerce/order';
import type { ShopVO } from '#/api/ecommerce/shop/types';
import type { PageQueryDTO } from '#/types/common';
import { Button, Input, Space, Tag } from 'ant-design-vue';
import { computed, ref } from 'vue';
import { createIconifyIcon } from '@vben/icons';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { getOrderPageApi } from '#/api/ecommerce/order';
import OrderFormModal from '#/views/ecommerce/order/components/OrderFormModal.vue';
defineOptions({ name: 'ShopOrderCard' });
const PlusIcon = createIconifyIcon('lucide:plus');
const PackageIcon = createIconifyIcon('lucide:package');
const props = defineProps<{
shopId: number;
data?: ShopVO.ShopOrderKpi;
}>();
const kpi = computed(() => props.data);
const gridReloadRef = ref<(() => void) | null>(null);
const searchForm = ref({
platformOrderNo: undefined as string | undefined,
});
const orderModalRef = ref<InstanceType<typeof OrderFormModal> | null>(null);
const gridOptions: VxeGridProps<any> = {
columns: [
{ type: 'seq', title: '序号', width: 60 },
{ field: 'platformOrderNo', title: '平台订单号', minWidth: 160 },
{ field: 'linkProductName', title: '商品名称', minWidth: 140 },
{ field: 'linkSpecName', title: '规格', minWidth: 140 },
{
field: 'quantity', title: '数量', width: 70,
formatter: ({ cellValue }) => String(Number(cellValue || 0)),
},
{
field: 'unitPrice', title: '单价', width: 100,
formatter: ({ cellValue }) => `¥${Number(cellValue || 0).toFixed(2)}`,
},
{
field: 'receivedAmount', title: '实收金额', width: 110,
formatter: ({ cellValue }) => `¥${Number(cellValue || 0).toFixed(2)}`,
},
{ field: 'statusName', title: '状态', width: 100 },
{ field: 'orderTime', title: '下单时间', minWidth: 160 },
{
title: '操作',
width: 80,
fixed: 'right',
slots: { default: 'action' },
},
],
height: 'auto',
maxHeight: 340,
border: true,
stripe: true,
size: 'small',
pagerConfig: { enabled: true, pageSizes: [10, 20, 50] },
proxyConfig: {
ajax: {
query: async ({ page }) => {
const params: PageQueryDTO<OrderDTO.Filters> = {
page: page.currentPage,
pageSize: page.pageSize,
filters: {
shopId: props.shopId || undefined,
platformOrderNo: searchForm.value.platformOrderNo,
},
};
const data = await getOrderPageApi(params);
return { items: data.records, total: data.total };
},
},
},
};
const [Grid, gridApi] = useVbenVxeGrid({
gridOptions,
showSearchForm: false,
});
gridReloadRef.value = () => gridApi.reload();
function handleView(row: OrderVO.Info) {
orderModalRef.value?.open(true, row);
}
function handleImport() {
orderModalRef.value?.open(false);
}
const statusColorMap: Record<string, string> = {
'已付款': 'blue',
'已发货': 'purple',
'已完成': 'green',
'已退款': 'red',
'已取消': 'default',
};
</script>
<template>
<div class="rounded-2xl border border-slate-200/80 bg-white/90 shadow-sm dark:border-[hsl(222.34deg_10.43%_16%)] dark:bg-[hsl(222.34deg_10.43%_12.27%)]">
<!-- 标题栏 + 筛选区(单行) -->
<div class="flex items-center justify-between gap-3 border-b border-slate-100 px-6 py-3 dark:border-[hsl(222.34deg_10.43%_16%)]">
<h3 class="flex shrink-0 items-center gap-2 text-base font-semibold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
<PackageIcon class="h-4 w-4" />
<span>店铺订单</span>
</h3>
<div class="flex items-center gap-2">
<Input
v-model:value="searchForm.platformOrderNo"
placeholder="平台订单号"
class="!w-44"
allow-clear
@change="() => gridReloadRef?.()"
/>
</div>
<Button type="primary" size="small" @click="handleImport">
<template #icon><PlusIcon /></template>
导入订单
</Button>
</div>
<!-- KPI 指标卡 -->
<div class="grid grid-cols-3 gap-4 border-b border-slate-100 px-6 py-4 dark:border-[hsl(222.34deg_10.43%_16%)]">
<div class="text-center">
<div class="text-xs font-medium text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">累计实收金额</div>
<div class="mt-1 text-lg font-bold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">¥{{ Number(kpi?.totalReceivedAmount || 0).toLocaleString() }}</div>
</div>
<div class="text-center">
<div class="text-xs font-medium text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">累计佣金</div>
<div class="mt-1 text-lg font-bold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">¥{{ Number(kpi?.totalCommission || 0).toLocaleString() }}</div>
</div>
<div class="text-center">
<div class="text-xs font-medium text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">累计订单数</div>
<div class="mt-1 text-lg font-bold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">{{ kpi?.totalOrderCount ?? 0 }} 笔</div>
</div>
</div>
<div class="p-4">
<Grid>
<template #statusName="{ row }: { row: OrderVO.Info }">
<Tag :color="statusColorMap[row.statusName] || 'default'">{{ row.statusName }}</Tag>
</template>
<template #action="{ row }: { row: OrderVO.Info }">
<Space>
<Button size="small" type="primary" @click="handleView(row)">查看</Button>
</Space>
</template>
</Grid>
</div>
<OrderFormModal
ref="orderModalRef"
@success="gridReloadRef?.()"
/>
</div>
</template>
@@ -1,164 +0,0 @@
<script lang="ts" setup>
import type { ShopDTO, ShopVO } from '#/api/ecommerce/shop/types';
import { onMounted, ref, watch } from 'vue';
import {
Card,
Col,
DatePicker,
message,
Row,
Space,
Statistic,
} from 'ant-design-vue';
import dayjs from 'dayjs';
import { getShopOverviewApi } from '#/api/ecommerce/shop';
defineOptions({ name: 'ShopStatistics' });
const props = defineProps<Props>();
interface Props {
shopId: number;
}
// 响应式数据
const loading = ref(false);
const customStats = ref<null | ShopVO.Statistics>(null);
const dateRange = ref<[dayjs.Dayjs, dayjs.Dayjs]>([
dayjs().startOf('month'),
dayjs(),
]);
// 格式化金额
function formatCurrency(value: number): string {
return `¥${value.toLocaleString('zh-CN', {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
})}`;
}
// 格式化百分比
function formatPercent(value: number): string {
return `${(value * 100).toFixed(2)}%`;
}
// 从 Overview 中提取统计信息
function extractStatistics(overview: ShopVO.Overview): ShopVO.Statistics {
return {
salesAmount: overview.salesAmount.total,
orderCount: overview.orderCount.total,
averageOrderValue: overview.averageOrderValue.total,
costAmount: overview.costAmount.total,
refundAmount: overview.refundAmount.total,
promotionFee: overview.promotionFee.total,
feeRatio: overview.feeRatio.total,
};
}
// 获取店铺总览数据
async function fetchShopOverview() {
if (!props.shopId || !dateRange.value) return;
try {
loading.value = true;
const params: ShopDTO.StatisticsQuery = {
shopId: props.shopId,
startDate: dateRange.value[0].format('YYYY-MM-DD'),
endDate: dateRange.value[1].format('YYYY-MM-DD'),
};
const data = await getShopOverviewApi(params);
customStats.value = extractStatistics(data);
} catch (error) {
console.error('获取店铺总览失败:', error);
message.error('获取店铺总览失败');
} finally {
loading.value = false;
}
}
// 处理日期范围变化
function handleDateRangeChange() {
fetchShopOverview();
}
// 监听 shopId 变化
watch(
() => props.shopId,
(newShopId) => {
if (newShopId) {
fetchShopOverview();
}
},
);
// 初始化数据
onMounted(() => {
if (props.shopId) {
fetchShopOverview();
}
});
</script>
<template>
<Card title="店铺统计信息" :loading="loading" class="mb-4 flex-shrink-0">
<div class="mb-4">
<Space>
<span>选择日期范围:</span>
<DatePicker.RangePicker
v-model:value="dateRange"
format="YYYY-MM-DD"
@change="handleDateRangeChange"
/>
</Space>
</div>
<Row :gutter="16" v-if="customStats">
<Col :span="6">
<Statistic
title="销售额"
:value="customStats.salesAmount"
:formatter="({ value }) => formatCurrency(value as number)"
/>
</Col>
<Col :span="6">
<Statistic title="订单数" :value="customStats.orderCount" />
</Col>
<Col :span="6">
<Statistic
title="客单价"
:value="customStats.averageOrderValue"
:formatter="({ value }) => formatCurrency(value as number)"
/>
</Col>
<Col :span="6">
<Statistic
title="成本"
:value="customStats.costAmount"
:formatter="({ value }) => formatCurrency(value as number)"
/>
</Col>
<Col :span="6" class="mt-4">
<Statistic
title="退款金额"
:value="customStats.refundAmount"
:formatter="({ value }) => formatCurrency(value as number)"
/>
</Col>
<Col :span="6" class="mt-4">
<Statistic
title="推广费"
:value="customStats.promotionFee"
:formatter="({ value }) => formatCurrency(value as number)"
/>
</Col>
<Col :span="6" class="mt-4">
<Statistic
title="费比"
:value="customStats.feeRatio"
:formatter="({ value }) => formatPercent(value as number)"
/>
</Col>
</Row>
</Card>
</template>
@@ -1,41 +1,79 @@
<script lang="ts" setup>
import { computed, ref } from 'vue';
import { computed, onMounted, ref } from 'vue';
import { useRoute } from 'vue-router';
import { Page } from '@vben/common-ui';
import { Tabs } from 'ant-design-vue';
import { message } from 'ant-design-vue';
import OverviewTab from './tabs/OverviewTab.vue';
import ProductsTab from './tabs/ProductsTab.vue';
import { getShopDetailsApi } from '#/api/ecommerce/shop';
import type { ShopVO } from '#/api/ecommerce/shop/types';
import MonthlyTargetCard from './components/MonthlyTargetCard.vue';
import PromotionFeeCard from './components/PromotionFeeCard.vue';
import BrushOrderCard from './components/BrushOrderCard.vue';
import ShopOrderCard from './components/ShopOrderCard.vue';
defineOptions({ name: 'ShopDetails' });
const route = useRoute();
// 店铺ID(从路由参数获取)
const shopId = computed(() => {
const id = route.params.id;
return id ? Number(id) : 0;
});
// 当前激活的 tab
const activeKey = ref('overview');
const loading = ref(false);
const dashboard = ref<ShopVO.Dashboard | null>(null);
async function fetchDashboard() {
if (!shopId.value) return;
loading.value = true;
try {
dashboard.value = await getShopDetailsApi({ shopId: shopId.value });
} catch {
message.error('获取店铺看板数据失败');
} finally {
loading.value = false;
}
}
onMounted(() => {
fetchDashboard();
});
</script>
<template>
<Page auto-content-height content-class="flex flex-col">
<Tabs
v-model:active-key="activeKey"
class="flex min-h-0 flex-1 flex-col"
:tab-bar-style="{ marginBottom: '16px' }"
>
<Tabs.TabPane key="overview" tab="总览">
<OverviewTab :shop-id="shopId" />
</Tabs.TabPane>
<Tabs.TabPane key="products" tab="商品">
<ProductsTab :shop-id="shopId" />
</Tabs.TabPane>
</Tabs>
<Page
:title="dashboard ? `店铺详情(${dashboard.shopInfo?.name})` : '店铺详情'"
auto-content-height
content-class="flex min-h-0 flex-1 flex-col bg-[#f8fafc] dark:bg-[hsl(222.34deg_10.43%_12.27%)]"
>
<div class="mx-auto grid w-full grid-cols-1 gap-6 md:grid-cols-2">
<!-- 月度目标 -->
<MonthlyTargetCard
v-if="dashboard"
:shop-id="shopId"
:data="dashboard.monthlyTarget"
/>
<!-- 推广费 -->
<PromotionFeeCard
v-if="dashboard"
:shop-id="shopId"
:data="dashboard.promotionFee"
/>
<!-- 刷单费 -->
<BrushOrderCard
v-if="dashboard"
:shop-id="shopId"
:data="dashboard.brushOrder"
/>
<!-- 店铺订单 -->
<ShopOrderCard
v-if="dashboard"
:shop-id="shopId"
:data="dashboard.shopOrder"
/>
</div>
</Page>
</template>
@@ -1,178 +0,0 @@
<script lang="ts" setup>
import type { ShopDTO, ShopVO } from '#/api/ecommerce/shop/types';
import { onMounted, ref, watch } from 'vue';
import { Card, Col, DatePicker, message, Row, Space } from 'ant-design-vue';
import dayjs from 'dayjs';
import { getShopOverviewApi } from '#/api/ecommerce/shop';
import ChartCard from '../components/ChartCard.vue';
defineOptions({ name: 'OverviewTab' });
const props = defineProps<Props>();
interface Props {
shopId: number;
}
// 响应式数据
const loading = ref(false);
const overviewData = ref<null | ShopVO.Overview>(null);
const dateRange = ref<[dayjs.Dayjs, dayjs.Dayjs]>([
dayjs().subtract(30, 'day'),
dayjs(),
]);
// 格式化金额
function formatCurrency(value: number): string {
return `¥${value.toLocaleString('zh-CN', {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
})}`;
}
// 格式化百分比
function formatPercent(value: number): string {
return `${(value * 100).toFixed(2)}%`;
}
// 获取店铺总览数据
async function fetchShopOverview() {
if (!props.shopId || !dateRange.value) return;
try {
loading.value = true;
const params: ShopDTO.StatisticsQuery = {
shopId: props.shopId,
startDate: dateRange.value[0].format('YYYY-MM-DD'),
endDate: dateRange.value[1].format('YYYY-MM-DD'),
};
const data = await getShopOverviewApi(params);
overviewData.value = data;
} catch (error) {
console.error('获取店铺总览失败:', error);
message.error('获取店铺总览失败');
} finally {
loading.value = false;
}
}
// 处理日期范围变化
function handleDateRangeChange() {
fetchShopOverview();
}
// 监听 shopId 变化
watch(
() => props.shopId,
(newShopId) => {
if (newShopId) {
fetchShopOverview();
}
},
);
// 初始化数据
onMounted(() => {
if (props.shopId) {
fetchShopOverview();
}
});
</script>
<template>
<div class="flex h-full flex-col">
<!-- 日期选择器 -->
<Card :loading="loading" class="mb-4 flex-shrink-0">
<Space>
<span>选择日期范围:</span>
<DatePicker.RangePicker
v-model:value="dateRange"
format="YYYY-MM-DD"
@change="handleDateRangeChange"
/>
</Space>
</Card>
<!-- 图表展示 -->
<div v-if="overviewData" class="min-h-0 flex-1 overflow-auto">
<Row :gutter="[16, 16]">
<!-- 销售额 -->
<Col :lg="12" :md="24" :sm="24" :xl="8" :xxl="8" :xs="24">
<ChartCard
:data="overviewData.salesAmount"
:formatter="formatCurrency"
title="销售额"
/>
</Col>
<!-- 订单数 -->
<Col :lg="12" :md="24" :sm="24" :xl="8" :xxl="8" :xs="24">
<ChartCard
:data="overviewData.orderCount"
chart-type="bar"
color="#019680"
title="订单数"
/>
</Col>
<!-- 客单价 -->
<Col :lg="12" :md="24" :sm="24" :xl="8" :xxl="8" :xs="24">
<ChartCard
:data="overviewData.averageOrderValue"
:formatter="formatCurrency"
color="#ff9800"
title="客单价"
/>
</Col>
<!-- 成本 -->
<Col :lg="12" :md="24" :sm="24" :xl="8" :xxl="8" :xs="24">
<ChartCard
:data="overviewData.costAmount"
:formatter="formatCurrency"
color="#f56c6c"
title="成本"
/>
</Col>
<!-- 退款金额 -->
<Col :lg="12" :md="24" :sm="24" :xl="8" :xxl="8" :xs="24">
<ChartCard
:data="overviewData.refundAmount"
:formatter="formatCurrency"
color="#e6a23c"
title="退款金额"
/>
</Col>
<!-- 推广费 -->
<Col :lg="12" :md="24" :sm="24" :xl="8" :xxl="8" :xs="24">
<ChartCard
:data="overviewData.promotionFee"
:formatter="formatCurrency"
color="#909399"
title="推广费"
/>
</Col>
<!-- 费比 -->
<Col :lg="12" :md="24" :sm="24" :xl="8" :xxl="8" :xs="24">
<ChartCard
:data="overviewData.feeRatio"
:formatter="formatPercent"
color="#67c23a"
title="费比"
/>
</Col>
</Row>
</div>
<!-- 空状态 -->
<div v-else class="flex flex-1 items-center justify-center">
<span class="text-gray-400">暂无数据</span>
</div>
</div>
</template>
@@ -1,214 +0,0 @@
<script lang="ts" setup>
import type { VxeGridProps } from '#/adapter/vxe-table';
import type { ShopDTO } from '#/api/ecommerce/shop/types';
import type { PageQueryDTO } from '#/types/common';
import { computed, ref, watch } from 'vue';
import { Page } from '@vben/common-ui';
import { Image, message, Tag } from 'ant-design-vue';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { getShopProductPageApi } from '#/api/ecommerce/shop';
interface Props {
shopId: number;
}
defineOptions({ name: 'ProductsTab' });
const props = defineProps<Props>();
// 响应式数据
const loading = ref(false);
// VbenVxeGrid 表格配置
const gridOptions: VxeGridProps<any> = {
columns: [
{
type: 'seq' as const,
minWidth: 'auto',
title: '序号',
},
{
title: '主图',
width: 60,
slots: { default: 'mainImage' },
},
{
field: 'name',
title: '商品名称',
minWidth: 200,
showOverflow: 'tooltip' as const,
},
{
field: 'productCode',
title: '商品编码',
minWidth: 150,
showOverflow: 'tooltip' as const,
},
{
title: '规格数量',
minWidth: 100,
slots: { default: 'specs' },
},
{
field: 'createTime',
title: '创建时间',
minWidth: 180,
},
{
field: 'updateTime',
title: '更新时间',
minWidth: 180,
},
],
height: 'auto',
border: true,
stripe: true,
rowConfig: { isHover: true },
showOverflow: true,
size: 'small',
toolbarConfig: {
custom: true,
refresh: true,
zoom: true,
},
data: [],
pagerConfig: {
enabled: true,
pageSizes: [10, 20, 50, 100],
layouts: [
'PrevJump',
'PrevPage',
'Number',
'NextPage',
'NextJump',
'Sizes',
'FullJump',
'Total',
] as (
| 'FullJump'
| 'NextJump'
| 'NextPage'
| 'Number'
| 'PrevJump'
| 'PrevPage'
| 'Sizes'
| 'Total'
)[],
},
// 配置远程加载
proxyConfig: {
ajax: {
query: async ({ page }) => {
if (!props.shopId) {
return {
items: [],
total: 0,
};
}
try {
loading.value = true;
const params: PageQueryDTO<ShopDTO.ProductPageFilters> = {
page: page.currentPage,
pageSize: page.pageSize,
filters: {
shopId: props.shopId,
},
};
const data = await getShopProductPageApi(params);
return {
items: data.records,
total: data.total,
};
} catch (error) {
console.error('获取商品列表失败:', error);
message.error('获取商品列表失败');
return {
items: [],
total: 0,
};
} finally {
loading.value = false;
}
},
},
},
};
// 搜索表单配置
const gridReloadRef = ref<(() => void) | null>(null);
const formOptions = computed(() => ({
schema: [
{
component: 'Input',
componentProps: {
placeholder: '请输入商品名称(回车搜索)',
onPressEnter: () => gridReloadRef.value?.(),
},
fieldName: 'name',
label: '商品名称',
},
{
component: 'Input',
componentProps: {
placeholder: '请输入商品编码(回车搜索)',
onPressEnter: () => gridReloadRef.value?.(),
},
fieldName: 'productCode',
label: '商品编码',
},
],
showDefaultActions: true,
collapsed: true,
collapsedRows: 1,
}));
// 创建 VbenVxeGrid 实例
const [Grid, gridApi] = useVbenVxeGrid({
gridOptions,
formOptions: formOptions.value,
showSearchForm: true,
tableTitle: '商品列表',
});
gridReloadRef.value = () => gridApi.reload();
// 监听 shopId 变化,刷新表格
watch(
() => props.shopId,
() => {
if (props.shopId && gridApi) {
gridApi.reload();
}
},
);
</script>
<template>
<Page auto-content-height content-class="flex flex-col">
<Grid :loading="loading">
<!-- 主图列 -->
<template #mainImage="{ row }: { row: any }">
<Image
v-if="row.mainImage"
:src="row.mainImage"
:alt="row.name"
width="60"
height="60"
style="object-fit: cover; border-radius: 4px"
:preview="true"
/>
<span v-else class="text-xs text-gray-400">暂无图片</span>
</template>
<!-- 规格数量列 -->
<template #specs="{ row }: { row: any }">
<Tag :color="(row.specs?.length || 0) > 0 ? 'blue' : 'default'">
{{ row.specs?.length || 0 }} 个规格
</Tag>
</template>
</Grid>
</Page>
</template>
@@ -288,6 +288,9 @@ function handleViewOverview(record: ShopVO.Info) {
<Button size="small" type="primary" @click="handleViewOverview(row)">
查看概览
</Button>
<Button size="small" @click="router.push(`/ecom/shop/details/${row.id}`)">
查看详情
</Button>
<Button size="small" @click="handleEdit(row)"> 编辑 </Button>
<Popconfirm
title="确定要删除这个店铺吗?"
+1
View File
@@ -119,6 +119,7 @@
]
},
"dependencies": {
"@ant-design/icons-vue": "^7.0.1",
"xlsx": "^0.18.5"
}
}
+3
View File
@@ -499,6 +499,9 @@ importers:
.:
dependencies:
'@ant-design/icons-vue':
specifier: ^7.0.1
version: 7.0.1(vue@3.5.17(typescript@5.8.3))
xlsx:
specifier: ^0.18.5
version: 0.18.5