mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 14:29:19 +08:00
refactor: 重构订单,店铺,商品
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
/**
|
||||
* 刷单记录相关DTO类型定义
|
||||
* 刷单记录相关 DTO 类型定义
|
||||
*/
|
||||
|
||||
export namespace BrushOrderDTO {
|
||||
/** 创建刷单记录参数 */
|
||||
export interface Create {
|
||||
/** 店铺ID */
|
||||
/** 店铺 ID */
|
||||
shopId: number;
|
||||
/** 商品ID(可选) */
|
||||
/** 商品 ID(可选) */
|
||||
productId?: number;
|
||||
/** 商品规格ID(可选) */
|
||||
productSpecId?: number;
|
||||
/** 商品 SKU ID(可选) */
|
||||
productSkuId?: number;
|
||||
/** 刷单金额 */
|
||||
brushAmount: number;
|
||||
/** 刷单时间 */
|
||||
@@ -23,12 +23,12 @@ export namespace BrushOrderDTO {
|
||||
|
||||
/** 更新刷单记录参数 */
|
||||
export interface Update {
|
||||
/** 店铺ID */
|
||||
/** 店铺 ID */
|
||||
shopId: number;
|
||||
/** 商品ID(可选) */
|
||||
/** 商品 ID(可选) */
|
||||
productId?: number;
|
||||
/** 商品规格ID(可选) */
|
||||
productSpecId?: number;
|
||||
/** 商品 SKU ID(可选) */
|
||||
productSkuId?: number;
|
||||
/** 刷单金额 */
|
||||
brushAmount: number;
|
||||
/** 刷单时间 */
|
||||
@@ -41,9 +41,9 @@ export namespace BrushOrderDTO {
|
||||
|
||||
/** 刷单记录过滤条件 */
|
||||
export interface Filters {
|
||||
/** 店铺ID */
|
||||
/** 店铺 ID */
|
||||
shopId?: number;
|
||||
/** 商品ID */
|
||||
/** 商品 ID */
|
||||
productId?: number;
|
||||
/** 平台订单号(模糊查询) */
|
||||
platformOrderNo?: string;
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
/**
|
||||
* 刷单记录相关VO类型定义
|
||||
* 刷单记录相关 VO 类型定义
|
||||
*/
|
||||
|
||||
export namespace BrushOrderVO {
|
||||
/** 刷单记录信息 */
|
||||
export interface Info {
|
||||
/** 刷单记录ID */
|
||||
/** 刷单记录 ID */
|
||||
id: number;
|
||||
/** 公司ID */
|
||||
/** 公司 ID */
|
||||
companyId: number;
|
||||
/** 店铺ID */
|
||||
/** 店铺 ID */
|
||||
shopId: number;
|
||||
/** 店铺名称 */
|
||||
shopName: string;
|
||||
/** 商品ID */
|
||||
/** 商品 ID */
|
||||
productId?: number;
|
||||
/** 商品名称 */
|
||||
productName?: string;
|
||||
/** 商品规格ID */
|
||||
productSpecId?: number;
|
||||
/** 商品规格名称 */
|
||||
productSpecName?: string;
|
||||
/** 商品 SKU ID */
|
||||
productSkuId?: number;
|
||||
/** 商品 SKU 名称 */
|
||||
productSkuName?: string;
|
||||
/** 刷单金额 */
|
||||
brushAmount: number;
|
||||
/** 刷单时间 */
|
||||
@@ -33,9 +33,9 @@ export namespace BrushOrderVO {
|
||||
createTime: string;
|
||||
/** 更新时间 */
|
||||
updateTime: string;
|
||||
/** 创建人ID */
|
||||
/** 创建人 ID */
|
||||
createBy?: number;
|
||||
/** 更新人ID */
|
||||
/** 更新人 ID */
|
||||
updateBy?: number;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,64 +1,12 @@
|
||||
import type { OrderStatusDTO, OrderStatusVO } from './types';
|
||||
import type { OrderStatusVO } from './types';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
/**
|
||||
* 订单状态管理API
|
||||
* 订单状态静态字典 API(无 CRUD)。
|
||||
*/
|
||||
|
||||
/**
|
||||
* 创建订单状态
|
||||
*/
|
||||
export async function createOrderStatusApi(data: OrderStatusDTO.Create) {
|
||||
return requestClient.post<OrderStatusVO.Info>(
|
||||
'/ec/order-status/create',
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新订单状态
|
||||
*/
|
||||
export async function updateOrderStatusApi(
|
||||
id: number,
|
||||
data: OrderStatusDTO.Update,
|
||||
) {
|
||||
return requestClient.put<OrderStatusVO.Info>(
|
||||
`/ec/order-status/update/${id}`,
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 部分更新订单状态(统计维度开关,字段可选)
|
||||
*/
|
||||
export async function patchOrderStatusApi(
|
||||
id: number,
|
||||
data: OrderStatusDTO.Patch,
|
||||
) {
|
||||
return requestClient.request<OrderStatusVO.Info>(
|
||||
`/ec/order-status/update/${id}`,
|
||||
{ data, method: 'PATCH' },
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除订单状态
|
||||
*/
|
||||
export async function deleteOrderStatusApi(id: number) {
|
||||
return requestClient.delete(`/ec/order-status/delete/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有订单状态列表
|
||||
*/
|
||||
/** 获取全部订单状态元数据列表 */
|
||||
export async function getAllOrderStatusListApi() {
|
||||
return requestClient.get<OrderStatusVO.Info[]>('/ec/order-status/list');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单状态详情
|
||||
*/
|
||||
export async function getOrderStatusByIdApi(id: number) {
|
||||
return requestClient.get<OrderStatusVO.Info>(`/ec/order-status/detail/${id}`);
|
||||
return requestClient.get<OrderStatusVO.Meta[]>('/ec/order-status/list');
|
||||
}
|
||||
|
||||
@@ -1,58 +1,2 @@
|
||||
/**
|
||||
* 订单状态相关DTO类型定义
|
||||
*/
|
||||
|
||||
export namespace OrderStatusDTO {
|
||||
/** 创建订单状态参数 */
|
||||
export interface Create {
|
||||
/** 状态名称(中文) */
|
||||
statusName: string;
|
||||
/** 状态描述 */
|
||||
description?: string;
|
||||
/** 状态颜色(十六进制,如 #1890ff) */
|
||||
color?: string;
|
||||
/** 排序 */
|
||||
sortOrder?: number;
|
||||
/** 是否计入销售额/单量等统计 0否 1是 */
|
||||
includeSalesAmount?: number;
|
||||
/** 是否计入商品成本统计 0否 1是 */
|
||||
includeProductCost?: number;
|
||||
/** 是否计入运费成本统计 0否 1是 */
|
||||
includeFreightCost?: number;
|
||||
/** 是否计入其他成本统计 0否 1是 */
|
||||
includeOtherCost?: number;
|
||||
/** 是否计入退款金额统计 0否 1是 */
|
||||
includeRefund?: number;
|
||||
}
|
||||
|
||||
/** 更新订单状态参数 */
|
||||
export interface Update {
|
||||
/** 状态名称(中文) */
|
||||
statusName: string;
|
||||
/** 状态描述 */
|
||||
description?: string;
|
||||
/** 状态颜色(十六进制,如 #1890ff) */
|
||||
color?: string;
|
||||
/** 排序 */
|
||||
sortOrder?: number;
|
||||
/** 是否计入销售额/单量等统计 0否 1是 */
|
||||
includeSalesAmount: number;
|
||||
/** 是否计入商品成本统计 0否 1是 */
|
||||
includeProductCost: number;
|
||||
/** 是否计入运费成本统计 0否 1是 */
|
||||
includeFreightCost: number;
|
||||
/** 是否计入其他成本统计 0否 1是 */
|
||||
includeOtherCost: number;
|
||||
/** 是否计入退款金额统计 0否 1是 */
|
||||
includeRefund: number;
|
||||
}
|
||||
|
||||
/** PATCH 部分更新(任意字段可选,与后端 PatchOrderStatusDTO 对齐) */
|
||||
export interface Patch {
|
||||
includeSalesAmount?: number;
|
||||
includeProductCost?: number;
|
||||
includeFreightCost?: number;
|
||||
includeOtherCost?: number;
|
||||
includeRefund?: number;
|
||||
}
|
||||
}
|
||||
/** 订单状态模块已无写操作 DTO,保留空命名空间供扩展 */
|
||||
export namespace OrderStatusDTO {}
|
||||
|
||||
@@ -1,39 +1,18 @@
|
||||
/**
|
||||
* 订单状态相关VO类型定义
|
||||
* 订单状态静态字典 VO
|
||||
*/
|
||||
|
||||
export namespace OrderStatusVO {
|
||||
/** 订单状态信息 */
|
||||
export interface Info {
|
||||
/** 订单状态ID */
|
||||
id: number;
|
||||
/** 公司ID */
|
||||
companyId?: number;
|
||||
/** 状态名称(中文) */
|
||||
statusName: string;
|
||||
/** 状态描述 */
|
||||
description?: string;
|
||||
/** 状态颜色(十六进制,如 #1890ff) */
|
||||
/** 订单状态元数据(code/label/color…) */
|
||||
export interface Meta {
|
||||
code: string;
|
||||
label: string;
|
||||
color?: string;
|
||||
/** 排序 */
|
||||
sortOrder?: number;
|
||||
/** 是否计入销售额/单量等统计 0否 1是 */
|
||||
includeSalesAmount: number;
|
||||
/** 是否计入商品成本统计 0否 1是 */
|
||||
includeProductCost: number;
|
||||
/** 是否计入运费成本统计 0否 1是 */
|
||||
includeFreightCost: number;
|
||||
/** 是否计入其他成本统计 0否 1是 */
|
||||
includeOtherCost: number;
|
||||
/** 是否计入退款金额统计 0否 1是 */
|
||||
includeRefund: number;
|
||||
/** 创建时间 */
|
||||
createTime: string;
|
||||
/** 更新时间 */
|
||||
updateTime: string;
|
||||
/** 创建人ID */
|
||||
createBy?: number;
|
||||
/** 更新人ID */
|
||||
updateBy?: number;
|
||||
includeSalesAmount: boolean;
|
||||
includeProductCost: boolean;
|
||||
includeFreightCost: boolean;
|
||||
includeOtherCost: boolean;
|
||||
includeRefund: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,37 +1,69 @@
|
||||
/**
|
||||
* 订单相关DTO类型定义
|
||||
* 订单相关 DTO 类型定义
|
||||
*/
|
||||
|
||||
/** 创建/更新订单明细 */
|
||||
export namespace OrderItemDTO {
|
||||
export interface Create {
|
||||
/** 商品规格 ID */
|
||||
productSkuId?: number;
|
||||
/** 规格编码 */
|
||||
skuCode?: string;
|
||||
/** 链接商品名称 */
|
||||
linkProductName: string;
|
||||
/** 链接规格名称 */
|
||||
linkSkuName?: string;
|
||||
/** 数量 */
|
||||
quantity: number;
|
||||
/** 销售单价 */
|
||||
unitPrice?: number;
|
||||
/** 行实收/行销售额 */
|
||||
lineAmount?: number;
|
||||
/** 单件商品成本快照 */
|
||||
productCost?: number;
|
||||
/** 单件运费成本快照 */
|
||||
shippingCost?: number;
|
||||
/** 单件其他成本快照 */
|
||||
otherCost?: number;
|
||||
/** 明细备注 */
|
||||
remark?: string;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace OrderDTO {
|
||||
/** 创建订单参数 */
|
||||
export interface Create {
|
||||
/** 店铺ID */
|
||||
/** 店铺 ID */
|
||||
shopId: number;
|
||||
/** 平台订单号 */
|
||||
platformOrderNo?: string;
|
||||
/** 订单状态ID */
|
||||
statusId: number;
|
||||
/** 商家实收金额 */
|
||||
receivedAmount: number;
|
||||
/** 订单状态码 */
|
||||
status: string;
|
||||
/** 实付/商家实收金额 */
|
||||
payAmount: number;
|
||||
/** 兼容旧字段名(后端 JsonAlias) */
|
||||
receivedAmount?: number;
|
||||
/** 下单时间 */
|
||||
orderTime: string;
|
||||
/** 商品规格ID */
|
||||
productSpecId: number;
|
||||
/** 规格编码(可选,服务端可按规格ID补全) */
|
||||
specCode?: string;
|
||||
/** 链接商品名称(冗余存储) */
|
||||
linkProductName: string;
|
||||
/** 链接规格名称(冗余存储) */
|
||||
linkSpecName?: string;
|
||||
/** 数量 */
|
||||
quantity: number;
|
||||
/** 销售单价 */
|
||||
unitPrice: number;
|
||||
/** 单件商品成本(下单时快照) */
|
||||
productCost: number;
|
||||
/** 单件运费成本(下单时快照) */
|
||||
/** 订单明细(未传时后端用扁平字段合成一行) */
|
||||
items?: OrderItemDTO.Create[];
|
||||
/** 商品规格 ID(扁平导入/表单兼容) */
|
||||
productSkuId?: number;
|
||||
/** SKU 编码 */
|
||||
skuCode?: string;
|
||||
/** 链接商品名称(扁平导入/表单兼容) */
|
||||
linkProductName?: string;
|
||||
/** 链接 SKU 名称(扁平导入/表单兼容) */
|
||||
linkSkuName?: string;
|
||||
/** 数量(扁平导入/表单兼容) */
|
||||
quantity?: number;
|
||||
/** 销售单价(扁平导入/表单兼容) */
|
||||
unitPrice?: number;
|
||||
/** 单件商品成本(扁平导入/表单兼容) */
|
||||
productCost?: number;
|
||||
/** 单件运费成本(扁平导入/表单兼容) */
|
||||
shippingCost?: number;
|
||||
/** 单件其他成本(下单时快照) */
|
||||
/** 单件其他成本(扁平导入/表单兼容) */
|
||||
otherCost?: number;
|
||||
/** 备注 */
|
||||
remark?: string;
|
||||
@@ -39,49 +71,47 @@ export namespace OrderDTO {
|
||||
|
||||
/** 更新订单参数 */
|
||||
export interface Update {
|
||||
/** 店铺ID */
|
||||
/** 店铺 ID */
|
||||
shopId: number;
|
||||
/** 平台订单号 */
|
||||
platformOrderNo?: string;
|
||||
/** 订单状态ID */
|
||||
statusId?: number;
|
||||
/** 商家实收金额 */
|
||||
receivedAmount: number;
|
||||
/** 订单状态码 */
|
||||
status?: string;
|
||||
/** 实付/商家实收金额 */
|
||||
payAmount: number;
|
||||
/** 兼容旧字段名 */
|
||||
receivedAmount?: number;
|
||||
/** 下单时间 */
|
||||
orderTime: string;
|
||||
/** 商品规格ID */
|
||||
productSpecId?: number;
|
||||
/** 规格编码 */
|
||||
specCode?: string;
|
||||
/** 链接商品名称(冗余存储) */
|
||||
/** 订单明细(全量替换) */
|
||||
items?: OrderItemDTO.Create[];
|
||||
/** 扁平字段(未传 items 时合成一行) */
|
||||
productSkuId?: number;
|
||||
skuCode?: string;
|
||||
linkProductName?: string;
|
||||
/** 链接规格名称(冗余存储) */
|
||||
linkSpecName?: string;
|
||||
/** 数量 */
|
||||
linkSkuName?: string;
|
||||
quantity?: number;
|
||||
/** 销售单价 */
|
||||
unitPrice?: number;
|
||||
/** 单件商品成本(下单时快照) */
|
||||
productCost?: number;
|
||||
/** 单件运费成本(下单时快照) */
|
||||
shippingCost?: number;
|
||||
/** 单件其他成本(下单时快照) */
|
||||
otherCost?: number;
|
||||
/** 备注 */
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
/** 订单过滤条件 */
|
||||
export interface Filters {
|
||||
/** 店铺ID */
|
||||
/** 店铺 ID */
|
||||
shopId?: number;
|
||||
/** 平台订单号(默认前缀匹配;含 %/_ 时全模糊) */
|
||||
platformOrderNo?: string;
|
||||
/** 订单状态ID */
|
||||
statusId?: number;
|
||||
/** 实收金额范围-最小值 */
|
||||
/** 订单状态码 */
|
||||
status?: string;
|
||||
/** 实付金额范围-最小值 */
|
||||
minPayAmount?: number;
|
||||
/** 实付金额范围-最大值 */
|
||||
maxPayAmount?: number;
|
||||
/** 兼容旧字段名 */
|
||||
minReceivedAmount?: number;
|
||||
/** 实收金额范围-最大值 */
|
||||
maxReceivedAmount?: number;
|
||||
/** 确认状态(0 未确认 / 1 已确认) */
|
||||
confirm?: number;
|
||||
@@ -89,7 +119,7 @@ export namespace OrderDTO {
|
||||
startOrderTime?: string;
|
||||
/** 下单时间范围-结束时间 */
|
||||
endOrderTime?: string;
|
||||
/** 商品ID */
|
||||
/** 商品 ID */
|
||||
productId?: number;
|
||||
}
|
||||
|
||||
@@ -101,7 +131,7 @@ export namespace OrderDTO {
|
||||
|
||||
/** 批量删除订单参数 */
|
||||
export interface BatchDelete {
|
||||
/** 订单ID列表 */
|
||||
/** 订单 ID 列表 */
|
||||
orderIds: number[];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,74 +1,113 @@
|
||||
/**
|
||||
* 订单相关VO类型定义
|
||||
* 订单相关 VO 类型定义
|
||||
*/
|
||||
|
||||
import type { OrderStatusVO } from '#/api/ecommerce/order-status/types';
|
||||
import type { ProductSpecVO } from '#/api/ecommerce/product-spec/types';
|
||||
import type { ProductSkuVO } from '#/api/ecommerce/product-sku/types';
|
||||
import type { ProductVO } from '#/api/ecommerce/product/types';
|
||||
import type { ShopVO } from '#/api/ecommerce/shop/types';
|
||||
|
||||
export namespace OrderVO {
|
||||
/** 订单信息 */
|
||||
/** 订单明细行 */
|
||||
export namespace OrderItemVO {
|
||||
export interface Info {
|
||||
/** 订单ID */
|
||||
/** 明细 ID */
|
||||
id?: number;
|
||||
/** 行号 */
|
||||
lineNo?: number;
|
||||
/** 商品 ID */
|
||||
productId?: number;
|
||||
/** 商品规格 ID */
|
||||
productSkuId?: number;
|
||||
/** 规格编码 */
|
||||
skuCode?: string;
|
||||
/** 链接商品名称 */
|
||||
linkProductName: string;
|
||||
/** 链接规格名称 */
|
||||
linkSkuName?: string;
|
||||
/** 商品图片 URL */
|
||||
goodsImg?: string;
|
||||
/** 数量 */
|
||||
quantity: number;
|
||||
/** 销售单价 */
|
||||
unitPrice?: number;
|
||||
/** 行实收/行销售额 */
|
||||
lineAmount?: number;
|
||||
/** 单件商品成本快照 */
|
||||
productCost?: number;
|
||||
/** 单件运费成本快照 */
|
||||
shippingCost?: number;
|
||||
/** 单件其他成本快照 */
|
||||
otherCost?: number;
|
||||
/** 明细备注 */
|
||||
remark?: string;
|
||||
/** 关联商品 */
|
||||
product?: ProductVO.Info;
|
||||
/** 关联规格 */
|
||||
productSku?: ProductSkuVO.Info;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace OrderVO {
|
||||
/** 订单信息(主表 + 明细列表) */
|
||||
export interface Info {
|
||||
/** 订单 ID */
|
||||
id: number;
|
||||
/** 公司ID */
|
||||
/** 公司 ID */
|
||||
companyId: number;
|
||||
/** 店铺ID */
|
||||
/** 店铺 ID */
|
||||
shopId: number;
|
||||
/** 店铺名称 */
|
||||
shopName: string;
|
||||
/** 平台代码 */
|
||||
platformCode?: string;
|
||||
/** 平台订单号 */
|
||||
platformOrderNo: string;
|
||||
/** 订单状态ID */
|
||||
statusId: number;
|
||||
/** 订单状态名称(中文) */
|
||||
statusName: string;
|
||||
/** 商家实收金额 */
|
||||
receivedAmount: number;
|
||||
/** 订单状态码(如 PENDING_SHIPMENT) */
|
||||
status: string;
|
||||
/** 订单状态中文名 */
|
||||
statusLabel: string;
|
||||
/** 订单状态展示色 */
|
||||
statusColor?: string;
|
||||
/** 来源 */
|
||||
source?: string;
|
||||
/** 实付/商家实收金额 */
|
||||
payAmount: number;
|
||||
/** 兼容旧字段名(后端 JSON 别名) */
|
||||
receivedAmount?: number;
|
||||
/** 商品金额合计 */
|
||||
goodsAmount?: number;
|
||||
/** 折扣金额合计 */
|
||||
discountAmount?: number;
|
||||
/** 邮费 */
|
||||
postage?: number;
|
||||
/** 下单时间 */
|
||||
orderTime: string;
|
||||
/** 创建时间 */
|
||||
createTime: string;
|
||||
/** 更新时间 */
|
||||
updateTime: string;
|
||||
/** 创建人ID */
|
||||
/** 创建人 ID */
|
||||
createBy?: number;
|
||||
/** 更新人ID */
|
||||
/** 更新人 ID */
|
||||
updateBy?: number;
|
||||
/** 商品规格ID */
|
||||
productSpecId?: number;
|
||||
/** 规格编码 */
|
||||
specCode?: string;
|
||||
/** 链接商品名称(冗余存储) */
|
||||
linkProductName: string;
|
||||
/** 链接规格名称(冗余存储) */
|
||||
linkSpecName?: string;
|
||||
/** 数量 */
|
||||
quantity: number;
|
||||
/** 销售单价 */
|
||||
unitPrice: number;
|
||||
/** 单件商品成本(下单时快照) */
|
||||
productCost: number;
|
||||
/** 单件运费成本(下单时快照) */
|
||||
shippingCost?: number;
|
||||
/** 单件其他成本(下单时快照) */
|
||||
otherCost?: number;
|
||||
/** 备注 */
|
||||
remark?: string;
|
||||
/** 关联商品信息 */
|
||||
product?: ProductVO.Info;
|
||||
/** 关联商品规格信息 */
|
||||
productSpec?: ProductSpecVO.Info;
|
||||
/** 关联订单状态信息 */
|
||||
orderStatus?: OrderStatusVO.Info;
|
||||
/** 导入任务 ID */
|
||||
importTaskId?: number;
|
||||
/** 确认(0-否 1-是) */
|
||||
confirm?: number;
|
||||
/** 明细行数(列表汇总) */
|
||||
itemCount?: number;
|
||||
/** 首行链接商品名(列表汇总) */
|
||||
firstLinkProductName?: string;
|
||||
/** 订单明细 */
|
||||
items?: OrderItemVO.Info[];
|
||||
/** 关联店铺信息 */
|
||||
shop?: ShopVO.Info;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单字段信息VO
|
||||
* 订单字段信息 VO(导入映射;fieldName 仍用 received_amount,后端映射 payAmount)
|
||||
*/
|
||||
export namespace OrderFieldVO {
|
||||
/** 订单字段信息 */
|
||||
@@ -89,7 +128,7 @@ export namespace OrderFieldVO {
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量导入结果相关VO类型定义
|
||||
* 批量导入结果相关 VO 类型定义
|
||||
*/
|
||||
|
||||
export namespace BatchImportResultVO {
|
||||
|
||||
@@ -1,49 +1,12 @@
|
||||
import type { PlatformDTO, PlatformVO } from './types';
|
||||
|
||||
import type { PageQueryDTO, PageResultVO } from '#/types/common';
|
||||
import type { PlatformVO } from './types';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
/**
|
||||
* 平台管理API
|
||||
* 平台静态字典 API(无 CRUD)。
|
||||
*/
|
||||
|
||||
/**
|
||||
* 分页获取平台列表
|
||||
*/
|
||||
export async function getPlatformPageApi(
|
||||
params: PageQueryDTO<PlatformDTO.Filters>,
|
||||
) {
|
||||
return requestClient.post<PageResultVO<PlatformVO.Info>>(
|
||||
'/ec/platform/list',
|
||||
params,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建平台
|
||||
*/
|
||||
export async function createPlatformApi(data: PlatformDTO.Create) {
|
||||
return requestClient.post<PlatformVO.Info>('/ec/platform/create', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新平台
|
||||
*/
|
||||
export async function updatePlatformApi(id: number, data: PlatformDTO.Update) {
|
||||
return requestClient.put<PlatformVO.Info>(`/ec/platform/update/${id}`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除平台
|
||||
*/
|
||||
export async function deletePlatformApi(id: number) {
|
||||
return requestClient.delete(`/ec/platform/delete/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有启用的平台列表
|
||||
*/
|
||||
export async function getActivePlatformsApi() {
|
||||
return requestClient.get<PlatformVO.Info[]>('/ec/platform/active');
|
||||
/** 获取全部预置电商平台字典 */
|
||||
export async function getPlatformListApi() {
|
||||
return requestClient.get<PlatformVO.Meta[]>('/ec/platform/list');
|
||||
}
|
||||
|
||||
@@ -1,30 +1,2 @@
|
||||
export namespace PlatformDTO {
|
||||
/**
|
||||
* 创建平台
|
||||
*/
|
||||
export interface Create {
|
||||
platformName: string;
|
||||
platformCode: string;
|
||||
sortOrder?: number;
|
||||
isActive?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新平台
|
||||
*/
|
||||
export interface Update {
|
||||
platformName: string;
|
||||
platformCode: string;
|
||||
sortOrder: number;
|
||||
isActive: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤条件
|
||||
*/
|
||||
export interface Filters {
|
||||
platformName?: string;
|
||||
platformCode?: string;
|
||||
isActive?: number;
|
||||
}
|
||||
}
|
||||
/** 平台模块已无写操作 DTO,保留空命名空间供扩展 */
|
||||
export namespace PlatformDTO {}
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
export namespace PlatformVO {
|
||||
/**
|
||||
* 平台信息
|
||||
*/
|
||||
export interface Info {
|
||||
id: number;
|
||||
platformName: string;
|
||||
platformCode: string;
|
||||
/** 平台静态字典项(code/label/sortOrder) */
|
||||
export interface Meta {
|
||||
code: string;
|
||||
label: string;
|
||||
sortOrder: number;
|
||||
isActive: number;
|
||||
createTime: string;
|
||||
updateTime: string;
|
||||
}
|
||||
}
|
||||
|
||||
+31
-31
@@ -15,28 +15,28 @@ export namespace ProductOverviewVO {
|
||||
dailyDataList: TrendDataItem[];
|
||||
}
|
||||
|
||||
/** 规格销量排名项 */
|
||||
export interface SpecSalesRankItem {
|
||||
/** 规格ID */
|
||||
specId?: number;
|
||||
/** 规格名称 */
|
||||
specName?: string;
|
||||
/** 规格编码 */
|
||||
specCode?: string;
|
||||
/** SKU 销量排名项 */
|
||||
export interface SkuSalesRankItem {
|
||||
/** SKU ID */
|
||||
skuId?: number;
|
||||
/** SKU 名称 */
|
||||
skuName?: string;
|
||||
/** SKU 编码 */
|
||||
skuCode?: string;
|
||||
/** 订单量 */
|
||||
orderCount?: number;
|
||||
/** 销售额 */
|
||||
salesAmount?: number;
|
||||
}
|
||||
|
||||
/** 规格销售明细项 */
|
||||
export interface SpecSummaryItem {
|
||||
/** 规格ID */
|
||||
specId: number;
|
||||
/** 规格名称 */
|
||||
specName: string;
|
||||
/** 规格编码 */
|
||||
specCode: string;
|
||||
/** SKU 销售明细项 */
|
||||
export interface SkuSummaryItem {
|
||||
/** SKU ID */
|
||||
skuId: number;
|
||||
/** SKU 名称 */
|
||||
skuName: string;
|
||||
/** SKU 编码 */
|
||||
skuCode: string;
|
||||
/** 销售额 */
|
||||
salesAmount: number;
|
||||
/** 订单量 */
|
||||
@@ -69,8 +69,8 @@ export namespace ProductOverviewVO {
|
||||
profitAfterTax: number;
|
||||
}
|
||||
|
||||
/** 规格销售汇总合计行 */
|
||||
export interface SpecSummaryTotal {
|
||||
/** SKU 销售汇总合计行 */
|
||||
export interface SkuSummaryTotal {
|
||||
/** 销售额 */
|
||||
salesAmount: number;
|
||||
/** 订单量 */
|
||||
@@ -103,17 +103,17 @@ export namespace ProductOverviewVO {
|
||||
profitAfterTax: number;
|
||||
}
|
||||
|
||||
/** 规格销售汇总 */
|
||||
export interface SpecSummary {
|
||||
/** 各规格明细列表 */
|
||||
list: SpecSummaryItem[];
|
||||
/** SKU 销售汇总 */
|
||||
export interface SkuSummary {
|
||||
/** 各 SKU 明细列表 */
|
||||
list: SkuSummaryItem[];
|
||||
/** 合计行 */
|
||||
total: SpecSummaryTotal;
|
||||
total: SkuSummaryTotal;
|
||||
}
|
||||
|
||||
/** 商品概览响应 */
|
||||
export interface Overview {
|
||||
/** 商品ID */
|
||||
/** 商品 ID */
|
||||
productId: number;
|
||||
/** 商品名称 */
|
||||
productName: string;
|
||||
@@ -135,12 +135,12 @@ export namespace ProductOverviewVO {
|
||||
orderCountAchievementRate: number;
|
||||
/** 销售额目标达成率 */
|
||||
salesAmountAchievementRate: number;
|
||||
/** 汇总ROI */
|
||||
/** 汇总 ROI */
|
||||
totalROI: number;
|
||||
|
||||
// ========== 各规格销量 Top10 ==========
|
||||
/** 各规格销量 Top10 */
|
||||
specSalesTop10: SpecSalesRankItem[];
|
||||
// ========== 各 SKU 销量 Top10 ==========
|
||||
/** 各 SKU 销量 Top10(后端字段名仍为 specSalesTop10) */
|
||||
specSalesTop10: SkuSalesRankItem[];
|
||||
|
||||
// ========== 趋势数据 ==========
|
||||
/** 销售额趋势分析 */
|
||||
@@ -148,8 +148,8 @@ export namespace ProductOverviewVO {
|
||||
/** 单量趋势分析 */
|
||||
orderCountTrend: TrendData;
|
||||
|
||||
// ========== 规格销售汇总 ==========
|
||||
/** 规格销售汇总 */
|
||||
specSummaries: SpecSummary;
|
||||
// ========== SKU 销售汇总 ==========
|
||||
/** SKU 销售汇总(后端字段名仍为 specSummaries) */
|
||||
specSummaries: SkuSummary;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
import type { ProductSkuDTO, ProductSkuVO } from './types';
|
||||
|
||||
import type { ProductVO } from '#/api/ecommerce/product/types';
|
||||
import type { PageQueryDTO, PageResultVO } from '#/types/common';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
/**
|
||||
* 创建商品 SKU
|
||||
*/
|
||||
export async function createProductSkuApi(data: ProductSkuDTO.Create) {
|
||||
return requestClient.post<ProductSkuVO.Info>(
|
||||
'/ec/product-sku/create',
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商品 SKU
|
||||
*/
|
||||
export async function updateProductSkuApi(
|
||||
id: number,
|
||||
data: ProductSkuDTO.Update,
|
||||
) {
|
||||
return requestClient.put<ProductSkuVO.Info>(
|
||||
`/ec/product-sku/update/${id}`,
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品 SKU
|
||||
*/
|
||||
export async function deleteProductSkuApi(id: number) {
|
||||
return requestClient.delete(`/ec/product-sku/delete/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页获取商品 SKU 列表
|
||||
*/
|
||||
export async function getProductSkuPageApi(
|
||||
params: PageQueryDTO<ProductSkuDTO.Filters>,
|
||||
) {
|
||||
return requestClient.post<PageResultVO<ProductSkuVO.Info>>(
|
||||
'/ec/product-sku/list',
|
||||
params,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据商品名称和 SKU 编码精准查询商品 SKU
|
||||
*/
|
||||
export async function getProductSkuByProductAndSkuApi(
|
||||
productName: string,
|
||||
skuCode: string,
|
||||
) {
|
||||
return requestClient.get<ProductSkuVO.Info>(
|
||||
`/ec/product-sku/find-by-product-and-sku/${encodeURIComponent(productName)}/${encodeURIComponent(skuCode)}`,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量根据商品名称和 SKU 编码查询商品 SKU
|
||||
*/
|
||||
export async function getProductSkusByProductAndSkusApi(
|
||||
queries: ProductSkuDTO.Query[],
|
||||
) {
|
||||
return requestClient.post<ProductVO.Info[]>(
|
||||
'/ec/product-sku/find-by-product-and-skus',
|
||||
queries,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 ID 列表批量查询商品 SKU
|
||||
*/
|
||||
export async function getProductSkusByIdsApi(skuIds: number[]) {
|
||||
return requestClient.post<ProductSkuVO.Info[]>(
|
||||
'/ec/product-sku/batch-get-by-ids',
|
||||
skuIds,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步 SKU 成本到历史订单(单个 SKU)
|
||||
*/
|
||||
export async function syncCostsToOrdersApi(data: ProductSkuDTO.SyncCost) {
|
||||
return requestClient.post<number>('/ec/product-sku/sync-costs-to-orders', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量同步 SKU 成本到历史订单
|
||||
*/
|
||||
export async function batchSyncCostsToOrdersApi(data: ProductSkuDTO.BatchSyncCost) {
|
||||
return requestClient.post<number>('/ec/product-sku/batch-sync-costs-to-orders', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计指定 SKU 与时间范围内将参与成本同步的订单数量
|
||||
*/
|
||||
export async function countOrdersForCostSyncApi(data: ProductSkuDTO.BatchSyncCost) {
|
||||
return requestClient.post<number>('/ec/product-sku/count-orders-for-cost-sync', data);
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* 商品规格模块API导出
|
||||
* 商品 SKU 模块 API 导出
|
||||
*/
|
||||
|
||||
export * from './apis';
|
||||
+30
-30
@@ -1,16 +1,16 @@
|
||||
/**
|
||||
* 商品规格相关DTO类型定义
|
||||
* 商品 SKU 相关 DTO 类型定义
|
||||
*/
|
||||
|
||||
export namespace ProductSpecDTO {
|
||||
/** 创建商品规格参数 */
|
||||
export namespace ProductSkuDTO {
|
||||
/** 创建商品 SKU 参数 */
|
||||
export interface Create {
|
||||
/** 商品ID */
|
||||
/** 商品 ID */
|
||||
productId: number;
|
||||
/** 规格名称 */
|
||||
/** SKU 名称 */
|
||||
name: string;
|
||||
/** 规格编码 */
|
||||
specCode?: string;
|
||||
/** SKU 编码 */
|
||||
skuCode?: string;
|
||||
/** 商品成本 */
|
||||
productCost: number;
|
||||
/** 运费成本 */
|
||||
@@ -21,14 +21,14 @@ export namespace ProductSpecDTO {
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
/** 更新商品规格参数 */
|
||||
/** 更新商品 SKU 参数 */
|
||||
export interface Update {
|
||||
/** 规格ID */
|
||||
/** SKU ID */
|
||||
id: number;
|
||||
/** 规格名称 */
|
||||
/** SKU 名称 */
|
||||
name: string;
|
||||
/** 规格编码 */
|
||||
specCode?: string;
|
||||
/** SKU 编码 */
|
||||
skuCode?: string;
|
||||
/** 商品成本 */
|
||||
productCost: number;
|
||||
/** 运费成本 */
|
||||
@@ -39,32 +39,32 @@ export namespace ProductSpecDTO {
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
/** 商品规格过滤条件 */
|
||||
/** 商品 SKU 过滤条件 */
|
||||
export interface Filters {
|
||||
/** 商品ID */
|
||||
/** 商品 ID */
|
||||
productId?: number;
|
||||
/** 规格ID */
|
||||
/** SKU ID */
|
||||
id?: number;
|
||||
/** 规格名称 */
|
||||
/** SKU 名称 */
|
||||
name?: string;
|
||||
/** 规格编码 */
|
||||
specCode?: string;
|
||||
/** 关键字(模糊查询规格名称、规格编码) */
|
||||
/** SKU 编码 */
|
||||
skuCode?: string;
|
||||
/** 关键字(模糊查询 SKU 名称、SKU 编码) */
|
||||
keywords?: string;
|
||||
}
|
||||
|
||||
/** 商品规格查询DTO(用于批量查询) */
|
||||
/** 商品 SKU 查询 DTO(用于批量查询) */
|
||||
export interface Query {
|
||||
/** 商品名称 */
|
||||
productName: string;
|
||||
/** 规格编码 */
|
||||
specCode: string;
|
||||
/** SKU 编码 */
|
||||
skuCode: string;
|
||||
}
|
||||
|
||||
/** 同步规格成本到订单(单个规格) */
|
||||
/** 同步 SKU 成本到订单(单个 SKU) */
|
||||
export interface SyncCost {
|
||||
/** 规格ID */
|
||||
specId: number;
|
||||
/** SKU ID */
|
||||
skuId: number;
|
||||
/** 商品成本 */
|
||||
productCost: number;
|
||||
/** 运费成本 */
|
||||
@@ -77,13 +77,13 @@ export namespace ProductSpecDTO {
|
||||
endTime: string;
|
||||
}
|
||||
|
||||
/** 批量同步规格成本到订单(按订单 orderTime,起止为含时分秒的 LocalDateTime 字符串) */
|
||||
/** 批量同步 SKU 成本到订单 */
|
||||
export interface BatchSyncCost {
|
||||
/** 规格ID列表 */
|
||||
specIds: number[];
|
||||
/** 订单时间下限(含),如 `2024-01-01 00:00:00` */
|
||||
/** SKU ID 列表 */
|
||||
skuIds: number[];
|
||||
/** 订单时间下限(含) */
|
||||
startTime: string;
|
||||
/** 订单时间上限(含),如 `2024-01-31 23:59:59` */
|
||||
/** 订单时间上限(含) */
|
||||
endTime: string;
|
||||
}
|
||||
}
|
||||
+13
-11
@@ -1,22 +1,22 @@
|
||||
/**
|
||||
* 商品规格相关VO类型定义
|
||||
* 商品 SKU 相关 VO 类型定义
|
||||
*/
|
||||
|
||||
export namespace ProductSpecVO {
|
||||
/** 商品规格信息 */
|
||||
export namespace ProductSkuVO {
|
||||
/** 商品 SKU 信息 */
|
||||
export interface Info {
|
||||
/** 规格ID */
|
||||
/** SKU ID */
|
||||
id: number;
|
||||
/** 公司ID */
|
||||
/** 公司 ID */
|
||||
companyId: number;
|
||||
/** 商品ID */
|
||||
/** 商品 ID */
|
||||
productId: number;
|
||||
/** 商品名称 */
|
||||
productName: string;
|
||||
/** 规格名称 */
|
||||
/** SKU 名称 */
|
||||
name: string;
|
||||
/** 规格编码 */
|
||||
specCode?: string;
|
||||
/** SKU 编码 */
|
||||
skuCode?: string;
|
||||
/** 商品成本 */
|
||||
productCost: number;
|
||||
/** 运费成本 */
|
||||
@@ -29,9 +29,11 @@ export namespace ProductSpecVO {
|
||||
createTime: string;
|
||||
/** 更新时间 */
|
||||
updateTime: string;
|
||||
/** 创建人ID */
|
||||
/** 创建人 ID */
|
||||
createBy?: number;
|
||||
/** 更新人ID */
|
||||
/** 更新人 ID */
|
||||
updateBy?: number;
|
||||
/** 成本是否变更(本次更新中成本字段有变化) */
|
||||
costChanged?: boolean;
|
||||
}
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
import type { ProductSpecDTO, ProductSpecVO } from './types';
|
||||
|
||||
import type { ProductVO } from '#/api/ecommerce/product/types';
|
||||
import type { PageQueryDTO, PageResultVO } from '#/types/common';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
/**
|
||||
* 商品规格管理API
|
||||
*/
|
||||
|
||||
/**
|
||||
* 创建商品规格
|
||||
*/
|
||||
export async function createProductSpecApi(data: ProductSpecDTO.Create) {
|
||||
return requestClient.post<ProductSpecVO.Info>(
|
||||
'/ec/product-spec/create',
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商品规格
|
||||
*/
|
||||
export async function updateProductSpecApi(
|
||||
id: number,
|
||||
data: ProductSpecDTO.Update,
|
||||
) {
|
||||
return requestClient.put<ProductSpecVO.Info>(
|
||||
`/ec/product-spec/update/${id}`,
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品规格
|
||||
*/
|
||||
export async function deleteProductSpecApi(id: number) {
|
||||
return requestClient.delete(`/ec/product-spec/delete/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页获取商品规格列表
|
||||
*/
|
||||
export async function getProductSpecPageApi(
|
||||
params: PageQueryDTO<ProductSpecDTO.Filters>,
|
||||
) {
|
||||
return requestClient.post<PageResultVO<ProductSpecVO.Info>>(
|
||||
'/ec/product-spec/list',
|
||||
params,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据商品名称和规格编码精准查询商品规格
|
||||
*/
|
||||
export async function getProductSpecByProductAndSpecApi(
|
||||
productName: string,
|
||||
specCode: string,
|
||||
) {
|
||||
return requestClient.get<ProductSpecVO.Info>(
|
||||
`/ec/product-spec/find-by-product-and-spec/${encodeURIComponent(productName)}/${encodeURIComponent(specCode)}`,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量根据商品名称和规格编码查询商品规格
|
||||
* 返回商品信息列表,每个商品包含匹配的规格信息
|
||||
*/
|
||||
export async function getProductSpecsByProductAndSpecsApi(
|
||||
queries: ProductSpecDTO.Query[],
|
||||
) {
|
||||
return requestClient.post<ProductVO.Info[]>(
|
||||
'/ec/product-spec/find-by-product-and-specs',
|
||||
queries,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID列表批量查询商品规格
|
||||
*/
|
||||
export async function getProductSpecsByIdsApi(specIds: number[]) {
|
||||
return requestClient.post<ProductSpecVO.Info[]>(
|
||||
'/ec/product-spec/batch-get-by-ids',
|
||||
specIds,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步规格成本到历史订单(单个规格)
|
||||
*/
|
||||
export async function syncCostsToOrdersApi(data: ProductSpecDTO.SyncCost) {
|
||||
return requestClient.post<number>('/ec/product-spec/sync-costs-to-orders', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量同步规格成本到历史订单
|
||||
*/
|
||||
export async function batchSyncCostsToOrdersApi(data: ProductSpecDTO.BatchSyncCost) {
|
||||
return requestClient.post<number>('/ec/product-spec/batch-sync-costs-to-orders', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计指定规格与时间范围内将参与成本同步的订单数量(与批量同步匹配规则一致)
|
||||
*/
|
||||
export async function countOrdersForCostSyncApi(data: ProductSpecDTO.BatchSyncCost) {
|
||||
return requestClient.post<number>('/ec/product-spec/count-orders-for-cost-sync', data);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* 商品相关DTO类型定义
|
||||
* 商品相关 DTO 类型定义
|
||||
*/
|
||||
|
||||
export namespace ProductDTO {
|
||||
@@ -9,12 +9,12 @@ export namespace ProductDTO {
|
||||
name: string;
|
||||
/** 商品编码 */
|
||||
productCode?: string;
|
||||
/** 类目ID */
|
||||
/** 类目 ID */
|
||||
categoryId?: number;
|
||||
/** 主图图片ID */
|
||||
/** 主图图片 ID */
|
||||
mainImageId?: number;
|
||||
/** 商品规格列表(可选) */
|
||||
specs?: Spec[];
|
||||
/** 商品 SKU 列表(可选) */
|
||||
skus?: Sku[];
|
||||
}
|
||||
|
||||
/** 更新商品参数 */
|
||||
@@ -23,22 +23,22 @@ export namespace ProductDTO {
|
||||
name: string;
|
||||
/** 商品编码 */
|
||||
productCode?: string;
|
||||
/** 类目ID */
|
||||
/** 类目 ID */
|
||||
categoryId?: number;
|
||||
/** 主图图片ID */
|
||||
/** 主图图片 ID */
|
||||
mainImageId?: number;
|
||||
/** 商品规格列表:含 id 为更新,不含 id 为新增 */
|
||||
specs?: UpdateSpec[];
|
||||
/** 编辑时从商品上移除的规格 ID(须为打开表单时已有的规格) */
|
||||
removedSpecIds?: number[];
|
||||
/** 商品 SKU 列表:含 id 为更新,不含 id 为新增 */
|
||||
skus?: UpdateSku[];
|
||||
/** 编辑时从商品上移除的 SKU ID(须为打开表单时已有的 SKU) */
|
||||
removedSkuIds?: number[];
|
||||
}
|
||||
|
||||
/** 商品规格DTO(创建时) */
|
||||
export interface Spec {
|
||||
/** 规格名称 */
|
||||
/** 商品 SKU DTO(创建时) */
|
||||
export interface Sku {
|
||||
/** SKU 名称 */
|
||||
name: string;
|
||||
/** 规格编码 */
|
||||
specCode?: string;
|
||||
/** SKU 编码 */
|
||||
skuCode?: string;
|
||||
/** 商品成本 */
|
||||
productCost: number;
|
||||
/** 运费成本 */
|
||||
@@ -49,14 +49,14 @@ export namespace ProductDTO {
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
/** 创建商品规格参数(独立接口用) */
|
||||
export interface CreateSpec {
|
||||
/** 商品ID */
|
||||
/** 创建商品 SKU 参数(独立接口用) */
|
||||
export interface CreateSku {
|
||||
/** 商品 ID */
|
||||
productId: number;
|
||||
/** 规格名称 */
|
||||
/** SKU 名称 */
|
||||
name: string;
|
||||
/** 规格编码 */
|
||||
specCode?: string;
|
||||
/** SKU 编码 */
|
||||
skuCode?: string;
|
||||
/** 商品成本 */
|
||||
productCost: number;
|
||||
/** 运费成本 */
|
||||
@@ -67,14 +67,14 @@ export namespace ProductDTO {
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
/** 更新商品规格参数 */
|
||||
export interface UpdateSpec {
|
||||
/** 规格ID:有值表示更新已有规格;不传或空表示新增一条规格 */
|
||||
/** 更新商品 SKU 参数 */
|
||||
export interface UpdateSku {
|
||||
/** SKU ID:有值表示更新已有 SKU;不传或空表示新增一条 SKU */
|
||||
id?: number;
|
||||
/** 规格名称 */
|
||||
/** SKU 名称 */
|
||||
name: string;
|
||||
/** 规格编码 */
|
||||
specCode?: string;
|
||||
/** SKU 编码 */
|
||||
skuCode?: string;
|
||||
/** 商品成本 */
|
||||
productCost: number;
|
||||
/** 运费成本 */
|
||||
@@ -91,24 +91,24 @@ export namespace ProductDTO {
|
||||
name?: string;
|
||||
/** 商品编码(精准查询) */
|
||||
productCode?: string;
|
||||
/** 规格编码(精准查询) */
|
||||
specCode?: string;
|
||||
/** 规格名称(模糊查询) */
|
||||
specName?: string;
|
||||
/** 关键字(模糊查询商品名称、商品编码、规格名称、规格编码) */
|
||||
/** SKU 编码(精准查询) */
|
||||
skuCode?: string;
|
||||
/** SKU 名称(模糊查询) */
|
||||
skuName?: string;
|
||||
/** 关键字(模糊查询商品名称、商品编码、SKU 名称、SKU 编码) */
|
||||
keywords?: string;
|
||||
}
|
||||
|
||||
/** 商品规格过滤条件 */
|
||||
export interface SpecFilters {
|
||||
/** 商品ID */
|
||||
/** 商品 SKU 过滤条件 */
|
||||
export interface SkuFilters {
|
||||
/** 商品 ID */
|
||||
productId?: number;
|
||||
/** 商品名称(模糊查询) */
|
||||
productName?: string;
|
||||
/** 规格名称(模糊查询) */
|
||||
/** SKU 名称(模糊查询) */
|
||||
name?: string;
|
||||
/** 规格编码(模糊查询) */
|
||||
specCode?: string;
|
||||
/** SKU 编码(模糊查询) */
|
||||
skuCode?: string;
|
||||
/** 成本价范围-最小值 */
|
||||
minCostPrice?: number;
|
||||
/** 成本价范围-最大值 */
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
/**
|
||||
* 商品相关VO类型定义
|
||||
* 商品相关 VO 类型定义
|
||||
*/
|
||||
|
||||
export namespace ProductVO {
|
||||
/** 商品信息 */
|
||||
export interface Info {
|
||||
/** 商品ID */
|
||||
/** 商品 ID */
|
||||
id: number;
|
||||
/** 公司ID */
|
||||
/** 公司 ID */
|
||||
companyId: number;
|
||||
/** 类目ID */
|
||||
/** 类目 ID */
|
||||
categoryId?: number;
|
||||
/** 类目名称 */
|
||||
categoryName?: string;
|
||||
@@ -17,51 +17,51 @@ export namespace ProductVO {
|
||||
name: string;
|
||||
/** 商品编码 */
|
||||
productCode?: string;
|
||||
/** 主图URL */
|
||||
/** 主图 URL */
|
||||
mainImage?: string;
|
||||
/** 创建时间 */
|
||||
createTime: string;
|
||||
/** 更新时间 */
|
||||
updateTime: string;
|
||||
/** 创建人ID */
|
||||
/** 创建人 ID */
|
||||
createBy?: number;
|
||||
/** 更新人ID */
|
||||
/** 更新人 ID */
|
||||
updateBy?: number;
|
||||
/** 商品规格列表 */
|
||||
specs?: SpecInfo[];
|
||||
/** 商品 SKU 列表 */
|
||||
skus?: SkuInfo[];
|
||||
}
|
||||
|
||||
/** 更新商品响应 */
|
||||
export interface UpdateProductResult {
|
||||
/**
|
||||
* 需提示同步:成本已变更且有关联订单;或新增规格(编码非空、商品/运费/其他成本至少一项大于 0)且有关联订单
|
||||
* 需提示同步:成本已变更且有关联订单;或新增 SKU(编码非空、成本至少一项大于 0)且有关联订单
|
||||
*/
|
||||
specIdsCostChangedWithLinkedOrders: number[];
|
||||
skuIdsCostChangedWithLinkedOrders: number[];
|
||||
/** 更新后的商品完整信息 */
|
||||
product: ProductVO.Info;
|
||||
}
|
||||
|
||||
/** 创建商品响应 */
|
||||
export interface CreateProductResult {
|
||||
/** 新增规格:编码非空、至少一项成本大于 0、且有关联订单的规格 ID */
|
||||
specIdsCostChangedWithLinkedOrders: number[];
|
||||
/** 新增 SKU:编码非空、至少一项成本大于 0、且有关联订单的 SKU ID */
|
||||
skuIdsCostChangedWithLinkedOrders: number[];
|
||||
product: ProductVO.Info;
|
||||
}
|
||||
|
||||
/** 商品规格信息 */
|
||||
export interface SpecInfo {
|
||||
/** 规格ID */
|
||||
/** 商品 SKU 信息 */
|
||||
export interface SkuInfo {
|
||||
/** SKU ID */
|
||||
id: number;
|
||||
/** 公司ID */
|
||||
/** 公司 ID */
|
||||
companyId: number;
|
||||
/** 商品ID */
|
||||
/** 商品 ID */
|
||||
productId: number;
|
||||
/** 商品名称 */
|
||||
productName: string;
|
||||
/** 规格名称 */
|
||||
/** SKU 名称 */
|
||||
name: string;
|
||||
/** 规格编码 */
|
||||
specCode?: string;
|
||||
/** SKU 编码 */
|
||||
skuCode?: string;
|
||||
/** 商品成本 */
|
||||
productCost: number;
|
||||
/** 运费成本 */
|
||||
@@ -74,9 +74,9 @@ export namespace ProductVO {
|
||||
createTime: string;
|
||||
/** 更新时间 */
|
||||
updateTime: string;
|
||||
/** 创建人ID */
|
||||
/** 创建人 ID */
|
||||
createBy?: number;
|
||||
/** 更新人ID */
|
||||
/** 更新人 ID */
|
||||
updateBy?: number;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ export namespace ShopDTO {
|
||||
name: string;
|
||||
/** logo图片ID */
|
||||
logoImageId?: number;
|
||||
/** 平台ID */
|
||||
platformId?: number;
|
||||
/** 平台代码 */
|
||||
platformCode?: string;
|
||||
}
|
||||
|
||||
/** 更新店铺参数 */
|
||||
@@ -19,16 +19,16 @@ export namespace ShopDTO {
|
||||
name: string;
|
||||
/** logo图片ID */
|
||||
logoImageId?: number;
|
||||
/** 平台ID */
|
||||
platformId?: number;
|
||||
/** 平台代码 */
|
||||
platformCode?: string;
|
||||
}
|
||||
|
||||
/** 店铺过滤条件 */
|
||||
export interface Filters {
|
||||
/** 店铺名称(模糊查询) */
|
||||
name?: string;
|
||||
/** 平台ID */
|
||||
platformId?: number;
|
||||
/** 平台代码 */
|
||||
platformCode?: string;
|
||||
}
|
||||
|
||||
/** 店铺商品分页查询过滤条件 */
|
||||
|
||||
@@ -43,9 +43,9 @@ export namespace ShopVO {
|
||||
logo?: string;
|
||||
/** logo图片ID */
|
||||
logoImageId?: number;
|
||||
/** 平台ID */
|
||||
platformId?: number;
|
||||
/** 平台名称 */
|
||||
/** 平台代码 */
|
||||
platformCode?: string;
|
||||
/** 平台名称(后端回填) */
|
||||
platformName?: string;
|
||||
/** 外部店铺ID(如拼多多 mall_id) */
|
||||
externalShopId?: null | string;
|
||||
|
||||
@@ -185,8 +185,8 @@ export namespace CompanyOverviewVO {
|
||||
|
||||
/** 平台维度汇总 */
|
||||
export interface PlatformSummary {
|
||||
/** 平台ID */
|
||||
platformId: number;
|
||||
/** 平台代码 */
|
||||
platformCode: string;
|
||||
/** 平台名称 */
|
||||
platformName: string;
|
||||
/** 目标单量 */
|
||||
|
||||
@@ -7,8 +7,8 @@ export namespace WorkbenchDTO {
|
||||
dateRange: string[];
|
||||
/** 税率,默认 0.04 */
|
||||
taxRate?: number;
|
||||
/** 平台 ID,不传表示全平台 */
|
||||
platformId?: number;
|
||||
/** 平台代码,不传表示全平台 */
|
||||
platformCode?: string;
|
||||
/** 店铺 ID,不传表示当前筛选下全部门店 */
|
||||
shopId?: number;
|
||||
}
|
||||
@@ -16,7 +16,7 @@ export namespace WorkbenchDTO {
|
||||
/** 工作台四表导出(与后端 WorkbenchExportDTO 对齐) */
|
||||
export interface ExportPayload extends Query {
|
||||
shopIds?: number[];
|
||||
platformIds?: number[];
|
||||
platformCodes?: string[];
|
||||
categoryIds?: number[];
|
||||
productIds?: number[];
|
||||
}
|
||||
|
||||
@@ -38,15 +38,6 @@ const routes: RouteRecordRaw[] = [
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'PlatformManagement',
|
||||
path: '/data/platform',
|
||||
component: () => import('#/views/ecommerce/platform/list/index.vue'),
|
||||
meta: {
|
||||
icon: 'lucide:app-store',
|
||||
title: '平台管理',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* 订单展示辅助:从主表 + items 明细读取列表/卡片字段
|
||||
*/
|
||||
import type { OrderItemVO, OrderVO } from '#/api/ecommerce/order';
|
||||
|
||||
/** 实付/商家实收(兼容 receivedAmount 别名) */
|
||||
export function getOrderPayAmount(
|
||||
order: Pick<OrderVO.Info, 'payAmount' | 'receivedAmount'>,
|
||||
): number {
|
||||
return Number(order.payAmount ?? order.receivedAmount ?? 0);
|
||||
}
|
||||
|
||||
/** 首行明细(列表/卡片单行展示) */
|
||||
export function getFirstOrderItem(
|
||||
order: OrderVO.Info,
|
||||
): OrderItemVO.Info | undefined {
|
||||
return order.items?.[0];
|
||||
}
|
||||
|
||||
export function getOrderLinkProductName(order: OrderVO.Info): string {
|
||||
const item = getFirstOrderItem(order);
|
||||
return item?.linkProductName ?? order.firstLinkProductName ?? '';
|
||||
}
|
||||
|
||||
export function getOrderLinkSkuName(order: OrderVO.Info): string {
|
||||
return getFirstOrderItem(order)?.linkSkuName ?? '';
|
||||
}
|
||||
|
||||
export function getOrderQuantity(order: OrderVO.Info): number {
|
||||
return getFirstOrderItem(order)?.quantity ?? 0;
|
||||
}
|
||||
|
||||
export function getOrderUnitPrice(order: OrderVO.Info): number {
|
||||
return Number(getFirstOrderItem(order)?.unitPrice ?? 0);
|
||||
}
|
||||
|
||||
export function getOrderProductCost(order: OrderVO.Info): number {
|
||||
return Number(getFirstOrderItem(order)?.productCost ?? 0);
|
||||
}
|
||||
|
||||
export function getOrderShippingCost(order: OrderVO.Info): number {
|
||||
return Number(getFirstOrderItem(order)?.shippingCost ?? 0);
|
||||
}
|
||||
|
||||
export function getOrderOtherCost(order: OrderVO.Info): number {
|
||||
return Number(getFirstOrderItem(order)?.otherCost ?? 0);
|
||||
}
|
||||
|
||||
export function getOrderProduct(order: OrderVO.Info) {
|
||||
return getFirstOrderItem(order)?.product;
|
||||
}
|
||||
|
||||
export function getOrderProductSku(order: OrderVO.Info) {
|
||||
return getFirstOrderItem(order)?.productSku;
|
||||
}
|
||||
@@ -19,8 +19,11 @@ export const overviewTableHints = {
|
||||
salesAmountShort:
|
||||
'统计口径下,计入销售额的订单实收金额合计(与后端订单状态统计一致)。',
|
||||
orderCount: '统计口径下,计入销量的有效订单笔数。',
|
||||
orderCountSku:
|
||||
'该 SKU 下计入统计的订单笔数;括号内「件」为销售件数合计。',
|
||||
/** @deprecated 使用 orderCountSku */
|
||||
orderCountSpec:
|
||||
'该规格下计入统计的订单笔数;括号内「件」为销售件数合计。',
|
||||
'该 SKU 下计入统计的订单笔数;括号内「件」为销售件数合计。',
|
||||
averageOrderValue: '销售额 ÷ 单量。',
|
||||
productCost: '订单维度「商品成本」字段汇总。',
|
||||
shippingCost: '订单维度「运费成本」字段汇总。',
|
||||
@@ -29,8 +32,11 @@ export const overviewTableHints = {
|
||||
'订单成本 = 商品成本 + 运费 + 其他成本(订单维度汇总,不含推广费、刷单费)。',
|
||||
refundAmount: '统计口径下,计入退款的实收金额合计。',
|
||||
totalPromotionFee: '该维度下推广费金额合计(来自推广费单据)。',
|
||||
promotionFeeSku:
|
||||
'该 SKU 推广费 = 店铺推广费总额 ×(该 SKU 订单数 ÷ 所选时间范围内订单总数),由后端按比例分摊。',
|
||||
/** @deprecated 使用 promotionFeeSku */
|
||||
promotionFeeSpec:
|
||||
'该规格推广费 = 店铺推广费总额 ×(该规格订单数 ÷ 所选时间范围内订单总数),由后端按比例分摊。',
|
||||
'该 SKU 推广费 = 店铺推广费总额 ×(该 SKU 订单数 ÷ 所选时间范围内订单总数),由后端按比例分摊。',
|
||||
brushFee: '该维度下刷单费用合计(来自刷单记录)。',
|
||||
feeRatioShopRow:
|
||||
'费比 = 推广费 ÷ 实际销售额。(「合计」行:推广费与刷单费之和 ÷ 实际销售额)',
|
||||
@@ -40,12 +46,18 @@ export const overviewTableHints = {
|
||||
'费比 = 推广费 ÷ 实际销售额。全店品类行的推广费、刷单费按店铺在该品类销售额占比分摊;「合计」行费比 =(推广费 + 刷单费)÷ 实际销售额。',
|
||||
feeRatioPlatform:
|
||||
'费比 =(推广费 + 刷单费用)÷ 实际销售额。数据行与「合计」行口径一致。',
|
||||
feeRatioSku:
|
||||
'费比(%)= 推广费 ÷ 销售额;接口字段已为百分数数值(0–100),与店铺商品表费比展示方式不同。',
|
||||
/** @deprecated 使用 feeRatioSku */
|
||||
feeRatioSpec:
|
||||
'费比(%)= 推广费 ÷ 销售额;接口字段已为百分数数值(0–100),与店铺商品表费比展示方式不同。',
|
||||
totalProfitBeforeTax:
|
||||
'税前净利 = 毛利 − 推广费 − 刷单费用。',
|
||||
profitBeforeTaxSku:
|
||||
'税前净利 = 销售额 − 订单成本 − 退款金额 − 推广费(SKU 维度不含刷单费)。',
|
||||
/** @deprecated 使用 profitBeforeTaxSku */
|
||||
profitBeforeTaxSpec:
|
||||
'税前净利 = 销售额 − 订单成本 − 退款金额 − 推广费(规格维度不含刷单费)。',
|
||||
'税前净利 = 销售额 − 订单成本 − 退款金额 − 推广费(SKU 维度不含刷单费)。',
|
||||
roi: 'ROI =(实际销售额 − 退款金额)÷ 推广费;推广费为 0 时后端记为 0。',
|
||||
profitAfterTax: '税后净利 = 税前净利 − 税额。',
|
||||
profitAfterTaxNet: '税后净利 = 税前净利 − 税额(与「税后盈亏」同口径,表头名称不同)。',
|
||||
|
||||
+6
-6
@@ -61,9 +61,9 @@ const fieldMappings = ref<Record<string, string>>({});
|
||||
// 订单状态映射相关(ORDER_STATUS 类型)
|
||||
interface StatusMappingItem {
|
||||
csvStatus: string;
|
||||
mappedStatusId: number;
|
||||
mappedStatusCode: string;
|
||||
}
|
||||
const orderStatusList = ref<OrderStatusVO.Info[]>([]);
|
||||
const orderStatusList = ref<OrderStatusVO.Meta[]>([]);
|
||||
const statusMappings = ref<StatusMappingItem[]>([]);
|
||||
|
||||
// 获取字段定义
|
||||
@@ -156,7 +156,7 @@ async function handleConfirm() {
|
||||
if (props.type === MappingTypeEnum.ORDER_STATUS) {
|
||||
// 过滤掉未映射的
|
||||
const validMappings = statusMappings.value.filter(
|
||||
(m) => m.mappedStatusId,
|
||||
(m) => m.mappedStatusCode,
|
||||
);
|
||||
mappingJson = JSON.stringify(validMappings);
|
||||
} else {
|
||||
@@ -233,15 +233,15 @@ defineExpose({ open });
|
||||
}}</span>
|
||||
<span class="text-gray-400">→</span>
|
||||
<Select
|
||||
v-model:value="item.mappedStatusId"
|
||||
v-model:value="item.mappedStatusCode"
|
||||
placeholder="选择订单状态"
|
||||
class="flex-1"
|
||||
show-search
|
||||
allow-clear
|
||||
:options="
|
||||
orderStatusList.map((s) => ({
|
||||
label: s.statusName,
|
||||
value: s.id,
|
||||
label: s.label,
|
||||
value: s.code,
|
||||
}))
|
||||
"
|
||||
/>
|
||||
|
||||
+5
-5
@@ -15,7 +15,7 @@ interface Props {
|
||||
taxRate: number;
|
||||
platformSummary?: CompanyOverviewVO.PlatformOverview;
|
||||
platformExportMode: boolean;
|
||||
selectedExportPlatformIds: number[];
|
||||
selectedExportPlatformCodes: string[];
|
||||
shopSummary?: CompanyOverviewVO.ShopOverview;
|
||||
shopExportMode: boolean;
|
||||
selectedExportShopIds: number[];
|
||||
@@ -25,7 +25,7 @@ interface Props {
|
||||
}
|
||||
|
||||
interface Emits {
|
||||
(e: 'update:selectedExportPlatformIds', ids: number[]): void;
|
||||
(e: 'update:selectedExportPlatformCodes', codes: string[]): void;
|
||||
(e: 'togglePlatformExportMode', enabled: boolean): void;
|
||||
(e: 'platformExport'): void;
|
||||
(e: 'update:selectedExportShopIds', ids: number[]): void;
|
||||
@@ -71,9 +71,9 @@ const modeOptions = [
|
||||
:platform-summary="props.platformSummary"
|
||||
:tax-rate="props.taxRate"
|
||||
:platform-export-mode="props.platformExportMode"
|
||||
:selected-export-platform-ids="props.selectedExportPlatformIds"
|
||||
@update:selected-export-platform-ids="
|
||||
(ids) => emit('update:selectedExportPlatformIds', ids)
|
||||
:selected-export-platform-codes="props.selectedExportPlatformCodes"
|
||||
@update:selected-export-platform-codes="
|
||||
(codes) => emit('update:selectedExportPlatformCodes', codes)
|
||||
"
|
||||
@toggle-platform-export-mode="
|
||||
(enabled) => emit('togglePlatformExportMode', enabled)
|
||||
|
||||
+16
-16
@@ -17,20 +17,20 @@ interface Props {
|
||||
taxRate?: number;
|
||||
platformSummary?: CompanyOverviewVO.PlatformOverview;
|
||||
platformExportMode?: boolean;
|
||||
selectedExportPlatformIds?: number[];
|
||||
selectedExportPlatformCodes?: string[];
|
||||
headingTitle?: string;
|
||||
headingSubtitle?: string;
|
||||
}
|
||||
|
||||
interface Emits {
|
||||
(e: 'update:selectedExportPlatformIds', ids: number[]): void;
|
||||
(e: 'update:selectedExportPlatformCodes', codes: string[]): void;
|
||||
(e: 'togglePlatformExportMode', enabled: boolean): void;
|
||||
(e: 'export'): void;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
platformExportMode: false,
|
||||
selectedExportPlatformIds: () => [],
|
||||
selectedExportPlatformCodes: () => [],
|
||||
headingTitle: '各平台多维度经营明细汇总',
|
||||
headingSubtitle: '目标达成 · 规模 · 成本费用 · 盈利分析,四大维度完整汇总',
|
||||
});
|
||||
@@ -38,10 +38,10 @@ const emit = defineEmits<Emits>();
|
||||
|
||||
const allPlatformsSelected = computed(() => {
|
||||
const total = platformData.value.length;
|
||||
return total > 0 && props.selectedExportPlatformIds.length === total;
|
||||
return total > 0 && props.selectedExportPlatformCodes.length === total;
|
||||
});
|
||||
const somePlatformsSelected = computed(() => {
|
||||
return props.selectedExportPlatformIds.length > 0;
|
||||
return props.selectedExportPlatformCodes.length > 0;
|
||||
});
|
||||
|
||||
const formatAmount = (amount: number) => {
|
||||
@@ -63,7 +63,7 @@ const taxRateNum = computed(() => (props.taxRate ?? 0.04) * 100);
|
||||
const platformData = computed(() => {
|
||||
if (props.platformSummary?.platforms && props.platformSummary.platforms.length > 0) {
|
||||
return props.platformSummary.platforms.map(p => ({
|
||||
platformId: p.platformId,
|
||||
platformCode: p.platformCode,
|
||||
platformName: p.platformName,
|
||||
targetOrderCount: p.targetOrderCount ?? 0,
|
||||
orderCountAchievementRate: p.orderCountAchievementRate ?? 0,
|
||||
@@ -132,10 +132,10 @@ const sortedData = computed(() => {
|
||||
</button>
|
||||
<button
|
||||
class="rounded-2xl bg-blue-600 px-8 py-3 text-sm font-bold text-white shadow-xl shadow-slate-200 transition-all hover:scale-105 active:scale-95 dark:shadow-none"
|
||||
:disabled="selectedExportPlatformIds.length === 0"
|
||||
:disabled="selectedExportPlatformCodes.length === 0"
|
||||
@click="emit('export')"
|
||||
>
|
||||
导出已选平台 ({{ selectedExportPlatformIds.length }})
|
||||
导出已选平台 ({{ selectedExportPlatformCodes.length }})
|
||||
</button>
|
||||
</template>
|
||||
<template v-else>
|
||||
@@ -176,11 +176,11 @@ const sortedData = computed(() => {
|
||||
(e) => {
|
||||
if ((e.target as HTMLInputElement).checked) {
|
||||
emit(
|
||||
'update:selectedExportPlatformIds',
|
||||
platformData.map((p) => p.platformId) || [],
|
||||
'update:selectedExportPlatformCodes',
|
||||
platformData.map((p) => p.platformCode) || [],
|
||||
);
|
||||
} else {
|
||||
emit('update:selectedExportPlatformIds', []);
|
||||
emit('update:selectedExportPlatformCodes', []);
|
||||
}
|
||||
}
|
||||
"
|
||||
@@ -303,7 +303,7 @@ const sortedData = computed(() => {
|
||||
<tbody class="divide-y divide-slate-100 dark:divide-[hsl(240deg_3.7%_22%)]">
|
||||
<tr
|
||||
v-for="p in sortedData"
|
||||
:key="p.platformId"
|
||||
:key="p.platformCode"
|
||||
class="transition-colors hover:bg-blue-50/50 dark:hover:bg-[hsl(217.2deg_32.6%_17.5%/30%)] dark:bg-[hsl(217.2deg_32.6%_17.5%/50%)]"
|
||||
>
|
||||
<td
|
||||
@@ -313,14 +313,14 @@ const sortedData = computed(() => {
|
||||
<input
|
||||
type="checkbox"
|
||||
class="h-4 w-4 cursor-pointer accent-blue-600"
|
||||
:checked="selectedExportPlatformIds.includes(p.platformId)"
|
||||
:checked="selectedExportPlatformCodes.includes(p.platformCode)"
|
||||
@change="
|
||||
(e) => {
|
||||
const checked = (e.target as HTMLInputElement).checked;
|
||||
const newIds = checked
|
||||
? [...selectedExportPlatformIds, p.platformId]
|
||||
: selectedExportPlatformIds.filter((id) => id !== p.platformId);
|
||||
emit('update:selectedExportPlatformIds', newIds);
|
||||
? [...selectedExportPlatformCodes, p.platformCode]
|
||||
: selectedExportPlatformCodes.filter((id) => id !== p.platformCode);
|
||||
emit('update:selectedExportPlatformCodes', newIds);
|
||||
}
|
||||
"
|
||||
/>
|
||||
|
||||
@@ -48,7 +48,7 @@ const selectedExportShopIds = ref<number[]>([]);
|
||||
|
||||
// 指定平台导出模式
|
||||
const platformExportMode = ref(false);
|
||||
const selectedExportPlatformIds = ref<number[]>([]);
|
||||
const selectedExportPlatformCodes = ref<string[]>([]);
|
||||
|
||||
// 日期范围(默认:本月至今日)
|
||||
const dateRange = ref<[dayjs.Dayjs, dayjs.Dayjs]>([
|
||||
@@ -377,7 +377,7 @@ const toggleShopExportMode = (enabled: boolean) => {
|
||||
const togglePlatformExportMode = (enabled: boolean) => {
|
||||
platformExportMode.value = enabled;
|
||||
if (!enabled) {
|
||||
selectedExportPlatformIds.value = [];
|
||||
selectedExportPlatformCodes.value = [];
|
||||
}
|
||||
};
|
||||
|
||||
@@ -394,8 +394,8 @@ const handlePlatformExport = async () => {
|
||||
startDate.format('YYYY-MM-DD'),
|
||||
endDate.format('YYYY-MM-DD'),
|
||||
],
|
||||
platformIds: selectedExportPlatformIds.value.length > 0
|
||||
? selectedExportPlatformIds.value
|
||||
platformCodes: selectedExportPlatformCodes.value.length > 0
|
||||
? selectedExportPlatformCodes.value
|
||||
: undefined,
|
||||
taxRate: taxRate.value,
|
||||
},
|
||||
@@ -562,14 +562,14 @@ const navigateToShopOverview = (shopId: number) => {
|
||||
:tax-rate="taxRate"
|
||||
:platform-summary="overviewData?.platformSummary"
|
||||
:platform-export-mode="platformExportMode"
|
||||
:selected-export-platform-ids="selectedExportPlatformIds"
|
||||
:selected-export-platform-codes="selectedExportPlatformCodes"
|
||||
:shop-summary="overviewData?.shopSummary"
|
||||
:shop-export-mode="shopExportMode"
|
||||
:selected-export-shop-ids="selectedExportShopIds"
|
||||
:category-summary="overviewData?.categorySummary"
|
||||
:category-export-mode="categoryExportMode"
|
||||
:selected-export-category-ids="selectedExportCategoryIds"
|
||||
@update:selected-export-platform-ids="(ids) => (selectedExportPlatformIds = ids)"
|
||||
@update:selected-export-platform-codes="(codes) => (selectedExportPlatformCodes = codes)"
|
||||
@toggle-platform-export-mode="togglePlatformExportMode"
|
||||
@platform-export="handlePlatformExport"
|
||||
@update:selected-export-shop-ids="(ids) => (selectedExportShopIds = ids)"
|
||||
|
||||
@@ -8,7 +8,7 @@ import { createIconifyIcon } from '@vben/icons';
|
||||
import { DatePicker, InputNumber, message, Popover, Select, Spin, Tabs } from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import { getPlatformPageApi } from '#/api/ecommerce/platform/apis';
|
||||
import { getPlatformListApi } from '#/api/ecommerce/platform/apis';
|
||||
import type { PlatformVO } from '#/api/ecommerce/platform/types';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop/apis';
|
||||
import type { ShopDTO, ShopVO } from '#/api/ecommerce/shop/types';
|
||||
@@ -212,10 +212,8 @@ const parseTaxRate = (value: string | undefined) => {
|
||||
|
||||
const FILTER_PAGE_SIZE = 20;
|
||||
|
||||
const platforms = ref<PlatformVO.Info[]>([]);
|
||||
const platforms = ref<PlatformVO.Meta[]>([]);
|
||||
const platformLoading = ref(false);
|
||||
const platformPage = ref(1);
|
||||
const platformTotal = ref(0);
|
||||
const platformSearchKeyword = ref('');
|
||||
const selectedPlatformLabelCache = ref('');
|
||||
|
||||
@@ -236,11 +234,9 @@ const selectedShopSlug = ref<string | undefined>(undefined);
|
||||
let platformSearchTimer: ReturnType<typeof setTimeout> | undefined;
|
||||
let shopSearchTimer: ReturnType<typeof setTimeout> | undefined;
|
||||
|
||||
function parseSelectedPlatformId(): number | undefined {
|
||||
const slug = selectedPlatformSlug.value;
|
||||
if (!slug) return undefined;
|
||||
const id = Number(slug);
|
||||
return Number.isFinite(id) && id > 0 ? id : undefined;
|
||||
function parseSelectedPlatformCode(): string | undefined {
|
||||
const code = selectedPlatformSlug.value?.trim();
|
||||
return code || undefined;
|
||||
}
|
||||
|
||||
function parseSelectedShopId(): number | undefined {
|
||||
@@ -251,14 +247,22 @@ function parseSelectedShopId(): number | undefined {
|
||||
}
|
||||
|
||||
const platformSelectOptions = computed(() => {
|
||||
const opts = platforms.value.map((p) => ({
|
||||
label: p.platformName,
|
||||
value: String(p.id),
|
||||
const keyword = platformSearchKeyword.value.trim().toLowerCase();
|
||||
const filtered = keyword
|
||||
? platforms.value.filter(
|
||||
(p) =>
|
||||
p.label.toLowerCase().includes(keyword) ||
|
||||
p.code.toLowerCase().includes(keyword),
|
||||
)
|
||||
: platforms.value;
|
||||
const opts = filtered.map((p) => ({
|
||||
label: p.label,
|
||||
value: p.code,
|
||||
}));
|
||||
const slug = selectedPlatformSlug.value;
|
||||
if (slug && !opts.some((o) => o.value === slug)) {
|
||||
opts.unshift({
|
||||
label: selectedPlatformLabelCache.value || `平台 #${slug}`,
|
||||
label: selectedPlatformLabelCache.value || slug,
|
||||
value: slug,
|
||||
});
|
||||
}
|
||||
@@ -284,8 +288,8 @@ watch(selectedPlatformSlug, (slug) => {
|
||||
if (!slug) {
|
||||
selectedPlatformLabelCache.value = '';
|
||||
} else {
|
||||
const hit = platforms.value.find((p) => String(p.id) === slug);
|
||||
if (hit) selectedPlatformLabelCache.value = hit.platformName;
|
||||
const hit = platforms.value.find((p) => p.code === slug);
|
||||
if (hit) selectedPlatformLabelCache.value = hit.label;
|
||||
}
|
||||
selectedShopSlug.value = undefined;
|
||||
selectedShopLabelCache.value = '';
|
||||
@@ -302,23 +306,11 @@ watch(selectedShopSlug, (slug) => {
|
||||
if (hit) selectedShopLabelCache.value = hit.name;
|
||||
});
|
||||
|
||||
async function fetchPlatformList(page = 1, append = false) {
|
||||
async function fetchPlatformList() {
|
||||
if (platformLoading.value) return;
|
||||
platformLoading.value = true;
|
||||
try {
|
||||
const keyword = platformSearchKeyword.value.trim();
|
||||
const data = await getPlatformPageApi({
|
||||
page,
|
||||
pageSize: FILTER_PAGE_SIZE,
|
||||
filters: {
|
||||
...(keyword ? { platformName: keyword } : {}),
|
||||
isActive: 1,
|
||||
},
|
||||
});
|
||||
const records = data.records ?? [];
|
||||
platforms.value = append ? [...platforms.value, ...records] : records;
|
||||
platformTotal.value = data.total ?? 0;
|
||||
platformPage.value = page;
|
||||
platforms.value = (await getPlatformListApi()) ?? [];
|
||||
} catch {
|
||||
message.error('平台列表加载失败');
|
||||
} finally {
|
||||
@@ -333,9 +325,9 @@ async function fetchShopList(page = 1, append = false) {
|
||||
const keyword = shopSearchKeyword.value.trim();
|
||||
const filters: ShopDTO.Filters = {};
|
||||
if (keyword) filters.name = keyword;
|
||||
const platformId = parseSelectedPlatformId();
|
||||
if (platformId != null) {
|
||||
filters.platformId = platformId;
|
||||
const platformCode = parseSelectedPlatformCode();
|
||||
if (platformCode) {
|
||||
filters.platformCode = platformCode;
|
||||
}
|
||||
const data = await getShopPageApi({
|
||||
page,
|
||||
@@ -357,7 +349,6 @@ function handlePlatformSearch(keyword: string) {
|
||||
if (platformSearchTimer) clearTimeout(platformSearchTimer);
|
||||
platformSearchTimer = setTimeout(() => {
|
||||
platformSearchKeyword.value = keyword;
|
||||
void fetchPlatformList(1, false);
|
||||
}, 300);
|
||||
}
|
||||
|
||||
@@ -369,17 +360,6 @@ function handleShopSearch(keyword: string) {
|
||||
}, 300);
|
||||
}
|
||||
|
||||
function handlePlatformPopupScroll(e: Event) {
|
||||
const target = e.target as HTMLElement;
|
||||
const { scrollTop, scrollHeight, clientHeight } = target;
|
||||
if (scrollHeight - scrollTop - clientHeight < 50) {
|
||||
const hasMore = platformPage.value * FILTER_PAGE_SIZE < platformTotal.value;
|
||||
if (hasMore && !platformLoading.value) {
|
||||
void fetchPlatformList(platformPage.value + 1, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function handleShopPopupScroll(e: Event) {
|
||||
const target = e.target as HTMLElement;
|
||||
const { scrollTop, scrollHeight, clientHeight } = target;
|
||||
@@ -391,26 +371,32 @@ function handleShopPopupScroll(e: Event) {
|
||||
}
|
||||
}
|
||||
|
||||
function handlePlatformDropdownVisibleChange(open: boolean) {
|
||||
if (!open) return;
|
||||
platformSearchKeyword.value = '';
|
||||
void fetchPlatformList(1, false);
|
||||
}
|
||||
|
||||
function handleShopDropdownVisibleChange(open: boolean) {
|
||||
if (!open) return;
|
||||
shopSearchKeyword.value = '';
|
||||
void fetchShopList(1, false);
|
||||
}
|
||||
|
||||
function handlePlatformPopupScroll(_e: Event) {
|
||||
// 静态字典无需分页加载
|
||||
}
|
||||
|
||||
function handlePlatformDropdownVisibleChange(open: boolean) {
|
||||
if (!open) return;
|
||||
platformSearchKeyword.value = '';
|
||||
if (platforms.value.length === 0) {
|
||||
void fetchPlatformList();
|
||||
}
|
||||
}
|
||||
|
||||
const workbenchExportContext = computed<WorkbenchDTO.ExportPayload>(() => ({
|
||||
dateRange: [
|
||||
dateRange.value[0].format('YYYY-MM-DD'),
|
||||
dateRange.value[1].format('YYYY-MM-DD'),
|
||||
],
|
||||
taxRate: taxRate.value,
|
||||
...(parseSelectedPlatformId() != null
|
||||
? { platformId: parseSelectedPlatformId()! }
|
||||
...(parseSelectedPlatformCode()
|
||||
? { platformCode: parseSelectedPlatformCode()! }
|
||||
: {}),
|
||||
...(parseSelectedShopId() != null ? { shopId: parseSelectedShopId()! } : {}),
|
||||
}));
|
||||
@@ -423,9 +409,9 @@ function buildWorkbenchQuery(): WorkbenchDTO.Query {
|
||||
],
|
||||
taxRate: taxRate.value,
|
||||
};
|
||||
const platformId = parseSelectedPlatformId();
|
||||
if (platformId != null) {
|
||||
query.platformId = platformId;
|
||||
const platformCode = parseSelectedPlatformCode();
|
||||
if (platformCode) {
|
||||
query.platformCode = platformCode;
|
||||
}
|
||||
const shopId = parseSelectedShopId();
|
||||
if (shopId != null) {
|
||||
@@ -914,7 +900,7 @@ onUnmounted(() => {
|
||||
ref="periodCompareTabRef"
|
||||
:active-tab="activeTab"
|
||||
:tax-rate="taxRate"
|
||||
:platform-id="parseSelectedPlatformId()"
|
||||
:platform-code="parseSelectedPlatformCode()"
|
||||
:shop-id="parseSelectedShopId()"
|
||||
/>
|
||||
</Tabs.TabPane>
|
||||
|
||||
+4
-4
@@ -29,7 +29,7 @@ const props = withDefaults(
|
||||
activeTab: string;
|
||||
/** 与页头税率一致 */
|
||||
taxRate: number;
|
||||
platformId?: number;
|
||||
platformCode?: string;
|
||||
shopId?: number;
|
||||
}>(),
|
||||
{ activeTab: 'finance' },
|
||||
@@ -291,8 +291,8 @@ function buildWorkbenchQuery(range: [dayjs.Dayjs, dayjs.Dayjs]): WorkbenchDTO.Qu
|
||||
dateRange: [range[0].format('YYYY-MM-DD'), range[1].format('YYYY-MM-DD')],
|
||||
taxRate: props.taxRate,
|
||||
};
|
||||
if (props.platformId != null) {
|
||||
q.platformId = props.platformId;
|
||||
if (props.platformCode) {
|
||||
q.platformCode = props.platformCode;
|
||||
}
|
||||
if (props.shopId != null) {
|
||||
q.shopId = props.shopId;
|
||||
@@ -328,7 +328,7 @@ watch(
|
||||
() => ({
|
||||
tab: props.activeTab,
|
||||
tax: props.taxRate,
|
||||
plat: props.platformId,
|
||||
plat: props.platformCode,
|
||||
shop: props.shopId,
|
||||
a0: periodA.value[0]?.valueOf(),
|
||||
a1: periodA.value[1]?.valueOf(),
|
||||
|
||||
+7
-7
@@ -38,7 +38,7 @@ const activeMode = ref<'category' | 'platform' | 'product' | 'shop'>('shop');
|
||||
const shopExportMode = ref(false);
|
||||
const selectedExportShopIds = ref<number[]>([]);
|
||||
const platformExportMode = ref(false);
|
||||
const selectedExportPlatformIds = ref<number[]>([]);
|
||||
const selectedExportPlatformCodes = ref<string[]>([]);
|
||||
const categoryExportMode = ref(false);
|
||||
const selectedExportCategoryIds = ref<number[]>([]);
|
||||
const productExportMode = ref(false);
|
||||
@@ -70,7 +70,7 @@ function baseExportParams(): Record<string, unknown> | null {
|
||||
dateRange: ctx.dateRange,
|
||||
taxRate: ctx.taxRate ?? props.taxRate,
|
||||
};
|
||||
if (ctx.platformId != null) p.platformId = ctx.platformId;
|
||||
if (ctx.platformCode) p.platformCode = ctx.platformCode;
|
||||
if (ctx.shopId != null) p.shopId = ctx.shopId;
|
||||
return p;
|
||||
}
|
||||
@@ -108,8 +108,8 @@ async function handlePlatformExport() {
|
||||
try {
|
||||
exportLoading.value = true;
|
||||
const payload: Record<string, unknown> = { ...base };
|
||||
if (platformExportMode.value && selectedExportPlatformIds.value.length > 0) {
|
||||
payload.platformIds = selectedExportPlatformIds.value;
|
||||
if (platformExportMode.value && selectedExportPlatformCodes.value.length > 0) {
|
||||
payload.platformCodes = selectedExportPlatformCodes.value;
|
||||
}
|
||||
await exportByPost(
|
||||
'/ec/workbench/export/by-platform',
|
||||
@@ -117,7 +117,7 @@ async function handlePlatformExport() {
|
||||
`多维度经营明细_按平台汇总_${dateSegmentForFilename()}.xlsx`,
|
||||
);
|
||||
platformExportMode.value = false;
|
||||
selectedExportPlatformIds.value = [];
|
||||
selectedExportPlatformCodes.value = [];
|
||||
} finally {
|
||||
exportLoading.value = false;
|
||||
}
|
||||
@@ -204,8 +204,8 @@ async function handleProductExport() {
|
||||
:platform-summary="platformSummary ?? undefined"
|
||||
:tax-rate="taxRate"
|
||||
:platform-export-mode="platformExportMode"
|
||||
:selected-export-platform-ids="selectedExportPlatformIds"
|
||||
@update:selected-export-platform-ids="selectedExportPlatformIds = $event"
|
||||
:selected-export-platform-codes="selectedExportPlatformCodes"
|
||||
@update:selected-export-platform-codes="selectedExportPlatformCodes = $event"
|
||||
@toggle-platform-export-mode="platformExportMode = $event"
|
||||
@export="handlePlatformExport"
|
||||
/>
|
||||
|
||||
+16
-16
@@ -17,20 +17,20 @@ interface Props {
|
||||
taxRate?: number;
|
||||
platformSummary?: CompanyOverviewVO.PlatformOverview;
|
||||
platformExportMode?: boolean;
|
||||
selectedExportPlatformIds?: number[];
|
||||
selectedExportPlatformCodes?: string[];
|
||||
headingTitle?: string;
|
||||
headingSubtitle?: string;
|
||||
}
|
||||
|
||||
interface Emits {
|
||||
(e: 'update:selectedExportPlatformIds', ids: number[]): void;
|
||||
(e: 'update:selectedExportPlatformCodes', codes: string[]): void;
|
||||
(e: 'togglePlatformExportMode', enabled: boolean): void;
|
||||
(e: 'export'): void;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
platformExportMode: false,
|
||||
selectedExportPlatformIds: () => [],
|
||||
selectedExportPlatformCodes: () => [],
|
||||
headingTitle: '各平台多维度经营明细汇总',
|
||||
headingSubtitle: '目标达成 · 规模 · 成本费用 · 盈利分析,四大维度完整汇总',
|
||||
});
|
||||
@@ -38,10 +38,10 @@ const emit = defineEmits<Emits>();
|
||||
|
||||
const allPlatformsSelected = computed(() => {
|
||||
const total = platformData.value.length;
|
||||
return total > 0 && props.selectedExportPlatformIds.length === total;
|
||||
return total > 0 && props.selectedExportPlatformCodes.length === total;
|
||||
});
|
||||
const somePlatformsSelected = computed(() => {
|
||||
return props.selectedExportPlatformIds.length > 0;
|
||||
return props.selectedExportPlatformCodes.length > 0;
|
||||
});
|
||||
|
||||
const formatAmount = (amount: number) => {
|
||||
@@ -63,7 +63,7 @@ const taxRateNum = computed(() => (props.taxRate ?? 0.04) * 100);
|
||||
const platformData = computed(() => {
|
||||
if (props.platformSummary?.platforms && props.platformSummary.platforms.length > 0) {
|
||||
return props.platformSummary.platforms.map(p => ({
|
||||
platformId: p.platformId,
|
||||
platformCode: p.platformCode,
|
||||
platformName: p.platformName,
|
||||
targetOrderCount: p.targetOrderCount ?? 0,
|
||||
orderCountAchievementRate: p.orderCountAchievementRate ?? 0,
|
||||
@@ -134,10 +134,10 @@ const sortedData = computed(() => {
|
||||
</button>
|
||||
<button
|
||||
class="rounded-2xl bg-blue-600 px-8 py-3 text-sm font-bold text-white shadow-xl shadow-slate-200 transition-all hover:scale-105 active:scale-95 dark:shadow-none"
|
||||
:disabled="selectedExportPlatformIds.length === 0"
|
||||
:disabled="selectedExportPlatformCodes.length === 0"
|
||||
@click="emit('export')"
|
||||
>
|
||||
导出已选平台 ({{ selectedExportPlatformIds.length }})
|
||||
导出已选平台 ({{ selectedExportPlatformCodes.length }})
|
||||
</button>
|
||||
</template>
|
||||
<template v-else>
|
||||
@@ -178,11 +178,11 @@ const sortedData = computed(() => {
|
||||
(e) => {
|
||||
if ((e.target as HTMLInputElement).checked) {
|
||||
emit(
|
||||
'update:selectedExportPlatformIds',
|
||||
platformData.map((p) => p.platformId) || [],
|
||||
'update:selectedExportPlatformCodes',
|
||||
platformData.map((p) => p.platformCode) || [],
|
||||
);
|
||||
} else {
|
||||
emit('update:selectedExportPlatformIds', []);
|
||||
emit('update:selectedExportPlatformCodes', []);
|
||||
}
|
||||
}
|
||||
"
|
||||
@@ -311,7 +311,7 @@ const sortedData = computed(() => {
|
||||
<tbody class="divide-y divide-slate-100 dark:divide-[hsl(240deg_3.7%_22%)]">
|
||||
<tr
|
||||
v-for="p in sortedData"
|
||||
:key="p.platformId"
|
||||
:key="p.platformCode"
|
||||
class="transition-colors hover:bg-blue-50/50 dark:hover:bg-[hsl(217.2deg_32.6%_17.5%/30%)] dark:bg-[hsl(217.2deg_32.6%_17.5%/50%)]"
|
||||
>
|
||||
<td
|
||||
@@ -321,14 +321,14 @@ const sortedData = computed(() => {
|
||||
<input
|
||||
type="checkbox"
|
||||
class="h-4 w-4 cursor-pointer accent-blue-600"
|
||||
:checked="selectedExportPlatformIds.includes(p.platformId)"
|
||||
:checked="selectedExportPlatformCodes.includes(p.platformCode)"
|
||||
@change="
|
||||
(e) => {
|
||||
const checked = (e.target as HTMLInputElement).checked;
|
||||
const newIds = checked
|
||||
? [...selectedExportPlatformIds, p.platformId]
|
||||
: selectedExportPlatformIds.filter((id) => id !== p.platformId);
|
||||
emit('update:selectedExportPlatformIds', newIds);
|
||||
? [...selectedExportPlatformCodes, p.platformCode]
|
||||
: selectedExportPlatformCodes.filter((id) => id !== p.platformCode);
|
||||
emit('update:selectedExportPlatformCodes', newIds);
|
||||
}
|
||||
"
|
||||
/>
|
||||
|
||||
+3
-6
@@ -59,7 +59,6 @@ function aggregateShopTotal(
|
||||
totalPromotionFee,
|
||||
brushFee: sum('brushFee'),
|
||||
feeRatio,
|
||||
gmv: 0,
|
||||
grossProfit: sum('grossProfit'),
|
||||
totalProfitBeforeTax: sum('totalProfitBeforeTax'),
|
||||
salesTaxAmount: sum('salesTaxAmount'),
|
||||
@@ -126,7 +125,6 @@ function aggregateCategoryTotal(
|
||||
totalPromotionFee,
|
||||
brushFee: sum('brushFee'),
|
||||
feeRatio,
|
||||
gmv: 0,
|
||||
grossProfit: sum('grossProfit'),
|
||||
totalProfitBeforeTax: sum('totalProfitBeforeTax'),
|
||||
salesTaxAmount: sum('salesTaxAmount'),
|
||||
@@ -150,9 +148,9 @@ function dimRowToPlatformSummary(
|
||||
const grossYuan = yuanField(row.grossProfitYuan);
|
||||
const profitAfterTax = yuanField(row.netProfitYuan);
|
||||
const orderCost = Math.max(0, salesAmount - refundAmount - grossYuan);
|
||||
const platformId = Number(row.key);
|
||||
const platformCode = row.key?.trim() || '';
|
||||
return {
|
||||
platformId: Number.isFinite(platformId) ? platformId : 0,
|
||||
platformCode,
|
||||
platformName: row.name,
|
||||
salesAmount,
|
||||
gmv: 0,
|
||||
@@ -178,7 +176,7 @@ function aggregatePlatformTotal(
|
||||
const averageOrderValue = salesAmount / orderCount;
|
||||
const feeRatio = salesAmount ? (totalPromotionFee / salesAmount) * 100 : 0;
|
||||
return {
|
||||
platformId: 0,
|
||||
platformCode: '',
|
||||
platformName: '合计',
|
||||
targetOrderCount: sum('targetOrderCount'),
|
||||
orderCountAchievementRate: sum('orderCountAchievementRate'),
|
||||
@@ -196,7 +194,6 @@ function aggregatePlatformTotal(
|
||||
totalPromotionFee,
|
||||
brushFee: sum('brushFee'),
|
||||
feeRatio,
|
||||
gmv: 0,
|
||||
grossProfit: sum('grossProfit'),
|
||||
totalProfitBeforeTax: sum('totalProfitBeforeTax'),
|
||||
salesTaxAmount: sum('salesTaxAmount'),
|
||||
|
||||
+41
-41
@@ -1,9 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import type { BrushOrderDTO, BrushOrderVO } from '#/api/ecommerce/brush-order';
|
||||
import type {
|
||||
ProductSpecDTO,
|
||||
ProductSpecVO,
|
||||
} from '#/api/ecommerce/product-spec/types';
|
||||
ProductSkuDTO,
|
||||
ProductSkuVO,
|
||||
} from '#/api/ecommerce/product-sku/types';
|
||||
import type { ProductDTO, ProductVO } from '#/api/ecommerce/product/types';
|
||||
import type { ShopVO } from '#/api/ecommerce/shop/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
@@ -30,7 +30,7 @@ import {
|
||||
updateBrushOrderApi,
|
||||
} from '#/api/ecommerce/brush-order';
|
||||
import { getProductPageApi } from '#/api/ecommerce/product';
|
||||
import { getProductSpecPageApi } from '#/api/ecommerce/product-spec';
|
||||
import { getProductSkuPageApi } from '#/api/ecommerce/product-sku';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
|
||||
defineOptions({ name: 'BrushOrderFormModal' });
|
||||
@@ -81,7 +81,7 @@ const isEdit = ref(false);
|
||||
const formData = ref<BrushOrderDTO.Create>({
|
||||
shopId: undefined as any,
|
||||
productId: undefined,
|
||||
productSpecId: undefined,
|
||||
productSkuId: undefined,
|
||||
brushAmount: undefined as any,
|
||||
brushTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
quantity: 1,
|
||||
@@ -110,11 +110,11 @@ const productLoading = ref(false);
|
||||
const productSearchKeyword = ref('');
|
||||
|
||||
// 规格选项数据
|
||||
const productSpecOptions = ref<
|
||||
{ label: string; spec: ProductSpecVO.Info; value: number }[]
|
||||
const productSkuOptions = ref<
|
||||
{ label: string; sku: ProductSkuVO.Info; value: number }[]
|
||||
>([]);
|
||||
const productSpecLoading = ref(false);
|
||||
const productSpecSearchKeyword = ref('');
|
||||
const productSkuLoading = ref(false);
|
||||
const productSkuSearchKeyword = ref('');
|
||||
|
||||
// 处理日期选择器的双向绑定
|
||||
const brushTimeValue = computed({
|
||||
@@ -144,7 +144,7 @@ watch(
|
||||
formData.value = {
|
||||
shopId: props.brushOrderData.shopId,
|
||||
productId: props.brushOrderData.productId,
|
||||
productSpecId: props.brushOrderData.productSpecId,
|
||||
productSkuId: props.brushOrderData.productSkuId,
|
||||
brushAmount: props.brushOrderData.brushAmount,
|
||||
brushTime: props.brushOrderData.brushTime
|
||||
? dayjs(props.brushOrderData.brushTime).format('YYYY-MM-DD HH:mm:ss')
|
||||
@@ -165,7 +165,7 @@ watch(
|
||||
// 远程搜索 Select 仅 @search 不会在「只点开下拉」时请求,这里打开弹窗后预加载一页
|
||||
void searchProducts('');
|
||||
if (formData.value.productId) {
|
||||
void searchProductSpecs('');
|
||||
void searchProductSkus('');
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
@@ -215,15 +215,15 @@ async function searchProducts(keyword: string) {
|
||||
}
|
||||
|
||||
// 搜索规格
|
||||
async function searchProductSpecs(keyword: string) {
|
||||
async function searchProductSkus(keyword: string) {
|
||||
if (!formData.value.productId) {
|
||||
productSpecOptions.value = [];
|
||||
productSkuOptions.value = [];
|
||||
return;
|
||||
}
|
||||
productSpecSearchKeyword.value = keyword;
|
||||
productSpecLoading.value = true;
|
||||
productSkuSearchKeyword.value = keyword;
|
||||
productSkuLoading.value = true;
|
||||
try {
|
||||
const params: PageQueryDTO<ProductSpecDTO.Filters> = {
|
||||
const params: PageQueryDTO<ProductSkuDTO.Filters> = {
|
||||
page: 1,
|
||||
pageSize: 50,
|
||||
filters: {
|
||||
@@ -231,17 +231,17 @@ async function searchProductSpecs(keyword: string) {
|
||||
name: keyword || undefined,
|
||||
},
|
||||
};
|
||||
const data = await getProductSpecPageApi(params);
|
||||
productSpecOptions.value = data.records.map((spec: ProductSpecVO.Info) => ({
|
||||
label: `${spec.name}${spec.specCode ? ` (${spec.specCode})` : ''}`,
|
||||
value: spec.id,
|
||||
spec,
|
||||
const data = await getProductSkuPageApi(params);
|
||||
productSkuOptions.value = data.records.map((sku: ProductSkuVO.Info) => ({
|
||||
label: `${sku.name}${sku.skuCode ? ` (${sku.skuCode})` : ''}`,
|
||||
value: sku.id,
|
||||
sku,
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error('搜索规格失败:', error);
|
||||
message.error('搜索规格失败');
|
||||
} finally {
|
||||
productSpecLoading.value = false;
|
||||
productSkuLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,9 +253,9 @@ function onProductSelectFocus() {
|
||||
}
|
||||
|
||||
/** 点开规格下拉时拉规格列表 */
|
||||
function onProductSpecSelectFocus() {
|
||||
if (!formData.value.productId || productSpecLoading.value) return;
|
||||
void searchProductSpecs(productSpecSearchKeyword.value || '');
|
||||
function onProductSkuSelectFocus() {
|
||||
if (!formData.value.productId || productSkuLoading.value) return;
|
||||
void searchProductSkus(productSkuSearchKeyword.value || '');
|
||||
}
|
||||
|
||||
function normalizeProductId(value: SelectValue): number | undefined {
|
||||
@@ -276,10 +276,10 @@ function normalizeProductId(value: SelectValue): number | undefined {
|
||||
function handleProductChange(value: SelectValue) {
|
||||
const productId = normalizeProductId(value);
|
||||
if (!productId) {
|
||||
formData.value.productSpecId = undefined;
|
||||
productSpecOptions.value = [];
|
||||
formData.value.productSkuId = undefined;
|
||||
productSkuOptions.value = [];
|
||||
} else {
|
||||
void searchProductSpecs('');
|
||||
void searchProductSkus('');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,10 +288,10 @@ watch(
|
||||
() => formData.value.productId,
|
||||
(newProductId) => {
|
||||
if (newProductId) {
|
||||
searchProductSpecs('');
|
||||
searchProductSkus('');
|
||||
} else {
|
||||
productSpecOptions.value = [];
|
||||
formData.value.productSpecId = undefined;
|
||||
productSkuOptions.value = [];
|
||||
formData.value.productSkuId = undefined;
|
||||
}
|
||||
},
|
||||
);
|
||||
@@ -301,14 +301,14 @@ const resetFormData = () => {
|
||||
formData.value = {
|
||||
shopId: undefined as any,
|
||||
productId: undefined,
|
||||
productSpecId: undefined,
|
||||
productSkuId: undefined,
|
||||
brushAmount: undefined as any,
|
||||
brushTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
quantity: 1,
|
||||
remark: undefined,
|
||||
};
|
||||
productOptions.value = [];
|
||||
productSpecOptions.value = [];
|
||||
productSkuOptions.value = [];
|
||||
};
|
||||
|
||||
// 确认操作
|
||||
@@ -406,20 +406,20 @@ onMounted(() => {
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="商品规格" name="productSpecId">
|
||||
<Form.Item label="商品 SKU" name="productSkuId">
|
||||
<Select
|
||||
v-model:value="formData.productSpecId"
|
||||
placeholder="请选择商品规格(可选)"
|
||||
v-model:value="formData.productSkuId"
|
||||
placeholder="请选择商品 SKU(可选)"
|
||||
show-search
|
||||
:filter-option="false"
|
||||
:loading="productSpecLoading"
|
||||
:loading="productSkuLoading"
|
||||
:disabled="!formData.productId"
|
||||
allow-clear
|
||||
@search="searchProductSpecs"
|
||||
@focus="onProductSpecSelectFocus"
|
||||
@search="searchProductSkus"
|
||||
@focus="onProductSkuSelectFocus"
|
||||
>
|
||||
<template #notFoundContent>
|
||||
<div v-if="productSpecLoading" class="py-4 text-center">
|
||||
<div v-if="productSkuLoading" class="py-4 text-center">
|
||||
<Spin size="small" />
|
||||
<div class="mt-2">加载中...</div>
|
||||
</div>
|
||||
@@ -428,7 +428,7 @@ onMounted(() => {
|
||||
</div>
|
||||
</template>
|
||||
<Select.Option
|
||||
v-for="option in productSpecOptions"
|
||||
v-for="option in productSkuOptions"
|
||||
:key="option.value"
|
||||
:value="option.value"
|
||||
>
|
||||
|
||||
@@ -537,10 +537,10 @@ const formatAmount = (amount: number) => `¥${amount.toFixed(2)}`;
|
||||
<div v-if="row.productName">
|
||||
<div class="font-semibold">{{ row.productName }}</div>
|
||||
<div
|
||||
v-if="row.productSpecName"
|
||||
v-if="row.productSkuName"
|
||||
class="text-xs text-muted-foreground"
|
||||
>
|
||||
{{ row.productSpecName }}
|
||||
{{ row.productSkuName }}
|
||||
</div>
|
||||
</div>
|
||||
<span v-else class="text-muted-foreground">—</span>
|
||||
|
||||
-299
@@ -1,299 +0,0 @@
|
||||
<script lang="ts" setup>
|
||||
import type { OrderStatusVO } from '#/api/ecommerce/order-status';
|
||||
|
||||
import { patchOrderStatusApi } from '#/api/ecommerce/order-status';
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
|
||||
import { Button, Card, message, Popconfirm, Switch } from 'ant-design-vue';
|
||||
|
||||
const props = defineProps<{
|
||||
status: OrderStatusVO.Info;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
delete: [OrderStatusVO.Info];
|
||||
edit: [OrderStatusVO.Info];
|
||||
patched: [vo?: OrderStatusVO.Info];
|
||||
}>();
|
||||
|
||||
const EditIcon = createIconifyIcon('lucide:pencil');
|
||||
const TrashIcon = createIconifyIcon('lucide:trash-2');
|
||||
const RefundIcon = createIconifyIcon('lucide:rotate-ccw');
|
||||
|
||||
type StatKey = keyof Pick<
|
||||
OrderStatusVO.Info,
|
||||
| 'includeSalesAmount'
|
||||
| 'includeProductCost'
|
||||
| 'includeFreightCost'
|
||||
| 'includeOtherCost'
|
||||
| 'includeRefund'
|
||||
>;
|
||||
|
||||
function dim01(v: unknown): 0 | 1 {
|
||||
if (v === 1 || v === '1' || v === true) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
async function handleDimChange(key: StatKey, next: unknown) {
|
||||
const val = dim01(next);
|
||||
if (dim01(props.status[key]) === val) return;
|
||||
try {
|
||||
const updated = await patchOrderStatusApi(props.status.id, { [key]: val });
|
||||
message.success('更新成功');
|
||||
if (updated && typeof updated === 'object' && 'id' in updated) {
|
||||
emit('patched', updated as OrderStatusVO.Info);
|
||||
} else {
|
||||
emit('patched');
|
||||
}
|
||||
} catch {
|
||||
message.error('更新失败');
|
||||
emit('patched');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Card
|
||||
:body-style="{ padding: 0 }"
|
||||
class="order-status-card group h-full overflow-hidden rounded-3xl border border-slate-200 bg-white shadow-[0_4px_14px_-2px_rgba(15,23,42,0.08),0_2px_6px_-2px_rgba(15,23,42,0.06)] transition-transform duration-200 hover:-translate-y-0.5 hover:border-slate-300 hover:shadow-[0_20px_28px_-8px_rgba(15,23,42,0.14),0_8px_16px_-6px_rgba(15,23,42,0.08)] dark:border-neutral-600 dark:bg-[hsl(222.34deg_10.43%_12.27%)] dark:shadow-[0_1px_0_0_rgb(255_255_255/0.06)_inset] dark:hover:border-neutral-500 dark:hover:shadow-[0_12px_40px_-12px_rgb(0_0_0/0.45)]"
|
||||
>
|
||||
<!-- 操作:单独一行,状态名称区域占满宽 -->
|
||||
<div class="flex justify-end gap-0.5 px-8 pt-3 pb-0.5">
|
||||
<Button
|
||||
type="text"
|
||||
class="!flex !h-11 !w-11 !items-center !justify-center !rounded-xl !text-slate-600 hover:!bg-blue-50 hover:!text-blue-600 dark:!text-neutral-300 dark:hover:!bg-blue-950/40 dark:hover:!text-blue-400"
|
||||
@click="emit('edit', status)"
|
||||
>
|
||||
<EditIcon class="h-6 w-6" />
|
||||
</Button>
|
||||
<Popconfirm title="确定删除该订单状态?" @confirm="emit('delete', status)">
|
||||
<Button
|
||||
type="text"
|
||||
class="!flex !h-11 !w-11 !items-center !justify-center !rounded-xl !text-slate-600 hover:!bg-red-50 hover:!text-red-600 dark:!text-neutral-300 dark:hover:!bg-red-950/30 dark:hover:!text-red-400"
|
||||
>
|
||||
<TrashIcon class="h-6 w-6" />
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
</div>
|
||||
|
||||
<!-- 状态名称 + 描述:整行留给标题 -->
|
||||
<div
|
||||
class="order-status-card-hero border-b border-slate-200 bg-slate-50/60 px-8 pb-6 pt-1 dark:border-neutral-700 dark:bg-neutral-900/35"
|
||||
>
|
||||
<div class="flex min-w-0 items-start gap-4">
|
||||
<div
|
||||
class="mt-1 h-12 w-1.5 shrink-0 rounded-full bg-blue-600 dark:bg-blue-500"
|
||||
/>
|
||||
<div class="min-w-0 flex-1">
|
||||
<h1
|
||||
class="break-words text-4xl font-black leading-tight tracking-tight text-gray-950 dark:text-neutral-50"
|
||||
>
|
||||
{{ status.statusName }}
|
||||
</h1>
|
||||
<p
|
||||
class="desc-under-title mt-2 text-sm font-medium italic leading-relaxed text-gray-600 dark:text-neutral-400"
|
||||
>
|
||||
{{ status.description || '—' }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white px-8 pb-8 pt-1 dark:bg-transparent">
|
||||
<div class="mb-6 mt-5 flex items-center gap-2">
|
||||
<span
|
||||
class="text-xs font-bold uppercase tracking-widest text-slate-600 dark:text-neutral-400"
|
||||
>
|
||||
统计维度设置
|
||||
</span>
|
||||
<div class="h-px flex-1 bg-slate-200 dark:bg-neutral-600" />
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 gap-4 sm:grid-cols-2">
|
||||
<!-- 销售额 -->
|
||||
<div
|
||||
class="stat-tile stat-tile--sales group flex cursor-default flex-col justify-between rounded-2xl border border-slate-200 bg-slate-50 p-4 shadow-sm transition-all hover:border-blue-300 hover:bg-blue-50/80 hover:shadow-md dark:border-neutral-600 dark:bg-neutral-800 dark:shadow-none dark:hover:border-blue-600 dark:hover:bg-blue-950/35"
|
||||
>
|
||||
<span
|
||||
class="text-sm font-bold text-gray-800 transition-colors group-hover:text-blue-800 dark:text-neutral-100 dark:group-hover:text-blue-300"
|
||||
>销售额/单量</span
|
||||
>
|
||||
<div class="mt-4 flex items-center justify-between">
|
||||
<span
|
||||
class="text-[10px] font-bold uppercase text-slate-600 dark:text-neutral-400"
|
||||
>计入统计</span
|
||||
>
|
||||
<Switch
|
||||
size="small"
|
||||
class="stat-tile-switch"
|
||||
:checked="dim01(status.includeSalesAmount)"
|
||||
:checked-value="1"
|
||||
:un-checked-value="0"
|
||||
@update:checked="(v: unknown) => handleDimChange('includeSalesAmount', v)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 商品成本 -->
|
||||
<div
|
||||
class="stat-tile stat-tile--product group flex cursor-default flex-col justify-between rounded-2xl border border-slate-200 bg-slate-50 p-4 shadow-sm transition-all hover:border-emerald-300 hover:bg-emerald-50/80 hover:shadow-md dark:border-neutral-600 dark:bg-neutral-800 dark:shadow-none dark:hover:border-emerald-600 dark:hover:bg-emerald-950/35"
|
||||
>
|
||||
<span
|
||||
class="text-sm font-bold text-gray-800 transition-colors group-hover:text-emerald-800 dark:text-neutral-100 dark:group-hover:text-emerald-300"
|
||||
>商品成本</span
|
||||
>
|
||||
<div class="mt-4 flex items-center justify-between">
|
||||
<span
|
||||
class="text-[10px] font-bold uppercase text-slate-600 dark:text-neutral-400"
|
||||
>计入统计</span
|
||||
>
|
||||
<Switch
|
||||
size="small"
|
||||
class="stat-tile-switch"
|
||||
:checked="dim01(status.includeProductCost)"
|
||||
:checked-value="1"
|
||||
:un-checked-value="0"
|
||||
@update:checked="(v: unknown) => handleDimChange('includeProductCost', v)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 运费成本 -->
|
||||
<div
|
||||
class="stat-tile stat-tile--freight group flex cursor-default flex-col justify-between rounded-2xl border border-slate-200 bg-slate-50 p-4 shadow-sm transition-all hover:border-amber-300 hover:bg-amber-50/80 hover:shadow-md dark:border-neutral-600 dark:bg-neutral-800 dark:shadow-none dark:hover:border-amber-600 dark:hover:bg-amber-950/35"
|
||||
>
|
||||
<span
|
||||
class="text-sm font-bold text-gray-800 transition-colors group-hover:text-amber-800 dark:text-neutral-100 dark:group-hover:text-amber-300"
|
||||
>运费成本</span
|
||||
>
|
||||
<div class="mt-4 flex items-center justify-between">
|
||||
<span
|
||||
class="text-[10px] font-bold uppercase text-slate-600 dark:text-neutral-400"
|
||||
>计入统计</span
|
||||
>
|
||||
<Switch
|
||||
size="small"
|
||||
class="stat-tile-switch"
|
||||
:checked="dim01(status.includeFreightCost)"
|
||||
:checked-value="1"
|
||||
:un-checked-value="0"
|
||||
@update:checked="(v: unknown) => handleDimChange('includeFreightCost', v)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 其他成本 -->
|
||||
<div
|
||||
class="stat-tile stat-tile--other group flex cursor-default flex-col justify-between rounded-2xl border border-slate-200 bg-slate-50 p-4 shadow-sm transition-all hover:border-purple-300 hover:bg-purple-50/80 hover:shadow-md dark:border-neutral-600 dark:bg-neutral-800 dark:shadow-none dark:hover:border-purple-600 dark:hover:bg-purple-950/35"
|
||||
>
|
||||
<span
|
||||
class="text-sm font-bold text-gray-800 transition-colors group-hover:text-purple-800 dark:text-neutral-100 dark:group-hover:text-purple-300"
|
||||
>其他成本</span
|
||||
>
|
||||
<div class="mt-4 flex items-center justify-between">
|
||||
<span
|
||||
class="text-[10px] font-bold uppercase text-slate-600 dark:text-neutral-400"
|
||||
>计入统计</span
|
||||
>
|
||||
<Switch
|
||||
size="small"
|
||||
class="stat-tile-switch"
|
||||
:checked="dim01(status.includeOtherCost)"
|
||||
:checked-value="1"
|
||||
:un-checked-value="0"
|
||||
@update:checked="(v: unknown) => handleDimChange('includeOtherCost', v)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 退款:全宽、虚线、弱化 -->
|
||||
<div
|
||||
class="stat-tile stat-tile--refund group col-span-1 flex cursor-default items-center justify-between rounded-2xl border border-dashed border-slate-300 bg-slate-100 p-4 shadow-sm transition-all hover:border-orange-300 hover:bg-orange-50/50 hover:shadow-md sm:col-span-2 dark:border-neutral-500 dark:bg-neutral-800/90 dark:shadow-none dark:hover:border-orange-700/80 dark:hover:bg-orange-950/25"
|
||||
>
|
||||
<div class="flex min-w-0 items-center gap-3">
|
||||
<RefundIcon
|
||||
class="h-4 w-4 shrink-0 text-slate-600 transition-colors group-hover:text-orange-700 dark:text-neutral-300 dark:group-hover:text-orange-400"
|
||||
/>
|
||||
<span
|
||||
class="text-sm font-bold text-gray-800 transition-colors group-hover:text-gray-950 dark:text-neutral-100 dark:group-hover:text-neutral-50"
|
||||
>
|
||||
计入退款金额统计
|
||||
</span>
|
||||
</div>
|
||||
<Switch
|
||||
size="small"
|
||||
class="stat-tile-switch"
|
||||
:checked="dim01(status.includeRefund)"
|
||||
:checked-value="1"
|
||||
:un-checked-value="0"
|
||||
@update:checked="(v: unknown) => handleDimChange('includeRefund', v)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.desc-under-title {
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 3;
|
||||
line-clamp: 3;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.order-status-card {
|
||||
.stat-tile-switch:deep(.ant-switch) {
|
||||
min-width: 48px;
|
||||
}
|
||||
|
||||
/* 非退款 tile:关态轨道略深,与白底区分 */
|
||||
.stat-tile:not(.stat-tile--refund) :deep(.ant-switch:not(.ant-switch-checked)) {
|
||||
background: #cbd5e1 !important;
|
||||
box-shadow: inset 0 0 0 1px rgb(15 23 42 / 0.06);
|
||||
}
|
||||
|
||||
.stat-tile--sales :deep(.ant-switch-checked) {
|
||||
background: #3b82f6 !important;
|
||||
}
|
||||
.stat-tile--product :deep(.ant-switch-checked) {
|
||||
background: #10b981 !important;
|
||||
}
|
||||
.stat-tile--freight :deep(.ant-switch-checked) {
|
||||
background: #f59e0b !important;
|
||||
}
|
||||
.stat-tile--other :deep(.ant-switch-checked) {
|
||||
background: #8b5cf6 !important;
|
||||
}
|
||||
/* 退款:关态浅灰轨 + 开态亮橙,与灰底卡片强对比 */
|
||||
.stat-tile--refund :deep(.ant-switch:not(.ant-switch-checked)) {
|
||||
background: #e5e7eb !important;
|
||||
box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.08);
|
||||
}
|
||||
.stat-tile--refund :deep(.ant-switch-checked) {
|
||||
background: #ea580c !important;
|
||||
box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.06);
|
||||
}
|
||||
.stat-tile--refund :deep(.ant-switch-checked .ant-switch-handle::before) {
|
||||
background: #fff !important;
|
||||
}
|
||||
}
|
||||
|
||||
html.dark .order-status-card {
|
||||
.stat-tile:not(.stat-tile--refund) :deep(.ant-switch:not(.ant-switch-checked)) {
|
||||
background: #3f3f46 !important;
|
||||
box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.08);
|
||||
}
|
||||
|
||||
.stat-tile--refund :deep(.ant-switch:not(.ant-switch-checked)) {
|
||||
background: #52525b !important;
|
||||
box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.12);
|
||||
}
|
||||
.stat-tile--refund :deep(.ant-switch-checked) {
|
||||
background: #f97316 !important;
|
||||
box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.2);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
-305
@@ -1,305 +0,0 @@
|
||||
<script lang="ts" setup>
|
||||
import type {
|
||||
OrderStatusDTO,
|
||||
OrderStatusVO,
|
||||
} from '#/api/ecommerce/order-status/types';
|
||||
|
||||
import { ref, watch } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { Form, Input, InputNumber, message, Switch } from 'ant-design-vue';
|
||||
|
||||
import {
|
||||
createOrderStatusApi,
|
||||
updateOrderStatusApi,
|
||||
} from '#/api/ecommerce/order-status';
|
||||
|
||||
const emit = defineEmits<{
|
||||
cancel: [];
|
||||
success: [];
|
||||
}>();
|
||||
|
||||
const STAT_DEFAULTS = {
|
||||
includeSalesAmount: 1,
|
||||
includeProductCost: 1,
|
||||
includeFreightCost: 1,
|
||||
includeOtherCost: 1,
|
||||
includeRefund: 0,
|
||||
} as const;
|
||||
|
||||
// 创建 vben modal
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
draggable: true,
|
||||
class: 'w-[640px]',
|
||||
onCancel() {
|
||||
close();
|
||||
},
|
||||
onConfirm() {
|
||||
handleSubmit();
|
||||
},
|
||||
});
|
||||
|
||||
// 响应式数据
|
||||
const loading = ref(false);
|
||||
const isEdit = ref(false);
|
||||
const currentRecord = ref<null | OrderStatusVO.Info>(null);
|
||||
|
||||
// 预设颜色列表
|
||||
const colorPresets = [
|
||||
'#1890ff', '#52c41a', '#faad14', '#f5222d',
|
||||
'#722ed1', '#13c2c2', '#eb2f96', '#fa8c16',
|
||||
'#a0d911', '#2f54eb', '#531dab', '#d9d9d9',
|
||||
];
|
||||
|
||||
// 表单数据
|
||||
const formData = ref<Partial<OrderStatusDTO.Create>>({
|
||||
statusName: '',
|
||||
description: '',
|
||||
color: '',
|
||||
sortOrder: 0,
|
||||
...STAT_DEFAULTS,
|
||||
});
|
||||
|
||||
// 表单验证规则
|
||||
const rules = {
|
||||
statusName: [{ required: true, message: '请输入状态名称', trigger: 'blur' }],
|
||||
sortOrder: [{ required: true, message: '请输入排序', trigger: 'blur' }],
|
||||
};
|
||||
|
||||
// 表单引用
|
||||
const formRef = ref();
|
||||
|
||||
function toStatNumber(v: number | undefined, fallback: number) {
|
||||
return v === 0 || v === 1 ? v : fallback;
|
||||
}
|
||||
|
||||
// 打开模态框
|
||||
function open(edit: boolean, record?: OrderStatusVO.Info) {
|
||||
isEdit.value = edit;
|
||||
currentRecord.value = record || null;
|
||||
modalApi.open();
|
||||
|
||||
// 根据模式填充表单数据
|
||||
formData.value =
|
||||
edit && record
|
||||
? {
|
||||
statusName: record.statusName,
|
||||
description: record.description || '',
|
||||
color: record.color || '',
|
||||
sortOrder: record.sortOrder || 0,
|
||||
includeSalesAmount: toStatNumber(
|
||||
record.includeSalesAmount,
|
||||
STAT_DEFAULTS.includeSalesAmount,
|
||||
),
|
||||
includeProductCost: toStatNumber(
|
||||
record.includeProductCost,
|
||||
STAT_DEFAULTS.includeProductCost,
|
||||
),
|
||||
includeFreightCost: toStatNumber(
|
||||
record.includeFreightCost,
|
||||
STAT_DEFAULTS.includeFreightCost,
|
||||
),
|
||||
includeOtherCost: toStatNumber(
|
||||
record.includeOtherCost,
|
||||
STAT_DEFAULTS.includeOtherCost,
|
||||
),
|
||||
includeRefund: toStatNumber(
|
||||
record.includeRefund,
|
||||
STAT_DEFAULTS.includeRefund,
|
||||
),
|
||||
}
|
||||
: {
|
||||
statusName: '',
|
||||
description: '',
|
||||
color: '',
|
||||
sortOrder: 0,
|
||||
...STAT_DEFAULTS,
|
||||
};
|
||||
}
|
||||
|
||||
// 关闭模态框
|
||||
function close() {
|
||||
modalApi.close();
|
||||
formRef.value?.resetFields();
|
||||
emit('cancel');
|
||||
}
|
||||
|
||||
// 选择颜色
|
||||
function selectColor(color: string) {
|
||||
formData.value.color = color;
|
||||
}
|
||||
|
||||
// 提交表单
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
await formRef.value?.validate();
|
||||
loading.value = true;
|
||||
|
||||
const dims = {
|
||||
includeSalesAmount: formData.value.includeSalesAmount!,
|
||||
includeProductCost: formData.value.includeProductCost!,
|
||||
includeFreightCost: formData.value.includeFreightCost!,
|
||||
includeOtherCost: formData.value.includeOtherCost!,
|
||||
includeRefund: formData.value.includeRefund!,
|
||||
};
|
||||
|
||||
if (isEdit.value && currentRecord.value) {
|
||||
const updateData: OrderStatusDTO.Update = {
|
||||
statusName: formData.value.statusName!,
|
||||
description: formData.value.description,
|
||||
color: formData.value.color,
|
||||
sortOrder: formData.value.sortOrder,
|
||||
...dims,
|
||||
};
|
||||
await updateOrderStatusApi(currentRecord.value.id, updateData);
|
||||
message.success('更新订单状态成功');
|
||||
} else {
|
||||
const createData: OrderStatusDTO.Create = {
|
||||
statusName: formData.value.statusName!,
|
||||
description: formData.value.description,
|
||||
color: formData.value.color,
|
||||
sortOrder: formData.value.sortOrder,
|
||||
...dims,
|
||||
};
|
||||
await createOrderStatusApi(createData);
|
||||
message.success('创建订单状态成功');
|
||||
}
|
||||
|
||||
emit('success');
|
||||
close();
|
||||
} catch (error) {
|
||||
console.error('提交订单状态失败:', (error as any).message);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 监听 modal 关闭状态
|
||||
watch(
|
||||
() => modalApi.useStore()?.value?.isOpen,
|
||||
(newVal) => {
|
||||
if (!newVal) {
|
||||
formRef.value?.resetFields();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// 暴露方法
|
||||
defineExpose({
|
||||
open,
|
||||
close,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal
|
||||
:title="isEdit ? '编辑订单状态' : '添加订单状态'"
|
||||
:confirm-loading="loading"
|
||||
>
|
||||
<Form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="rules as any"
|
||||
layout="vertical"
|
||||
>
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<Form.Item label="状态名称" name="statusName">
|
||||
<Input
|
||||
v-model:value="formData.statusName"
|
||||
placeholder="请输入状态名称"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="状态颜色" name="color">
|
||||
<div class="flex items-center gap-2">
|
||||
<div class="flex gap-1 flex-wrap">
|
||||
<div
|
||||
v-for="c in colorPresets"
|
||||
:key="c"
|
||||
class="h-6 w-6 cursor-pointer rounded border-2 transition-transform hover:scale-110"
|
||||
:style="{ backgroundColor: c, borderColor: formData.color === c ? '#000' : 'transparent' }"
|
||||
@click="selectColor(c)"
|
||||
></div>
|
||||
</div>
|
||||
<Input
|
||||
v-model:value="formData.color"
|
||||
placeholder="#1890ff"
|
||||
class="!w-24"
|
||||
/>
|
||||
</div>
|
||||
</Form.Item>
|
||||
</div>
|
||||
|
||||
<Form.Item label="状态描述" name="description">
|
||||
<Input.TextArea
|
||||
v-model:value="formData.description"
|
||||
placeholder="请输入状态描述(可选)"
|
||||
:rows="3"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<Form.Item label="排序" name="sortOrder">
|
||||
<InputNumber
|
||||
v-model:value="formData.sortOrder"
|
||||
placeholder="请输入排序"
|
||||
style="width: 100%"
|
||||
:min="0"
|
||||
/>
|
||||
</Form.Item>
|
||||
</div>
|
||||
|
||||
<div class="mb-2 text-sm font-medium text-foreground">
|
||||
统计维度(0/1)
|
||||
</div>
|
||||
<div class="grid grid-cols-2 gap-x-4 gap-y-2">
|
||||
<Form.Item label="计入销售额 / 单量" name="includeSalesAmount">
|
||||
<Switch
|
||||
v-model:checked="formData.includeSalesAmount"
|
||||
:checked-value="1"
|
||||
:un-checked-value="0"
|
||||
checked-children="计入"
|
||||
un-checked-children="不计入"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label="计入商品成本" name="includeProductCost">
|
||||
<Switch
|
||||
v-model:checked="formData.includeProductCost"
|
||||
:checked-value="1"
|
||||
:un-checked-value="0"
|
||||
checked-children="计入"
|
||||
un-checked-children="不计入"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label="计入运费成本" name="includeFreightCost">
|
||||
<Switch
|
||||
v-model:checked="formData.includeFreightCost"
|
||||
:checked-value="1"
|
||||
:un-checked-value="0"
|
||||
checked-children="计入"
|
||||
un-checked-children="不计入"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label="计入其他成本" name="includeOtherCost">
|
||||
<Switch
|
||||
v-model:checked="formData.includeOtherCost"
|
||||
:checked-value="1"
|
||||
:un-checked-value="0"
|
||||
checked-children="计入"
|
||||
un-checked-children="不计入"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label="计入退款金额" name="includeRefund" class="col-span-2">
|
||||
<Switch
|
||||
v-model:checked="formData.includeRefund"
|
||||
:checked-value="1"
|
||||
:un-checked-value="0"
|
||||
checked-children="计入"
|
||||
un-checked-children="不计入"
|
||||
/>
|
||||
</Form.Item>
|
||||
</div>
|
||||
</Form>
|
||||
</Modal>
|
||||
</template>
|
||||
-360
@@ -1,360 +0,0 @@
|
||||
<script lang="ts" setup>
|
||||
import type { OrderStatusVO } from '#/api/ecommerce/order-status';
|
||||
|
||||
import { computed, nextTick, onMounted, ref } from 'vue';
|
||||
import { Waterfall } from 'vue-waterfall-plugin-next';
|
||||
import 'vue-waterfall-plugin-next/dist/style.css';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
|
||||
import { Button, Card, Empty, message, Spin } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import {
|
||||
deleteOrderStatusApi,
|
||||
getAllOrderStatusListApi,
|
||||
} from '#/api/ecommerce/order-status';
|
||||
|
||||
import OrderStatusCard from './components/OrderStatusCard.vue';
|
||||
import OrderStatusFormModal from './components/OrderStatusFormModal.vue';
|
||||
|
||||
defineOptions({ name: 'OrderStatusConfig' });
|
||||
|
||||
/** 列表与筛选统一为 0 | 1,避免接口字符串与 Switch 受控值不一致 */
|
||||
function dim01(v: unknown): 0 | 1 {
|
||||
if (v === 1 || v === '1' || v === true) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
function normalizeOrderStatus(s: OrderStatusVO.Info): OrderStatusVO.Info {
|
||||
return {
|
||||
...s,
|
||||
includeSalesAmount: dim01(s.includeSalesAmount),
|
||||
includeProductCost: dim01(s.includeProductCost),
|
||||
includeFreightCost: dim01(s.includeFreightCost),
|
||||
includeOtherCost: dim01(s.includeOtherCost),
|
||||
includeRefund: dim01(s.includeRefund),
|
||||
};
|
||||
}
|
||||
|
||||
const PlusIcon = createIconifyIcon('lucide:plus');
|
||||
|
||||
const orderStatusFormModalRef = ref();
|
||||
const waterfallRef = ref();
|
||||
|
||||
const searchForm = ref({
|
||||
statusName: '',
|
||||
includeSalesAmount: undefined as number | undefined,
|
||||
});
|
||||
|
||||
const searchFormSubmitRef = ref<null | (() => Promise<unknown>)>(null);
|
||||
|
||||
const [SearchForm, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
},
|
||||
handleReset: handleSearchFormReset,
|
||||
handleSubmit: handleSearchFormSubmit,
|
||||
layout: 'horizontal',
|
||||
schema: [
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '状态名称(回车搜索)',
|
||||
allowClear: true,
|
||||
onPressEnter: () => void searchFormSubmitRef.value?.(),
|
||||
},
|
||||
defaultValue: '',
|
||||
fieldName: 'statusName',
|
||||
label: '状态名称',
|
||||
},
|
||||
{
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
placeholder: '是否计入销售额',
|
||||
allowClear: true,
|
||||
options: [
|
||||
{ label: '计入销售额', value: 1 },
|
||||
{ label: '不计入销售额', value: 0 },
|
||||
],
|
||||
},
|
||||
fieldName: 'includeSalesAmount',
|
||||
label: '销售额统计',
|
||||
},
|
||||
],
|
||||
showCollapseButton: false,
|
||||
showDefaultActions: true,
|
||||
submitButtonOptions: {
|
||||
content: '搜索',
|
||||
},
|
||||
resetButtonOptions: {
|
||||
content: '重置',
|
||||
},
|
||||
submitOnEnter: true,
|
||||
wrapperClass: 'grid-cols-1 md:grid-cols-2',
|
||||
});
|
||||
|
||||
searchFormSubmitRef.value = () => formApi.validateAndSubmitForm();
|
||||
|
||||
async function handleSearchFormSubmit(values: Record<string, any>) {
|
||||
searchForm.value = {
|
||||
statusName: String(values.statusName ?? '').trim(),
|
||||
includeSalesAmount:
|
||||
values.includeSalesAmount === '' || values.includeSalesAmount === undefined
|
||||
? undefined
|
||||
: Number(values.includeSalesAmount),
|
||||
};
|
||||
}
|
||||
|
||||
async function handleSearchFormReset() {
|
||||
await formApi.resetForm();
|
||||
searchForm.value = {
|
||||
statusName: '',
|
||||
includeSalesAmount: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
const loading = ref(false);
|
||||
const orderStatusList = ref<OrderStatusVO.Info[]>([]);
|
||||
|
||||
const displayList = computed(() => {
|
||||
let list = [...orderStatusList.value];
|
||||
const { statusName, includeSalesAmount } = searchForm.value;
|
||||
if (statusName) {
|
||||
list = list.filter((s) => s.statusName.includes(statusName));
|
||||
}
|
||||
if (includeSalesAmount === 0 || includeSalesAmount === 1) {
|
||||
list = list.filter((s) => dim01(s.includeSalesAmount) === includeSalesAmount);
|
||||
}
|
||||
list.sort((a, b) => (a.sortOrder ?? 0) - (b.sortOrder ?? 0));
|
||||
return list;
|
||||
});
|
||||
|
||||
async function loadOrderStatuses() {
|
||||
loading.value = true;
|
||||
try {
|
||||
const data = await getAllOrderStatusListApi();
|
||||
orderStatusList.value = (data || []).map(normalizeOrderStatus);
|
||||
} catch {
|
||||
message.error('获取订单状态列表失败');
|
||||
orderStatusList.value = [];
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
orderStatusFormModalRef.value?.open(false);
|
||||
}
|
||||
|
||||
function handleEdit(record: OrderStatusVO.Info) {
|
||||
orderStatusFormModalRef.value?.open(true, record);
|
||||
}
|
||||
|
||||
async function handleDelete(record: OrderStatusVO.Info) {
|
||||
try {
|
||||
await deleteOrderStatusApi(record.id);
|
||||
message.success('删除成功');
|
||||
await loadOrderStatuses();
|
||||
await handleWaterfallLayout();
|
||||
} catch {
|
||||
message.error('删除失败');
|
||||
}
|
||||
}
|
||||
|
||||
async function handleModalSuccess() {
|
||||
await loadOrderStatuses();
|
||||
await handleWaterfallLayout();
|
||||
}
|
||||
|
||||
/** 用 PATCH 返回体就地更新一条,避免再请求列表;找不到 id 时再全量拉取 */
|
||||
async function mergeOrderStatusFromPatch(vo: OrderStatusVO.Info) {
|
||||
const n = normalizeOrderStatus(vo);
|
||||
const idx = orderStatusList.value.findIndex(
|
||||
(s) => Number(s.id) === Number(n.id),
|
||||
);
|
||||
if (idx === -1) {
|
||||
await loadOrderStatuses();
|
||||
return;
|
||||
}
|
||||
const next = [...orderStatusList.value];
|
||||
next[idx] = n;
|
||||
orderStatusList.value = next;
|
||||
}
|
||||
|
||||
async function handlePatched(vo?: OrderStatusVO.Info) {
|
||||
if (vo) {
|
||||
await mergeOrderStatusFromPatch(vo);
|
||||
} else {
|
||||
await loadOrderStatuses();
|
||||
}
|
||||
await handleWaterfallLayout();
|
||||
}
|
||||
|
||||
async function handleWaterfallLayout() {
|
||||
await nextTick();
|
||||
await nextTick();
|
||||
waterfallRef.value?.renderer?.();
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadOrderStatuses();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page
|
||||
title="订单状态配置"
|
||||
auto-content-height
|
||||
content-class="flex min-h-0 flex-1 flex-col bg-[#f8fafc] dark:bg-[hsl(222.34deg_10.43%_12.27%)]"
|
||||
header-class="order-status-page-header"
|
||||
>
|
||||
<template #description>
|
||||
<div class="text-foreground/80 mt-2 max-w-4xl">
|
||||
管理订单状态及五个统计维度:销售额/单量、商品成本、运费成本、其他成本、退款金额;仅开启的维度会进入全店/店铺/商品概览与导出等统计。
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="flex min-h-0 flex-1 flex-col dark:bg-[hsl(222.34deg_10.43%_12.27%)]">
|
||||
<div class="flex min-h-0 flex-1 flex-col">
|
||||
<Card
|
||||
class="order-status-search mb-4 shrink-0 rounded-2xl border border-slate-200 bg-white/90 shadow-[0_4px_12px_rgba(0,0,0,0.03)] dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(222.34deg_10.43%_12.27%)] dark:shadow-none"
|
||||
:body-style="{ padding: '16px' }"
|
||||
>
|
||||
<SearchForm />
|
||||
</Card>
|
||||
|
||||
<div class="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden">
|
||||
<Card
|
||||
class="order-status-grid flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden rounded-2xl border border-slate-200 bg-white/90 shadow-[0_4px_12px_rgba(0,0,0,0.03)] dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(222.34deg_10.43%_12.27%)] dark:shadow-none"
|
||||
:body-style="{
|
||||
padding: '16px',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
flex: '1 1 0',
|
||||
minHeight: 0,
|
||||
overflow: 'hidden',
|
||||
}"
|
||||
>
|
||||
<div class="mb-3 flex shrink-0 items-center justify-between gap-3">
|
||||
<span class="text-sm text-gray-500 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
共 {{ displayList.length }} 个状态(全部 {{ orderStatusList.length }} 个)
|
||||
</span>
|
||||
<Button type="primary" @click="handleAdd">
|
||||
<PlusIcon class="mr-2 h-4 w-4" />
|
||||
添加状态
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="order-status-scroll flex min-h-0 min-w-0 flex-1 flex-col overflow-y-auto"
|
||||
>
|
||||
<Spin :spinning="loading && orderStatusList.length === 0">
|
||||
<div
|
||||
v-if="!loading && displayList.length === 0"
|
||||
class="flex min-h-[200px] items-center justify-center py-8"
|
||||
>
|
||||
<Empty description="暂无订单状态" />
|
||||
</div>
|
||||
|
||||
<Waterfall
|
||||
v-else-if="displayList.length > 0"
|
||||
ref="waterfallRef"
|
||||
:list="displayList"
|
||||
row-key="id"
|
||||
:horizontalOrder="true"
|
||||
:width="420"
|
||||
:breakpoints="{
|
||||
2000: { rowPerView: 3 },
|
||||
1400: { rowPerView: 2 },
|
||||
900: { rowPerView: 2 },
|
||||
600: { rowPerView: 1 },
|
||||
}"
|
||||
:gutter="20"
|
||||
class="order-status-waterfall"
|
||||
>
|
||||
<template #default="{ item }">
|
||||
<div class="w-full pb-1">
|
||||
<OrderStatusCard
|
||||
:status="item as OrderStatusVO.Info"
|
||||
@edit="handleEdit"
|
||||
@delete="handleDelete"
|
||||
@patched="(v) => handlePatched(v)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</Waterfall>
|
||||
</Spin>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<OrderStatusFormModal
|
||||
ref="orderStatusFormModalRef"
|
||||
@success="handleModalSuccess"
|
||||
/>
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.order-status-waterfall {
|
||||
background-color: transparent !important;
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
:deep(.order-status-page-header) {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
:deep(.order-status-page-header > div:first-child) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
:deep(.order-status-page-header > div:last-child) {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style>
|
||||
html.dark .order-status-search.ant-card,
|
||||
html.dark .order-status-grid.ant-card {
|
||||
background-color: hsl(var(--card)) !important;
|
||||
border-color: hsl(var(--border)) !important;
|
||||
}
|
||||
|
||||
html.dark .order-status-search.ant-card .ant-card-body,
|
||||
html.dark .order-status-grid.ant-card .ant-card-body {
|
||||
background-color: hsl(var(--card)) !important;
|
||||
}
|
||||
|
||||
html.dark .order-status-search .ant-form-item-label > label {
|
||||
color: hsl(var(--muted-foreground));
|
||||
}
|
||||
|
||||
html.dark .order-status-search .ant-input,
|
||||
html.dark .order-status-search .ant-input-affix-wrapper,
|
||||
html.dark .order-status-search .ant-select-selector {
|
||||
background-color: hsl(var(--input-background)) !important;
|
||||
border-color: hsl(var(--border)) !important;
|
||||
color: hsl(var(--foreground)) !important;
|
||||
}
|
||||
|
||||
html.dark .order-status-search .ant-btn-default {
|
||||
background-color: hsl(var(--secondary));
|
||||
border-color: hsl(var(--border));
|
||||
color: hsl(var(--foreground));
|
||||
}
|
||||
|
||||
html.dark .order-status-scroll .ant-empty-description {
|
||||
color: hsl(var(--muted-foreground));
|
||||
}
|
||||
|
||||
</style>
|
||||
+85
-79
@@ -35,7 +35,7 @@ import { getAllOrderStatusListApi } from '#/api/ecommerce/order-status';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
import { useImportTaskStore } from '#/store';
|
||||
import { uploadFileToOss } from '#/utils/oss-upload';
|
||||
import { createPatchedFile } from '../utils/specCodePatch';
|
||||
import { createPatchedFile } from '../utils/skuCodePatch';
|
||||
|
||||
// 定义映射项数据结构
|
||||
interface FieldMappingItem {
|
||||
@@ -53,18 +53,18 @@ interface FieldMappingItem {
|
||||
interface StatusMappingItem {
|
||||
/** CSV中的订单状态值 */
|
||||
csvStatus: string;
|
||||
/** 映射到的订单状态ID */
|
||||
mappedStatusId: number;
|
||||
/** 映射到的订单状态码 */
|
||||
mappedStatusCode: string;
|
||||
}
|
||||
|
||||
defineOptions({ name: 'ImportTaskWizard' });
|
||||
|
||||
const emit = defineEmits<{
|
||||
success: [];
|
||||
/** 规格编码列绑定到的 CSV 表头变化时,供左侧表格开启该列编辑 */
|
||||
specCodeColumnChange: [header: string | undefined];
|
||||
/** 规格编码空行预检结果变化(含左侧编辑后) */
|
||||
specMissingAfterPrecheck: [payload: { count: number; indices: number[] }];
|
||||
/** SKU 编码列绑定到的 CSV 表头变化时,供左侧表格开启该列编辑 */
|
||||
skuCodeColumnChange: [header: string | undefined];
|
||||
/** SKU 编码空行预检结果变化(含左侧编辑后) */
|
||||
skuMissingAfterPrecheck: [payload: { count: number; indices: number[] }];
|
||||
}>();
|
||||
|
||||
// 响应式数据
|
||||
@@ -74,22 +74,22 @@ const fieldDefsLoading = ref(false);
|
||||
/** 创建导入任务提交中(与 message.loading 配合,仅按钮 loading) */
|
||||
const createTaskSubmitting = ref(false);
|
||||
const csvHeaders = ref<string[]>([]);
|
||||
/** 与左侧「数据预览」表格共用同一数组引用,便于就地编辑规格编码 */
|
||||
/** 与左侧「数据预览」表格共用同一数组引用,便于就地编辑SKU 编码 */
|
||||
const previewData = defineModel<any[]>('previewData', { default: () => [] });
|
||||
/** 用户上传的原始文件,生成补录文件时始终以此为基准,避免多次 _patched 链式后缀 */
|
||||
const originalImportFile = ref<File | null>(null);
|
||||
const selectedFile = ref<File | null>(null);
|
||||
|
||||
// 规格编码补录(仅本次导入)
|
||||
// SKU 编码补录(仅本次导入)
|
||||
interface MissingSpecCodeRow {
|
||||
orderNo: string;
|
||||
productName: string;
|
||||
rowIndex: number;
|
||||
specCode: string;
|
||||
skuCode: string;
|
||||
}
|
||||
const missingSpecCodeCount = ref(0);
|
||||
const missingSkuCodeCount = ref(0);
|
||||
const missingSpecCodeRows = ref<MissingSpecCodeRow[]>([]);
|
||||
const specCodePrechecked = ref(false);
|
||||
const skuCodePrechecked = ref(false);
|
||||
const hasPatchedFile = ref(false);
|
||||
|
||||
// 店铺选择(在最终「确认信息」步骤内)
|
||||
@@ -126,7 +126,7 @@ const savingFieldToTemplate = ref<null | string>(null);
|
||||
const currentTemplateMappings = ref<FieldMappingItem[]>([]);
|
||||
|
||||
// 订单状态映射(向导第二步)
|
||||
const statusMappings = ref<Record<string, number>>({});
|
||||
const statusMappings = ref<Record<string, string>>({});
|
||||
const uniqueStatusValues = ref<string[]>([]);
|
||||
const statusMappingTemplates = ref<ImportMappingVO.ImportMappingInfoVO[]>([]);
|
||||
const selectedStatusTemplateId = ref<number | undefined>();
|
||||
@@ -138,13 +138,13 @@ const savingStatusFieldToTemplate = ref<null | string>(null);
|
||||
// 当前状态模板的原始映射数据
|
||||
const currentStatusTemplateMappings = ref<StatusMappingItem[]>([]);
|
||||
// 订单状态列表
|
||||
const orderStatusList = ref<OrderStatusVO.Info[]>([]);
|
||||
const orderStatusList = ref<OrderStatusVO.Meta[]>([]);
|
||||
const orderStatusLoading = ref(false);
|
||||
/** CSV 状态值:模板或历史映射指向的系统订单状态已删除,需用户手动重选或留空走自动匹配 */
|
||||
/** CSV 状态值:模板或历史映射指向的系统订单状态码无效,需用户手动重选 */
|
||||
const csvStatusesObsoleteSystemTarget = ref<string[]>([]);
|
||||
|
||||
function getValidOrderStatusIdSet(): Set<number> {
|
||||
return new Set(orderStatusList.value.map((s) => s.id));
|
||||
function getValidOrderStatusCodeSet(): Set<string> {
|
||||
return new Set(orderStatusList.value.map((s) => s.code));
|
||||
}
|
||||
|
||||
function mergeObsoleteSystemTargetRemind(csvList: string[]) {
|
||||
@@ -168,26 +168,26 @@ function clearObsoleteSystemTargetRemind() {
|
||||
/** 用户在下拉中选择了有效状态,或清空(留空走自动匹配)后,不再提示该行 */
|
||||
function handleOrderStatusMappingSelectChange(
|
||||
csvStatus: string,
|
||||
value: number | undefined,
|
||||
value: string | undefined,
|
||||
) {
|
||||
if (value === undefined || value === null) {
|
||||
if (value === undefined || value === null || value === '') {
|
||||
removeObsoleteSystemTargetRemind(csvStatus);
|
||||
return;
|
||||
}
|
||||
if (getValidOrderStatusIdSet().has(value)) {
|
||||
if (getValidOrderStatusCodeSet().has(value)) {
|
||||
removeObsoleteSystemTargetRemind(csvStatus);
|
||||
}
|
||||
}
|
||||
|
||||
/** 去掉指向已删除订单状态的映射,避免 Select 无 option 时显示裸 ID;返回被剔除的 CSV 状态值 */
|
||||
/** 去掉指向无效订单状态码的映射;返回被剔除的 CSV 状态值 */
|
||||
function pruneInvalidStatusMappings(): string[] {
|
||||
const valid = getValidOrderStatusIdSet();
|
||||
const valid = getValidOrderStatusCodeSet();
|
||||
const src = statusMappings.value;
|
||||
const next: Record<string, number> = {};
|
||||
const next: Record<string, string> = {};
|
||||
const removed: string[] = [];
|
||||
for (const [csvStatus, id] of Object.entries(src)) {
|
||||
if (typeof id === 'number' && valid.has(id)) {
|
||||
next[csvStatus] = id;
|
||||
for (const [csvStatus, code] of Object.entries(src)) {
|
||||
if (typeof code === 'string' && valid.has(code)) {
|
||||
next[csvStatus] = code;
|
||||
} else {
|
||||
removed.push(csvStatus);
|
||||
}
|
||||
@@ -302,7 +302,7 @@ const isStatusMappingFromTemplate = (csvStatus: string): boolean => {
|
||||
(item) => item.csvStatus === csvStatus,
|
||||
);
|
||||
if (!templateItem) return false;
|
||||
return statusMappings.value[csvStatus] === templateItem.mappedStatusId;
|
||||
return statusMappings.value[csvStatus] === templateItem.mappedStatusCode;
|
||||
};
|
||||
|
||||
// 判断某个订单状态的映射与模板原始定义是否相同
|
||||
@@ -318,7 +318,7 @@ const isStatusMappingChangedFromTemplate = (csvStatus: string): boolean => {
|
||||
);
|
||||
if (!templateItem) return false;
|
||||
// 模板有定义,但当前映射与模板不同
|
||||
if (statusMappings.value[csvStatus] !== templateItem.mappedStatusId) {
|
||||
if (statusMappings.value[csvStatus] !== templateItem.mappedStatusCode) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -663,12 +663,15 @@ const handleSelectStatusTemplate = async (value: any) => {
|
||||
currentStatusTemplateMappings.value = mappingItems;
|
||||
|
||||
// 根据模板填充订单状态映射(已删除的系统状态不写入,选择器保持未选)
|
||||
const validIds = getValidOrderStatusIdSet();
|
||||
const validCodes = getValidOrderStatusCodeSet();
|
||||
const mappings: typeof statusMappings.value = {};
|
||||
mappingItems.forEach((item) => {
|
||||
if (!uniqueStatusValues.value.includes(item.csvStatus)) return;
|
||||
if (!validIds.has(item.mappedStatusId)) return;
|
||||
mappings[item.csvStatus] = item.mappedStatusId;
|
||||
const code =
|
||||
item.mappedStatusCode ??
|
||||
(item as { mappedStatusId?: number | string }).mappedStatusId?.toString();
|
||||
if (!code || !validCodes.has(code)) return;
|
||||
mappings[item.csvStatus] = code;
|
||||
});
|
||||
|
||||
clearObsoleteSystemTargetRemind();
|
||||
@@ -677,7 +680,10 @@ const handleSelectStatusTemplate = async (value: any) => {
|
||||
const invalidFromTemplate: string[] = [];
|
||||
mappingItems.forEach((item) => {
|
||||
if (!uniqueStatusValues.value.includes(item.csvStatus)) return;
|
||||
if (!validIds.has(item.mappedStatusId)) {
|
||||
const code =
|
||||
item.mappedStatusCode ??
|
||||
(item as { mappedStatusId?: number | string }).mappedStatusId?.toString();
|
||||
if (!code || !validCodes.has(code)) {
|
||||
invalidFromTemplate.push(item.csvStatus);
|
||||
}
|
||||
});
|
||||
@@ -697,15 +703,15 @@ const handleAddStatusFieldToTemplate = async (csvStatus: string) => {
|
||||
return;
|
||||
}
|
||||
|
||||
const mappedStatusId = statusMappings.value[csvStatus];
|
||||
if (mappedStatusId === undefined) {
|
||||
const mappedStatusCode = statusMappings.value[csvStatus];
|
||||
if (!mappedStatusCode) {
|
||||
message.warning('请先完成该订单状态的映射');
|
||||
return;
|
||||
}
|
||||
|
||||
const statusItem: StatusMappingItem = {
|
||||
csvStatus,
|
||||
mappedStatusId,
|
||||
mappedStatusCode,
|
||||
};
|
||||
|
||||
try {
|
||||
@@ -795,7 +801,7 @@ const handleSaveStatusTemplate = () => {
|
||||
.filter((status) => statusMappings.value[status] !== undefined)
|
||||
.map((status) => ({
|
||||
csvStatus: status,
|
||||
mappedStatusId: statusMappings.value[status]!,
|
||||
mappedStatusCode: statusMappings.value[status]!,
|
||||
}));
|
||||
|
||||
if (mappingItems.length === 0) {
|
||||
@@ -891,7 +897,7 @@ async function handleConfirmSaveStatusTemplate() {
|
||||
.filter((status) => statusMappings.value[status] !== undefined)
|
||||
.map((status) => ({
|
||||
csvStatus: status,
|
||||
mappedStatusId: statusMappings.value[status]!,
|
||||
mappedStatusCode: statusMappings.value[status]!,
|
||||
}));
|
||||
|
||||
const mappingJson = JSON.stringify(mappingItems);
|
||||
@@ -1011,15 +1017,15 @@ const getOrderNoHeader = () => {
|
||||
};
|
||||
|
||||
const runMissingSpecCodePrecheck = () => {
|
||||
const specCodeHeader = getMappedHeaderByFieldCandidates(
|
||||
['spec_code', 'specCode'],
|
||||
'规格编码',
|
||||
const skuCodeHeader = getMappedHeaderByFieldCandidates(
|
||||
['sku_code', 'skuCode', 'spec_code', 'specCode'],
|
||||
'SKU 编码',
|
||||
);
|
||||
if (!specCodeHeader) {
|
||||
if (!skuCodeHeader) {
|
||||
missingSpecCodeRows.value = [];
|
||||
missingSpecCodeCount.value = 0;
|
||||
specCodePrechecked.value = true;
|
||||
emit('specMissingAfterPrecheck', { count: 0, indices: [] });
|
||||
missingSkuCodeCount.value = 0;
|
||||
skuCodePrechecked.value = true;
|
||||
emit('skuMissingAfterPrecheck', { count: 0, indices: [] });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1028,26 +1034,26 @@ const runMissingSpecCodePrecheck = () => {
|
||||
|
||||
const rows: MissingSpecCodeRow[] = [];
|
||||
previewData.value.forEach((row, index) => {
|
||||
if (isEmptyValue(row[specCodeHeader])) {
|
||||
if (isEmptyValue(row[skuCodeHeader])) {
|
||||
rows.push({
|
||||
rowIndex: index,
|
||||
orderNo: orderNoHeader ? String(row[orderNoHeader] ?? '') : '',
|
||||
productName: productNameHeader ? String(row[productNameHeader] ?? '') : '',
|
||||
specCode: '',
|
||||
skuCode: '',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
missingSpecCodeRows.value = rows;
|
||||
missingSpecCodeCount.value = rows.length;
|
||||
specCodePrechecked.value = true;
|
||||
emit('specMissingAfterPrecheck', {
|
||||
count: missingSpecCodeCount.value,
|
||||
missingSkuCodeCount.value = rows.length;
|
||||
skuCodePrechecked.value = true;
|
||||
emit('skuMissingAfterPrecheck', {
|
||||
count: missingSkuCodeCount.value,
|
||||
indices: missingSpecCodeRows.value.map((r) => r.rowIndex),
|
||||
});
|
||||
};
|
||||
|
||||
/** 用当前预览行从「原始上传文件」重新生成待上传文件(规格编码列编辑后调用) */
|
||||
/** 用当前预览行从「原始上传文件」重新生成待上传文件(SKU 编码列编辑后调用) */
|
||||
function syncPreviewToUploadFile() {
|
||||
if (!originalImportFile.value || previewData.value.length === 0) return;
|
||||
selectedFile.value = createPatchedFile(
|
||||
@@ -1058,11 +1064,11 @@ function syncPreviewToUploadFile() {
|
||||
hasPatchedFile.value = true;
|
||||
}
|
||||
|
||||
/** 左侧表格规格编码单元格编辑结束并落盘后,由父级防抖调用 */
|
||||
/** 左侧表格SKU 编码单元格编辑结束并落盘后,由父级防抖调用 */
|
||||
function onPreviewSpecCodeCellSaved() {
|
||||
const specHeader = getMappedHeaderByFieldCandidates(
|
||||
['spec_code', 'specCode'],
|
||||
'规格编码',
|
||||
['sku_code', 'skuCode', 'spec_code', 'specCode'],
|
||||
'SKU 编码',
|
||||
);
|
||||
if (!specHeader || !originalImportFile.value) return;
|
||||
syncPreviewToUploadFile();
|
||||
@@ -1086,9 +1092,9 @@ const handleNext = async () => {
|
||||
}
|
||||
|
||||
runMissingSpecCodePrecheck();
|
||||
if (missingSpecCodeCount.value > 0) {
|
||||
if (missingSkuCodeCount.value > 0) {
|
||||
message.warning(
|
||||
`检测到 ${missingSpecCodeCount.value} 行规格编码为空,请在左侧「数据预览」表格中,找到已映射为「规格编码」的列,直接点击单元格补全`,
|
||||
`检测到 ${missingSkuCodeCount.value} 行SKU 编码为空,请在左侧「数据预览」表格中,找到已映射为「SKU 编码」的列,直接点击单元格补全`,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1153,9 +1159,9 @@ const handleCreateTask = async () => {
|
||||
}
|
||||
|
||||
runMissingSpecCodePrecheck();
|
||||
if (missingSpecCodeCount.value > 0) {
|
||||
if (missingSkuCodeCount.value > 0) {
|
||||
message.warning(
|
||||
`仍有 ${missingSpecCodeCount.value} 行规格编码为空,请在左侧表格对应列补全后再创建任务`,
|
||||
`仍有 ${missingSkuCodeCount.value} 行SKU 编码为空,请在左侧表格对应列补全后再创建任务`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -1194,7 +1200,7 @@ const handleCreateTask = async () => {
|
||||
.filter((status) => statusMappings.value[status] !== undefined)
|
||||
.map((status) => ({
|
||||
csvStatus: status,
|
||||
mappedStatusId: statusMappings.value[status]!,
|
||||
mappedStatusCode: statusMappings.value[status]!,
|
||||
}));
|
||||
|
||||
// 构建完整的映射JSON,包含字段映射和订单状态映射
|
||||
@@ -1229,9 +1235,9 @@ const handleCreateTask = async () => {
|
||||
fieldMappings.value = {};
|
||||
statusMappings.value = {};
|
||||
uniqueStatusValues.value = [];
|
||||
missingSpecCodeCount.value = 0;
|
||||
missingSkuCodeCount.value = 0;
|
||||
missingSpecCodeRows.value = [];
|
||||
specCodePrechecked.value = false;
|
||||
skuCodePrechecked.value = false;
|
||||
hasPatchedFile.value = false;
|
||||
csvHeaders.value = [];
|
||||
previewData.value = [];
|
||||
@@ -1258,9 +1264,9 @@ async function open(headers: string[], file?: File) {
|
||||
csvHeaders.value = headers;
|
||||
originalImportFile.value = file ?? null;
|
||||
selectedFile.value = file ?? null;
|
||||
missingSpecCodeCount.value = 0;
|
||||
missingSkuCodeCount.value = 0;
|
||||
missingSpecCodeRows.value = [];
|
||||
specCodePrechecked.value = false;
|
||||
skuCodePrechecked.value = false;
|
||||
hasPatchedFile.value = false;
|
||||
|
||||
if (headersChanged) {
|
||||
@@ -1268,9 +1274,9 @@ async function open(headers: string[], file?: File) {
|
||||
statusMappings.value = {};
|
||||
uniqueStatusValues.value = [];
|
||||
clearObsoleteSystemTargetRemind();
|
||||
missingSpecCodeCount.value = 0;
|
||||
missingSkuCodeCount.value = 0;
|
||||
missingSpecCodeRows.value = [];
|
||||
specCodePrechecked.value = false;
|
||||
skuCodePrechecked.value = false;
|
||||
hasPatchedFile.value = false;
|
||||
currentStep.value = 0;
|
||||
}
|
||||
@@ -1310,9 +1316,9 @@ function reset() {
|
||||
fieldMappings.value = {};
|
||||
statusMappings.value = {};
|
||||
uniqueStatusValues.value = [];
|
||||
missingSpecCodeCount.value = 0;
|
||||
missingSkuCodeCount.value = 0;
|
||||
missingSpecCodeRows.value = [];
|
||||
specCodePrechecked.value = false;
|
||||
skuCodePrechecked.value = false;
|
||||
hasPatchedFile.value = false;
|
||||
csvHeaders.value = [];
|
||||
previewData.value = [];
|
||||
@@ -1326,10 +1332,10 @@ function reset() {
|
||||
watch(
|
||||
() =>
|
||||
fieldDefs.value.length > 0
|
||||
? getMappedHeaderByFieldCandidates(['spec_code', 'specCode'], '规格编码')
|
||||
? getMappedHeaderByFieldCandidates(['sku_code', 'skuCode', 'spec_code', 'specCode'], 'SKU 编码')
|
||||
: undefined,
|
||||
(h) => {
|
||||
emit('specCodeColumnChange', h);
|
||||
emit('skuCodeColumnChange', h);
|
||||
},
|
||||
{ flush: 'post', immediate: true },
|
||||
);
|
||||
@@ -1686,15 +1692,15 @@ const shopOptions = computed(() => {
|
||||
:loading="orderStatusLoading"
|
||||
:options="
|
||||
orderStatusList.map((status) => ({
|
||||
label: status.statusName,
|
||||
value: status.id,
|
||||
label: status.label,
|
||||
value: status.code,
|
||||
}))
|
||||
"
|
||||
@change="
|
||||
(v) =>
|
||||
handleOrderStatusMappingSelectChange(
|
||||
statusValue,
|
||||
v as number | undefined,
|
||||
v as string | undefined,
|
||||
)
|
||||
"
|
||||
/>
|
||||
@@ -1781,20 +1787,20 @@ const shopOptions = computed(() => {
|
||||
</Form.Item>
|
||||
</Form>
|
||||
<Alert
|
||||
v-if="specCodePrechecked && missingSpecCodeCount > 0"
|
||||
v-if="skuCodePrechecked && missingSkuCodeCount > 0"
|
||||
type="warning"
|
||||
show-icon
|
||||
:message="`仍有 ${missingSpecCodeCount} 行规格编码为空`"
|
||||
:message="`仍有 ${missingSkuCodeCount} 行SKU 编码为空`"
|
||||
>
|
||||
<template #description>
|
||||
请在左侧「数据预览」中点击已映射为「规格编码」的列单元格,直接填写后创建任务。
|
||||
请在左侧「数据预览」中点击已映射为「SKU 编码」的列单元格,直接填写后创建任务。
|
||||
</template>
|
||||
</Alert>
|
||||
<Alert
|
||||
v-else-if="specCodePrechecked"
|
||||
v-else-if="skuCodePrechecked"
|
||||
type="success"
|
||||
show-icon
|
||||
message="规格编码预检通过,未发现空值"
|
||||
message="SKU 编码预检通过,未发现空值"
|
||||
/>
|
||||
<Alert
|
||||
v-if="hasPatchedFile"
|
||||
@@ -1831,8 +1837,8 @@ const shopOptions = computed(() => {
|
||||
<span class="font-medium">
|
||||
{{
|
||||
orderStatusList.find(
|
||||
(status) => status.id === statusMappings[statusValue],
|
||||
)?.statusName ?? '-'
|
||||
(status) => status.code === statusMappings[statusValue],
|
||||
)?.label ?? '-'
|
||||
}}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -26,11 +26,11 @@ const tableHeight = ref<number>(600);
|
||||
|
||||
const importTaskWizardRef = ref<InstanceType<typeof ImportTaskWizard>>();
|
||||
|
||||
/** 与向导中「规格编码」字段映射绑定的 CSV 表头,用于左侧表格该列可编辑 */
|
||||
const specCodeCsvHeader = ref<string | undefined>();
|
||||
const specMissingCount = ref(0);
|
||||
/** 规格编码为空的行在 csvData 中的全局下标(0-based) */
|
||||
const specMissingRowIndices = ref<Set<number>>(new Set());
|
||||
/** 与向导中「SKU 编码」字段映射绑定的 CSV 表头,用于左侧表格该列可编辑 */
|
||||
const skuCodeCsvHeader = ref<string | undefined>();
|
||||
const skuMissingCount = ref(0);
|
||||
/** SKU 编码为空的行在 csvData 中的全局下标(0-based) */
|
||||
const skuMissingRowIndices = ref<Set<number>>(new Set());
|
||||
/** 与表格分页条 pageSize 同步,用于计算空缺所在页 */
|
||||
const tablePageSize = ref(50);
|
||||
/** 「下一处空缺」循环游标,-1 表示尚未开始循环 */
|
||||
@@ -52,14 +52,14 @@ const gridColumns = computed(() => {
|
||||
];
|
||||
|
||||
csvHeaders.value.forEach((header) => {
|
||||
const isSpecCol =
|
||||
!!specCodeCsvHeader.value && header === specCodeCsvHeader.value;
|
||||
const isSkuCol =
|
||||
!!skuCodeCsvHeader.value && header === skuCodeCsvHeader.value;
|
||||
columns.push({
|
||||
field: header,
|
||||
title: header,
|
||||
minWidth: isSpecCol ? 180 : 150,
|
||||
minWidth: isSkuCol ? 180 : 150,
|
||||
showOverflow: 'tooltip' as const,
|
||||
...(isSpecCol ? { editRender: { name: 'input' as const } } : {}),
|
||||
...(isSkuCol ? { editRender: { name: 'input' as const } } : {}),
|
||||
});
|
||||
});
|
||||
|
||||
@@ -140,14 +140,14 @@ const debouncedWizardSpecSync = useDebounceFn(() => {
|
||||
function rowClassNameForSpecMissing(params: { row?: Record<string, unknown> }) {
|
||||
const idx = params.row?.__srcRowIndex;
|
||||
if (typeof idx !== 'number') return '';
|
||||
return specMissingRowIndices.value.has(idx) ? 'order-import-row--spec-missing' : '';
|
||||
return skuMissingRowIndices.value.has(idx) ? 'order-import-row--sku-missing' : '';
|
||||
}
|
||||
|
||||
const gridEvents = {
|
||||
editClosed(params: { column?: { field?: string } }) {
|
||||
const field = params.column?.field;
|
||||
if (!field || !specCodeCsvHeader.value) return;
|
||||
if (field === specCodeCsvHeader.value) {
|
||||
if (!field || !skuCodeCsvHeader.value) return;
|
||||
if (field === skuCodeCsvHeader.value) {
|
||||
debouncedWizardSpecSync();
|
||||
}
|
||||
},
|
||||
@@ -194,16 +194,16 @@ const syncWizardOpen = () => {
|
||||
});
|
||||
};
|
||||
|
||||
function onSpecCodeColumnChange(header: string | undefined) {
|
||||
specCodeCsvHeader.value = header;
|
||||
function onSkuCodeColumnChange(header: string | undefined) {
|
||||
skuCodeCsvHeader.value = header;
|
||||
updateTable();
|
||||
}
|
||||
|
||||
function onSpecMissingAfterPrecheck(payload: { count: number; indices: number[] }) {
|
||||
specMissingCount.value = payload.count;
|
||||
specMissingRowIndices.value = new Set(payload.indices);
|
||||
function onSkuMissingAfterPrecheck(payload: { count: number; indices: number[] }) {
|
||||
skuMissingCount.value = payload.count;
|
||||
skuMissingRowIndices.value = new Set(payload.indices);
|
||||
missingCycleCursor.value = -1;
|
||||
// 必须用 query 而非 reload:reload 会重置分页到第 1 页,用户在其它页补规格编码时会被突然拉回首页
|
||||
// 必须用 query 而非 reload:reload 会重置分页到第 1 页,用户在其它页补SKU 编码时会被突然拉回首页
|
||||
if (csvData.value.length > 0) {
|
||||
void gridApi.query({});
|
||||
}
|
||||
@@ -222,12 +222,12 @@ function nextPaint() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 滚动到指定数据行(scrollToRow 返回 Promise;第二参为列 field 时同时横向滚到「规格编码」列)
|
||||
* 滚动到指定数据行(scrollToRow 返回 Promise;第二参为列 field 时同时横向滚到「SKU 编码」列)
|
||||
* 虚拟滚动场景 vxe 内部会延时二次校正,这里再补一次延迟滚动。
|
||||
*/
|
||||
async function scrollGridToDataRow(row: Record<string, unknown>) {
|
||||
const grid = gridApi.grid as any;
|
||||
const field = specCodeCsvHeader.value;
|
||||
const field = skuCodeCsvHeader.value;
|
||||
const candidates = [grid, getVxeInnerTable(grid)].filter(Boolean);
|
||||
|
||||
for (const inst of candidates) {
|
||||
@@ -276,9 +276,9 @@ async function goToRowIndex(globalRowIndex: number) {
|
||||
}
|
||||
|
||||
function jumpToFirstSpecMissing() {
|
||||
const sorted = [...specMissingRowIndices.value].sort((a, b) => a - b);
|
||||
const sorted = [...skuMissingRowIndices.value].sort((a, b) => a - b);
|
||||
if (sorted.length === 0) {
|
||||
message.info('当前没有空缺的规格编码');
|
||||
message.info('当前没有空缺的SKU 编码');
|
||||
return;
|
||||
}
|
||||
missingCycleCursor.value = 0;
|
||||
@@ -286,9 +286,9 @@ function jumpToFirstSpecMissing() {
|
||||
}
|
||||
|
||||
function jumpToNextSpecMissing() {
|
||||
const sorted = [...specMissingRowIndices.value].sort((a, b) => a - b);
|
||||
const sorted = [...skuMissingRowIndices.value].sort((a, b) => a - b);
|
||||
if (sorted.length === 0) {
|
||||
message.info('当前没有空缺的规格编码');
|
||||
message.info('当前没有空缺的SKU 编码');
|
||||
return;
|
||||
}
|
||||
missingCycleCursor.value = (missingCycleCursor.value + 1) % sorted.length;
|
||||
@@ -333,9 +333,9 @@ const handleClearData = () => {
|
||||
csvData.value = [];
|
||||
csvHeaders.value = [];
|
||||
currentFile.value = null;
|
||||
specCodeCsvHeader.value = undefined;
|
||||
specMissingCount.value = 0;
|
||||
specMissingRowIndices.value = new Set();
|
||||
skuCodeCsvHeader.value = undefined;
|
||||
skuMissingCount.value = 0;
|
||||
skuMissingRowIndices.value = new Set();
|
||||
missingCycleCursor.value = -1;
|
||||
importTaskWizardRef.value?.reset();
|
||||
updateTable();
|
||||
@@ -346,9 +346,9 @@ const handleWizardSuccess = () => {
|
||||
csvData.value = [];
|
||||
csvHeaders.value = [];
|
||||
currentFile.value = null;
|
||||
specCodeCsvHeader.value = undefined;
|
||||
specMissingCount.value = 0;
|
||||
specMissingRowIndices.value = new Set();
|
||||
skuCodeCsvHeader.value = undefined;
|
||||
skuMissingCount.value = 0;
|
||||
skuMissingRowIndices.value = new Set();
|
||||
missingCycleCursor.value = -1;
|
||||
updateTable();
|
||||
message.success('已创建导入任务,可继续上传新文件');
|
||||
@@ -445,16 +445,16 @@ onUnmounted(() => {
|
||||
</h2>
|
||||
<p class="m-0 text-xs text-slate-500 dark:text-[hsl(240deg_5%_64.9%)] sm:text-sm">
|
||||
共 {{ csvData.length }} 条 · 右侧配置导入任务
|
||||
<template v-if="specMissingCount > 0">
|
||||
<template v-if="skuMissingCount > 0">
|
||||
·
|
||||
<span class="font-medium text-amber-600 dark:text-amber-400">
|
||||
规格编码待补 {{ specMissingCount }} 行(点击本表对应列表格填写)
|
||||
SKU 编码待补 {{ skuMissingCount }} 行(点击本表对应列表格填写)
|
||||
</span>
|
||||
</template>
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex shrink-0 flex-wrap items-center justify-end gap-2">
|
||||
<template v-if="specMissingCount > 0">
|
||||
<template v-if="skuMissingCount > 0">
|
||||
<Button size="small" type="primary" @click="jumpToFirstSpecMissing">
|
||||
第一处空缺
|
||||
</Button>
|
||||
@@ -479,8 +479,8 @@ onUnmounted(() => {
|
||||
<ImportTaskWizard
|
||||
ref="importTaskWizardRef"
|
||||
v-model:preview-data="csvData"
|
||||
@spec-code-column-change="onSpecCodeColumnChange"
|
||||
@spec-missing-after-precheck="onSpecMissingAfterPrecheck"
|
||||
@sku-code-column-change="onSkuCodeColumnChange"
|
||||
@sku-missing-after-precheck="onSkuMissingAfterPrecheck"
|
||||
@success="handleWizardSuccess"
|
||||
/>
|
||||
</div>
|
||||
@@ -502,17 +502,17 @@ onUnmounted(() => {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
/* 规格编码为空的行:整行高亮,便于分页中辨认 */
|
||||
:deep(tr.order-import-row--spec-missing) {
|
||||
/* SKU 编码为空的行:整行高亮,便于分页中辨认 */
|
||||
:deep(tr.order-import-row--sku-missing) {
|
||||
background-color: rgb(254 243 199) !important;
|
||||
}
|
||||
:deep(tr.order-import-row--spec-missing:hover) {
|
||||
:deep(tr.order-import-row--sku-missing:hover) {
|
||||
background-color: rgb(253 230 138) !important;
|
||||
}
|
||||
.dark :deep(tr.order-import-row--spec-missing) {
|
||||
.dark :deep(tr.order-import-row--sku-missing) {
|
||||
background-color: rgb(120 53 15 / 0.45) !important;
|
||||
}
|
||||
.dark :deep(tr.order-import-row--spec-missing:hover) {
|
||||
.dark :deep(tr.order-import-row--sku-missing:hover) {
|
||||
background-color: rgb(120 53 15 / 0.6) !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
-1
@@ -50,4 +50,3 @@ export function createPatchedFile(
|
||||
});
|
||||
return new File([blob], filename, { type: blob.type });
|
||||
}
|
||||
|
||||
+169
-165
@@ -1,9 +1,9 @@
|
||||
<script lang="ts" setup>
|
||||
import type { OrderDTO, OrderVO } from '#/api/ecommerce/order';
|
||||
import type {
|
||||
ProductSpecDTO,
|
||||
ProductSpecVO,
|
||||
} from '#/api/ecommerce/product-spec/types';
|
||||
ProductSkuDTO,
|
||||
ProductSkuVO,
|
||||
} from '#/api/ecommerce/product-sku/types';
|
||||
import type { ProductDTO, ProductVO } from '#/api/ecommerce/product/types';
|
||||
import type { ShopVO } from '#/api/ecommerce/shop/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
@@ -30,8 +30,12 @@ import {
|
||||
import { getAllOrderStatusListApi } from '#/api/ecommerce/order-status';
|
||||
import type { OrderStatusVO } from '#/api/ecommerce/order-status/types';
|
||||
import { getProductPageApi } from '#/api/ecommerce/product';
|
||||
import { getProductSpecPageApi } from '#/api/ecommerce/product-spec';
|
||||
import { getProductSkuPageApi } from '#/api/ecommerce/product-sku';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
import {
|
||||
getFirstOrderItem,
|
||||
getOrderPayAmount,
|
||||
} from '#/utils/order-display';
|
||||
|
||||
const emit = defineEmits<{
|
||||
cancel: [];
|
||||
@@ -56,18 +60,20 @@ const isEdit = ref(false);
|
||||
const currentRecord = ref<null | OrderVO.Info>(null);
|
||||
|
||||
// 表单数据
|
||||
/** 表单含 UI 用 productId(选规格);提交用 productSpecId + specCode */
|
||||
const formData = ref<Partial<OrderDTO.Create> & { productId?: number }>({
|
||||
/** 表单含 UI 用 productId(选规格);提交组 items[0] + payAmount */
|
||||
const formData = ref<
|
||||
Partial<OrderDTO.Create> & { productId?: number; payAmount?: number }
|
||||
>({
|
||||
shopId: undefined,
|
||||
platformOrderNo: '',
|
||||
statusId: undefined as number | undefined,
|
||||
receivedAmount: 0,
|
||||
status: undefined as string | undefined,
|
||||
payAmount: 0,
|
||||
orderTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
productId: undefined,
|
||||
productSpecId: undefined,
|
||||
specCode: undefined,
|
||||
productSkuId: undefined,
|
||||
skuCode: undefined,
|
||||
linkProductName: '',
|
||||
linkSpecName: '',
|
||||
linkSkuName: '',
|
||||
quantity: 1,
|
||||
unitPrice: 0,
|
||||
productCost: 0,
|
||||
@@ -78,7 +84,7 @@ const formData = ref<Partial<OrderDTO.Create> & { productId?: number }>({
|
||||
|
||||
// 下拉选项数据
|
||||
const shopOptions = ref<{ label: string; value: number }[]>([]);
|
||||
const orderStatusOptions = ref<{ label: string; value: number }[]>([]);
|
||||
const orderStatusOptions = ref<{ label: string; value: string }[]>([]);
|
||||
|
||||
// 商品选项数据(支持分页)
|
||||
const productOptions = ref<
|
||||
@@ -93,27 +99,27 @@ const productLoaded = ref(false);
|
||||
let productSearchTimer: null | ReturnType<typeof setTimeout> = null;
|
||||
|
||||
// 规格选项数据(支持分页)
|
||||
const productSpecOptions = ref<
|
||||
{ label: string; spec: ProductSpecVO.Info; value: number }[]
|
||||
const productSkuOptions = ref<
|
||||
{ label: string; sku: ProductSkuVO.Info; value: number }[]
|
||||
>([]);
|
||||
const productSpecLoading = ref(false);
|
||||
const productSpecSearchKeyword = ref('');
|
||||
const specPage = ref(1);
|
||||
const specPageSize = 50;
|
||||
const specTotal = ref(0);
|
||||
const specLoaded = ref(false);
|
||||
let specSearchTimer: null | ReturnType<typeof setTimeout> = null;
|
||||
const productSkuLoading = ref(false);
|
||||
const productSkuSearchKeyword = ref('');
|
||||
const skuPage = ref(1);
|
||||
const skuPageSize = 50;
|
||||
const skuTotal = ref(0);
|
||||
const skuLoaded = ref(false);
|
||||
let skuSearchTimer: null | ReturnType<typeof setTimeout> = null;
|
||||
|
||||
// 表单验证规则
|
||||
const rules = {
|
||||
shopId: [{ required: true, message: '请选择店铺', trigger: 'change' }],
|
||||
statusId: [{ required: true, message: '请选择订单状态', trigger: 'change' }],
|
||||
receivedAmount: [
|
||||
{ required: true, message: '请输入实收金额', trigger: 'blur' },
|
||||
status: [{ required: true, message: '请选择订单状态', trigger: 'change' }],
|
||||
payAmount: [
|
||||
{ required: true, message: '请输入实付/商家实收金额', trigger: 'blur' },
|
||||
],
|
||||
orderTime: [{ required: true, message: '请选择下单时间', trigger: 'change' }],
|
||||
productId: [{ required: true, message: '请选择商品', trigger: 'change' }],
|
||||
productSpecId: [{ required: true, message: '请选择商品规格', trigger: 'change' }],
|
||||
productSkuId: [{ required: true, message: '请选择商品 SKU', trigger: 'change' }],
|
||||
linkProductName: [
|
||||
{ required: true, message: '请输入链接商品名称', trigger: 'blur' },
|
||||
],
|
||||
@@ -147,9 +153,9 @@ async function fetchShopOptions() {
|
||||
async function fetchOrderStatusOptions() {
|
||||
try {
|
||||
const data = await getAllOrderStatusListApi();
|
||||
orderStatusOptions.value = data.map((status: OrderStatusVO.Info) => ({
|
||||
label: status.statusName,
|
||||
value: status.id,
|
||||
orderStatusOptions.value = data.map((status: OrderStatusVO.Meta) => ({
|
||||
label: status.label,
|
||||
value: status.code,
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error('获取订单状态列表失败:', error);
|
||||
@@ -217,55 +223,55 @@ function handleProductPopupScroll(e: Event) {
|
||||
}
|
||||
|
||||
// 分页加载规格列表
|
||||
async function fetchProductSpecs(page = 1, append = false) {
|
||||
async function fetchProductSkus(page = 1, append = false) {
|
||||
if (!formData.value.productId) {
|
||||
productSpecOptions.value = [];
|
||||
productSkuOptions.value = [];
|
||||
return;
|
||||
}
|
||||
if (productSpecLoading.value) return;
|
||||
productSpecLoading.value = true;
|
||||
if (productSkuLoading.value) return;
|
||||
productSkuLoading.value = true;
|
||||
try {
|
||||
const params: PageQueryDTO<ProductSpecDTO.Filters> = {
|
||||
const params: PageQueryDTO<ProductSkuDTO.Filters> = {
|
||||
page,
|
||||
pageSize: specPageSize,
|
||||
pageSize: skuPageSize,
|
||||
filters: {
|
||||
productId: formData.value.productId,
|
||||
keywords: productSpecSearchKeyword.value || undefined,
|
||||
keywords: productSkuSearchKeyword.value || undefined,
|
||||
},
|
||||
};
|
||||
const data = await getProductSpecPageApi(params);
|
||||
productSpecOptions.value = append
|
||||
const data = await getProductSkuPageApi(params);
|
||||
productSkuOptions.value = append
|
||||
? [
|
||||
...productSpecOptions.value,
|
||||
...data.records.map((spec: ProductSpecVO.Info) => ({
|
||||
label: `${spec.name}${spec.specCode ? ` (${spec.specCode})` : ''}`,
|
||||
value: spec.id,
|
||||
spec,
|
||||
...productSkuOptions.value,
|
||||
...data.records.map((sku: ProductSkuVO.Info) => ({
|
||||
label: `${sku.name}${sku.skuCode ? ` (${sku.skuCode})` : ''}`,
|
||||
value: sku.id,
|
||||
sku,
|
||||
})),
|
||||
]
|
||||
: data.records.map((spec: ProductSpecVO.Info) => ({
|
||||
label: `${spec.name}${spec.specCode ? ` (${spec.specCode})` : ''}`,
|
||||
value: spec.id,
|
||||
spec,
|
||||
: data.records.map((sku: ProductSkuVO.Info) => ({
|
||||
label: `${sku.name}${sku.skuCode ? ` (${sku.skuCode})` : ''}`,
|
||||
value: sku.id,
|
||||
sku,
|
||||
}));
|
||||
specTotal.value = data.total;
|
||||
specPage.value = page;
|
||||
specLoaded.value = true;
|
||||
skuTotal.value = data.total;
|
||||
skuPage.value = page;
|
||||
skuLoaded.value = true;
|
||||
} catch (error) {
|
||||
console.error('获取规格列表失败:', error);
|
||||
message.error('获取规格列表失败');
|
||||
console.error('获取 SKU 列表失败:', error);
|
||||
message.error('获取 SKU 列表失败');
|
||||
} finally {
|
||||
productSpecLoading.value = false;
|
||||
productSkuLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 搜索规格(防抖)
|
||||
function handleProductSpecSearch(value: string) {
|
||||
if (specSearchTimer) clearTimeout(specSearchTimer);
|
||||
specSearchTimer = setTimeout(() => {
|
||||
productSpecSearchKeyword.value = value;
|
||||
specPage.value = 1;
|
||||
fetchProductSpecs(1, false);
|
||||
function handleProductSkuSearch(value: string) {
|
||||
if (skuSearchTimer) clearTimeout(skuSearchTimer);
|
||||
skuSearchTimer = setTimeout(() => {
|
||||
productSkuSearchKeyword.value = value;
|
||||
skuPage.value = 1;
|
||||
fetchProductSkus(1, false);
|
||||
}, 300);
|
||||
}
|
||||
|
||||
@@ -274,9 +280,9 @@ function handleSpecPopupScroll(e: Event) {
|
||||
const target = e.target as HTMLElement;
|
||||
const { scrollTop, scrollHeight, clientHeight } = target;
|
||||
if (scrollHeight - scrollTop - clientHeight < 50) {
|
||||
const hasMore = specPage.value * specPageSize < specTotal.value;
|
||||
if (hasMore && !productSpecLoading.value) {
|
||||
fetchProductSpecs(specPage.value + 1, true);
|
||||
const hasMore = skuPage.value * skuPageSize < skuTotal.value;
|
||||
if (hasMore && !productSkuLoading.value) {
|
||||
fetchProductSkus(skuPage.value + 1, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -291,44 +297,44 @@ function handleProductChange(productId: number | undefined) {
|
||||
formData.value.linkProductName = selectedProduct.product.name;
|
||||
}
|
||||
// 重置规格状态,重新加载
|
||||
specLoaded.value = false;
|
||||
specPage.value = 1;
|
||||
productSpecOptions.value = [];
|
||||
formData.value.productSpecId = undefined;
|
||||
formData.value.specCode = undefined;
|
||||
formData.value.linkSpecName = '';
|
||||
skuLoaded.value = false;
|
||||
skuPage.value = 1;
|
||||
productSkuOptions.value = [];
|
||||
formData.value.productSkuId = undefined;
|
||||
formData.value.skuCode = undefined;
|
||||
formData.value.linkSkuName = '';
|
||||
formData.value.productCost = 0;
|
||||
formData.value.shippingCost = 0;
|
||||
formData.value.otherCost = 0;
|
||||
fetchProductSpecs(1, false);
|
||||
fetchProductSkus(1, false);
|
||||
} else {
|
||||
formData.value.linkProductName = '';
|
||||
formData.value.productSpecId = undefined;
|
||||
formData.value.specCode = undefined;
|
||||
formData.value.linkSpecName = '';
|
||||
formData.value.productSkuId = undefined;
|
||||
formData.value.skuCode = undefined;
|
||||
formData.value.linkSkuName = '';
|
||||
formData.value.productCost = 0;
|
||||
formData.value.shippingCost = 0;
|
||||
formData.value.otherCost = 0;
|
||||
productSpecOptions.value = [];
|
||||
productSkuOptions.value = [];
|
||||
}
|
||||
}
|
||||
|
||||
// 处理规格选择
|
||||
function handleProductSpecChange(specId: number | undefined) {
|
||||
if (specId) {
|
||||
const selectedSpec = productSpecOptions.value.find(
|
||||
(opt) => opt.value === specId,
|
||||
function handleProductSkuChange(skuId: number | undefined) {
|
||||
if (skuId) {
|
||||
const selectedSku = productSkuOptions.value.find(
|
||||
(opt) => opt.value === skuId,
|
||||
);
|
||||
if (selectedSpec) {
|
||||
formData.value.linkSpecName = selectedSpec.spec.name;
|
||||
formData.value.specCode = selectedSpec.spec.specCode;
|
||||
formData.value.productCost = selectedSpec.spec.productCost;
|
||||
formData.value.shippingCost = selectedSpec.spec.shippingCost || 0;
|
||||
formData.value.otherCost = selectedSpec.spec.otherCost || 0;
|
||||
if (selectedSku) {
|
||||
formData.value.linkSkuName = selectedSku.sku.name;
|
||||
formData.value.skuCode = selectedSku.sku.skuCode;
|
||||
formData.value.productCost = selectedSku.sku.productCost;
|
||||
formData.value.shippingCost = selectedSku.sku.shippingCost || 0;
|
||||
formData.value.otherCost = selectedSku.sku.otherCost || 0;
|
||||
}
|
||||
} else {
|
||||
formData.value.linkSpecName = '';
|
||||
formData.value.specCode = undefined;
|
||||
formData.value.linkSkuName = '';
|
||||
formData.value.skuCode = undefined;
|
||||
formData.value.productCost = 0;
|
||||
formData.value.shippingCost = 0;
|
||||
formData.value.otherCost = 0;
|
||||
@@ -346,40 +352,43 @@ async function open(edit: boolean, record?: OrderVO.Info) {
|
||||
|
||||
modalApi.open();
|
||||
|
||||
// 根据模式填充表单数据
|
||||
const firstItem = record ? getFirstOrderItem(record) : undefined;
|
||||
|
||||
// 根据模式填充表单数据(编辑从 items[0] 回填)
|
||||
formData.value =
|
||||
edit && record
|
||||
? {
|
||||
shopId: record.shopId,
|
||||
platformOrderNo: record.platformOrderNo || '',
|
||||
statusId: record.statusId,
|
||||
receivedAmount: record.receivedAmount,
|
||||
status: record.status,
|
||||
payAmount: getOrderPayAmount(record),
|
||||
orderTime: record.orderTime
|
||||
? dayjs(record.orderTime).format('YYYY-MM-DD HH:mm:ss')
|
||||
: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
productId: record.product?.id,
|
||||
productSpecId: record.productSpecId,
|
||||
specCode: record.specCode,
|
||||
linkProductName: record.linkProductName,
|
||||
linkSpecName: record.linkSpecName,
|
||||
quantity: record.quantity,
|
||||
unitPrice: record.unitPrice,
|
||||
productCost: record.productCost,
|
||||
shippingCost: record.shippingCost || 0,
|
||||
otherCost: record.otherCost || 0,
|
||||
remark: record.remark || '',
|
||||
productId: firstItem?.product?.id ?? firstItem?.productId,
|
||||
productSkuId: firstItem?.productSkuId,
|
||||
skuCode: firstItem?.skuCode,
|
||||
linkProductName:
|
||||
firstItem?.linkProductName ?? record.firstLinkProductName ?? '',
|
||||
linkSkuName: firstItem?.linkSkuName,
|
||||
quantity: firstItem?.quantity ?? 1,
|
||||
unitPrice: firstItem?.unitPrice ?? 0,
|
||||
productCost: firstItem?.productCost ?? 0,
|
||||
shippingCost: firstItem?.shippingCost ?? 0,
|
||||
otherCost: firstItem?.otherCost ?? 0,
|
||||
remark: record.remark || firstItem?.remark || '',
|
||||
}
|
||||
: {
|
||||
shopId: undefined,
|
||||
platformOrderNo: '',
|
||||
statusId: undefined,
|
||||
receivedAmount: 0,
|
||||
status: undefined,
|
||||
payAmount: 0,
|
||||
orderTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
productId: undefined,
|
||||
productSpecId: undefined,
|
||||
specCode: undefined,
|
||||
productSkuId: undefined,
|
||||
skuCode: undefined,
|
||||
linkProductName: '',
|
||||
linkSpecName: '',
|
||||
linkSkuName: '',
|
||||
quantity: 1,
|
||||
unitPrice: 0,
|
||||
productCost: 0,
|
||||
@@ -389,38 +398,38 @@ async function open(edit: boolean, record?: OrderVO.Info) {
|
||||
};
|
||||
|
||||
// 如果是编辑模式且有商品/规格,加载商品和规格选项
|
||||
if (edit && record && (record.product?.id ?? record.productSpecId)) {
|
||||
if (edit && record && (firstItem?.product?.id ?? firstItem?.productSkuId)) {
|
||||
await fetchProducts(1, false);
|
||||
// 确保选中的商品在选项中
|
||||
const pid = record.product?.id;
|
||||
const pid = firstItem?.product?.id ?? firstItem?.productId;
|
||||
const linkProductName =
|
||||
firstItem?.linkProductName ?? record.firstLinkProductName ?? '';
|
||||
if (pid && !productOptions.value.some((opt) => opt.value === pid)) {
|
||||
productOptions.value.push({
|
||||
label: record.linkProductName,
|
||||
label: linkProductName,
|
||||
value: pid,
|
||||
product: {
|
||||
id: pid,
|
||||
name: record.linkProductName,
|
||||
name: linkProductName,
|
||||
} as ProductVO.Info,
|
||||
});
|
||||
}
|
||||
if (record.productSpecId) {
|
||||
await fetchProductSpecs(1, false);
|
||||
// 确保选中的规格在选项中
|
||||
if (firstItem?.productSkuId) {
|
||||
await fetchProductSkus(1, false);
|
||||
if (
|
||||
!productSpecOptions.value.some(
|
||||
(opt) => opt.value === record.productSpecId,
|
||||
!productSkuOptions.value.some(
|
||||
(opt) => opt.value === firstItem.productSkuId,
|
||||
)
|
||||
) {
|
||||
productSpecOptions.value.push({
|
||||
label: record.linkSpecName || '',
|
||||
value: record.productSpecId,
|
||||
spec: {
|
||||
id: record.productSpecId,
|
||||
name: record.linkSpecName || '',
|
||||
productCost: record.productCost,
|
||||
shippingCost: record.shippingCost,
|
||||
otherCost: record.otherCost,
|
||||
} as ProductSpecVO.Info,
|
||||
productSkuOptions.value.push({
|
||||
label: firstItem.linkSkuName || '',
|
||||
value: firstItem.productSkuId,
|
||||
sku: {
|
||||
id: firstItem.productSkuId,
|
||||
name: firstItem.linkSkuName || '',
|
||||
productCost: firstItem.productCost,
|
||||
shippingCost: firstItem.shippingCost,
|
||||
otherCost: firstItem.otherCost,
|
||||
} as ProductSkuVO.Info,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -440,44 +449,39 @@ async function handleSubmit() {
|
||||
await formRef.value?.validate();
|
||||
loading.value = true;
|
||||
|
||||
const itemPayload = {
|
||||
productSkuId: formData.value.productSkuId,
|
||||
skuCode: formData.value.skuCode,
|
||||
linkProductName: formData.value.linkProductName!,
|
||||
linkSkuName: formData.value.linkSkuName,
|
||||
quantity: formData.value.quantity!,
|
||||
unitPrice: formData.value.unitPrice,
|
||||
productCost: formData.value.productCost,
|
||||
shippingCost: formData.value.shippingCost,
|
||||
otherCost: formData.value.otherCost,
|
||||
remark: formData.value.remark,
|
||||
};
|
||||
|
||||
if (isEdit.value && currentRecord.value) {
|
||||
// 更新订单
|
||||
const updateData: OrderDTO.Update = {
|
||||
shopId: formData.value.shopId!,
|
||||
platformOrderNo: formData.value.platformOrderNo,
|
||||
statusId: formData.value.statusId,
|
||||
receivedAmount: formData.value.receivedAmount!,
|
||||
status: formData.value.status,
|
||||
payAmount: formData.value.payAmount!,
|
||||
orderTime: formData.value.orderTime!,
|
||||
productSpecId: formData.value.productSpecId,
|
||||
specCode: formData.value.specCode,
|
||||
linkProductName: formData.value.linkProductName,
|
||||
linkSpecName: formData.value.linkSpecName,
|
||||
quantity: formData.value.quantity,
|
||||
unitPrice: formData.value.unitPrice,
|
||||
productCost: formData.value.productCost,
|
||||
shippingCost: formData.value.shippingCost,
|
||||
otherCost: formData.value.otherCost,
|
||||
items: [itemPayload],
|
||||
remark: formData.value.remark,
|
||||
};
|
||||
await updateOrderApi(currentRecord.value.id, updateData);
|
||||
message.success('更新订单成功');
|
||||
} else {
|
||||
// 创建订单
|
||||
const createData: OrderDTO.Create = {
|
||||
shopId: formData.value.shopId!,
|
||||
platformOrderNo: formData.value.platformOrderNo,
|
||||
statusId: formData.value.statusId!,
|
||||
receivedAmount: formData.value.receivedAmount!,
|
||||
status: formData.value.status!,
|
||||
payAmount: formData.value.payAmount!,
|
||||
orderTime: formData.value.orderTime!,
|
||||
productSpecId: formData.value.productSpecId!,
|
||||
specCode: formData.value.specCode,
|
||||
linkProductName: formData.value.linkProductName!,
|
||||
linkSpecName: formData.value.linkSpecName,
|
||||
quantity: formData.value.quantity!,
|
||||
unitPrice: formData.value.unitPrice!,
|
||||
productCost: formData.value.productCost!,
|
||||
shippingCost: formData.value.shippingCost,
|
||||
otherCost: formData.value.otherCost,
|
||||
items: [itemPayload],
|
||||
remark: formData.value.remark,
|
||||
};
|
||||
await createOrderApi(createData);
|
||||
@@ -518,9 +522,9 @@ defineExpose({
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="订单状态" name="statusId">
|
||||
<Form.Item label="订单状态" name="status">
|
||||
<Select
|
||||
v-model:value="formData.statusId"
|
||||
v-model:value="formData.status"
|
||||
placeholder="请选择订单状态"
|
||||
:options="orderStatusOptions"
|
||||
/>
|
||||
@@ -573,31 +577,31 @@ defineExpose({
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="商品规格" name="productSpecId">
|
||||
<Form.Item label="商品 SKU" name="productSkuId">
|
||||
<Select
|
||||
v-model:value="formData.productSpecId"
|
||||
v-model:value="formData.productSkuId"
|
||||
placeholder="请先选择商品,然后搜索规格"
|
||||
show-search
|
||||
:filter-option="false"
|
||||
:loading="productSpecLoading"
|
||||
:loading="productSkuLoading"
|
||||
:disabled="!formData.productId"
|
||||
:options="productSpecOptions"
|
||||
@search="handleProductSpecSearch"
|
||||
@focus="() => { if (!specLoaded && formData.productId) fetchProductSpecs(1, false); }"
|
||||
:options="productSkuOptions"
|
||||
@search="handleProductSkuSearch"
|
||||
@focus="() => { if (!skuLoaded && formData.productId) fetchProductSkus(1, false); }"
|
||||
@popup-scroll="handleSpecPopupScroll"
|
||||
@change="(value) => handleProductSpecChange(value as number)"
|
||||
@change="(value) => handleProductSkuChange(value as number)"
|
||||
>
|
||||
<template #notFoundContent>
|
||||
<div v-if="productSpecLoading" class="py-4 text-center">
|
||||
<div v-if="productSkuLoading" class="py-4 text-center">
|
||||
<Spin size="small" />
|
||||
<div class="mt-2">加载中...</div>
|
||||
</div>
|
||||
<div v-else class="py-4 text-center text-gray-400">
|
||||
{{
|
||||
formData.productId
|
||||
? productSpecSearchKeyword
|
||||
? productSkuSearchKeyword
|
||||
? '未找到规格'
|
||||
: '请输入规格名称搜索'
|
||||
: '请输入SKU 名称搜索'
|
||||
: '请先选择商品'
|
||||
}}
|
||||
</div>
|
||||
@@ -614,10 +618,10 @@ defineExpose({
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="链接规格名称" name="linkSpecName">
|
||||
<Form.Item label="链接 SKU 名称" name="linkSkuName">
|
||||
<Input
|
||||
v-model:value="formData.linkSpecName"
|
||||
placeholder="请输入链接规格名称"
|
||||
v-model:value="formData.linkSkuName"
|
||||
placeholder="请输入链接 SKU 名称"
|
||||
/>
|
||||
</Form.Item>
|
||||
</div>
|
||||
@@ -683,10 +687,10 @@ defineExpose({
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="实收金额" name="receivedAmount">
|
||||
<Form.Item label="实付/商家实收" name="payAmount">
|
||||
<InputNumber
|
||||
v-model:value="formData.receivedAmount"
|
||||
placeholder="请输入实收金额"
|
||||
v-model:value="formData.payAmount"
|
||||
placeholder="请输入实付/商家实收金额"
|
||||
style="width: 100%"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
|
||||
@@ -34,6 +34,17 @@ import { getAllOrderStatusListApi } from '#/api/ecommerce/order-status';
|
||||
import { getProductPageApi } from '#/api/ecommerce/product';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
|
||||
import {
|
||||
getFirstOrderItem,
|
||||
getOrderOtherCost,
|
||||
getOrderPayAmount,
|
||||
getOrderProduct,
|
||||
getOrderProductCost,
|
||||
getOrderProductSku,
|
||||
getOrderQuantity,
|
||||
getOrderShippingCost,
|
||||
} from '#/utils/order-display';
|
||||
|
||||
import OrderFormModal from './components/OrderFormModal.vue';
|
||||
|
||||
defineOptions({ name: 'OrderManagement' });
|
||||
@@ -67,7 +78,7 @@ const shopLoaded = ref(false);
|
||||
let shopSearchTimer: null | ReturnType<typeof setTimeout> = null;
|
||||
|
||||
// 订单状态选项
|
||||
const orderStatusOptions = ref<{ label: string; value: number }[]>([]);
|
||||
const orderStatusOptions = ref<{ label: string; value: string }[]>([]);
|
||||
const orderStatusLoaded = ref(false);
|
||||
|
||||
// 商品分页数据
|
||||
@@ -102,7 +113,7 @@ const defaultOrderTime = buildDefaultOrderTimeRange();
|
||||
const searchForm = ref({
|
||||
platformOrderNo: '',
|
||||
shopId: undefined as number | undefined,
|
||||
statusId: undefined as number | undefined,
|
||||
status: undefined as string | undefined,
|
||||
startOrderTime: defaultOrderTime.start as string | undefined,
|
||||
endOrderTime: defaultOrderTime.end as string | undefined,
|
||||
productId: undefined as number | undefined,
|
||||
@@ -285,23 +296,24 @@ const gridOptions: VxeGridProps<any> = {
|
||||
slots: { default: 'productInfo' },
|
||||
},
|
||||
{
|
||||
title: '规格信息',
|
||||
title: 'SKU 信息',
|
||||
minWidth: 160,
|
||||
showOverflow: false,
|
||||
slots: { default: 'specInfo' },
|
||||
slots: { default: 'skuInfo' },
|
||||
},
|
||||
{
|
||||
field: 'quantity',
|
||||
title: '数量',
|
||||
minWidth: 'auto',
|
||||
sortable: true,
|
||||
slots: { default: 'quantity' },
|
||||
},
|
||||
{
|
||||
field: 'receivedAmount',
|
||||
title: '实收金额',
|
||||
field: 'payAmount',
|
||||
title: '实付金额',
|
||||
minWidth: 'auto',
|
||||
sortable: true,
|
||||
slots: { default: 'receivedAmount' },
|
||||
slots: { default: 'payAmount' },
|
||||
},
|
||||
{
|
||||
field: 'productCost',
|
||||
@@ -401,7 +413,7 @@ const gridOptions: VxeGridProps<any> = {
|
||||
searchForm.value.platformOrderNo ||
|
||||
undefined,
|
||||
shopId: searchParams.shopId ?? searchForm.value.shopId,
|
||||
statusId: searchParams.statusId ?? searchForm.value.statusId,
|
||||
status: searchParams.status ?? searchForm.value.status,
|
||||
startOrderTime: searchForm.value.startOrderTime,
|
||||
endOrderTime: searchForm.value.endOrderTime,
|
||||
productId: searchParams.productId ?? searchForm.value.productId,
|
||||
@@ -518,11 +530,11 @@ const formOptions = computed(() => ({
|
||||
}
|
||||
},
|
||||
onChange: (val: any) => {
|
||||
searchForm.value.statusId = val;
|
||||
searchForm.value.status = val;
|
||||
gridReloadRef.value?.();
|
||||
},
|
||||
},
|
||||
fieldName: 'statusId',
|
||||
fieldName: 'status',
|
||||
label: '订单状态',
|
||||
},
|
||||
{
|
||||
@@ -586,9 +598,9 @@ function handleSortChange({
|
||||
async function fetchOrderStatusOptions() {
|
||||
try {
|
||||
const data = await getAllOrderStatusListApi();
|
||||
orderStatusOptions.value = data.map((status: OrderStatusVO.Info) => ({
|
||||
label: status.statusName,
|
||||
value: status.id,
|
||||
orderStatusOptions.value = data.map((status: OrderStatusVO.Meta) => ({
|
||||
label: status.label,
|
||||
value: status.code,
|
||||
}));
|
||||
orderStatusLoaded.value = true;
|
||||
} catch (error) {
|
||||
@@ -715,82 +727,118 @@ onMounted(async () => {
|
||||
</a>
|
||||
</template>
|
||||
|
||||
<!-- 商品信息列 -->
|
||||
<template #productInfo="{ row }: { row: any }">
|
||||
<!-- 商品信息列(首行明细 / 列表汇总) -->
|
||||
<template #productInfo="{ row }: { row: OrderVO.Info }">
|
||||
<Popover
|
||||
v-if="row.product?.name"
|
||||
v-if="getOrderProduct(row)?.name || row.firstLinkProductName"
|
||||
:title="undefined"
|
||||
trigger="hover"
|
||||
>
|
||||
<template #content>
|
||||
<div>商品名称:{{ row.product.name }}</div>
|
||||
<div>商品编码:{{ row.product.productCode || '-' }}</div>
|
||||
<div>
|
||||
商品名称:{{
|
||||
getOrderProduct(row)?.name || row.firstLinkProductName
|
||||
}}
|
||||
</div>
|
||||
<div>
|
||||
商品编码:{{ getOrderProduct(row)?.productCode || '-' }}
|
||||
</div>
|
||||
<div v-if="(row.itemCount ?? 0) > 1">
|
||||
共 {{ row.itemCount }} 行明细
|
||||
</div>
|
||||
</template>
|
||||
<a
|
||||
v-if="row.product?.id"
|
||||
v-if="getOrderProduct(row)?.id"
|
||||
style="color: #1890ff; cursor: pointer"
|
||||
@click.stop="goToProductDetail(row.product.id)"
|
||||
@click.stop="goToProductDetail(getOrderProduct(row)!.id)"
|
||||
>
|
||||
{{ row.product.name }}
|
||||
{{ getOrderProduct(row)!.name }}
|
||||
</a>
|
||||
<span v-else style="color: #1890ff">{{ row.product.name }}</span>
|
||||
<span v-else style="color: #1890ff">
|
||||
{{
|
||||
getOrderProduct(row)?.name ||
|
||||
getFirstOrderItem(row)?.linkProductName ||
|
||||
row.firstLinkProductName ||
|
||||
'-'
|
||||
}}
|
||||
<Tag v-if="(row.itemCount ?? 0) > 1" color="blue" class="ml-1">
|
||||
+{{ (row.itemCount ?? 0) - 1 }}
|
||||
</Tag>
|
||||
</span>
|
||||
</Popover>
|
||||
<span v-else style="color: #999">暂无商品信息</span>
|
||||
</template>
|
||||
|
||||
<!-- 规格信息列 -->
|
||||
<template #specInfo="{ row }: { row: any }">
|
||||
<!-- SKU 信息列 -->
|
||||
<template #skuInfo="{ row }: { row: OrderVO.Info }">
|
||||
<Popover
|
||||
v-if="row.productSpec?.name"
|
||||
v-if="getOrderProductSku(row)?.name || getFirstOrderItem(row)?.linkSkuName"
|
||||
:title="undefined"
|
||||
trigger="hover"
|
||||
>
|
||||
<template #content>
|
||||
<div>规格名称:{{ row.productSpec.name }}</div>
|
||||
<div>规格编码:{{ row.productSpec.specCode || '-' }}</div>
|
||||
<div>
|
||||
SKU 名称:{{
|
||||
getOrderProductSku(row)?.name ||
|
||||
getFirstOrderItem(row)?.linkSkuName
|
||||
}}
|
||||
</div>
|
||||
<div>
|
||||
SKU 编码:{{
|
||||
getOrderProductSku(row)?.skuCode ||
|
||||
getFirstOrderItem(row)?.skuCode ||
|
||||
'-'
|
||||
}}
|
||||
</div>
|
||||
</template>
|
||||
<span style="cursor: default">{{ row.productSpec.name }}</span>
|
||||
<span style="cursor: default">
|
||||
{{
|
||||
getOrderProductSku(row)?.name ||
|
||||
getFirstOrderItem(row)?.linkSkuName ||
|
||||
'-'
|
||||
}}
|
||||
</span>
|
||||
</Popover>
|
||||
<span v-else style="color: #999">-</span>
|
||||
</template>
|
||||
|
||||
<!-- 数量列 -->
|
||||
<template #quantity="{ row }: { row: any }">
|
||||
{{ row.quantity || 0 }}
|
||||
<template #quantity="{ row }: { row: OrderVO.Info }">
|
||||
{{ getOrderQuantity(row) }}
|
||||
</template>
|
||||
|
||||
<!-- 实收金额列 -->
|
||||
<template #receivedAmount="{ row }: { row: any }">
|
||||
<!-- 实付金额列 -->
|
||||
<template #payAmount="{ row }: { row: OrderVO.Info }">
|
||||
<span style="color: #52c41a; font-weight: bold">
|
||||
¥{{ (row.receivedAmount || 0).toFixed(2) }}
|
||||
¥{{ getOrderPayAmount(row).toFixed(2) }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<!-- 商品成本列 -->
|
||||
<template #productCost="{ row }: { row: any }">
|
||||
<template #productCost="{ row }: { row: OrderVO.Info }">
|
||||
<span style="color: #ff7875; font-weight: 500">
|
||||
¥{{ (row.productCost || 0).toFixed(2) }}
|
||||
¥{{ getOrderProductCost(row).toFixed(2) }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<!-- 运费列 -->
|
||||
<template #shippingCost="{ row }: { row: any }">
|
||||
<template #shippingCost="{ row }: { row: OrderVO.Info }">
|
||||
<span style="color: #ff7875; font-weight: 500">
|
||||
¥{{ (row.shippingCost || 0).toFixed(2) }}
|
||||
¥{{ getOrderShippingCost(row).toFixed(2) }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<!-- 其他成本列 -->
|
||||
<template #otherCost="{ row }: { row: any }">
|
||||
<template #otherCost="{ row }: { row: OrderVO.Info }">
|
||||
<span style="color: #ff7875; font-weight: 500">
|
||||
¥{{ (row.otherCost || 0).toFixed(2) }}
|
||||
¥{{ getOrderOtherCost(row).toFixed(2) }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<!-- 订单状态列 -->
|
||||
<template #orderStatus="{ row }: { row: any }">
|
||||
<Tag :color="row.orderStatus?.color || 'blue'" type="outline">
|
||||
{{ row.statusName || '未知状态' }}
|
||||
<Tag :color="row.statusColor || 'blue'" type="outline">
|
||||
{{ row.statusLabel || '未知状态' }}
|
||||
</Tag>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { PlatformVO } from '#/api/ecommerce/platform/types';
|
||||
import type { PddOrderDTO, PddOrderVO } from '#/api/ecommerce/pdd/order';
|
||||
import type { ShopDTO, ShopVO } from '#/api/ecommerce/shop/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
@@ -15,7 +14,6 @@ import { Button, Image, Space, Tag, message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getPddOrderPageApi } from '#/api/ecommerce/pdd/order';
|
||||
import { getActivePlatformsApi } from '#/api/ecommerce/platform';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
|
||||
import PddOrderDetailDrawer from './components/PddOrderDetailDrawer.vue';
|
||||
@@ -88,12 +86,6 @@ function regionText(row: PddOrderVO.Info) {
|
||||
|
||||
async function loadPddShops() {
|
||||
try {
|
||||
const platforms = await getActivePlatformsApi();
|
||||
const pddPlatformIds = new Set(
|
||||
platforms
|
||||
.filter((p: PlatformVO.Info) => p.platformCode === PLATFORM_CODE_PDD)
|
||||
.map((p: PlatformVO.Info) => p.id),
|
||||
);
|
||||
const data = await getShopPageApi({
|
||||
page: 1,
|
||||
pageSize: 500,
|
||||
@@ -101,7 +93,7 @@ async function loadPddShops() {
|
||||
});
|
||||
const list = (data.records ?? []).filter(
|
||||
(s: ShopVO.Info) =>
|
||||
(s.platformId != null && pddPlatformIds.has(s.platformId)) ||
|
||||
s.platformCode === PLATFORM_CODE_PDD ||
|
||||
!!s.pddShop ||
|
||||
!!s.externalShopId,
|
||||
);
|
||||
|
||||
-168
@@ -1,168 +0,0 @@
|
||||
<script lang="ts" setup>
|
||||
import type { PlatformDTO, PlatformVO } from '#/api/ecommerce/platform/types';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { Form, Input, message, Switch } from 'ant-design-vue';
|
||||
|
||||
import { createPlatformApi, updatePlatformApi } from '#/api/ecommerce/platform';
|
||||
|
||||
interface Emits {
|
||||
(e: 'success'): void;
|
||||
}
|
||||
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
// 创建 vben modal
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
draggable: true,
|
||||
class: 'w-[500px]',
|
||||
onCancel() {
|
||||
handleCancel();
|
||||
},
|
||||
onConfirm() {
|
||||
handleSubmit();
|
||||
},
|
||||
});
|
||||
|
||||
// 内部状态
|
||||
const isEdit = ref(false);
|
||||
const currentPlatformData = ref<PlatformVO.Info | null>(null);
|
||||
const formRef = ref();
|
||||
const loading = ref(false);
|
||||
|
||||
// 表单数据
|
||||
const formData = ref({
|
||||
platformName: '',
|
||||
platformCode: '',
|
||||
sortOrder: 0,
|
||||
isActive: true,
|
||||
});
|
||||
|
||||
// 模态框标题
|
||||
const modalTitle = computed(() => (isEdit.value ? '编辑平台' : '添加平台'));
|
||||
|
||||
// 初始化表单数据
|
||||
function initFormData() {
|
||||
if (isEdit.value && currentPlatformData.value) {
|
||||
formData.value = {
|
||||
platformName: currentPlatformData.value.platformName || '',
|
||||
platformCode: currentPlatformData.value.platformCode || '',
|
||||
sortOrder: currentPlatformData.value.sortOrder || 0,
|
||||
isActive: currentPlatformData.value.isActive === 1,
|
||||
};
|
||||
} else {
|
||||
formData.value = {
|
||||
platformName: '',
|
||||
platformCode: '',
|
||||
sortOrder: 0,
|
||||
isActive: true,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// 关闭模态框
|
||||
function handleCancel() {
|
||||
formRef.value?.resetFields();
|
||||
modalApi.close();
|
||||
}
|
||||
|
||||
// 处理提交
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
await formRef.value?.validate();
|
||||
loading.value = true;
|
||||
|
||||
const submitData: PlatformDTO.Create | PlatformDTO.Update = {
|
||||
platformName: formData.value.platformName,
|
||||
platformCode: formData.value.platformCode,
|
||||
sortOrder: formData.value.sortOrder,
|
||||
isActive: formData.value.isActive ? 1 : 0,
|
||||
};
|
||||
|
||||
if (isEdit.value && currentPlatformData.value?.id) {
|
||||
await updatePlatformApi(
|
||||
currentPlatformData.value.id,
|
||||
submitData as PlatformDTO.Update,
|
||||
);
|
||||
message.success('更新成功');
|
||||
} else {
|
||||
await createPlatformApi(submitData as PlatformDTO.Create);
|
||||
message.success('创建成功');
|
||||
}
|
||||
|
||||
emit('success');
|
||||
handleCancel();
|
||||
} catch (error: any) {
|
||||
if (error?.errorFields) {
|
||||
return;
|
||||
}
|
||||
message.error(error?.message || '操作失败');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 暴露给父组件的方法
|
||||
function open(
|
||||
editMode: boolean = false,
|
||||
platformData?: PlatformVO.Info,
|
||||
) {
|
||||
isEdit.value = editMode;
|
||||
currentPlatformData.value = platformData || null;
|
||||
initFormData();
|
||||
modalApi.open();
|
||||
}
|
||||
|
||||
// 暴露方法给父组件
|
||||
defineExpose({
|
||||
open,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="modalTitle">
|
||||
<Form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
layout="vertical"
|
||||
class="mx-4 my-4"
|
||||
>
|
||||
<Form.Item
|
||||
label="平台名称"
|
||||
name="platformName"
|
||||
:rules="[{ required: true, message: '请输入平台名称' }]"
|
||||
>
|
||||
<Input
|
||||
v-model:value="formData.platformName"
|
||||
placeholder="如:淘宝、京东"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label="平台代码"
|
||||
name="platformCode"
|
||||
:rules="[{ required: true, message: '请输入平台代码' }]"
|
||||
>
|
||||
<Input
|
||||
v-model:value="formData.platformCode"
|
||||
placeholder="如:taobao、jd"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="排序" name="sortOrder">
|
||||
<Input
|
||||
v-model:value="formData.sortOrder"
|
||||
type="number"
|
||||
placeholder="数值越小越靠前"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="启用状态" name="isActive">
|
||||
<Switch v-model:checked="formData.isActive" />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -1,274 +0,0 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { PlatformVO } from '#/api/ecommerce/platform/types';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
|
||||
import { Button, message, Popconfirm, Space, Tag } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
deletePlatformApi,
|
||||
getPlatformPageApi,
|
||||
} from '#/api/ecommerce/platform';
|
||||
|
||||
import PlatformFormModal from './components/PlatformFormModal.vue';
|
||||
|
||||
defineOptions({ name: 'PlatformManagement' });
|
||||
|
||||
// 创建图标组件
|
||||
const PlusIcon = createIconifyIcon('lucide:plus');
|
||||
|
||||
// 响应式数据
|
||||
const loading = ref(false);
|
||||
const platformFormModalRef = ref<InstanceType<typeof PlatformFormModal>>();
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = ref({
|
||||
platformName: '',
|
||||
platformCode: '',
|
||||
isActive: undefined as number | undefined,
|
||||
});
|
||||
|
||||
// 当前排序状态
|
||||
const currentSort = ref<null | { field: string; order: 'asc' | 'desc' }>(null);
|
||||
|
||||
// VxeGrid 表格配置
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
columns: [
|
||||
{
|
||||
type: 'seq' as const,
|
||||
width: 80,
|
||||
title: '序号',
|
||||
},
|
||||
{
|
||||
field: 'platformName',
|
||||
title: '平台名称',
|
||||
minWidth: 140,
|
||||
showOverflow: true,
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
field: 'platformCode',
|
||||
title: '平台代码',
|
||||
minWidth: 120,
|
||||
showOverflow: true,
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
field: 'sortOrder',
|
||||
title: '排序',
|
||||
width: 80,
|
||||
align: 'center',
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
field: 'isActive',
|
||||
title: '状态',
|
||||
width: 100,
|
||||
align: 'center',
|
||||
slots: { default: 'isActive' },
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
minWidth: 160,
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
field: 'updateTime',
|
||||
title: '更新时间',
|
||||
minWidth: 160,
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 150,
|
||||
fixed: 'right',
|
||||
slots: { default: 'action' },
|
||||
},
|
||||
],
|
||||
height: 'auto',
|
||||
border: true,
|
||||
stripe: true,
|
||||
rowConfig: { isHover: true },
|
||||
showOverflow: true,
|
||||
size: 'small',
|
||||
pagerConfig: {
|
||||
enabled: true,
|
||||
pageSize: 20,
|
||||
pageSizes: [10, 20, 50, 100],
|
||||
},
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page, form }) => {
|
||||
try {
|
||||
loading.value = true;
|
||||
const filters = {
|
||||
platformName:
|
||||
form?.platformName || searchForm.value.platformName || undefined,
|
||||
platformCode:
|
||||
form?.platformCode || searchForm.value.platformCode || undefined,
|
||||
isActive: form?.isActive ?? searchForm.value.isActive,
|
||||
};
|
||||
const params: any = {
|
||||
page: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
filters,
|
||||
};
|
||||
if (currentSort.value) {
|
||||
params.sorts = [currentSort.value];
|
||||
}
|
||||
const data = await getPlatformPageApi(params);
|
||||
return {
|
||||
items: data.records || [],
|
||||
total: data.total || 0,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('获取平台列表失败:', error);
|
||||
message.error('获取平台列表失败');
|
||||
return { items: [], total: 0 };
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// 搜索表单配置(FormSearch 组件)
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入平台名称(回车搜索)',
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'platformName',
|
||||
label: '平台名称',
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入平台代码(回车搜索)',
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'platformCode',
|
||||
label: '平台代码',
|
||||
},
|
||||
{
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
placeholder: '请选择状态',
|
||||
allowClear: true,
|
||||
options: [
|
||||
{ label: '启用', value: 1 },
|
||||
{ label: '禁用', value: 0 },
|
||||
],
|
||||
onChange: (val: any) => {
|
||||
searchForm.value.isActive = val;
|
||||
gridReloadRef.value?.();
|
||||
},
|
||||
},
|
||||
fieldName: 'isActive',
|
||||
label: '状态',
|
||||
},
|
||||
],
|
||||
showDefaultActions: true,
|
||||
collapsed: true,
|
||||
collapsedRows: 1,
|
||||
}));
|
||||
|
||||
// 创建 VxeGrid 实例
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions,
|
||||
formOptions: formOptions.value,
|
||||
showSearchForm: true,
|
||||
tableTitle: '平台管理',
|
||||
});
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
// 刷新表格
|
||||
function refreshTable() {
|
||||
gridApi.reload();
|
||||
}
|
||||
|
||||
// 打开新增模态框
|
||||
function handleAdd() {
|
||||
platformFormModalRef.value?.open(false);
|
||||
}
|
||||
|
||||
// 打开编辑模态框
|
||||
function handleEdit(row: PlatformVO.Info) {
|
||||
platformFormModalRef.value?.open(true, row);
|
||||
}
|
||||
|
||||
// 删除平台
|
||||
async function handleDelete(id: number) {
|
||||
try {
|
||||
await deletePlatformApi(id);
|
||||
message.success('删除成功');
|
||||
refreshTable();
|
||||
} catch (error: any) {
|
||||
message.error(error?.message || '删除失败');
|
||||
}
|
||||
}
|
||||
|
||||
// 排序变化
|
||||
function handleSortChange({
|
||||
field,
|
||||
order,
|
||||
}: {
|
||||
field?: string;
|
||||
order?: 'asc' | 'desc' | null;
|
||||
}) {
|
||||
currentSort.value = field
|
||||
? { field, order: order || 'desc' }
|
||||
: null;
|
||||
gridReloadRef.value?.();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<!-- VxeGrid 表格 -->
|
||||
<Grid :loading="loading" @sort-change="handleSortChange">
|
||||
<!-- 工具栏 -->
|
||||
<template #toolbar-tools>
|
||||
<Space>
|
||||
<Button type="primary" @click="handleAdd">
|
||||
<PlusIcon />
|
||||
添加平台
|
||||
</Button>
|
||||
</Space>
|
||||
</template>
|
||||
|
||||
<!-- 状态列 -->
|
||||
<template #isActive="{ row }">
|
||||
<Tag :color="row.isActive === 1 ? 'success' : 'default'" type="outline">
|
||||
{{ row.isActive === 1 ? '启用' : '禁用' }}
|
||||
</Tag>
|
||||
</template>
|
||||
|
||||
<!-- 操作列 -->
|
||||
<template #action="{ row }">
|
||||
<Space>
|
||||
<Button type="link" size="small" @click="handleEdit(row)">
|
||||
编辑
|
||||
</Button>
|
||||
<Popconfirm title="确定删除该平台?" @confirm="handleDelete(row.id)">
|
||||
<Button type="link" danger size="small">删除</Button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
</template>
|
||||
</Grid>
|
||||
|
||||
<!-- 表单模态框 -->
|
||||
<PlatformFormModal ref="platformFormModalRef" @success="refreshTable" />
|
||||
</Page>
|
||||
</template>
|
||||
-1728
File diff suppressed because it is too large
Load Diff
+50
-50
@@ -1,5 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import type { ProductSpecVO } from '#/api/ecommerce/product-spec/types';
|
||||
import type { ProductSkuVO } from '#/api/ecommerce/product-sku/types';
|
||||
|
||||
import { onUnmounted, ref, watch } from 'vue';
|
||||
|
||||
@@ -10,8 +10,8 @@ import { DatePicker, message } from 'ant-design-vue';
|
||||
import {
|
||||
batchSyncCostsToOrdersApi,
|
||||
countOrdersForCostSyncApi,
|
||||
getProductSpecsByIdsApi,
|
||||
} from '#/api/ecommerce/product-spec/apis';
|
||||
getProductSkusByIdsApi,
|
||||
} from '#/api/ecommerce/product-sku/apis';
|
||||
|
||||
defineOptions({ name: 'ProductCostSyncToOrdersModal' });
|
||||
|
||||
@@ -50,8 +50,8 @@ const [SyncModal, syncModalApi] = useVbenModal({
|
||||
});
|
||||
|
||||
const syncFormData = ref<[string, string] | undefined>(undefined);
|
||||
const pendingCostChangedSpecs = ref<ProductSpecVO.Info[]>([]);
|
||||
const selectedSyncSpecIds = ref<number[]>([]);
|
||||
const pendingCostChangedSkus = ref<ProductSkuVO.Info[]>([]);
|
||||
const selectedSyncSkuIds = ref<number[]>([]);
|
||||
const costSyncModalEntry = ref<ProductCostSyncModalEntry>('after-save');
|
||||
|
||||
const costSyncOrderCount = ref<null | number>(null);
|
||||
@@ -74,7 +74,7 @@ async function fetchCostSyncOrderCount() {
|
||||
costSyncOrderCount.value = null;
|
||||
return;
|
||||
}
|
||||
if (selectedSyncSpecIds.value.length === 0) {
|
||||
if (selectedSyncSkuIds.value.length === 0) {
|
||||
costSyncOrderCount.value = null;
|
||||
return;
|
||||
}
|
||||
@@ -82,7 +82,7 @@ async function fetchCostSyncOrderCount() {
|
||||
try {
|
||||
const { startTime, endTime } = dateRangeToApiTimes(range);
|
||||
costSyncOrderCount.value = await countOrdersForCostSyncApi({
|
||||
specIds: [...selectedSyncSpecIds.value],
|
||||
skuIds: [...selectedSyncSkuIds.value],
|
||||
startTime,
|
||||
endTime,
|
||||
});
|
||||
@@ -94,7 +94,7 @@ async function fetchCostSyncOrderCount() {
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [...selectedSyncSpecIds.value],
|
||||
() => [...selectedSyncSkuIds.value],
|
||||
() => {
|
||||
scheduleFetchCostSyncOrderCount();
|
||||
},
|
||||
@@ -109,18 +109,18 @@ watch(
|
||||
);
|
||||
|
||||
/**
|
||||
* 打开成本同步弹窗(先拉取规格详情再展示)
|
||||
* 打开成本同步弹窗(先拉取SKU详情再展示)
|
||||
*/
|
||||
async function open(specIds: number[], options?: ProductCostSyncOpenOptions) {
|
||||
async function open(skuIds: number[], options?: ProductCostSyncOpenOptions) {
|
||||
const entry = options?.entry ?? 'after-save';
|
||||
costSyncModalEntry.value = entry;
|
||||
syncModalApi.setState?.({
|
||||
title: entry === 'manual' ? '同步成本到订单' : '成本变更同步确认',
|
||||
});
|
||||
try {
|
||||
const specs = await getProductSpecsByIdsApi(specIds);
|
||||
pendingCostChangedSpecs.value = specs ?? [];
|
||||
selectedSyncSpecIds.value = [...specIds];
|
||||
const skus = await getProductSkusByIdsApi(skuIds);
|
||||
pendingCostChangedSkus.value = skus ?? [];
|
||||
selectedSyncSkuIds.value = [...skuIds];
|
||||
syncFormData.value = options?.initialDateRange
|
||||
? [options.initialDateRange[0], options.initialDateRange[1]]
|
||||
: undefined;
|
||||
@@ -130,23 +130,23 @@ async function open(specIds: number[], options?: ProductCostSyncOpenOptions) {
|
||||
scheduleFetchCostSyncOrderCount();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取规格详情失败:', error);
|
||||
message.error('获取规格详情失败,无法进行成本同步');
|
||||
console.error('获取SKU详情失败:', error);
|
||||
message.error('获取SKU详情失败,无法进行成本同步');
|
||||
}
|
||||
}
|
||||
|
||||
function toggleSpec(specId: number) {
|
||||
const idx = selectedSyncSpecIds.value.indexOf(specId);
|
||||
function toggleSku(skuId: number) {
|
||||
const idx = selectedSyncSkuIds.value.indexOf(skuId);
|
||||
if (idx === -1) {
|
||||
selectedSyncSpecIds.value.push(specId);
|
||||
selectedSyncSkuIds.value.push(skuId);
|
||||
} else {
|
||||
selectedSyncSpecIds.value.splice(idx, 1);
|
||||
selectedSyncSkuIds.value.splice(idx, 1);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSyncConfirm() {
|
||||
if (selectedSyncSpecIds.value.length === 0) {
|
||||
message.warning('请至少选择一个规格');
|
||||
if (selectedSyncSkuIds.value.length === 0) {
|
||||
message.warning('请至少选择一个SKU');
|
||||
return;
|
||||
}
|
||||
const range = syncFormData.value;
|
||||
@@ -158,7 +158,7 @@ async function handleSyncConfirm() {
|
||||
syncModalApi.setState?.({ confirmLoading: true });
|
||||
const { startTime, endTime } = dateRangeToApiTimes(range);
|
||||
const totalUpdated = await batchSyncCostsToOrdersApi({
|
||||
specIds: selectedSyncSpecIds.value,
|
||||
skuIds: selectedSyncSkuIds.value,
|
||||
startTime,
|
||||
endTime,
|
||||
});
|
||||
@@ -200,51 +200,51 @@ defineExpose({ open });
|
||||
</svg>
|
||||
<template v-if="costSyncModalEntry === 'after-save'">
|
||||
检测到
|
||||
<strong>{{ pendingCostChangedSpecs.length }}</strong>
|
||||
个规格的成本已更新,请勾选需要同步的规格:
|
||||
<strong>{{ pendingCostChangedSkus.length }}</strong>
|
||||
个SKU的成本已更新,请勾选需要同步的SKU:
|
||||
</template>
|
||||
<template v-else>
|
||||
将所选规格<strong>当前</strong>的商品成本、运费、其他成本写入订单(会覆盖该时间范围内订单上的对应成本字段)。请勾选需要同步的规格,共
|
||||
<strong>{{ pendingCostChangedSpecs.length }}</strong> 个:
|
||||
将所选SKU<strong>当前</strong>的商品成本、运费、其他成本写入订单(会覆盖该时间范围内订单上的对应成本字段)。请勾选需要同步的SKU,共
|
||||
<strong>{{ pendingCostChangedSkus.length }}</strong> 个:
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="spec-list mb-4 max-h-72 min-h-[200px] overflow-y-auto rounded-lg"
|
||||
class="sku-list mb-4 max-h-72 min-h-[200px] overflow-y-auto rounded-lg"
|
||||
>
|
||||
<div
|
||||
v-for="spec in pendingCostChangedSpecs"
|
||||
:key="spec.id"
|
||||
class="spec-item-card"
|
||||
:class="{ active: selectedSyncSpecIds.includes(spec.id) }"
|
||||
@click="toggleSpec(spec.id)"
|
||||
v-for="sku in pendingCostChangedSkus"
|
||||
:key="sku.id"
|
||||
class="sku-item-card"
|
||||
:class="{ active: selectedSyncSkuIds.includes(sku.id) }"
|
||||
@click="toggleSku(sku.id)"
|
||||
>
|
||||
<div class="checkbox-wrapper">
|
||||
<div class="custom-checkbox">
|
||||
<span
|
||||
v-if="selectedSyncSpecIds.includes(spec.id)"
|
||||
v-if="selectedSyncSkuIds.includes(sku.id)"
|
||||
class="check-icon"
|
||||
>
|
||||
✓
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="spec-info">
|
||||
<div class="spec-title">{{ spec.name }}</div>
|
||||
<div class="spec-code">{{ spec.specCode || '无编码' }}</div>
|
||||
<div class="sku-info">
|
||||
<div class="sku-title">{{ sku.name }}</div>
|
||||
<div class="sku-code">{{ sku.skuCode || '无编码' }}</div>
|
||||
</div>
|
||||
<div class="cost-snapshot">
|
||||
<div class="cost-tag changed">
|
||||
<span>商品成本</span>
|
||||
<span>¥{{ Number(spec.productCost || 0).toFixed(2) }}</span>
|
||||
<span>¥{{ Number(sku.productCost || 0).toFixed(2) }}</span>
|
||||
</div>
|
||||
<div class="cost-tag">
|
||||
<span>运费</span>
|
||||
<span>¥{{ Number(spec.shippingCost || 0).toFixed(2) }}</span>
|
||||
<span>¥{{ Number(sku.shippingCost || 0).toFixed(2) }}</span>
|
||||
</div>
|
||||
<div class="cost-tag">
|
||||
<span>其他</span>
|
||||
<span>¥{{ Number(spec.otherCost || 0).toFixed(2) }}</span>
|
||||
<span>¥{{ Number(sku.otherCost || 0).toFixed(2) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -268,7 +268,7 @@ defineExpose({ open });
|
||||
syncFormData &&
|
||||
syncFormData[0] &&
|
||||
syncFormData[1] &&
|
||||
selectedSyncSpecIds.length > 0
|
||||
selectedSyncSkuIds.length > 0
|
||||
"
|
||||
>
|
||||
当前日期范围内共
|
||||
@@ -297,13 +297,13 @@ defineExpose({ open });
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.spec-list {
|
||||
.sku-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.spec-item-card {
|
||||
.sku-item-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 16px;
|
||||
@@ -314,12 +314,12 @@ defineExpose({ open });
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.spec-item-card:hover {
|
||||
.sku-item-card:hover {
|
||||
border-color: #d1d9ff;
|
||||
background: #fafbff;
|
||||
}
|
||||
|
||||
.spec-item-card.active {
|
||||
.sku-item-card.active {
|
||||
border-color: #5b6df5;
|
||||
background: #f0f2ff;
|
||||
}
|
||||
@@ -353,12 +353,12 @@ defineExpose({ open });
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.spec-info {
|
||||
.sku-info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.spec-title {
|
||||
.sku-title {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: #2d3436;
|
||||
@@ -370,7 +370,7 @@ defineExpose({ open });
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.spec-code {
|
||||
.sku-code {
|
||||
font-size: 12px;
|
||||
color: #636e72;
|
||||
font-family: monospace;
|
||||
@@ -425,7 +425,7 @@ $primary: hsl(var(--primary));
|
||||
|
||||
html.dark .product-cost-sync {
|
||||
.section-label,
|
||||
.spec-code,
|
||||
.sku-code,
|
||||
.cost-tag {
|
||||
color: $muted-text;
|
||||
}
|
||||
@@ -436,7 +436,7 @@ html.dark .product-cost-sync {
|
||||
color: hsl(var(--warning));
|
||||
}
|
||||
|
||||
.spec-item-card {
|
||||
.sku-item-card {
|
||||
border-color: $border-base;
|
||||
background: hsl(var(--muted));
|
||||
|
||||
@@ -456,7 +456,7 @@ html.dark .product-cost-sync {
|
||||
border-color: $border-base;
|
||||
}
|
||||
|
||||
.spec-title {
|
||||
.sku-title {
|
||||
color: $card-text;
|
||||
}
|
||||
|
||||
|
||||
+15
-15
@@ -26,18 +26,18 @@ const emit = defineEmits<{
|
||||
/** 金额展示 */
|
||||
const formatCost = (val?: number) => `¥${(val ?? 0).toFixed(2)}`;
|
||||
|
||||
const specDataSource = computed(() => product.value?.specs ?? []);
|
||||
const skuDataSource = computed(() => product.value?.skus ?? []);
|
||||
|
||||
const specColumns = [
|
||||
const skuColumns = [
|
||||
{
|
||||
title: '规格编码',
|
||||
dataIndex: 'specCode',
|
||||
key: 'specCode',
|
||||
title: 'SKU 编码',
|
||||
dataIndex: 'skuCode',
|
||||
key: 'skuCode',
|
||||
width: 140,
|
||||
customRender: ({ text }: { text?: string }) => text || '-',
|
||||
},
|
||||
{
|
||||
title: '规格名称',
|
||||
title: 'SKU 名称',
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
ellipsis: true,
|
||||
@@ -47,7 +47,7 @@ const specColumns = [
|
||||
dataIndex: 'productCost',
|
||||
key: 'productCost',
|
||||
width: 110,
|
||||
customRender: ({ record }: { record: ProductVO.SpecInfo }) =>
|
||||
customRender: ({ record }: { record: ProductVO.SkuInfo }) =>
|
||||
formatCost(record.productCost),
|
||||
},
|
||||
{
|
||||
@@ -55,7 +55,7 @@ const specColumns = [
|
||||
dataIndex: 'shippingCost',
|
||||
key: 'shippingCost',
|
||||
width: 110,
|
||||
customRender: ({ record }: { record: ProductVO.SpecInfo }) =>
|
||||
customRender: ({ record }: { record: ProductVO.SkuInfo }) =>
|
||||
formatCost(record.shippingCost),
|
||||
},
|
||||
{
|
||||
@@ -63,7 +63,7 @@ const specColumns = [
|
||||
dataIndex: 'otherCost',
|
||||
key: 'otherCost',
|
||||
width: 110,
|
||||
customRender: ({ record }: { record: ProductVO.SpecInfo }) =>
|
||||
customRender: ({ record }: { record: ProductVO.SkuInfo }) =>
|
||||
formatCost(record.otherCost),
|
||||
},
|
||||
{
|
||||
@@ -151,8 +151,8 @@ defineExpose({
|
||||
<span>{{ product.categoryName || '-' }}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span class="text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">规格数量:</span>
|
||||
<span>{{ product.specs?.length ?? 0 }}</span>
|
||||
<span class="text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">SKU 数量:</span>
|
||||
<span>{{ product.skus?.length ?? 0 }}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span class="text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">创建时间:</span>
|
||||
@@ -162,14 +162,14 @@ defineExpose({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 规格明细表 -->
|
||||
<!-- SKU 明细表 -->
|
||||
<div>
|
||||
<div class="mb-3 text-base font-medium text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
|
||||
规格明细
|
||||
SKU 明细
|
||||
</div>
|
||||
<Table
|
||||
:columns="specColumns"
|
||||
:data-source="specDataSource"
|
||||
:columns="skuColumns"
|
||||
:data-source="skuDataSource"
|
||||
:pagination="false"
|
||||
row-key="id"
|
||||
size="small"
|
||||
|
||||
+84
-84
@@ -61,8 +61,8 @@ const productCostSyncModalRef = ref<InstanceType<
|
||||
typeof ProductCostSyncToOrdersModal
|
||||
> | null>(null);
|
||||
|
||||
async function openSyncModal(specIds: number[]) {
|
||||
await productCostSyncModalRef.value?.open(specIds, {
|
||||
async function openSyncModal(skuIds: number[]) {
|
||||
await productCostSyncModalRef.value?.open(skuIds, {
|
||||
entry: 'after-save',
|
||||
initialDateRange: [
|
||||
dayjs().startOf('day').format('YYYY-MM-DD'),
|
||||
@@ -149,19 +149,19 @@ const categoryTreeDropdownRender: DropdownRender = (opt) => {
|
||||
};
|
||||
|
||||
/** 表格行:创建规格无 id,编辑已有规格带 id;_clientKey 用于行 key */
|
||||
type SpecFormRow = ProductDTO.Spec & {
|
||||
type SkuFormRow = ProductDTO.Sku & {
|
||||
_clientKey?: string;
|
||||
id?: number;
|
||||
};
|
||||
|
||||
// 规格数据 - 支持创建和更新
|
||||
const specs = ref<SpecFormRow[]>([]);
|
||||
const showSpecs = ref(false);
|
||||
const skus = ref<SkuFormRow[]>([]);
|
||||
const showSkus = ref(false);
|
||||
|
||||
/** 编辑打开时已有的规格 ID,用于提交时计算 removedSpecIds */
|
||||
const initialEditSpecIds = ref<Set<number>>(new Set());
|
||||
/** 编辑打开时已有的规格 ID,用于提交时计算 removedSkuIds */
|
||||
const initialEditSkuIds = ref<Set<number>>(new Set());
|
||||
|
||||
let nextSpecClientKey = 0;
|
||||
let nextSkuClientKey = 0;
|
||||
|
||||
// 当前显示的图片 URL(优先显示新选择的)
|
||||
const currentImageUrl = computed(() => {
|
||||
@@ -196,47 +196,47 @@ function initFormData() {
|
||||
imageLoadError.value = false;
|
||||
|
||||
// 重置规格数据
|
||||
specs.value = [];
|
||||
showSpecs.value = false;
|
||||
skus.value = [];
|
||||
showSkus.value = false;
|
||||
|
||||
// 如果有传入的规格信息,则自动填入
|
||||
if (
|
||||
currentProductData.value &&
|
||||
'specs' in currentProductData.value &&
|
||||
currentProductData.value.specs
|
||||
'skus' in currentProductData.value &&
|
||||
currentProductData.value.skus
|
||||
) {
|
||||
const mapSpec = (spec: ProductVO.SpecInfo) => ({
|
||||
name: spec.name || spec.specCode || '',
|
||||
specCode: spec.specCode || '',
|
||||
const mapSku = (spec: ProductVO.SkuInfo) => ({
|
||||
name: spec.name || spec.skuCode || '',
|
||||
skuCode: spec.skuCode || '',
|
||||
productCost: spec.productCost ?? 0,
|
||||
shippingCost: spec.shippingCost ?? 0,
|
||||
otherCost: spec.otherCost ?? 0,
|
||||
remark: spec.remark || '',
|
||||
});
|
||||
specs.value = isEdit.value
|
||||
? currentProductData.value.specs.map((spec) => {
|
||||
const s = spec as ProductVO.SpecInfo;
|
||||
skus.value = isEdit.value
|
||||
? currentProductData.value.skus.map((spec) => {
|
||||
const s = spec as ProductVO.SkuInfo;
|
||||
return {
|
||||
id: s.id,
|
||||
_clientKey: `exist-${s.id}`,
|
||||
...mapSpec(s),
|
||||
} as SpecFormRow;
|
||||
...mapSku(s),
|
||||
} as SkuFormRow;
|
||||
})
|
||||
: currentProductData.value.specs.map((spec) => ({
|
||||
_clientKey: `seed-${++nextSpecClientKey}`,
|
||||
...mapSpec(spec as ProductVO.SpecInfo),
|
||||
: currentProductData.value.skus.map((spec) => ({
|
||||
_clientKey: `seed-${++nextSkuClientKey}`,
|
||||
...mapSku(spec as ProductVO.SkuInfo),
|
||||
}));
|
||||
showSpecs.value = specs.value.length > 0;
|
||||
showSkus.value = skus.value.length > 0;
|
||||
}
|
||||
|
||||
if (isEdit.value) {
|
||||
initialEditSpecIds.value = new Set(
|
||||
specs.value
|
||||
initialEditSkuIds.value = new Set(
|
||||
skus.value
|
||||
.map((s) => (s.id != null ? Number(s.id) : null))
|
||||
.filter((x): x is number => x != null),
|
||||
);
|
||||
} else {
|
||||
initialEditSpecIds.value = new Set();
|
||||
initialEditSkuIds.value = new Set();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,9 +246,9 @@ function resetForm() {
|
||||
newImageFile.value = null;
|
||||
originalImageUrl.value = '';
|
||||
imageLoadError.value = false;
|
||||
specs.value = [];
|
||||
showSpecs.value = false;
|
||||
initialEditSpecIds.value = new Set();
|
||||
skus.value = [];
|
||||
showSkus.value = false;
|
||||
initialEditSkuIds.value = new Set();
|
||||
categoryOptions.value = [];
|
||||
}
|
||||
|
||||
@@ -279,21 +279,21 @@ async function handleSubmit() {
|
||||
'id' in currentProductData.value &&
|
||||
currentProductData.value.id
|
||||
) {
|
||||
const keptSpecIds = new Set(
|
||||
specs.value
|
||||
const keptSkuIds = new Set(
|
||||
skus.value
|
||||
.map((s) => (s.id != null ? Number(s.id) : null))
|
||||
.filter((x): x is number => x != null),
|
||||
);
|
||||
const removedSpecIds = [...initialEditSpecIds.value].filter(
|
||||
(sid) => !keptSpecIds.has(sid),
|
||||
const removedSkuIds = [...initialEditSkuIds.value].filter(
|
||||
(sid) => !keptSkuIds.has(sid),
|
||||
);
|
||||
|
||||
const specsPayload: ProductDTO.UpdateSpec[] = specs.value.map((row) => {
|
||||
const skusPayload: ProductDTO.UpdateSku[] = skus.value.map((row) => {
|
||||
const {
|
||||
_clientKey: _c,
|
||||
id,
|
||||
name,
|
||||
specCode,
|
||||
skuCode,
|
||||
productCost,
|
||||
shippingCost,
|
||||
otherCost,
|
||||
@@ -301,7 +301,7 @@ async function handleSubmit() {
|
||||
} = row;
|
||||
const base = {
|
||||
name,
|
||||
specCode: specCode ?? '',
|
||||
skuCode: skuCode ?? '',
|
||||
productCost: productCost ?? 0,
|
||||
shippingCost: shippingCost ?? 0,
|
||||
otherCost: otherCost ?? 0,
|
||||
@@ -318,15 +318,15 @@ async function handleSubmit() {
|
||||
productCode: submitData.productCode || undefined,
|
||||
categoryId: submitData.categoryId,
|
||||
mainImageId: submitData.mainImageId,
|
||||
...(specs.value.length > 0 && { specs: specsPayload }),
|
||||
...(removedSpecIds.length > 0 && { removedSpecIds }),
|
||||
...(skus.value.length > 0 && { skus: skusPayload }),
|
||||
...(removedSkuIds.length > 0 && { removedSkuIds }),
|
||||
};
|
||||
const result = await updateProductApi(currentProductData.value.id, updateData);
|
||||
if (specs.value.length > 0 && result.specIdsCostChangedWithLinkedOrders?.length > 0) {
|
||||
message.success('商品和规格更新成功');
|
||||
openSyncModal(result.specIdsCostChangedWithLinkedOrders);
|
||||
if (skus.value.length > 0 && result.skuIdsCostChangedWithLinkedOrders?.length > 0) {
|
||||
message.success('商品和 SKU更新成功');
|
||||
openSyncModal(result.skuIdsCostChangedWithLinkedOrders);
|
||||
} else {
|
||||
message.success('商品和规格更新成功');
|
||||
message.success('商品和 SKU更新成功');
|
||||
}
|
||||
} else {
|
||||
// 创建模式:统一使用创建接口,规格信息作为可选字段
|
||||
@@ -335,15 +335,15 @@ async function handleSubmit() {
|
||||
productCode: submitData.productCode || undefined,
|
||||
categoryId: submitData.categoryId,
|
||||
mainImageId: submitData.mainImageId,
|
||||
...(specs.value.length > 0 && {
|
||||
specs: specs.value.map(({ _clientKey: _c, id: _id, ...rest }) => rest),
|
||||
...(skus.value.length > 0 && {
|
||||
skus: skus.value.map(({ _clientKey: _c, id: _id, ...rest }) => rest),
|
||||
}),
|
||||
};
|
||||
const createResult = await createProductApi(createData);
|
||||
if (specs.value.length > 0) {
|
||||
message.success('商品和规格创建成功');
|
||||
if (createResult.specIdsCostChangedWithLinkedOrders?.length > 0) {
|
||||
void openSyncModal(createResult.specIdsCostChangedWithLinkedOrders);
|
||||
if (skus.value.length > 0) {
|
||||
message.success('商品和 SKU创建成功');
|
||||
if (createResult.skuIdsCostChangedWithLinkedOrders?.length > 0) {
|
||||
void openSyncModal(createResult.skuIdsCostChangedWithLinkedOrders);
|
||||
}
|
||||
} else {
|
||||
message.success('创建成功');
|
||||
@@ -436,41 +436,41 @@ function removeNewImage() {
|
||||
message.success('已重置图片');
|
||||
}
|
||||
|
||||
const defaultSpec = (): SpecFormRow => ({
|
||||
_clientKey: `new-${++nextSpecClientKey}`,
|
||||
const defaultSku = (): SkuFormRow => ({
|
||||
_clientKey: `new-${++nextSkuClientKey}`,
|
||||
name: '',
|
||||
specCode: '',
|
||||
skuCode: '',
|
||||
productCost: 0,
|
||||
shippingCost: 0,
|
||||
otherCost: 0,
|
||||
remark: '',
|
||||
});
|
||||
|
||||
// 添加规格
|
||||
function addSpec() {
|
||||
specs.value.push(defaultSpec());
|
||||
// 添加 SKU
|
||||
function addSku() {
|
||||
skus.value.push(defaultSku());
|
||||
}
|
||||
|
||||
// 删除规格
|
||||
function removeSpec(index: number) {
|
||||
specs.value.splice(index, 1);
|
||||
function removeSku(index: number) {
|
||||
skus.value.splice(index, 1);
|
||||
}
|
||||
|
||||
// 表格列配置
|
||||
const specColumns = [
|
||||
const skuColumns = [
|
||||
{
|
||||
title: '规格名称',
|
||||
title: 'SKU 名称',
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
width: 300,
|
||||
customRender: ({
|
||||
record,
|
||||
}: {
|
||||
record: SpecFormRow;
|
||||
record: SkuFormRow;
|
||||
}) => {
|
||||
return h(Input, {
|
||||
value: record.name,
|
||||
placeholder: '请输入规格名称',
|
||||
placeholder: '请输入SKU 名称',
|
||||
'onUpdate:value': (value: string) => {
|
||||
record.name = value;
|
||||
},
|
||||
@@ -478,20 +478,20 @@ const specColumns = [
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '规格编码',
|
||||
dataIndex: 'specCode',
|
||||
key: 'specCode',
|
||||
title: 'SKU 编码',
|
||||
dataIndex: 'skuCode',
|
||||
key: 'skuCode',
|
||||
width: 140,
|
||||
customRender: ({
|
||||
record,
|
||||
}: {
|
||||
record: SpecFormRow;
|
||||
record: SkuFormRow;
|
||||
}) => {
|
||||
return h(Input, {
|
||||
value: record.specCode,
|
||||
placeholder: '请输入规格编码',
|
||||
value: record.skuCode,
|
||||
placeholder: '请输入SKU 编码',
|
||||
'onUpdate:value': (value: string) => {
|
||||
record.specCode = value;
|
||||
record.skuCode = value;
|
||||
},
|
||||
});
|
||||
},
|
||||
@@ -504,7 +504,7 @@ const specColumns = [
|
||||
customRender: ({
|
||||
record,
|
||||
}: {
|
||||
record: SpecFormRow;
|
||||
record: SkuFormRow;
|
||||
}) => {
|
||||
return h(InputNumber, {
|
||||
value: record.productCost,
|
||||
@@ -526,7 +526,7 @@ const specColumns = [
|
||||
customRender: ({
|
||||
record,
|
||||
}: {
|
||||
record: SpecFormRow;
|
||||
record: SkuFormRow;
|
||||
}) => {
|
||||
return h(InputNumber, {
|
||||
value: record.shippingCost ?? 0,
|
||||
@@ -548,7 +548,7 @@ const specColumns = [
|
||||
customRender: ({
|
||||
record,
|
||||
}: {
|
||||
record: SpecFormRow;
|
||||
record: SkuFormRow;
|
||||
}) => {
|
||||
return h(InputNumber, {
|
||||
value: record.otherCost ?? 0,
|
||||
@@ -570,7 +570,7 @@ const specColumns = [
|
||||
customRender: ({
|
||||
record,
|
||||
}: {
|
||||
record: SpecFormRow;
|
||||
record: SkuFormRow;
|
||||
}) => {
|
||||
return h(Input, {
|
||||
value: record.remark ?? '',
|
||||
@@ -593,7 +593,7 @@ const specColumns = [
|
||||
type: 'text',
|
||||
danger: true,
|
||||
size: 'small',
|
||||
onClick: () => removeSpec(index),
|
||||
onClick: () => removeSku(index),
|
||||
},
|
||||
{
|
||||
default: () => '删除',
|
||||
@@ -767,42 +767,42 @@ onUnmounted(() => {
|
||||
</Form.Item>
|
||||
|
||||
<!-- 规格管理 -->
|
||||
<Form.Item label="商品规格">
|
||||
<Form.Item label="商品 SKU">
|
||||
<div class="space-y-4">
|
||||
<div class="flex items-center justify-between">
|
||||
<Space>
|
||||
<Button type="dashed" @click="showSpecs = !showSpecs">
|
||||
<Button type="dashed" @click="showSkus = !showSkus">
|
||||
<template #icon>
|
||||
<component
|
||||
:is="showSpecs ? UpIcon : DownIcon"
|
||||
:is="showSkus ? UpIcon : DownIcon"
|
||||
class="h-4 w-4"
|
||||
/>
|
||||
</template>
|
||||
{{ showSpecs ? '收起规格' : '添加规格' }}
|
||||
{{ showSkus ? '收起 SKU' : '添加 SKU' }}
|
||||
</Button>
|
||||
</Space>
|
||||
<Button v-if="showSpecs" type="primary" @click="addSpec">
|
||||
<Button v-if="showSkus" type="primary" @click="addSku">
|
||||
<template #icon>
|
||||
<PlusIcon class="h-4 w-4" />
|
||||
</template>
|
||||
添加规格
|
||||
添加 SKU
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="showSpecs"
|
||||
v-if="showSkus"
|
||||
class="rounded-lg border border-gray-200 bg-white p-4"
|
||||
>
|
||||
<Table
|
||||
:columns="specColumns"
|
||||
:data-source="specs"
|
||||
:columns="skuColumns"
|
||||
:data-source="skus"
|
||||
:pagination="false"
|
||||
:row-key="(r: SpecFormRow) => (r.id != null ? String(r.id) : r._clientKey ?? '')"
|
||||
:row-key="(r: SkuFormRow) => (r.id != null ? String(r.id) : r._clientKey ?? '')"
|
||||
size="small"
|
||||
>
|
||||
<template #emptyText>
|
||||
<div class="py-4 text-center text-gray-400">
|
||||
暂无规格,点击上方"添加规格"按钮添加
|
||||
暂无 SKU,点击上方"添加 SKU"按钮添加
|
||||
</div>
|
||||
</template>
|
||||
</Table>
|
||||
|
||||
-413
@@ -1,413 +0,0 @@
|
||||
<script lang="ts" setup>
|
||||
import type {
|
||||
ProductSpecDTO,
|
||||
ProductSpecVO,
|
||||
} from '#/api/ecommerce/product-spec/types';
|
||||
import type { ProductVO } from '#/api/ecommerce/product/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { h, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import {
|
||||
Button,
|
||||
Form,
|
||||
Input,
|
||||
InputNumber,
|
||||
message,
|
||||
Popconfirm,
|
||||
Table,
|
||||
} from 'ant-design-vue';
|
||||
|
||||
import {
|
||||
createProductSpecApi,
|
||||
deleteProductSpecApi,
|
||||
getProductSpecPageApi,
|
||||
updateProductSpecApi,
|
||||
} from '#/api/ecommerce/product-spec';
|
||||
|
||||
interface Emits {
|
||||
(e: 'success'): void;
|
||||
}
|
||||
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
// 内部状态管理
|
||||
const currentProduct = ref<null | ProductVO.Info>(null);
|
||||
|
||||
// 响应式数据
|
||||
const specLoading = ref(false);
|
||||
const specList = ref<ProductSpecVO.Info[]>([]);
|
||||
const specTotal = ref(0);
|
||||
const specCurrent = ref(1);
|
||||
const specPageSize = ref(10);
|
||||
|
||||
// 规格表单相关
|
||||
const specFormRef = ref();
|
||||
const isEditSpec = ref(false);
|
||||
const currentSpecId = ref<null | number>(null);
|
||||
|
||||
const specFormData = ref({
|
||||
name: '',
|
||||
specCode: '',
|
||||
productCost: 0,
|
||||
shippingCost: 0,
|
||||
otherCost: 0,
|
||||
remark: '',
|
||||
});
|
||||
|
||||
// 声明模态框 API(稍后赋值)
|
||||
let modalApi: ReturnType<typeof useVbenModal>[1];
|
||||
let specFormModalApi: ReturnType<typeof useVbenModal>[1];
|
||||
|
||||
// 处理取消
|
||||
function handleCancel() {
|
||||
modalApi?.close();
|
||||
}
|
||||
|
||||
// 处理规格表单取消
|
||||
function handleSpecCancel() {
|
||||
specFormModalApi?.close();
|
||||
}
|
||||
|
||||
// 处理规格表单提交
|
||||
async function handleSpecSubmit() {
|
||||
try {
|
||||
await specFormRef.value?.validate();
|
||||
specFormModalApi?.setState({ confirmLoading: true });
|
||||
|
||||
if (isEditSpec.value && currentSpecId.value) {
|
||||
const updateData: ProductSpecDTO.Update = {
|
||||
id: currentSpecId.value,
|
||||
...specFormData.value,
|
||||
};
|
||||
await updateProductSpecApi(currentSpecId.value, updateData);
|
||||
message.success('更新成功');
|
||||
} else {
|
||||
if (!currentProduct.value) {
|
||||
message.error('商品信息不存在');
|
||||
return;
|
||||
}
|
||||
|
||||
const createData: ProductSpecDTO.Create = {
|
||||
productId: currentProduct.value.id,
|
||||
...specFormData.value,
|
||||
};
|
||||
await createProductSpecApi(createData);
|
||||
message.success('创建成功');
|
||||
}
|
||||
|
||||
specFormModalApi?.close();
|
||||
await fetchSpecList();
|
||||
} catch (error) {
|
||||
console.error('保存规格失败:', error);
|
||||
message.error('保存规格失败');
|
||||
} finally {
|
||||
specFormModalApi?.setState({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
|
||||
// 创建主模态框
|
||||
const [Modal, _modalApi] = useVbenModal({
|
||||
title: '管理规格',
|
||||
draggable: true,
|
||||
class: 'w-[800px]',
|
||||
contentClass: 'px-6 py-4',
|
||||
showConfirmButton: false,
|
||||
showCancelButton: false,
|
||||
onCancel: handleCancel,
|
||||
onOpenChange: (isOpen: boolean) => {
|
||||
if (!isOpen) {
|
||||
emit('success');
|
||||
}
|
||||
},
|
||||
});
|
||||
modalApi = _modalApi;
|
||||
|
||||
// 创建规格表单模态框
|
||||
const [SpecFormModal, _specFormModalApi] = useVbenModal({
|
||||
title: '添加规格',
|
||||
draggable: true,
|
||||
contentClass: 'px-6 py-4',
|
||||
onConfirm: handleSpecSubmit,
|
||||
onCancel: handleSpecCancel,
|
||||
});
|
||||
specFormModalApi = _specFormModalApi;
|
||||
|
||||
// 模态框标题(通过 modalApi 动态更新)
|
||||
// 规格表单标题(通过 specFormModalApi 动态更新)
|
||||
|
||||
// 表格列配置
|
||||
const columns = [
|
||||
{
|
||||
title: '规格名称',
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
width: 200,
|
||||
},
|
||||
{
|
||||
title: '规格编码',
|
||||
dataIndex: 'specCode',
|
||||
key: 'specCode',
|
||||
width: 150,
|
||||
},
|
||||
{
|
||||
title: '商品成本',
|
||||
dataIndex: 'productCost',
|
||||
key: 'productCost',
|
||||
width: 120,
|
||||
customRender: ({ record }: { record: ProductSpecVO.Info }) => {
|
||||
return `¥${record.productCost.toFixed(2)}`;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
width: 180,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 150,
|
||||
fixed: 'right' as const,
|
||||
customRender: ({ record }: { record: ProductSpecVO.Info }) => {
|
||||
return h('div', { style: 'display: flex; gap: 8px;' }, [
|
||||
h(
|
||||
Button,
|
||||
{
|
||||
size: 'small',
|
||||
onClick: () => handleEditSpec(record),
|
||||
},
|
||||
{ default: () => '编辑' },
|
||||
),
|
||||
h(
|
||||
Popconfirm,
|
||||
{
|
||||
title: '确定要删除这个规格吗?',
|
||||
onConfirm: () => handleDeleteSpec(record),
|
||||
},
|
||||
{
|
||||
default: () =>
|
||||
h(
|
||||
Button,
|
||||
{ size: 'small', danger: true },
|
||||
{ default: () => '删除' },
|
||||
),
|
||||
},
|
||||
),
|
||||
]);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
// 获取规格列表
|
||||
async function fetchSpecList() {
|
||||
if (!currentProduct.value) return;
|
||||
|
||||
try {
|
||||
specLoading.value = true;
|
||||
const params: PageQueryDTO<ProductSpecDTO.Filters> = {
|
||||
page: specCurrent.value,
|
||||
pageSize: specPageSize.value,
|
||||
filters: {
|
||||
productId: currentProduct.value.id,
|
||||
},
|
||||
};
|
||||
const data = await getProductSpecPageApi(params);
|
||||
specList.value = data.records;
|
||||
specTotal.value = data.total;
|
||||
} catch (error) {
|
||||
console.error('获取规格列表失败:', error);
|
||||
message.error('获取规格列表失败');
|
||||
} finally {
|
||||
specLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 处理规格表格变化
|
||||
function handleSpecTableChange(pagination: any) {
|
||||
specCurrent.value = pagination.current;
|
||||
specPageSize.value = pagination.pageSize;
|
||||
fetchSpecList();
|
||||
}
|
||||
|
||||
// 处理添加规格
|
||||
function handleAddSpec() {
|
||||
isEditSpec.value = false;
|
||||
currentSpecId.value = null;
|
||||
specFormData.value = {
|
||||
name: '',
|
||||
specCode: '',
|
||||
productCost: 0,
|
||||
shippingCost: 0,
|
||||
otherCost: 0,
|
||||
remark: '',
|
||||
};
|
||||
specFormModalApi.setState({ title: '添加规格' });
|
||||
specFormModalApi.open();
|
||||
}
|
||||
|
||||
// 处理编辑规格
|
||||
function handleEditSpec(record: ProductSpecVO.Info) {
|
||||
isEditSpec.value = true;
|
||||
currentSpecId.value = record.id;
|
||||
specFormData.value = {
|
||||
name: record.name,
|
||||
specCode: record.specCode || '',
|
||||
productCost: record.productCost,
|
||||
shippingCost: record.shippingCost || 0,
|
||||
otherCost: record.otherCost || 0,
|
||||
remark: record.remark || '',
|
||||
};
|
||||
specFormModalApi.setState({ title: '编辑规格' });
|
||||
specFormModalApi.open();
|
||||
}
|
||||
|
||||
// 处理删除规格
|
||||
async function handleDeleteSpec(record: ProductSpecVO.Info) {
|
||||
try {
|
||||
await deleteProductSpecApi(record.id);
|
||||
message.success('删除成功');
|
||||
await fetchSpecList();
|
||||
} catch (error) {
|
||||
console.error('删除规格失败:', error);
|
||||
message.error('删除规格失败');
|
||||
}
|
||||
}
|
||||
|
||||
// 暴露给父组件的方法
|
||||
function open(product: ProductVO.Info) {
|
||||
currentProduct.value = product;
|
||||
specCurrent.value = 1;
|
||||
specPageSize.value = 10;
|
||||
modalApi.setState({
|
||||
title: `管理规格 - ${product.name}`,
|
||||
});
|
||||
modalApi.open();
|
||||
fetchSpecList();
|
||||
}
|
||||
|
||||
// 暴露方法给父组件
|
||||
defineExpose({
|
||||
open,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal>
|
||||
<div class="space-y-4">
|
||||
<!-- 商品信息 -->
|
||||
<div class="rounded-lg bg-gray-50 p-4">
|
||||
<h3 class="mb-2 font-medium text-gray-900">商品信息</h3>
|
||||
<div class="grid grid-cols-2 gap-4 text-sm">
|
||||
<div>
|
||||
<span class="text-gray-500">商品名称:</span>
|
||||
<span class="ml-2 font-medium">{{ currentProduct?.name }}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span class="text-gray-500">商品ID:</span>
|
||||
<span class="ml-2 font-medium">{{ currentProduct?.id }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 规格列表 -->
|
||||
<div>
|
||||
<div class="mb-4 flex items-center justify-between">
|
||||
<h3 class="font-medium text-gray-900">商品规格</h3>
|
||||
<Button type="primary" @click="handleAddSpec"> 添加规格 </Button>
|
||||
</div>
|
||||
|
||||
<Table
|
||||
:columns="columns"
|
||||
:data-source="specList"
|
||||
:loading="specLoading"
|
||||
:pagination="{
|
||||
current: specCurrent,
|
||||
pageSize: specPageSize,
|
||||
total: specTotal,
|
||||
showSizeChanger: true,
|
||||
showQuickJumper: true,
|
||||
showTotal: (total, range) =>
|
||||
`第 ${range[0]}-${range[1]} 条/共 ${total} 条`,
|
||||
}"
|
||||
row-key="id"
|
||||
@change="handleSpecTableChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
|
||||
<!-- 规格表单模态框 -->
|
||||
<SpecFormModal>
|
||||
<Form
|
||||
ref="specFormRef"
|
||||
:model="specFormData"
|
||||
:label-col="{ span: 6 }"
|
||||
:wrapper-col="{ span: 18 }"
|
||||
>
|
||||
<Form.Item
|
||||
label="规格名称"
|
||||
name="name"
|
||||
:rules="[{ required: true, message: '请输入规格名称' }]"
|
||||
>
|
||||
<Input v-model:value="specFormData.name" placeholder="请输入规格名称" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label="规格编码"
|
||||
name="specCode"
|
||||
:rules="[{ required: true, message: '请输入规格编码' }]"
|
||||
>
|
||||
<Input
|
||||
v-model:value="specFormData.specCode"
|
||||
placeholder="请输入规格编码"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label="商品成本"
|
||||
name="productCost"
|
||||
:rules="[{ required: true, message: '请输入商品成本' }]"
|
||||
>
|
||||
<InputNumber
|
||||
v-model:value="specFormData.productCost"
|
||||
placeholder="请输入商品成本"
|
||||
style="width: 100%"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="运费成本" name="shippingCost">
|
||||
<InputNumber
|
||||
v-model:value="specFormData.shippingCost"
|
||||
placeholder="请输入运费成本"
|
||||
style="width: 100%"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="其他成本" name="otherCost">
|
||||
<InputNumber
|
||||
v-model:value="specFormData.otherCost"
|
||||
placeholder="请输入其他成本"
|
||||
style="width: 100%"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="备注" name="remark">
|
||||
<Input.TextArea
|
||||
v-model:value="specFormData.remark"
|
||||
placeholder="请输入备注"
|
||||
:rows="3"
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</SpecFormModal>
|
||||
</template>
|
||||
@@ -34,30 +34,30 @@ const productDetailModalRef = ref<InstanceType<typeof ProductDetailModal> | null
|
||||
null,
|
||||
);
|
||||
|
||||
/** 列表行内最多展示的规格编码标签数 */
|
||||
const MAX_SPEC_CODE_TAGS = 4;
|
||||
/** 列表行内最多展示的 SKU 编码标签数 */
|
||||
const MAX_SKU_CODE_TAGS = 4;
|
||||
|
||||
// 搜索条件
|
||||
const searchForm = ref({
|
||||
name: '',
|
||||
productCode: '',
|
||||
specCode: '',
|
||||
specName: '',
|
||||
skuCode: '',
|
||||
skuName: '',
|
||||
});
|
||||
|
||||
/** 提取规格编码列表 */
|
||||
function getSpecCodes(row: ProductVO.Info): string[] {
|
||||
return (row.specs || [])
|
||||
.map((spec) => spec.specCode?.trim())
|
||||
/** 提取 SKU 编码列表 */
|
||||
function getSkuCodes(row: ProductVO.Info): string[] {
|
||||
return (row.skus || [])
|
||||
.map((sku) => sku.skuCode?.trim())
|
||||
.filter((code): code is string => !!code);
|
||||
}
|
||||
|
||||
/** 列表规格编码预览 */
|
||||
function getSpecCodePreview(row: ProductVO.Info) {
|
||||
const codes = getSpecCodes(row);
|
||||
/** 列表 SKU 编码预览 */
|
||||
function getSkuCodePreview(row: ProductVO.Info) {
|
||||
const codes = getSkuCodes(row);
|
||||
return {
|
||||
visible: codes.slice(0, MAX_SPEC_CODE_TAGS),
|
||||
rest: Math.max(codes.length - MAX_SPEC_CODE_TAGS, 0),
|
||||
visible: codes.slice(0, MAX_SKU_CODE_TAGS),
|
||||
rest: Math.max(codes.length - MAX_SKU_CODE_TAGS, 0),
|
||||
empty: codes.length === 0,
|
||||
};
|
||||
}
|
||||
@@ -89,15 +89,15 @@ const gridOptions: VxeGridProps<ProductVO.Info> = {
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
{
|
||||
title: '规格编码',
|
||||
title: 'SKU 编码',
|
||||
minWidth: 200,
|
||||
showOverflow: false,
|
||||
slots: { default: 'specCodes' },
|
||||
slots: { default: 'skuCodes' },
|
||||
},
|
||||
{
|
||||
title: '规格数',
|
||||
title: 'SKU 数',
|
||||
minWidth: 80,
|
||||
slots: { default: 'specCount' },
|
||||
slots: { default: 'skuCount' },
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
@@ -166,11 +166,11 @@ const gridOptions: VxeGridProps<ProductVO.Info> = {
|
||||
String(
|
||||
searchParams.productCode ?? searchForm.value.productCode ?? '',
|
||||
).trim() || undefined,
|
||||
specCode:
|
||||
String(searchParams.specCode ?? searchForm.value.specCode ?? '').trim() ||
|
||||
skuCode:
|
||||
String(searchParams.skuCode ?? searchForm.value.skuCode ?? '').trim() ||
|
||||
undefined,
|
||||
specName:
|
||||
String(searchParams.specName ?? searchForm.value.specName ?? '').trim() ||
|
||||
skuName:
|
||||
String(searchParams.skuName ?? searchForm.value.skuName ?? '').trim() ||
|
||||
undefined,
|
||||
};
|
||||
const params: PageQueryDTO<ProductDTO.Filters> = {
|
||||
@@ -231,28 +231,28 @@ const formOptions = computed(() => ({
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入规格名称(回车搜索)',
|
||||
placeholder: '请输入 SKU 名称(回车搜索)',
|
||||
allowClear: true,
|
||||
onChange: (e: Event) => {
|
||||
searchForm.value.specName = (e.target as HTMLInputElement).value;
|
||||
searchForm.value.skuName = (e.target as HTMLInputElement).value;
|
||||
},
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'specName',
|
||||
label: '规格名称',
|
||||
fieldName: 'skuName',
|
||||
label: 'SKU 名称',
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入规格编码(回车搜索)',
|
||||
placeholder: '请输入 SKU 编码(回车搜索)',
|
||||
allowClear: true,
|
||||
onChange: (e: Event) => {
|
||||
searchForm.value.specCode = (e.target as HTMLInputElement).value;
|
||||
searchForm.value.skuCode = (e.target as HTMLInputElement).value;
|
||||
},
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'specCode',
|
||||
label: '规格编码',
|
||||
fieldName: 'skuCode',
|
||||
label: 'SKU 编码',
|
||||
},
|
||||
],
|
||||
showDefaultActions: true,
|
||||
@@ -357,30 +357,30 @@ function handleDetailEdit(record: ProductVO.Info) {
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 规格编码预览,点击同样打开详情 -->
|
||||
<template #specCodes="{ row }: { row: ProductVO.Info }">
|
||||
<!-- SKU 编码预览,点击同样打开详情 -->
|
||||
<template #skuCodes="{ row }: { row: ProductVO.Info }">
|
||||
<div
|
||||
class="spec-codes-cell flex cursor-pointer flex-wrap items-center gap-1"
|
||||
class="sku-codes-cell flex cursor-pointer flex-wrap items-center gap-1"
|
||||
@click="openProductDetail(row)"
|
||||
>
|
||||
<template v-if="!getSpecCodePreview(row).empty">
|
||||
<template v-if="!getSkuCodePreview(row).empty">
|
||||
<Tag
|
||||
v-for="code in getSpecCodePreview(row).visible"
|
||||
v-for="code in getSkuCodePreview(row).visible"
|
||||
:key="code"
|
||||
class="m-0"
|
||||
>
|
||||
{{ code }}
|
||||
</Tag>
|
||||
<Tag v-if="getSpecCodePreview(row).rest > 0" class="m-0">
|
||||
+{{ getSpecCodePreview(row).rest }}
|
||||
<Tag v-if="getSkuCodePreview(row).rest > 0" class="m-0">
|
||||
+{{ getSkuCodePreview(row).rest }}
|
||||
</Tag>
|
||||
</template>
|
||||
<span v-else class="text-slate-400">-</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #specCount="{ row }: { row: ProductVO.Info }">
|
||||
{{ row.specs?.length ?? 0 }}
|
||||
<template #skuCount="{ row }: { row: ProductVO.Info }">
|
||||
{{ row.skus?.length ?? 0 }}
|
||||
</template>
|
||||
|
||||
<template #action="{ row }: { row: ProductVO.Info }">
|
||||
@@ -423,7 +423,7 @@ function handleDetailEdit(record: ProductVO.Info) {
|
||||
}
|
||||
|
||||
.product-info-cell,
|
||||
.spec-codes-cell {
|
||||
.sku-codes-cell {
|
||||
min-height: 64px;
|
||||
}
|
||||
</style>
|
||||
|
||||
+12
-12
@@ -1,14 +1,14 @@
|
||||
<script lang="ts" setup>
|
||||
interface SpecSalesRankItem {
|
||||
specId?: number;
|
||||
specName?: string;
|
||||
specCode?: string;
|
||||
interface SkuSalesRankItem {
|
||||
skuId?: number;
|
||||
skuName?: string;
|
||||
skuCode?: string;
|
||||
orderCount?: number;
|
||||
salesAmount?: number;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
data: SpecSalesRankItem[] | null;
|
||||
data: SkuSalesRankItem[] | null;
|
||||
}
|
||||
|
||||
defineProps<Props>();
|
||||
@@ -24,7 +24,7 @@ const formatAmount = (amount: number | undefined) => {
|
||||
class="flex flex-col rounded-[20px] border border-slate-200/80 dark:border-[hsl(240deg_3.7%_22%)] bg-white/85 dark:bg-[hsl(222.34deg_10.43%_12.27%)] p-8 shadow-[0_4px_20px_rgba(0,0,0,0.02)] dark:shadow-none backdrop-blur-[12px]"
|
||||
>
|
||||
<h3 class="mb-1 text-lg font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
|
||||
各规格销量 Top10
|
||||
各 SKU 销量 Top10
|
||||
</h3>
|
||||
<p class="mb-5 text-xs font-medium text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
按单量排序,与上方时间范围一致
|
||||
@@ -34,7 +34,7 @@ const formatAmount = (amount: number | undefined) => {
|
||||
<template v-if="data?.length">
|
||||
<div
|
||||
v-for="(row, idx) in data"
|
||||
:key="row.specId ?? `rank-${idx}`"
|
||||
:key="row.skuId ?? `rank-${idx}`"
|
||||
class="flex items-center gap-3 rounded-xl border border-slate-100/90 bg-slate-50/60 px-3 py-2.5 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%/50%)]"
|
||||
>
|
||||
<span
|
||||
@@ -54,15 +54,15 @@ const formatAmount = (amount: number | undefined) => {
|
||||
<div class="min-w-0 flex-1">
|
||||
<div
|
||||
class="truncate text-sm font-bold text-slate-800 dark:text-[hsl(0deg_0%_95%)]"
|
||||
:title="row.specName"
|
||||
:title="row.skuName"
|
||||
>
|
||||
{{ row.specName || '-' }}
|
||||
{{ row.skuName || '-' }}
|
||||
</div>
|
||||
<div
|
||||
v-if="row.specCode"
|
||||
v-if="row.skuCode"
|
||||
class="truncate text-[11px] text-slate-400 dark:text-[hsl(240deg_5%_55%)]"
|
||||
>
|
||||
{{ row.specCode }}
|
||||
{{ row.skuCode }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="shrink-0 text-right">
|
||||
@@ -80,7 +80,7 @@ const formatAmount = (amount: number | undefined) => {
|
||||
v-else
|
||||
class="flex flex-1 items-center justify-center py-16 text-sm text-slate-400 dark:text-[hsl(240deg_5%_55%)]"
|
||||
>
|
||||
暂无规格数据
|
||||
暂无 SKU 数据
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
+20
-20
@@ -10,10 +10,10 @@ import {
|
||||
} from '#/utils/overview-table-hints';
|
||||
import { formatNumberCell } from '#/utils/overview-table-cells';
|
||||
|
||||
interface SpecData {
|
||||
specId: number;
|
||||
specName: string;
|
||||
specCode?: string;
|
||||
interface SkuData {
|
||||
skuId: number;
|
||||
skuName: string;
|
||||
skuCode?: string;
|
||||
salesAmount: number;
|
||||
orderCount: number;
|
||||
quantity: number;
|
||||
@@ -32,9 +32,9 @@ interface SpecData {
|
||||
}
|
||||
|
||||
interface Props {
|
||||
data: SpecData[];
|
||||
data: SkuData[];
|
||||
/** 后端合计行(含 orderCost),优先展示 */
|
||||
footerTotal?: ProductOverviewVO.SpecSummaryTotal | null;
|
||||
footerTotal?: ProductOverviewVO.SkuSummaryTotal | null;
|
||||
taxRate?: number;
|
||||
}
|
||||
|
||||
@@ -68,9 +68,9 @@ const formatCount = (value: number | undefined) => {
|
||||
/** 无后端合计时由行数据汇总(兼容旧数据) */
|
||||
const computedFooter = computed(() => {
|
||||
if (!props.data || props.data.length === 0) return null;
|
||||
const total: SpecData = {
|
||||
specId: 0,
|
||||
specName: '合计',
|
||||
const total: SkuData = {
|
||||
skuId: 0,
|
||||
skuName: '合计',
|
||||
salesAmount: 0,
|
||||
orderCount: 0,
|
||||
quantity: 0,
|
||||
@@ -127,9 +127,9 @@ const footerRow = computed(() => props.footerTotal ?? computedFooter.value);
|
||||
class="flex items-center justify-between border-b border-slate-100 dark:border-[hsl(240deg_3.7%_22%)] bg-white/40 dark:bg-[hsl(222.34deg_10.43%_12.27%)] p-6"
|
||||
>
|
||||
<div>
|
||||
<h3 class="text-lg font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">商品规格销售汇总</h3>
|
||||
<h3 class="text-lg font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">商品 SKU 销售汇总</h3>
|
||||
<p class="mt-1 text-xs font-bold text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
各规格经营明细:规模、成本及最终损益
|
||||
各 SKU 经营明细:规模、成本及最终损益
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -144,7 +144,7 @@ const footerRow = computed(() => props.footerTotal ?? computedFooter.value);
|
||||
rowspan="2"
|
||||
class="sticky-col border-r-2 border-slate-100 dark:border-[hsl(240deg_3.7%_22%)] bg-white dark:bg-[hsl(222.34deg_10.43%_12.27%)] p-5 text-base font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)] shadow-sm dark:shadow-none"
|
||||
>
|
||||
规格名称
|
||||
SKU 名称
|
||||
</th>
|
||||
<th
|
||||
colspan="3"
|
||||
@@ -173,7 +173,7 @@ const footerRow = computed(() => props.footerTotal ?? computedFooter.value);
|
||||
</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b px-5 py-3">
|
||||
<OverviewColumnHint :title="overviewTableHints.orderCountSpec">
|
||||
<OverviewColumnHint :title="overviewTableHints.orderCountSku">
|
||||
订单量
|
||||
</OverviewColumnHint>
|
||||
</th>
|
||||
@@ -197,14 +197,14 @@ const footerRow = computed(() => props.footerTotal ?? computedFooter.value);
|
||||
<OverviewColumnHint :title="overviewTableHints.refundAmount">退款金额</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b px-5 py-3">
|
||||
<OverviewColumnHint :title="overviewTableHints.promotionFeeSpec">推广费</OverviewColumnHint>
|
||||
<OverviewColumnHint :title="overviewTableHints.promotionFeeSku">推广费</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b px-5 py-3 text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
<OverviewColumnHint :title="overviewTableHints.feeRatioSpec">费比 %</OverviewColumnHint>
|
||||
<OverviewColumnHint :title="overviewTableHints.feeRatioSku">费比 %</OverviewColumnHint>
|
||||
</th>
|
||||
<!-- 盈利 -->
|
||||
<th class="border-b border-l px-5 py-3 font-bold">
|
||||
<OverviewColumnHint :title="overviewTableHints.profitBeforeTaxSpec">税前盈亏</OverviewColumnHint>
|
||||
<OverviewColumnHint :title="overviewTableHints.profitBeforeTaxSku">税前盈亏</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b px-5 py-3 italic text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
<OverviewColumnHint :title="salesTaxColumnHint(taxRate)">
|
||||
@@ -224,12 +224,12 @@ const footerRow = computed(() => props.footerTotal ?? computedFooter.value);
|
||||
<tbody class="divide-y divide-slate-100 dark:divide-[hsl(240deg_3.7%_22%)]">
|
||||
<tr
|
||||
v-for="item in data"
|
||||
:key="item.specId"
|
||||
:key="item.skuId"
|
||||
class="transition-colors hover:bg-slate-50/50 dark:hover:bg-[hsl(240deg_3.7%_15.9%/30%)]"
|
||||
>
|
||||
<!-- 规格名称 -->
|
||||
<!-- SKU 名称 -->
|
||||
<td class="sticky-col border-r-2 border-slate-100 dark:border-[hsl(240deg_3.7%_22%)] bg-white dark:bg-[hsl(222.34deg_10.43%_12.27%)] p-5 shadow-sm dark:shadow-none">
|
||||
<span class="inline-block rounded-full bg-blue-50 dark:bg-blue-900/30 px-3 py-1 text-sm font-bold text-blue-600 dark:text-blue-400">{{ item.specName }}</span>
|
||||
<span class="inline-block rounded-full bg-blue-50 dark:bg-blue-900/30 px-3 py-1 text-sm font-bold text-blue-600 dark:text-blue-400">{{ item.skuName }}</span>
|
||||
</td>
|
||||
<!-- 规模 -->
|
||||
<td class="p-5 font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">{{ formatAmount(item.salesAmount) }}</td>
|
||||
@@ -262,7 +262,7 @@ const footerRow = computed(() => props.footerTotal ?? computedFooter.value);
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="!data || data.length === 0">
|
||||
<td colspan="16" class="p-8 text-center text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">暂无规格数据</td>
|
||||
<td colspan="16" class="p-8 text-center text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">暂无 SKU 数据</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tfoot v-if="footerRow" class="bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)]">
|
||||
@@ -12,8 +12,8 @@ import dayjs from 'dayjs';
|
||||
import TimeRangeBar from './components/TimeRangeBar.vue';
|
||||
import StatCards from './components/StatCards.vue';
|
||||
import SalesTrendChart from './components/SalesTrendChart.vue';
|
||||
import SpecSalesTop10Panel from './components/SpecSalesTop10Panel.vue';
|
||||
import SpecSummaryTable from './components/SpecSummaryTable.vue';
|
||||
import SkuSalesTop10Panel from './components/SkuSalesTop10Panel.vue';
|
||||
import SkuSummaryTable from './components/SkuSummaryTable.vue';
|
||||
import { getProductPageApi } from '#/api/ecommerce/product/apis';
|
||||
import type { ProductVO } from '#/api/ecommerce/product/types';
|
||||
import { getProductOverviewApi } from '#/api/ecommerce/product-overview';
|
||||
@@ -478,11 +478,11 @@ onUnmounted(() => {
|
||||
<!-- 第二层:趋势与财务拆解 -->
|
||||
<div class="grid grid-cols-1 gap-6 xl:grid-cols-3">
|
||||
<SalesTrendChart :data="overviewData" />
|
||||
<SpecSalesTop10Panel :data="overviewData?.specSalesTop10 ?? []" />
|
||||
<SkuSalesTop10Panel :data="overviewData?.specSalesTop10 ?? []" />
|
||||
</div>
|
||||
|
||||
<!-- 第三层:规格销售汇总 -->
|
||||
<SpecSummaryTable
|
||||
<!-- 第三层:SKU 销售汇总 -->
|
||||
<SkuSummaryTable
|
||||
:data="overviewData?.specSummaries?.list ?? []"
|
||||
:footer-total="overviewData?.specSummaries?.total"
|
||||
:tax-rate="taxRate"
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ const gridOptions: VxeGridProps<any> = {
|
||||
columns: [
|
||||
{ type: 'seq', title: '序号', width: 60 },
|
||||
{ field: 'productName', title: '商品名称', minWidth: 160 },
|
||||
{ field: 'productSpecName', title: '规格名称', minWidth: 160 },
|
||||
{ field: 'productSkuName', title: 'SKU 名称', minWidth: 160 },
|
||||
{
|
||||
field: 'brushAmount', title: '刷单金额', width: 120,
|
||||
formatter: ({ cellValue }) => `¥${Number(cellValue || 0).toLocaleString()}`,
|
||||
|
||||
+34
-12
@@ -10,6 +10,13 @@ import { computed, ref } from 'vue';
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getOrderPageApi } from '#/api/ecommerce/order';
|
||||
import {
|
||||
getOrderLinkProductName,
|
||||
getOrderLinkSkuName,
|
||||
getOrderPayAmount,
|
||||
getOrderQuantity,
|
||||
getOrderUnitPrice,
|
||||
} from '#/utils/order-display';
|
||||
|
||||
import OrderFormModal from '#/views/ecommerce/order/components/OrderFormModal.vue';
|
||||
|
||||
@@ -32,25 +39,36 @@ const searchForm = ref({
|
||||
|
||||
const orderModalRef = ref<InstanceType<typeof OrderFormModal> | null>(null);
|
||||
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
const gridOptions: VxeGridProps<OrderVO.Info> = {
|
||||
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)),
|
||||
title: '商品名称',
|
||||
minWidth: 140,
|
||||
formatter: ({ row }) => getOrderLinkProductName(row),
|
||||
},
|
||||
{
|
||||
field: 'unitPrice', title: '单价', width: 100,
|
||||
formatter: ({ cellValue }) => `¥${Number(cellValue || 0).toFixed(2)}`,
|
||||
title: 'SKU',
|
||||
minWidth: 140,
|
||||
formatter: ({ row }) => getOrderLinkSkuName(row) || '-',
|
||||
},
|
||||
{
|
||||
field: 'receivedAmount', title: '实收金额', width: 110,
|
||||
formatter: ({ cellValue }) => `¥${Number(cellValue || 0).toFixed(2)}`,
|
||||
title: '数量',
|
||||
width: 70,
|
||||
formatter: ({ row }) => String(getOrderQuantity(row)),
|
||||
},
|
||||
{ field: 'statusName', title: '状态', width: 100 },
|
||||
{
|
||||
title: '单价',
|
||||
width: 100,
|
||||
formatter: ({ row }) => `¥${getOrderUnitPrice(row).toFixed(2)}`,
|
||||
},
|
||||
{
|
||||
title: '实付金额',
|
||||
width: 110,
|
||||
formatter: ({ row }) => `¥${getOrderPayAmount(row).toFixed(2)}`,
|
||||
},
|
||||
{ field: 'statusLabel', title: '状态', width: 100, slots: { default: 'statusLabel' } },
|
||||
{ field: 'orderTime', title: '下单时间', minWidth: 160 },
|
||||
{
|
||||
title: '操作',
|
||||
@@ -105,6 +123,10 @@ const statusColorMap: Record<string, string> = {
|
||||
'已退款': 'red',
|
||||
'已取消': 'default',
|
||||
};
|
||||
|
||||
function resolveStatusColor(row: OrderVO.Info) {
|
||||
return row.statusColor || statusColorMap[row.statusLabel] || 'default';
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -148,8 +170,8 @@ const statusColorMap: Record<string, string> = {
|
||||
|
||||
<div class="p-4">
|
||||
<Grid>
|
||||
<template #statusName="{ row }: { row: OrderVO.Info }">
|
||||
<Tag :color="statusColorMap[row.statusName] || 'default'">{{ row.statusName }}</Tag>
|
||||
<template #statusLabel="{ row }: { row: OrderVO.Info }">
|
||||
<Tag :color="resolveStatusColor(row)">{{ row.statusLabel }}</Tag>
|
||||
</template>
|
||||
<template #action="{ row }: { row: OrderVO.Info }">
|
||||
<Space>
|
||||
|
||||
+12
-12
@@ -9,7 +9,7 @@ import { createIconifyIcon } from '@vben/icons';
|
||||
import { Button, Form, Input, message, Select } from 'ant-design-vue';
|
||||
|
||||
import { createShopApi, updateShopApi } from '#/api/ecommerce/shop';
|
||||
import { getActivePlatformsApi } from '#/api/ecommerce/platform';
|
||||
import { getPlatformListApi } from '#/api/ecommerce/platform';
|
||||
import { uploadFileToOss } from '#/utils/oss-upload';
|
||||
|
||||
interface Emits {
|
||||
@@ -47,21 +47,21 @@ const imageLoadError = ref(false); // 图片加载错误状态
|
||||
// 表单数据
|
||||
const formData = ref({
|
||||
name: '',
|
||||
platformId: undefined as number | undefined,
|
||||
platformCode: undefined as string | undefined,
|
||||
logoImageId: undefined as number | undefined,
|
||||
});
|
||||
|
||||
// 平台选项(动态加载)
|
||||
const platformOptions = ref<{ label: string; value: number }[]>([]);
|
||||
// 平台选项(静态字典)
|
||||
const platformOptions = ref<{ label: string; value: string }[]>([]);
|
||||
|
||||
|
||||
// 加载平台列表
|
||||
async function fetchPlatformOptions() {
|
||||
try {
|
||||
const data = await getActivePlatformsApi();
|
||||
platformOptions.value = data.map((p: any) => ({
|
||||
label: p.platformName,
|
||||
value: p.id,
|
||||
const data = await getPlatformListApi();
|
||||
platformOptions.value = data.map((p) => ({
|
||||
label: p.label,
|
||||
value: p.code,
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error('获取平台列表失败:', error);
|
||||
@@ -85,7 +85,7 @@ function initFormData() {
|
||||
// 编辑模式
|
||||
formData.value = {
|
||||
name: currentShopData.value.name || '',
|
||||
platformId: currentShopData.value.platformId,
|
||||
platformCode: currentShopData.value.platformCode,
|
||||
logoImageId: undefined,
|
||||
};
|
||||
|
||||
@@ -95,7 +95,7 @@ function initFormData() {
|
||||
// 创建模式 - 如果有传入的shopData,则使用它来初始化表单
|
||||
formData.value = {
|
||||
name: currentShopData.value?.name || '',
|
||||
platformId: currentShopData.value?.platformId,
|
||||
platformCode: currentShopData.value?.platformCode,
|
||||
logoImageId: undefined,
|
||||
};
|
||||
originalLogoUrl.value = currentShopData.value?.logo || '';
|
||||
@@ -378,9 +378,9 @@ onUnmounted(() => {
|
||||
<Input v-model:value="formData.name" placeholder="请输入店铺名称" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="平台" name="platformId">
|
||||
<Form.Item label="平台" name="platformCode">
|
||||
<Select
|
||||
v-model:value="formData.platformId"
|
||||
v-model:value="formData.platformCode"
|
||||
placeholder="请选择平台"
|
||||
:options="platformOptions"
|
||||
allow-clear
|
||||
|
||||
@@ -14,7 +14,7 @@ import { Button, message, Popconfirm, Space, Tag } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getPddAuthorizeUrlApi } from '#/api/ecommerce/pdd/auth';
|
||||
import { getActivePlatformsApi } from '#/api/ecommerce/platform';
|
||||
import { getPlatformListApi } from '#/api/ecommerce/platform';
|
||||
import { deleteShopApi, getShopPageApi } from '#/api/ecommerce/shop';
|
||||
|
||||
import PddOrderSyncModal from './components/PddOrderSyncModal.vue';
|
||||
@@ -37,11 +37,10 @@ const pddOrderSyncModalRef = ref();
|
||||
|
||||
const searchForm = ref({
|
||||
name: '',
|
||||
platformId: undefined as number | undefined,
|
||||
platformCode: undefined as string | undefined,
|
||||
});
|
||||
|
||||
const platformOptions = ref<{ label: string; value: number }[]>([]);
|
||||
const platformCodeById = ref<Record<number, string>>({});
|
||||
const platformOptions = ref<{ label: string; value: string }[]>([]);
|
||||
|
||||
let authPollTimer: null | ReturnType<typeof setInterval> = null;
|
||||
|
||||
@@ -143,7 +142,7 @@ const gridOptions: VxeGridProps<any> = {
|
||||
pageSize: page.pageSize,
|
||||
filters: {
|
||||
name: searchForm.value.name || undefined,
|
||||
platformId: searchForm.value.platformId,
|
||||
platformCode: searchForm.value.platformCode,
|
||||
},
|
||||
};
|
||||
const data = await getShopPageApi(params);
|
||||
@@ -185,11 +184,11 @@ const formOptions = computed(() => ({
|
||||
options: platformOptions.value,
|
||||
allowClear: true,
|
||||
onChange: (val: any) => {
|
||||
searchForm.value.platformId = val;
|
||||
searchForm.value.platformCode = val;
|
||||
gridReloadRef.value?.();
|
||||
},
|
||||
},
|
||||
fieldName: 'platformId',
|
||||
fieldName: 'platformCode',
|
||||
label: '平台',
|
||||
},
|
||||
],
|
||||
@@ -208,20 +207,15 @@ gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
async function fetchPlatformOptions() {
|
||||
try {
|
||||
const data = await getActivePlatformsApi();
|
||||
platformOptions.value = data.map((p: PlatformVO.Info) => ({
|
||||
label: p.platformName,
|
||||
value: p.id,
|
||||
const data = await getPlatformListApi();
|
||||
platformOptions.value = data.map((p: PlatformVO.Meta) => ({
|
||||
label: p.label,
|
||||
value: p.code,
|
||||
}));
|
||||
const codeMap: Record<number, string> = {};
|
||||
data.forEach((p: PlatformVO.Info) => {
|
||||
codeMap[p.id] = p.platformCode;
|
||||
});
|
||||
platformCodeById.value = codeMap;
|
||||
|
||||
await gridApi.formApi?.updateSchema([
|
||||
{
|
||||
fieldName: 'platformId',
|
||||
fieldName: 'platformCode',
|
||||
componentProps: {
|
||||
options: platformOptions.value,
|
||||
},
|
||||
@@ -237,8 +231,7 @@ function refreshTable() {
|
||||
}
|
||||
|
||||
function isPddShop(row: ShopVO.Info) {
|
||||
if (!row.platformId) return false;
|
||||
return platformCodeById.value[row.platformId] === PLATFORM_CODE_PDD;
|
||||
return row.platformCode === PLATFORM_CODE_PDD;
|
||||
}
|
||||
|
||||
function hasExternalShop(row: ShopVO.Info) {
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
} from 'ant-design-vue';
|
||||
|
||||
import { deleteShopApi, getShopPageApi } from '#/api/ecommerce/shop';
|
||||
import { getActivePlatformsApi } from '#/api/ecommerce/platform/apis';
|
||||
import { getPlatformListApi } from '#/api/ecommerce/platform/apis';
|
||||
import type { PlatformVO } from '#/api/ecommerce/platform/types';
|
||||
|
||||
import ShopFormModal from '../list/components/ShopFormModal.vue';
|
||||
@@ -38,7 +38,7 @@ const page = ref(1);
|
||||
const pageSize = ref(20);
|
||||
|
||||
const searchName = ref('');
|
||||
const platformOptions = ref<{ label: string; value: number }[]>([]);
|
||||
const platformOptions = ref<{ label: string; value: string }[]>([]);
|
||||
|
||||
const shopFormModalRef = ref();
|
||||
|
||||
@@ -103,10 +103,10 @@ function handlePageSizeChange(ps: number) {
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const platforms = await getActivePlatformsApi();
|
||||
platformOptions.value = (platforms ?? []).map((p: PlatformVO.Info) => ({
|
||||
label: p.platformName,
|
||||
value: p.id,
|
||||
const platforms = await getPlatformListApi();
|
||||
platformOptions.value = (platforms ?? []).map((p: PlatformVO.Meta) => ({
|
||||
label: p.label,
|
||||
value: p.code,
|
||||
}));
|
||||
} catch {
|
||||
platformOptions.value = [];
|
||||
|
||||
Reference in New Issue
Block a user