优化部分模块

This commit is contained in:
ah--desktop
2025-09-20 01:49:35 +08:00
parent a7bf2c5bba
commit 570e8986cd
55 changed files with 2116 additions and 1701 deletions
@@ -1,143 +0,0 @@
import { requestClient } from '#/api/request';
import type { PageQueryDTO, PageResultVO } from '#/types/common';
import type { OrderDTO, OrderVO, BatchImportResultVO, OrderStatusDTO, OrderStatusVO, PromotionFeeTypeDTO, PromotionFeeTypeVO } from './types';
/**
* 订单管理API
*/
/**
* 分页获取订单列表
*/
export async function getOrderPageApi(params: PageQueryDTO<OrderDTO.OrderFilterDTO>) {
return requestClient.post<PageResultVO<OrderVO.OrderInfoVO>>('/ec/order/page', params);
}
/**
* 创建订单
*/
export async function createOrderApi(data: OrderDTO.CreateOrderDTO) {
return requestClient.post<OrderVO.OrderInfoVO>('/ec/order/create', data);
}
/**
* 更新订单
*/
export async function updateOrderApi(id: number, data: OrderDTO.UpdateOrderDTO) {
return requestClient.put<OrderVO.OrderInfoVO>(`/ec/order/update/${id}`, data);
}
/**
* 删除订单
*/
export async function deleteOrderApi(id: number) {
return requestClient.delete<void>(`/ec/order/delete/${id}`);
}
/**
* 获取订单详情
*/
export async function getOrderByIdApi(id: number) {
return requestClient.get<OrderVO.OrderInfoVO>(`/ec/order/detail/${id}`);
}
/**
* 批量导入订单
*/
export async function batchImportOrdersApi(data: OrderDTO.BatchImportOrderDTO) {
return requestClient.post<BatchImportResultVO.BatchImportResultInfoVO>('/ec/order/batch-import', data);
}
/**
* 订单状态管理API
*/
/**
* 创建订单状态
*/
export async function createOrderStatusApi(data: OrderStatusDTO.CreateOrderStatusDTO) {
return requestClient.post<number>('/ec/order-status', data);
}
/**
* 更新订单状态
*/
export async function updateOrderStatusApi(data: OrderStatusDTO.UpdateOrderStatusDTO) {
return requestClient.put<void>('/ec/order-status', data);
}
/**
* 删除订单状态
*/
export async function deleteOrderStatusApi(id: number) {
return requestClient.delete<void>(`/ec/order-status/${id}`);
}
/**
* 获取订单状态详情
*/
export async function getOrderStatusByIdApi(id: number) {
return requestClient.get<OrderStatusVO.OrderStatusInfoVO>(`/ec/order-status/${id}`);
}
/**
* 获取启用的订单状态列表
*/
export async function getActiveOrderStatusListApi() {
return requestClient.get<OrderStatusVO.OrderStatusInfoVO[]>('/ec/order-status/active');
}
/**
* 获取所有订单状态列表
*/
export async function getAllOrderStatusListApi() {
return requestClient.get<OrderStatusVO.OrderStatusInfoVO[]>('/ec/order-status/all');
}
/**
* 推广费类型管理API
*/
/**
* 创建推广费类型
*/
export async function createPromotionFeeTypeApi(data: PromotionFeeTypeDTO.CreatePromotionFeeTypeDTO) {
return requestClient.post<number>('/ec/promotion-fee-type', data);
}
/**
* 更新推广费类型
*/
export async function updatePromotionFeeTypeApi(data: PromotionFeeTypeDTO.UpdatePromotionFeeTypeDTO) {
return requestClient.put<void>('/ec/promotion-fee-type', data);
}
/**
* 删除推广费类型
*/
export async function deletePromotionFeeTypeApi(id: number) {
return requestClient.delete<void>(`/ec/promotion-fee-type/${id}`);
}
/**
* 获取推广费类型详情
*/
export async function getPromotionFeeTypeByIdApi(id: number) {
return requestClient.get<PromotionFeeTypeVO.PromotionFeeTypeInfoVO>(`/ec/promotion-fee-type/${id}`);
}
/**
* 获取启用的推广费类型列表
*/
export async function getActivePromotionFeeTypeListApi() {
return requestClient.get<PromotionFeeTypeVO.PromotionFeeTypeInfoVO[]>('/ec/promotion-fee-type/active');
}
/**
* 获取所有推广费类型列表
*/
export async function getAllPromotionFeeTypeListApi() {
return requestClient.get<PromotionFeeTypeVO.PromotionFeeTypeInfoVO[]>('/ec/promotion-fee-type/all');
}
@@ -2,5 +2,11 @@
* 电商模块API导出
*/
export * from './apis';
export * from './types';
// 订单相关API
export * from './order.apis';
// 订单状态相关API
export * from './order-status.apis';
// 推广费类型相关API
export * from './promotion-fee-type.apis';
@@ -0,0 +1,49 @@
import { requestClient } from '#/api/request';
import type { OrderStatusDTO, OrderStatusVO } from './types';
/**
* 订单状态管理API
*/
/**
* 创建订单状态
*/
export async function createOrderStatusApi(data: OrderStatusDTO.Create) {
return requestClient.post<number>('/ec/order-status', data);
}
/**
* 更新订单状态
*/
export async function updateOrderStatusApi(data: OrderStatusDTO.Update) {
return requestClient.put<void>('/ec/order-status', data);
}
/**
* 删除订单状态
*/
export async function deleteOrderStatusApi(id: number) {
return requestClient.delete<void>(`/ec/order-status/${id}`);
}
/**
* 获取订单状态详情
*/
export async function getOrderStatusByIdApi(id: number) {
return requestClient.get<OrderStatusVO.Info>(`/ec/order-status/${id}`);
}
/**
* 获取启用的订单状态列表
*/
export async function getActiveOrderStatusListApi() {
return requestClient.get<OrderStatusVO.Info[]>('/ec/order-status/active');
}
/**
* 获取所有订单状态列表
*/
export async function getAllOrderStatusListApi() {
return requestClient.get<OrderStatusVO.Info[]>('/ec/order-status/all');
}
@@ -0,0 +1,50 @@
import { requestClient } from '#/api/request';
import type { PageQueryDTO, PageResultVO } from '#/types/common';
import type { OrderDTO, OrderVO, BatchImportResultVO } from './types';
/**
* 订单管理API
*/
/**
* 分页获取订单列表
*/
export async function getOrderPageApi(params: PageQueryDTO<OrderDTO.Filters>) {
return requestClient.post<PageResultVO<OrderVO.Info>>('/ec/order/page', params);
}
/**
* 创建订单
*/
export async function createOrderApi(data: OrderDTO.Create) {
return requestClient.post<OrderVO.Info>('/ec/order/create', data);
}
/**
* 更新订单
*/
export async function updateOrderApi(id: number, data: OrderDTO.Update) {
return requestClient.put<OrderVO.Info>(`/ec/order/update/${id}`, data);
}
/**
* 删除订单
*/
export async function deleteOrderApi(id: number) {
return requestClient.delete<void>(`/ec/order/delete/${id}`);
}
/**
* 获取订单详情
*/
export async function getOrderByIdApi(id: number) {
return requestClient.get<OrderVO.Info>(`/ec/order/detail/${id}`);
}
/**
* 批量导入订单
*/
export async function batchImportOrdersApi(data: OrderDTO.BatchImport) {
return requestClient.post<BatchImportResultVO.Info>('/ec/order/batch-import', data);
}
@@ -0,0 +1,49 @@
import { requestClient } from '#/api/request';
import type { PromotionFeeTypeDTO, PromotionFeeTypeVO } from './types';
/**
* 推广费类型管理API
*/
/**
* 创建推广费类型
*/
export async function createPromotionFeeTypeApi(data: PromotionFeeTypeDTO.Create) {
return requestClient.post<number>('/ec/promotion-fee-type', data);
}
/**
* 更新推广费类型
*/
export async function updatePromotionFeeTypeApi(data: PromotionFeeTypeDTO.Update) {
return requestClient.put<void>('/ec/promotion-fee-type', data);
}
/**
* 删除推广费类型
*/
export async function deletePromotionFeeTypeApi(id: number) {
return requestClient.delete<void>(`/ec/promotion-fee-type/${id}`);
}
/**
* 获取推广费类型详情
*/
export async function getPromotionFeeTypeByIdApi(id: number) {
return requestClient.get<PromotionFeeTypeVO.Info>(`/ec/promotion-fee-type/${id}`);
}
/**
* 获取启用的推广费类型列表
*/
export async function getActivePromotionFeeTypeListApi() {
return requestClient.get<PromotionFeeTypeVO.Info[]>('/ec/promotion-fee-type/active');
}
/**
* 获取所有推广费类型列表
*/
export async function getAllPromotionFeeTypeListApi() {
return requestClient.get<PromotionFeeTypeVO.Info[]>('/ec/promotion-fee-type/all');
}
@@ -0,0 +1,31 @@
/**
* 订单状态相关DTO类型定义
*/
export namespace OrderStatusDTO {
/** 创建订单状态参数 */
export interface Create {
/** 状态名称 */
statusName: string;
/** 状态描述 */
description?: string;
/** 排序 */
sortOrder?: number;
/** 是否启用 0禁用 1启用 */
isActive?: number;
}
/** 更新订单状态参数 */
export interface Update {
/** 状态ID */
id: number;
/** 状态名称 */
statusName: string;
/** 状态描述 */
description?: string;
/** 排序 */
sortOrder?: number;
/** 是否启用 0禁用 1启用 */
isActive?: number;
}
}
@@ -0,0 +1,89 @@
/**
* 订单相关DTO类型定义
*/
export namespace OrderDTO {
/** 创建订单参数 */
export interface Create {
/** 店铺ID */
shopId: number;
/** 平台订单号 */
platformOrderNo?: string;
/** 订单状态ID */
statusId: number;
/** 商家实收金额 */
receivedAmount: number;
/** 运费 */
shippingFee?: number;
/** 下单时间 */
orderDate: string;
/** 商品ID */
productId: number;
/** 商品规格ID */
productSpecId?: number;
/** 商品名称(冗余存储) */
productName: string;
/** 规格名称(冗余存储) */
specName?: string;
/** 数量 */
quantity: number;
/** 销售单价 */
unitPrice: number;
/** 成本价(下单时快照) */
costPrice: number;
/** 成本小计 */
costTotal: number;
}
/** 更新订单参数 */
export interface Update {
/** 店铺ID */
shopId: number;
/** 平台订单号 */
platformOrderNo?: string;
/** 订单状态ID */
statusId?: number;
/** 商家实收金额 */
receivedAmount: number;
/** 运费 */
shippingFee?: number;
/** 下单时间 */
orderDate: string;
/** 商品ID */
productId?: number;
/** 商品规格ID */
productSpecId?: number;
/** 商品名称(冗余存储) */
productName?: string;
/** 规格名称(冗余存储) */
specName?: string;
/** 数量 */
quantity?: number;
/** 销售单价 */
unitPrice?: number;
/** 成本价(下单时快照) */
costPrice?: number;
/** 成本小计 */
costTotal?: number;
}
/** 订单过滤条件 */
export interface Filters {
/** 店铺ID */
shopId?: number;
/** 商品规格ID */
productSpecId?: number;
/** 订单状态ID */
orderStatusId?: number;
/** 订单编号(模糊查询) */
orderNumber?: string;
/** 商品名称(模糊查询) */
productName?: string;
}
/** 批量导入订单参数 */
export interface BatchImport {
/** 订单列表 */
orders: Create[];
}
}
@@ -0,0 +1,35 @@
/**
* 推广费类型相关DTO类型定义
*/
export namespace PromotionFeeTypeDTO {
/** 创建推广费类型参数 */
export interface Create {
/** 类型名称 */
typeName: string;
/** 类型描述 */
description?: string;
/** 计算方式 1固定金额 2按比例 3按点击 4按展示 */
calculationMethod?: number;
/** 排序 */
sortOrder?: number;
/** 是否启用 0禁用 1启用 */
isActive?: number;
}
/** 更新推广费类型参数 */
export interface Update {
/** 推广费类型ID */
id: number;
/** 类型名称 */
typeName: string;
/** 类型描述 */
description?: string;
/** 计算方式 1固定金额 2按比例 3按点击 4按展示 */
calculationMethod?: number;
/** 排序 */
sortOrder?: number;
/** 是否启用 0禁用 1启用 */
isActive?: number;
}
}
@@ -2,5 +2,13 @@
* 电商模块类型定义导出
*/
export * from './types.dto';
export * from './types.vo';
// DTO类型导出
export * from './dto.order';
export * from './dto.order-status';
export * from './dto.promotion-fee-type';
// VO类型导出
export * from './vo.order';
export * from './vo.order-status';
export * from './vo.promotion-fee-type';
export * from './vo.batch-import-result';
@@ -1,131 +0,0 @@
/**
* 电商模块DTO类型定义
*/
export namespace OrderDTO {
/** 创建订单参数 */
export interface CreateOrderDTO {
/** 店铺ID */
shopId: number;
/** 平台订单号 */
platformOrderNo?: string;
/** 订单状态ID */
statusId: number;
/** 商家实收金额 */
receivedAmount: number;
/** 运费 */
shippingFee?: number;
/** 下单时间 */
orderDate: string;
/** 商品ID */
productId: number;
/** 商品规格ID */
productSpecId: number;
/** 数量 */
quantity: number;
}
/** 更新订单参数 */
export interface UpdateOrderDTO {
/** 店铺ID */
shopId: number;
/** 平台订单号 */
platformOrderNo?: string;
/** 订单状态ID */
statusId?: number;
/** 商家实收金额 */
receivedAmount: number;
/** 运费 */
shippingFee?: number;
/** 下单时间 */
orderDate: string;
}
/** 订单过滤条件 */
export interface OrderFilterDTO {
/** 店铺ID */
shopId?: number;
/** 商品规格ID */
productSpecId?: number;
/** 订单状态ID */
orderStatusId?: number;
/** 订单编号(模糊查询) */
orderNumber?: string;
/** 商品名称(模糊查询) */
productName?: string;
}
/** 批量导入订单参数 */
export interface BatchImportOrderDTO {
/** 订单列表 */
orders: CreateOrderDTO[];
}
}
export namespace OrderStatusDTO {
/** 创建订单状态参数 */
export interface CreateOrderStatusDTO {
/** 状态码 */
statusCode: number;
/** 状态名称 */
statusName: string;
/** 状态描述 */
description?: string;
/** 排序 */
sortOrder?: number;
/** 是否启用 0禁用 1启用 */
isActive?: number;
}
/** 更新订单状态参数 */
export interface UpdateOrderStatusDTO {
/** 状态ID */
id: number;
/** 状态码 */
statusCode: number;
/** 状态名称 */
statusName: string;
/** 状态描述 */
description?: string;
/** 排序 */
sortOrder?: number;
/** 是否启用 0禁用 1启用 */
isActive?: number;
}
}
export namespace PromotionFeeTypeDTO {
/** 创建推广费类型参数 */
export interface CreatePromotionFeeTypeDTO {
/** 类型编码 */
typeCode: string;
/** 类型名称 */
typeName: string;
/** 类型描述 */
description?: string;
/** 计算方式 1固定金额 2按比例 3按点击 4按展示 */
calculationMethod?: number;
/** 排序 */
sortOrder?: number;
/** 是否启用 0禁用 1启用 */
isActive?: number;
}
/** 更新推广费类型参数 */
export interface UpdatePromotionFeeTypeDTO {
/** 推广费类型ID */
id: number;
/** 类型编码 */
typeCode: string;
/** 类型名称 */
typeName: string;
/** 类型描述 */
description?: string;
/** 计算方式 1固定金额 2按比例 3按点击 4按展示 */
calculationMethod?: number;
/** 排序 */
sortOrder?: number;
/** 是否启用 0禁用 1启用 */
isActive?: number;
}
}
@@ -1,147 +0,0 @@
/**
* 电商模块VO类型定义
*/
export namespace OrderVO {
/** 订单信息 */
export interface OrderInfoVO {
/** 订单ID */
id: number;
/** 公司ID */
companyId: number;
/** 店铺ID */
shopId: number;
/** 店铺名称 */
shopName: string;
/** 平台订单号 */
platformOrderNo: string;
/** 订单状态ID */
statusId: number;
/** 订单状态名称 */
statusName: string;
/** 商家实收金额 */
receivedAmount: number;
/** 运费 */
shippingFee: number;
/** 下单时间 */
orderDate: string;
/** 创建时间 */
createTime: string;
/** 更新时间 */
updateTime: string;
/** 创建人ID */
createBy?: number;
/** 更新人ID */
updateBy?: number;
/** 订单明细 */
orderItem?: OrderItemVO.OrderItemInfoVO;
}
}
export namespace OrderItemVO {
/** 订单明细信息 */
export interface OrderItemInfoVO {
/** 订单明细ID */
id: number;
/** 订单ID */
orderId: number;
/** 商品ID */
productId: number;
/** 商品规格ID */
productSpecId: number;
/** 商品名称 */
productName: string;
/** 规格名称 */
specName: string;
/** 商品主图 */
productImage?: string;
/** 数量 */
quantity: number;
/** 销售单价 */
unitPrice: number;
/** 成本价 */
costPrice: number;
/** 小计金额 */
subtotal: number;
/** 成本小计 */
costTotal: number;
/** 创建时间 */
createTime: string;
/** 更新时间 */
updateTime: string;
}
}
export namespace BatchImportResultVO {
/** 批量导入结果 */
export interface BatchImportResultInfoVO {
/** 总数量 */
totalCount: number;
/** 成功数量 */
successCount: number;
/** 失败数量 */
failureCount: number;
/** 失败详情 */
failureDetails: string[];
}
}
export namespace OrderStatusVO {
/** 订单状态信息 */
export interface OrderStatusInfoVO {
/** 状态ID */
id: number;
/** 公司ID */
companyId: number;
/** 状态码 */
statusCode: number;
/** 状态名称 */
statusName: string;
/** 状态描述 */
description?: string;
/** 排序 */
sortOrder?: number;
/** 是否启用 0禁用 1启用 */
isActive: number;
/** 创建时间 */
createTime: string;
/** 更新时间 */
updateTime: string;
/** 创建人ID */
createBy?: number;
/** 更新人ID */
updateBy?: number;
}
}
export namespace PromotionFeeTypeVO {
/** 推广费类型信息 */
export interface PromotionFeeTypeInfoVO {
/** 推广费类型ID */
id: number;
/** 公司ID */
companyId: number;
/** 类型编码 */
typeCode: string;
/** 类型名称 */
typeName: string;
/** 类型描述 */
description?: string;
/** 计算方式 1固定金额 2按比例 3按点击 4按展示 */
calculationMethod?: number;
/** 计算方式描述 */
calculationMethodDesc?: string;
/** 排序 */
sortOrder?: number;
/** 是否启用 0禁用 1启用 */
isActive?: number;
/** 创建时间 */
createTime: string;
/** 更新时间 */
updateTime: string;
/** 创建人ID */
createBy?: number;
/** 更新人ID */
updateBy?: number;
}
}
@@ -0,0 +1,17 @@
/**
* 批量导入结果相关VO类型定义
*/
export namespace BatchImportResultVO {
/** 批量导入结果 */
export interface Info {
/** 总数量 */
totalCount: number;
/** 成功数量 */
successCount: number;
/** 失败数量 */
failureCount: number;
/** 失败详情 */
failureDetails: string[];
}
}
@@ -0,0 +1,31 @@
/**
* 订单状态相关VO类型定义
*/
export namespace OrderStatusVO {
/** 订单状态信息 */
export interface Info {
/** 状态ID */
id: number;
/** 公司ID */
companyId: number;
/** 状态码 */
statusCode: number;
/** 状态名称 */
statusName: string;
/** 状态描述 */
description?: string;
/** 排序 */
sortOrder?: number;
/** 是否启用 0禁用 1启用 */
isActive: number;
/** 创建时间 */
createTime: string;
/** 更新时间 */
updateTime: string;
/** 创建人ID */
createBy?: number;
/** 更新人ID */
updateBy?: number;
}
}
@@ -0,0 +1,53 @@
/**
* 订单相关VO类型定义
*/
export namespace OrderVO {
/** 订单信息 */
export interface Info {
/** 订单ID */
id: number;
/** 公司ID */
companyId: number;
/** 店铺ID */
shopId: number;
/** 店铺名称 */
shopName: string;
/** 平台订单号 */
platformOrderNo: string;
/** 订单状态ID */
statusId: number;
/** 订单状态名称 */
statusName: string;
/** 商家实收金额 */
receivedAmount: number;
/** 运费 */
shippingFee: number;
/** 下单时间 */
orderDate: string;
/** 创建时间 */
createTime: string;
/** 更新时间 */
updateTime: string;
/** 创建人ID */
createBy?: number;
/** 更新人ID */
updateBy?: number;
/** 商品ID */
productId: number;
/** 商品规格ID */
productSpecId?: number;
/** 商品名称(冗余存储) */
productName: string;
/** 规格名称(冗余存储) */
specName?: string;
/** 数量 */
quantity: number;
/** 销售单价 */
unitPrice: number;
/** 成本价(下单时快照) */
costPrice: number;
/** 成本小计 */
costTotal: number;
}
}
@@ -0,0 +1,35 @@
/**
* 推广费类型相关VO类型定义
*/
export namespace PromotionFeeTypeVO {
/** 推广费类型信息 */
export interface Info {
/** 推广费类型ID */
id: number;
/** 公司ID */
companyId: number;
/** 类型编码 */
typeCode: string;
/** 类型名称 */
typeName: string;
/** 类型描述 */
description?: string;
/** 计算方式 1固定金额 2按比例 3按点击 4按展示 */
calculationMethod?: number;
/** 计算方式描述 */
calculationMethodDesc?: string;
/** 排序 */
sortOrder?: number;
/** 是否启用 0禁用 1启用 */
isActive?: number;
/** 创建时间 */
createTime: string;
/** 更新时间 */
updateTime: string;
/** 创建人ID */
createBy?: number;
/** 更新人ID */
updateBy?: number;
}
}
@@ -1,110 +0,0 @@
import { requestClient } from '#/api/request';
import type { MediaFileDTO, MediaFileVO, MediaImageDTO, MediaImageVO } from './types';
import type { PageQueryDTO, PageResultVO } from '#/types/common';
/**
* 文件管理相关API
*/
// 文件上传
export async function uploadFileApi(file: File) {
const formData = new FormData();
formData.append('file', file);
return requestClient.post<MediaFileVO.MediaFileInfoVO>('/media/file/upload', formData, {
headers: {
'Content-Type': 'multipart/form-data',
},
});
}
// 批量文件上传
export async function batchUploadFilesApi(files: File[]) {
const formData = new FormData();
files.forEach(file => {
formData.append('files', file);
});
return requestClient.post<MediaFileVO.MediaFileInfoVO[]>('/media/file/batch-upload', formData, {
headers: {
'Content-Type': 'multipart/form-data',
},
});
}
// 更新文件信息
export async function updateFileApi(data: MediaFileDTO.UpdateFileDTO) {
return requestClient.put<MediaFileVO.MediaFileInfoVO>('/media/file/update', data);
}
// 删除文件
export async function deleteFileApi(id: number) {
return requestClient.delete(`/media/file/delete/${id}`);
}
// 根据哈希查询文件
export async function getFileByHashApi(fileHash: string) {
return requestClient.get<MediaFileVO.MediaFileInfoVO>(`/media/file/hash/${fileHash}`);
}
// 批量根据哈希查询文件
export async function getFilesByHashesApi(fileHashes: string[]) {
return requestClient.post<MediaFileVO.MediaFileInfoVO[]>('/media/file/batch-hash', fileHashes);
}
// 分页获取文件列表
export async function getFilePageApi(params: PageQueryDTO<MediaFileDTO.MediaFileFilterDTO>) {
return requestClient.post<PageResultVO<MediaFileVO.MediaFileInfoVO>>('/media/file/page', params);
}
/**
* 图片管理相关API
*/
// 图片上传
export async function uploadImageApi(file: File) {
const formData = new FormData();
formData.append('file', file);
return requestClient.post<MediaImageVO.MediaImageInfoVO>('/media/image/upload', formData, {
headers: {
'Content-Type': 'multipart/form-data',
},
});
}
// 批量图片上传
export async function batchUploadImagesApi(files: File[]) {
const formData = new FormData();
files.forEach(file => {
formData.append('files', file);
});
return requestClient.post<MediaImageVO.MediaImageInfoVO[]>('/media/image/batch-upload', formData, {
headers: {
'Content-Type': 'multipart/form-data',
},
});
}
// 更新图片信息
export async function updateImageApi(data: MediaImageDTO.UpdateImageDTO) {
return requestClient.put<MediaImageVO.MediaImageInfoVO>('/media/image/update', data);
}
// 删除图片
export async function deleteImageApi(id: number) {
return requestClient.delete(`/media/image/delete/${id}`);
}
// 根据哈希查询图片
export async function getImageByHashApi(fileHash: string) {
return requestClient.get<MediaImageVO.MediaImageInfoVO>(`/media/image/hash/${fileHash}`);
}
// 批量根据哈希查询图片
export async function getImagesByHashesApi(fileHashes: string[]) {
return requestClient.post<MediaImageVO.MediaImageInfoVO[]>('/media/image/batch-hash', fileHashes);
}
// 分页获取图片列表
export async function getImagePageApi(params: PageQueryDTO<MediaImageDTO.MediaImageFilterDTO>) {
return requestClient.post<PageResultVO<MediaImageVO.MediaImageInfoVO>>('/media/image/page', params);
}
@@ -0,0 +1,80 @@
import { requestClient } from '#/api/request';
import type { PageQueryDTO, PageResultVO } from '#/types/common';
import type { FileDTO, FileVO } from './types';
/**
* 文件管理API
*/
/**
* 分页获取文件列表
*/
export async function getFilePageApi(params: PageQueryDTO<FileDTO.Filters>) {
return requestClient.post<PageResultVO<FileVO.Info>>('/media/file/page', params);
}
/**
* 上传文件
*/
export async function uploadFileApi(file: File) {
const formData = new FormData();
formData.append('file', file);
return requestClient.post<FileVO.Info>('/media/file/upload', formData, {
headers: {
'Content-Type': 'multipart/form-data',
},
});
}
/**
* 批量上传文件
*/
export async function batchUploadFilesApi(files: File[]) {
const formData = new FormData();
files.forEach(file => {
formData.append('files', file);
});
return requestClient.post<FileVO.Info[]>('/media/file/batch-upload', formData, {
headers: {
'Content-Type': 'multipart/form-data',
},
});
}
/**
* 更新文件信息
*/
export async function updateFileApi(id: number, data: FileDTO.Update) {
return requestClient.put<FileVO.Info>(`/media/file/update/${id}`, data);
}
/**
* 删除文件
*/
export async function deleteFileApi(id: number) {
return requestClient.delete<void>(`/media/file/delete/${id}`);
}
/**
* 获取文件详情
*/
export async function getFileByIdApi(id: number) {
return requestClient.get<FileVO.Info>(`/media/file/detail/${id}`);
}
/**
* 批量删除文件
*/
export async function batchDeleteFilesApi(ids: number[]) {
return requestClient.delete<void>('/media/file/batch-delete', { data: { ids } });
}
/**
* 下载文件
*/
export async function downloadFileApi(id: number) {
return requestClient.get(`/media/file/download/${id}`, {
responseType: 'blob',
});
}
@@ -0,0 +1,84 @@
import { requestClient } from '#/api/request';
import type { PageQueryDTO, PageResultVO } from '#/types/common';
import type { ImageDTO, ImageVO } from './types';
/**
* 图片管理API
*/
/**
* 分页获取图片列表
*/
export async function getImagePageApi(params: PageQueryDTO<ImageDTO.Filters>) {
return requestClient.post<PageResultVO<ImageVO.Info>>('/media/image/page', params);
}
/**
* 上传图片
*/
export async function uploadImageApi(file: File) {
const formData = new FormData();
formData.append('file', file);
return requestClient.post<ImageVO.Info>('/media/image/upload', formData, {
headers: {
'Content-Type': 'multipart/form-data',
},
});
}
/**
* 批量上传图片
*/
export async function batchUploadImagesApi(files: File[]) {
const formData = new FormData();
files.forEach(file => {
formData.append('files', file);
});
return requestClient.post<ImageVO.Info[]>('/media/image/batch-upload', formData, {
headers: {
'Content-Type': 'multipart/form-data',
},
});
}
/**
* 更新图片信息
*/
export async function updateImageApi(id: number, data: ImageDTO.Update) {
return requestClient.put<ImageVO.Info>(`/media/image/update/${id}`, data);
}
/**
* 删除图片
*/
export async function deleteImageApi(id: number) {
return requestClient.delete<void>(`/media/image/delete/${id}`);
}
/**
* 获取图片详情
*/
export async function getImageByIdApi(id: number) {
return requestClient.get<ImageVO.Info>(`/media/image/detail/${id}`);
}
/**
* 批量删除图片
*/
export async function batchDeleteImagesApi(ids: number[]) {
return requestClient.delete<void>('/media/image/batch-delete', { data: { ids } });
}
/**
* 获取图片缩略图
*/
export async function getImageThumbnailApi(id: number, width?: number, height?: number) {
const params = new URLSearchParams();
if (width) params.append('width', width.toString());
if (height) params.append('height', height.toString());
return requestClient.get(`/media/image/thumbnail/${id}?${params.toString()}`, {
responseType: 'blob',
});
}
@@ -1,2 +1,12 @@
export * from './apis';
export * from './types';
/**
* 媒体管理模块API导出
*/
// 文件相关API
export * from './file.apis';
// 图片相关API
export * from './image.apis';
// 类型定义
export * from './types';
@@ -1,63 +0,0 @@
/**
* 媒体文件相关类型定义
*/
export namespace MediaFileVO {
export interface MediaFileInfoVO {
id: number;
companyId: number;
url: string;
filename: string;
fileType: string;
fileHash: string;
tags: string;
remark: string;
uploadBy: number;
uploadTime: string;
}
}
export namespace MediaImageVO {
export interface MediaImageInfoVO {
id: number;
companyId: number;
url: string;
filename: string;
type: string;
fileHash: string;
tags: string;
remark: string;
uploadBy: number;
uploadTime: string;
}
}
export namespace MediaFileDTO {
export interface UpdateFileDTO {
id: number;
fileType?: string;
tags?: string;
remark?: string;
}
export interface MediaFileFilterDTO {
filename?: string;
fileType?: string;
tags?: string;
}
}
export namespace MediaImageDTO {
export interface UpdateImageDTO {
id: number;
type?: string;
tags?: string;
remark?: string;
}
export interface MediaImageFilterDTO {
filename?: string;
type?: string;
tags?: string;
}
}
@@ -0,0 +1,34 @@
/**
* 文件管理相关DTO类型定义
*/
export namespace FileDTO {
/** 文件查询过滤条件 */
export interface Filters {
/** 文件名 */
filename?: string;
/** 文件格式 */
fileFormat?: string;
/** 标签 */
tags?: string;
/** 上传人ID */
uploadBy?: number;
/** 上传时间范围-开始 */
uploadTimeStart?: string;
/** 上传时间范围-结束 */
uploadTimeEnd?: string;
}
/** 更新文件 */
export interface Update {
tags?: string;
/** 文件描述 */
remark?: string;
}
/** 批量上传文件 */
export interface BatchUpload {
/** 文件列表 */
files: File[];
}
}
@@ -0,0 +1,36 @@
/**
* 图片管理相关DTO类型定义
*/
export namespace ImageDTO {
/** 图片查询过滤条件 */
export interface Filters {
/** 文件名 */
filename?: string;
/** 图片分类 (image,avatar,logo) */
category?: string;
/** 图片格式 */
imageFormat?: string;
/** 标签 */
tags?: string;
/** 上传人ID */
uploadBy?: number;
/** 上传时间范围-开始 */
uploadTimeStart?: string;
/** 上传时间范围-结束 */
uploadTimeEnd?: string;
}
/** 更新图片 */
export interface Update {
tags?: string;
/** 图片说明 */
remark?: string;
}
/** 批量上传图片 */
export interface BatchUpload {
/** 图片文件列表 */
files: File[];
}
}
@@ -0,0 +1,11 @@
/**
* 媒体管理模块类型定义导出
*/
// DTO类型导出
export * from './dto.file';
export * from './dto.image';
// VO类型导出
export * from './vo.file';
export * from './vo.image';
@@ -0,0 +1,37 @@
/**
* 文件管理相关VO类型定义
*/
export namespace FileVO {
/** 文件信息 */
export interface Info {
/** 文件ID */
id: number;
/** 公司ID */
companyId: number;
/** 文件URL */
url: string;
/** 文件名 */
filename: string;
/** 文件格式,如 pdf/cad/xlsx/doc */
fileFormat?: string;
/** 文件哈希值,用于去重 */
fileHash?: string;
/** 标签,逗号分隔 */
tags?: string;
/** 文件描述 */
remark?: string;
/** 上传人ID */
uploadBy?: number;
/** 上传时间 */
uploadTime: string;
/** 更新时间 */
updateTime?: string;
/** 更新人ID */
updateBy?: number;
/** 删除时间 */
deleteTime?: string;
/** 删除人ID */
deleteBy?: number;
}
}
@@ -0,0 +1,39 @@
/**
* 图片管理相关VO类型定义
*/
export namespace ImageVO {
/** 图片信息 */
export interface Info {
/** 图片ID */
id: number;
/** 公司ID */
companyId: number;
/** 图片URL */
url: string;
/** 原始文件名 */
filename?: string;
/** 图片分类 (image,avatar,logo) */
category?: string;
/** 图片格式,如 jpg/png/gif/webp */
imageFormat?: string;
/** 文件哈希值,用于去重 */
fileHash?: string;
/** 标签,逗号分隔 */
tags?: string;
/** 图片说明 */
remark?: string;
/** 上传人ID */
uploadBy?: number;
/** 上传时间 */
uploadTime: string;
/** 更新时间 */
updateTime?: string;
/** 更新人ID */
updateBy?: number;
/** 删除时间 */
deleteTime?: string;
/** 删除人ID */
deleteBy?: number;
}
}
@@ -1,166 +0,0 @@
import { requestClient } from '#/api/request';
import type { PageQueryDTO, PageResultVO } from '#/types/common';
import type { ShopDTO, ShopVO, ProductDTO, ProductVO } from './types';
/**
* 店铺管理API
*/
/**
* 分页获取店铺列表
*/
export async function getShopPageApi(params: PageQueryDTO<ShopDTO.ShopFiltersDTO>) {
return requestClient.post<PageResultVO<ShopVO.ShopInfoVO>>('/ec/shop/page', params);
}
/**
* 创建店铺
*/
export async function createShopApi(data: ShopDTO.CreateShopDTO) {
return requestClient.post<ShopVO.ShopInfoVO>('/ec/shop/create', data);
}
/**
* 更新店铺
*/
export async function updateShopApi(id: number, data: ShopDTO.UpdateShopDTO) {
return requestClient.put<ShopVO.ShopInfoVO>(`/ec/shop/update/${id}`, data);
}
/**
* 删除店铺
*/
export async function deleteShopApi(id: number) {
return requestClient.delete<void>(`/ec/shop/delete/${id}`);
}
/**
* 上传店铺Logo
*/
export async function uploadShopLogoApi(file: File) {
const formData = new FormData();
formData.append('file', file);
return requestClient.post<ShopVO.ShopInfoVO>('/ec/shop/upload-logo', formData, {
headers: {
'Content-Type': 'multipart/form-data',
},
});
}
/**
* 商品管理API
*/
/**
* 分页获取商品列表
*/
export async function getProductPageApi(params: PageQueryDTO<ProductDTO.ProductFiltersDTO>) {
return requestClient.post<PageResultVO<ProductVO.ProductInfoVO>>('/ec/product/page', params);
}
/**
* 创建商品
*/
export async function createProductApi(data: ProductDTO.CreateProductDTO) {
return requestClient.post<ProductVO.ProductInfoVO>('/ec/product/create', data);
}
/**
* 更新商品
*/
export async function updateProductApi(id: number, data: ProductDTO.UpdateProductDTO) {
return requestClient.put<ProductVO.ProductInfoVO>(`/ec/product/update/${id}`, data);
}
/**
* 删除商品
*/
export async function deleteProductApi(id: number) {
return requestClient.delete<void>(`/ec/product/delete/${id}`);
}
/**
* 一键创建商品和规格
*/
export async function createProductWithSpecsApi(data: ProductDTO.CreateProductWithSpecsDTO) {
return requestClient.post<ProductVO.ProductInfoVO>('/ec/product/create-with-specs', data);
}
/**
* 商品规格管理API
*/
/**
* 分页获取商品规格列表
*/
export async function getProductSpecPageApi(params: PageQueryDTO<ProductDTO.ProductSpecFilterDTO>) {
return requestClient.post<PageResultVO<ProductVO.ProductSpecInfoVO>>('/ec/product-spec/page', params);
}
/**
* 创建商品规格
*/
export async function createProductSpecApi(data: ProductDTO.CreateProductSpecDTO) {
return requestClient.post<ProductVO.ProductSpecInfoVO>('/ec/product-spec/create', data);
}
/**
* 更新商品规格
*/
export async function updateProductSpecApi(id: number, data: ProductDTO.UpdateProductSpecDTO) {
return requestClient.put<ProductVO.ProductSpecInfoVO>(`/ec/product-spec/update/${id}`, data);
}
/**
* 删除商品规格
*/
export async function deleteProductSpecApi(id: number) {
return requestClient.delete<void>(`/ec/product-spec/delete/${id}`);
}
/**
* 精准查询API - 用于数据导入
*/
/**
* 根据名称精准查询店铺
*/
export async function getShopByNameApi(name: string) {
return requestClient.get<ShopVO.ShopInfoVO>(`/ec/shop/find-by-name/${encodeURIComponent(name)}`);
}
/**
* 批量根据名称查询店铺
*/
export async function getShopsByNamesApi(names: string[]) {
return requestClient.post<ShopVO.ShopInfoVO[]>('/ec/shop/find-by-names', names);
}
/**
* 根据名称精准查询商品
*/
export async function getProductByNameApi(name: string) {
return requestClient.get<ProductVO.ProductInfoVO>(`/ec/product/find-by-name/${encodeURIComponent(name)}`);
}
/**
* 批量根据名称查询商品
*/
export async function getProductsByNamesApi(names: string[]) {
return requestClient.post<ProductVO.ProductInfoVO[]>('/ec/product/find-by-names', names);
}
/**
* 根据商品名称和规格编码精准查询商品规格
*/
export async function getProductSpecByProductAndSpecApi(productName: string, specCode: string) {
return requestClient.get<ProductVO.ProductSpecInfoVO>(`/ec/product-spec/find-by-product-and-spec/${encodeURIComponent(productName)}/${encodeURIComponent(specCode)}`);
}
/**
* 批量根据商品名称和规格编码查询商品规格
*/
export async function getProductSpecsByProductAndSpecsApi(queries: { productName: string; specCode: string }[]) {
return requestClient.post<ProductVO.ProductInfoVO[]>('/ec/product-spec/find-by-product-and-specs', queries);
}
@@ -2,5 +2,8 @@
* 店铺管理模块API导出
*/
export * from './apis';
export * from './types';
// 店铺相关API
export * from './shop.apis';
// 商品相关API
export * from './product.apis';
@@ -0,0 +1,107 @@
import { requestClient } from '#/api/request';
import type { PageQueryDTO, PageResultVO } from '#/types/common';
import type { ProductDTO, ProductVO } from './types';
/**
* 商品管理API
*/
/**
* 分页获取商品列表
*/
export async function getProductPageApi(params: PageQueryDTO<ProductDTO.Filters>) {
return requestClient.post<PageResultVO<ProductVO.Info>>('/ec/product/page', params);
}
/**
* 创建商品
*/
export async function createProductApi(data: ProductDTO.Create) {
return requestClient.post<ProductVO.Info>('/ec/product/create', data);
}
/**
* 更新商品
*/
export async function updateProductApi(id: number, data: ProductDTO.Update) {
return requestClient.put<ProductVO.Info>(`/ec/product/update/${id}`, data);
}
/**
* 删除商品
*/
export async function deleteProductApi(id: number) {
return requestClient.delete<void>(`/ec/product/delete/${id}`);
}
/**
* 一键创建商品和规格
*/
export async function createProductWithSpecsApi(data: ProductDTO.CreateWithSpecs) {
return requestClient.post<ProductVO.Info>('/ec/product/create-with-specs', data);
}
/**
* 商品规格管理API
*/
/**
* 分页获取商品规格列表
*/
export async function getProductSpecPageApi(params: PageQueryDTO<ProductDTO.SpecFilters>) {
return requestClient.post<PageResultVO<ProductVO.SpecInfo>>('/ec/product-spec/page', params);
}
/**
* 创建商品规格
*/
export async function createProductSpecApi(data: ProductDTO.CreateSpec) {
return requestClient.post<ProductVO.SpecInfo>('/ec/product-spec/create', data);
}
/**
* 更新商品规格
*/
export async function updateProductSpecApi(id: number, data: ProductDTO.UpdateSpec) {
return requestClient.put<ProductVO.SpecInfo>(`/ec/product-spec/update/${id}`, data);
}
/**
* 删除商品规格
*/
export async function deleteProductSpecApi(id: number) {
return requestClient.delete<void>(`/ec/product-spec/delete/${id}`);
}
/**
* 精准查询API - 用于数据导入
*/
/**
* 根据名称精准查询商品
*/
export async function getProductByNameApi(name: string) {
return requestClient.get<ProductVO.Info>(`/ec/product/find-by-name/${encodeURIComponent(name)}`);
}
/**
* 批量根据名称查询商品
*/
export async function getProductsByNamesApi(names: string[]) {
return requestClient.post<ProductVO.Info[]>('/ec/product/find-by-names', names);
}
/**
* 根据商品名称和规格编码精准查询商品规格
*/
export async function getProductSpecByProductAndSpecApi(productName: string, specCode: string) {
return requestClient.get<ProductVO.SpecInfo>(`/ec/product-spec/find-by-product-and-spec/${encodeURIComponent(productName)}/${encodeURIComponent(specCode)}`);
}
/**
* 批量根据商品名称和规格编码查询商品规格
*/
export async function getProductSpecsByProductAndSpecsApi(queries: { productName: string; specCode: string }[]) {
return requestClient.post<ProductVO.Info[]>('/ec/product-spec/find-by-product-and-specs', queries);
}
@@ -0,0 +1,67 @@
import { requestClient } from '#/api/request';
import type { PageQueryDTO, PageResultVO } from '#/types/common';
import type { ShopDTO, ShopVO } from './types';
/**
* 店铺管理API
*/
/**
* 分页获取店铺列表
*/
export async function getShopPageApi(params: PageQueryDTO<ShopDTO.Filters>) {
return requestClient.post<PageResultVO<ShopVO.Info>>('/ec/shop/page', params);
}
/**
* 创建店铺
*/
export async function createShopApi(data: ShopDTO.Create) {
return requestClient.post<ShopVO.Info>('/ec/shop/create', data);
}
/**
* 更新店铺
*/
export async function updateShopApi(id: number, data: ShopDTO.Update) {
return requestClient.put<ShopVO.Info>(`/ec/shop/update/${id}`, data);
}
/**
* 删除店铺
*/
export async function deleteShopApi(id: number) {
return requestClient.delete<void>(`/ec/shop/delete/${id}`);
}
/**
* 上传店铺Logo
*/
export async function uploadShopLogoApi(file: File) {
const formData = new FormData();
formData.append('file', file);
return requestClient.post<ShopVO.Info>('/ec/shop/upload-logo', formData, {
headers: {
'Content-Type': 'multipart/form-data',
},
});
}
/**
* 精准查询API - 用于数据导入
*/
/**
* 根据名称精准查询店铺
*/
export async function getShopByNameApi(name: string) {
return requestClient.get<ShopVO.Info>(`/ec/shop/find-by-name/${encodeURIComponent(name)}`);
}
/**
* 批量根据名称查询店铺
*/
export async function getShopsByNamesApi(names: string[]) {
return requestClient.post<ShopVO.Info[]>('/ec/shop/find-by-names', names);
}
@@ -1,40 +1,10 @@
/**
* 店铺管理模块DTO类型定义
* 商品相关DTO类型定义
*/
export namespace ShopDTO {
/** 创建店铺参数 */
export interface CreateShopDTO {
/** 店铺名称 */
name: string;
/** logo图片ID */
logoImageId?: number;
/** 平台(如淘宝、京东、拼多多) */
platform?: string;
}
/** 更新店铺参数 */
export interface UpdateShopDTO {
/** 店铺名称 */
name: string;
/** logo图片ID */
logoImageId?: number;
/** 平台(如淘宝、京东、拼多多) */
platform?: string;
}
/** 店铺过滤条件 */
export interface ShopFiltersDTO {
/** 店铺名称(模糊查询) */
name?: string;
/** 平台 */
platform?: string;
}
}
export namespace ProductDTO {
/** 创建商品参数 */
export interface CreateProductDTO {
export interface Create {
/** 商品名称 */
name: string;
/** 主图图片ID */
@@ -42,7 +12,7 @@ export namespace ProductDTO {
}
/** 更新商品参数 */
export interface UpdateProductDTO {
export interface Update {
/** 商品名称 */
name: string;
/** 商品编码 */
@@ -56,17 +26,17 @@ export namespace ProductDTO {
}
/** 一键创建商品和规格参数 */
export interface CreateProductWithSpecsDTO {
export interface CreateWithSpecs {
/** 商品名称 */
name: string;
/** 主图图片ID */
mainImageId?: number;
/** 商品规格列表 */
specs: ProductSpecDTO[];
specs: Spec[];
}
/** 商品规格DTO */
export interface ProductSpecDTO {
export interface Spec {
/** 规格名称 */
name: string;
/** 规格编码 */
@@ -76,7 +46,7 @@ export namespace ProductDTO {
}
/** 创建商品规格参数 */
export interface CreateProductSpecDTO {
export interface CreateSpec {
/** 商品ID */
productId: number;
/** 规格名称 */
@@ -88,7 +58,7 @@ export namespace ProductDTO {
}
/** 更新商品规格参数 */
export interface UpdateProductSpecDTO {
export interface UpdateSpec {
/** 规格名称 */
name: string;
/** 规格编码 */
@@ -98,7 +68,7 @@ export namespace ProductDTO {
}
/** 商品过滤条件 */
export interface ProductFiltersDTO {
export interface Filters {
/** 商品名称(模糊查询) */
name?: string;
/** 商品编码(模糊查询) */
@@ -112,7 +82,7 @@ export namespace ProductDTO {
}
/** 商品规格过滤条件 */
export interface ProductSpecFilterDTO {
export interface SpecFilters {
/** 商品ID */
productId?: number;
/** 商品名称(模糊查询) */
@@ -0,0 +1,33 @@
/**
* 店铺相关DTO类型定义
*/
export namespace ShopDTO {
/** 创建店铺参数 */
export interface Create {
/** 店铺名称 */
name: string;
/** logo图片ID */
logoImageId?: number;
/** 平台(如淘宝、京东、拼多多) */
platform?: string;
}
/** 更新店铺参数 */
export interface Update {
/** 店铺名称 */
name: string;
/** logo图片ID */
logoImageId?: number;
/** 平台(如淘宝、京东、拼多多) */
platform?: string;
}
/** 店铺过滤条件 */
export interface Filters {
/** 店铺名称(模糊查询) */
name?: string;
/** 平台 */
platform?: string;
}
}
@@ -2,5 +2,10 @@
* 店铺管理模块类型定义导出
*/
export * from './types.dto';
export * from './types.vo';
// DTO类型导出
export * from './dto.shop';
export * from './dto.product';
// VO类型导出
export * from './vo.shop';
export * from './vo.product';
@@ -1,42 +1,20 @@
/**
* 店铺管理模块VO类型定义
* 商品相关VO类型定义
*/
export namespace ShopVO {
/** 店铺信息 */
export interface ShopInfoVO {
/** 店铺ID */
id: number;
/** 所属公司ID */
companyId: number;
/** 店铺名称 */
name: string;
/** logo URL */
logo?: string;
/** 平台(如淘宝、京东、拼多多) */
platform?: string;
/** 创建时间 */
createTime: string;
/** 更新时间 */
updateTime: string;
/** 创建人ID */
createBy?: number;
/** 更新人ID */
updateBy?: number;
}
}
export namespace ProductVO {
/** 商品信息 */
export interface ProductInfoVO {
export interface Info {
/** 商品ID */
id: number;
/** 公司ID */
companyId: number;
/** 商品名称 */
name: string;
/** 主图URL */
/** 主图URL(冗余字段) */
mainImage?: string;
/** 主图图片ID */
mainImageId?: number;
/** 创建时间 */
createTime: string;
/** 更新时间 */
@@ -46,11 +24,11 @@ export namespace ProductVO {
/** 更新人ID */
updateBy?: number;
/** 商品规格列表 */
specs?: ProductSpecInfoVO[];
specs?: SpecInfo[];
}
/** 商品规格信息 */
export interface ProductSpecInfoVO {
export interface SpecInfo {
/** 规格ID */
id: number;
/** 公司ID */
@@ -0,0 +1,29 @@
/**
* 店铺相关VO类型定义
*/
export namespace ShopVO {
/** 店铺信息 */
export interface Info {
/** 店铺ID */
id: number;
/** 所属公司ID */
companyId: number;
/** 店铺名称 */
name: string;
/** logo URL(冗余字段) */
logo?: string;
/** logo图片ID */
logoImageId?: number;
/** 平台(如淘宝、京东、拼多多) */
platform?: string;
/** 创建时间 */
createTime: string;
/** 更新时间 */
updateTime: string;
/** 创建人ID */
createBy?: number;
/** 更新人ID */
updateBy?: number;
}
}
@@ -1,174 +0,0 @@
# 电商数据中台系统
## 功能概述
这是一个基于Vue Vben Admin框架开发的电商数据中台系统,主要用于处理电商店铺的营业数据。
## 主要功能
### 1. 数据导入 (Data Import)
- **CSV文件上传**: 支持拖拽或点击上传CSV格式的营业数据文件
- **数据预览**: 上传后可以预览前10条数据,了解数据结构
- **字段映射**: 将CSV字段映射到标准字段,支持自定义字段名
- **数据清洗**: 自动清洗和格式化数据(去除空格、数字格式化等)
- **JSON导出**: 将处理后的数据导出为JSON格式
### 2. 数据分析 (Data Analysis)
- 数据统计和分析功能(开发中)
### 3. 店铺管理 (Shop Management)
- **店铺信息管理**: 支持店铺的增删改查操作
- **平台管理**: 支持淘宝、京东、拼多多、天猫等主流电商平台
- **Logo管理**: 支持店铺Logo的URL设置和预览
- **搜索过滤**: 支持按店铺名称和平台进行搜索过滤
- **分页展示**: 支持分页展示店铺列表
### 4. 商品管理 (Product Management)
- **商品信息管理**: 支持商品的增删改查操作
- **商品编码管理**: 支持商品编码和SKU管理
- **价格管理**: 支持成本价设置和价格范围搜索
- **图片管理**: 支持商品主图URL设置和预览
- **高级搜索**: 支持按商品名称、编码、SKU和价格范围进行搜索过滤
- **分页展示**: 支持分页展示商品列表
## 使用流程
### 数据导入流程
1. **上传CSV文件**
- 点击"电商数据中台" -> "数据导入"
- 拖拽或点击上传CSV文件
- 系统会自动解析和验证数据
2. **预览数据**
- 查看解析后的数据预览
- 确认数据格式正确
3. **配置字段映射**
- 点击"配置字段映射"按钮
- 为每个CSV字段选择对应的标准字段
- 可选择自定义字段名称
- 实时预览映射后的数据
4. **导出JSON**
- 确认字段映射无误后,点击"导出JSON"
- 系统会生成包含元数据的JSON文件
- 文件会保存到本地下载目录
## 支持的数据格式
### CSV文件要求
- 文件格式:`.csv`
- 文件大小:最大10MB
- 编码格式:UTF-8
- 必要字段:
- 商品
- 订单号
- 订单状态
- 商品数量(件)
- 商家实收金额(元)
### 标准字段映射
系统支持以下标准字段:
- `product_name`: 商品名称
- `order_id`: 订单号
- `order_status`: 订单状态
- `quantity`: 商品数量
- `product_id`: 商品ID
- `product_spec`: 商品规格
- `after_sale_status`: 售后状态
- `amount`: 实收金额
- `shop_name`: 店铺名称
- `order_date`: 订单日期
- `customer_id`: 客户ID
- `payment_method`: 支付方式
- `delivery_address`: 收货地址
- `remark`: 备注
## 导出的JSON格式
```json
{
"metadata": {
"source": "CSV导入",
"totalRecords": 100,
"exportTime": "2024-01-15T10:30:00.000Z",
"fieldMappings": {
"商品": "product_name",
"订单号": "order_id"
},
"customFieldNames": {},
"shopName": "店铺名称"
},
"data": [
{
"product_name": "商品名称",
"order_id": "订单号",
"order_status": "订单状态"
}
]
}
```
## 技术栈
- **前端框架**: Vue 3 + TypeScript
- **UI组件库**: Ant Design Vue
- **构建工具**: Vite
- **CSV解析**: PapaParse
- **状态管理**: Pinia
- **路由**: Vue Router
## 开发说明
### 项目结构
```
src/views/ecommerce/
├── data-import/
│ ├── components/
│ │ └── FieldMapping.vue # 字段映射组件
│ └── index.vue # 数据导入主页面
├── data-analysis/
│ └── index.vue # 数据分析页面
├── shop-management/
│ └── index.vue # 店铺管理页面
├── product-management/
│ └── index.vue # 商品管理页面
└── README.md # 说明文档
```
### 工具函数
`src/utils/csv-utils.ts` 提供了以下工具函数:
- `parseCSV()`: 解析CSV文件
- `transformDataWithMapping()`: 根据字段映射转换数据
- `generateExportData()`: 生成导出数据
- `downloadJSON()`: 下载JSON文件
- `validateCSVData()`: 验证CSV数据格式
- `cleanAndFormatData()`: 数据清洗和格式化
## 注意事项
1. 确保CSV文件格式正确,包含必要的字段
2. 字段映射时,建议保留所有重要字段
3. 导出的JSON文件包含完整的元数据,便于后续处理
4. 系统会自动从文件名提取店铺名称
5. 数据清洗会自动处理数字字段和去除空格
## 后续开发计划
- [ ] 数据分析功能
- [ ] 店铺管理功能
- [ ] 数据可视化图表
- [ ] 批量数据处理
- [ ] 数据导入历史记录
- [ ] 数据导出模板管理
@@ -17,17 +17,25 @@
<!-- 工具栏工具 -->
<template #toolbar-tools>
<Space>
<Button @click="showUploadModal = true" ghost>
<Button @click="showUploadModal = true" type="default">
<UploadIcon class="w-4 h-4 mr-1" />
继续导入
</Button>
<Button
@click="performImport"
type="primary"
:loading="importLoading"
:disabled="!matchingResult || matchingResult.matchedOrders.length === 0"
>
一键上传订单 ({{ matchingResult?.matchedOrders.length || 0 }})
</Button>
<Button @click="selectAll">
全选
</Button>
<Button @click="clearSelection">
清空选择
</Button>
<Button @click="showFieldMapping = true" type="primary" :disabled="selectedRows.length === 0">
<Button @click="showFieldMapping = true" :disabled="selectedRows.length === 0">
配置字段映射 ({{ selectedRows.length }})
</Button>
</Space>
@@ -80,7 +88,7 @@
:loading="importLoading"
:disabled="matchingResult.matchedOrders.length === 0"
>
开始导入 ({{ matchingResult.matchedOrders.length }})
一键上传订单 ({{ matchingResult.matchedOrders.length }})
</Button>
<Button @click="performEntityMatching" size="small">
重新匹配
@@ -438,10 +446,10 @@ const performImport = async () => {
importProgress.value = 100
message.success(`导入完成!成功导入 ${result.successCount} 条,失败 ${result.failureCount} 条`)
message.success(`导入完成!成功导入 ${result.successCount || 0} 条,失败 ${result.failureCount || 0} 条`)
// 显示失败详情
if (result.failureDetails.length > 0) {
if (result.failureDetails && result.failureDetails.length > 0) {
console.warn('导入失败详情:', result.failureDetails)
}
@@ -6,15 +6,14 @@
import {
getShopsByNamesApi,
getProductsByNamesApi,
getProductSpecsByProductAndSpecsApi,
type ShopVO,
type ProductVO
getProductSpecsByProductAndSpecsApi
} from '#/api/shop';
import { type OrderDTO } from '#/api/ecommerce';
import type { OrderDTO} from '#/api/ecommerce/types';
import type { ShopVO, ProductVO } from '#/api/shop/types';
export interface EntityMatchingResult {
/** 匹配成功的订单数据 */
matchedOrders: OrderDTO.CreateOrderDTO[];
matchedOrders: OrderDTO.Create[];
/** 匹配失败的记录 */
failedRecords: FailedRecord[];
/** 需要创建的实体 */
@@ -54,9 +53,9 @@ export interface CSVOrderData {
}
export class EntityMatchingService {
private shopCache: Map<string, ShopVO.ShopInfoVO> = new Map();
private productCache: Map<string, ProductVO.ProductInfoVO> = new Map();
private specCache: Map<string, ProductVO.ProductSpecInfoVO> = new Map();
private shopCache: Map<string, ShopVO.Info> = new Map();
private productCache: Map<string, ProductVO.Info> = new Map();
private specCache: Map<string, ProductVO.SpecInfo> = new Map();
private orderStatusMap: Map<string, number> = new Map();
constructor() {
@@ -100,7 +99,7 @@ export class EntityMatchingService {
// 批量查询所有实体
await this.loadEntitiesBatch(shopNames, productNames, specQueries);
const matchedOrders: OrderDTO.CreateOrderDTO[] = [];
const matchedOrders: OrderDTO.Create[] = [];
const failedRecords: FailedRecord[] = [];
const entitiesToCreate = {
shops: new Set<string>(),
@@ -184,8 +183,8 @@ export class EntityMatchingService {
}
}
// 创建订单数据(简化结构,直接包含订单明细字段)
const orderData: OrderDTO.CreateOrderDTO = {
// 创建订单数据(新的合并结构)
const orderData: OrderDTO.Create = {
shopId: shop.id,
platformOrderNo: row.orderNumber,
statusId: orderStatusId,
@@ -194,7 +193,12 @@ export class EntityMatchingService {
orderDate: orderDate,
productId: product.id,
productSpecId: spec.id,
productName: row.productName,
specName: row.productSpecName,
quantity: row.quantity,
unitPrice: row.shopActualAmount / row.quantity, // 根据实收金额和数量计算单价
costPrice: spec.costPrice || 0, // 使用规格的成本价
costTotal: (spec.costPrice || 0) * row.quantity, // 成本小计
};
matchedOrders.push(orderData);
@@ -274,21 +278,21 @@ export class EntityMatchingService {
/**
* 获取店铺信息
*/
getShopByName(name: string): ShopVO.ShopInfoVO | undefined {
getShopByName(name: string): ShopVO.Info | undefined {
return this.shopCache.get(name);
}
/**
* 获取商品信息
*/
getProductByName(name: string): ProductVO.ProductInfoVO | undefined {
getProductByName(name: string): ProductVO.Info | undefined {
return this.productCache.get(name);
}
/**
* 获取商品规格信息
*/
getProductSpecByKey(productName: string, specCode: string): ProductVO.ProductSpecInfoVO | undefined {
getProductSpecByKey(productName: string, specCode: string): ProductVO.SpecInfo | undefined {
const key = `${productName}_${specCode}`;
return this.specCache.get(key);
}
@@ -0,0 +1,105 @@
<template>
<Modal
v-model:open="visible"
title="编辑文件信息"
@ok="handleOk"
@cancel="handleCancel"
>
<Form
ref="formRef"
:model="formData"
:label-col="{ span: 6 }"
:wrapper-col="{ span: 18 }"
>
<Form.Item label="标签" name="tags">
<Input
v-model:value="formData.tags"
placeholder="请输入标签,多个标签用逗号分隔"
/>
</Form.Item>
<Form.Item label="描述" name="remark">
<Input.TextArea
v-model:value="formData.remark"
placeholder="请输入文件描述"
:rows="3"
/>
</Form.Item>
</Form>
</Modal>
</template>
<script setup lang="ts">
import { ref, watch } from 'vue'
import { Modal, Form, Input, message } from 'ant-design-vue'
import { updateFileApi } from '#/api/media'
import type { FileDTO, FileVO } from '#/api/media/types'
defineOptions({ name: 'FileEditModal' })
// Props
interface Props {
open: boolean
fileData?: FileVO.Info | null
}
// Emits
interface Emits {
(e: 'update:open', value: boolean): void
(e: 'success'): void
(e: 'cancel'): void
}
const props = defineProps<Props>()
const emit = defineEmits<Emits>()
// 响应式数据
const visible = ref(false)
const formRef = ref()
const formData = ref<FileDTO.Update>({
tags: '',
remark: '',
})
// 监听props变化
watch(() => props.open, (newVal) => {
visible.value = newVal
if (newVal && props.fileData) {
// 填充表单数据
formData.value = {
tags: props.fileData.tags,
remark: props.fileData.remark,
}
}
})
// 监听visible变化,同步到父组件
watch(visible, (newVal) => {
emit('update:open', newVal)
})
// 确认操作
const handleOk = async () => {
try {
await formRef.value?.validate()
if (props.fileData?.id) {
await updateFileApi(props.fileData.id, formData.value)
message.success('更新成功')
emit('success')
visible.value = false
}
} catch (error) {
message.error('更新失败')
}
}
// 取消操作
const handleCancel = () => {
emit('cancel')
visible.value = false
// 重置表单数据
formData.value = {
tags: '',
remark: '',
}
}
</script>
@@ -6,7 +6,6 @@ import {
Button,
Form,
Input,
Modal,
Select,
Table,
Upload,
@@ -17,6 +16,7 @@ import {
Tooltip
} from 'ant-design-vue';
import { createIconifyIcon } from '@vben/icons';
import FileEditModal from './components/FileEditModal.vue';
// 创建图标组件
const UploadIcon = createIconifyIcon('lucide:upload');
@@ -28,55 +28,43 @@ const EyeIcon = createIconifyIcon('lucide:eye');
import {
uploadFileApi,
batchUploadFilesApi,
updateFileApi,
deleteFileApi,
getFilePageApi,
type MediaFileVO,
type MediaFileDTO
} from '#/api/media';
import type { FileVO, FileDTO } from '#/api/media/types';
import type { PageQueryDTO } from '#/types/common';
defineOptions({ name: 'FileRepository' });
// 响应式数据
const loading = ref(false);
const fileList = ref<MediaFileVO.MediaFileInfoVO[]>([]);
const fileList = ref<FileVO.Info[]>([]);
const total = ref(0);
const current = ref(1);
const pageSize = ref(20);
const modalVisible = ref(false);
const modalTitle = ref('');
const isEdit = ref(false);
const currentFileId = ref<number | null>(null);
const formRef = ref();
const editModalVisible = ref(false);
const currentFileData = ref<FileVO.Info | null>(null);
const uploadLoading = ref(false);
// 搜索表单
const searchForm = ref({
filename: '',
fileType: undefined as string | undefined,
fileFormat: undefined as string | undefined,
});
// 表单数据
const formData = ref<MediaFileDTO.UpdateFileDTO>({
id: 0,
fileType: '',
tags: '',
remark: '',
});
// 文件类型选项
const fileTypeOptions = [
{ label: 'PDF', value: 'PDF' },
{ label: 'CAD', value: 'CAD' },
{ label: 'Excel', value: 'Excel' },
{ label: 'Word', value: 'Word' },
{ label: 'PPT', value: 'PPT' },
{ label: '图片', value: '图片' },
{ label: '视频', value: '视频' },
{ label: '音频', value: '音频' },
{ label: '压缩包', value: '压缩包' },
{ label: '其他', value: '其他' },
// 文件格式选项
const fileFormatOptions = [
{ label: 'PDF', value: 'pdf' },
{ label: 'CAD', value: 'cad' },
{ label: 'Excel', value: 'xlsx' },
{ label: 'Word', value: 'doc' },
{ label: 'PPT', value: 'ppt' },
{ label: '图片', value: 'jpg' },
{ label: '视频', value: 'mp4' },
{ label: '音频', value: 'mp3' },
{ label: '压缩包', value: 'zip' },
{ label: '其他', value: 'other' },
];
// 表格列配置
@@ -86,20 +74,20 @@ const columns = [
dataIndex: 'filename',
key: 'filename',
width: 300,
customRender: ({ record }: { record: MediaFileVO.MediaFileInfoVO }) => {
customRender: ({ record }: { record: FileVO.Info }) => {
return h('div', { style: 'display: flex; align-items: center; gap: 8px;' }, [
h('span', { style: 'font-weight: 500;' }, record.filename),
h(Tag, { color: 'blue', size: 'small' }, () => record.fileType || '未知'),
h(Tag, { color: 'blue', size: 'small' }, () => record.fileFormat || '未知'),
]);
},
},
{
title: '文件类型',
dataIndex: 'fileType',
key: 'fileType',
title: '文件格式',
dataIndex: 'fileFormat',
key: 'fileFormat',
width: 120,
customRender: ({ record }: { record: MediaFileVO.MediaFileInfoVO }) => {
return h(Tag, { color: 'blue' }, () => record.fileType || '未知');
customRender: ({ record }: { record: FileVO.Info }) => {
return h(Tag, { color: 'blue' }, () => record.fileFormat || '未知');
},
},
{
@@ -107,7 +95,7 @@ const columns = [
dataIndex: 'tags',
key: 'tags',
width: 200,
customRender: ({ record }: { record: MediaFileVO.MediaFileInfoVO }) => {
customRender: ({ record }: { record: FileVO.Info }) => {
if (!record.tags) return h('span', { style: 'color: #999;' }, '无标签');
const tags = record.tags.split(',').filter(tag => tag.trim());
return h('div', { style: 'display: flex; flex-wrap: wrap; gap: 4px;' },
@@ -120,7 +108,7 @@ const columns = [
dataIndex: 'remark',
key: 'remark',
width: 200,
customRender: ({ record }: { record: MediaFileVO.MediaFileInfoVO }) => {
customRender: ({ record }: { record: FileVO.Info }) => {
if (!record.remark) return h('span', { style: 'color: #999;' }, '无描述');
return h(Tooltip, { title: record.remark }, {
default: () => h('span', {
@@ -140,7 +128,7 @@ const columns = [
key: 'action',
width: 200,
fixed: 'right' as const,
customRender: ({ record }: { record: MediaFileVO.MediaFileInfoVO }) => {
customRender: ({ record }: { record: FileVO.Info }) => {
return h('div', { style: 'display: flex; gap: 8px;' }, [
h(Tooltip, { title: '预览' }, {
default: () => h(Button, {
@@ -195,12 +183,12 @@ const filteredFileList = computed(() => fileList.value);
const loadFileList = async () => {
loading.value = true;
try {
const params: PageQueryDTO<MediaFileDTO.MediaFileFilterDTO> = {
const params: PageQueryDTO<FileDTO.Filters> = {
page: current.value,
pageSize: pageSize.value,
filters: {
filename: searchForm.value.filename || undefined,
fileType: searchForm.value.fileType || undefined,
fileFormat: searchForm.value.fileFormat || undefined,
}
};
@@ -222,7 +210,7 @@ const handleSearch = () => {
const handleReset = () => {
searchForm.value = {
filename: '',
fileType: undefined,
fileFormat: undefined,
};
handleSearch();
};
@@ -253,24 +241,16 @@ const handleBatchUpload = async (files: File[]) => {
}
};
const handleEdit = (record: MediaFileVO.MediaFileInfoVO) => {
isEdit.value = true;
modalTitle.value = '编辑文件信息';
currentFileId.value = record.id;
formData.value = {
id: record.id,
fileType: record.fileType,
tags: record.tags,
remark: record.remark,
};
modalVisible.value = true;
const handleEdit = (record: FileVO.Info) => {
currentFileData.value = record;
editModalVisible.value = true;
};
const handlePreview = (record: MediaFileVO.MediaFileInfoVO) => {
const handlePreview = (record: FileVO.Info) => {
window.open(record.url, '_blank');
};
const handleDownload = (record: MediaFileVO.MediaFileInfoVO) => {
const handleDownload = (record: FileVO.Info) => {
const link = document.createElement('a');
link.href = record.url;
link.download = record.filename;
@@ -287,26 +267,8 @@ const handleDelete = async (id: number) => {
}
};
const handleModalOk = async () => {
try {
await formRef.value?.validate();
await updateFileApi(formData.value);
message.success('更新成功');
modalVisible.value = false;
loadFileList();
} catch (error) {
message.error('更新失败');
}
};
const handleModalCancel = () => {
modalVisible.value = false;
formData.value = {
id: 0,
fileType: '',
tags: '',
remark: '',
};
const handleEditSuccess = () => {
loadFileList();
};
// 上传配置
@@ -350,15 +312,15 @@ loadFileList();
@press-enter="handleSearch"
/>
</Form.Item>
<Form.Item label="文件类型">
<Form.Item label="文件格式">
<Select
v-model:value="searchForm.fileType"
placeholder="请选择文件类型"
v-model:value="searchForm.fileFormat"
placeholder="请选择文件格式"
style="width: 150px"
allow-clear
>
<Select.Option
v-for="option in fileTypeOptions"
v-for="option in fileFormatOptions"
:key="option.value"
:value="option.value"
>
@@ -411,44 +373,12 @@ loadFileList();
</div>
<!-- 编辑弹窗 -->
<Modal
v-model:open="modalVisible"
:title="modalTitle"
@ok="handleModalOk"
@cancel="handleModalCancel"
>
<Form
ref="formRef"
:model="formData"
:label-col="{ span: 6 }"
:wrapper-col="{ span: 18 }"
>
<Form.Item label="文件类型" name="fileType">
<Select v-model:value="formData.fileType" placeholder="请选择文件类型">
<Select.Option
v-for="option in fileTypeOptions"
:key="option.value"
:value="option.value"
>
{{ option.label }}
</Select.Option>
</Select>
</Form.Item>
<Form.Item label="标签" name="tags">
<Input
v-model:value="formData.tags"
placeholder="请输入标签,多个标签用逗号分隔"
/>
</Form.Item>
<Form.Item label="描述" name="remark">
<Input.TextArea
v-model:value="formData.remark"
placeholder="请输入文件描述"
:rows="3"
/>
</Form.Item>
</Form>
</Modal>
<FileEditModal
v-model:open="editModalVisible"
:file-data="currentFileData"
@success="handleEditSuccess"
@cancel="editModalVisible = false"
/>
</Page>
</template>
@@ -1,7 +1,7 @@
<script lang="ts" setup>
import { Card, Image, Tag, Button, Space, Popconfirm } from 'ant-design-vue';
import { createIconifyIcon } from '@vben/icons';
import type { MediaImageVO } from '#/api/media';
import type { ImageVO } from '#/api/media/types';
// 创建图标组件
const DownloadIcon = createIconifyIcon('lucide:download');
@@ -9,23 +9,23 @@ const EditIcon = createIconifyIcon('lucide:edit');
const TrashIcon = createIconifyIcon('lucide:trash-2');
interface Props {
image: MediaImageVO.MediaImageInfoVO;
image: ImageVO.Info;
}
interface Emits {
(e: 'download', image: MediaImageVO.MediaImageInfoVO): void;
(e: 'edit', image: MediaImageVO.MediaImageInfoVO): void;
(e: 'download', image: ImageVO.Info): void;
(e: 'edit', image: ImageVO.Info): void;
(e: 'delete', id: number): void;
}
defineProps<Props>();
const emit = defineEmits<Emits>();
const handleDownload = (image: MediaImageVO.MediaImageInfoVO) => {
const handleDownload = (image: ImageVO.Info) => {
emit('download', image);
};
const handleEdit = (image: MediaImageVO.MediaImageInfoVO) => {
const handleEdit = (image: ImageVO.Info) => {
emit('edit', image);
};
@@ -33,15 +33,13 @@ const handleDelete = (id: number) => {
emit('delete', id);
};
const getTagColor = (type: string | undefined) => {
switch (type) {
case '设计图':
const getTagColor = (category: string | undefined) => {
switch (category) {
case 'image':
return 'blue';
case '实物图':
case 'avatar':
return 'green';
case '细节图':
return 'orange';
case '工艺图':
case 'logo':
return 'purple';
default:
return '#006BE6';
@@ -55,22 +53,26 @@ const getTagColor = (type: string | undefined) => {
:body-style="{ padding: '8px' }"
class="image-card"
>
<div class="relative">
<div class="relative overflow-hidden">
<Image
:src="image.url"
:alt="image.filename"
class="w-full h-32 object-cover rounded"
:preview="true"
/>
<div class="absolute top-2 right-2">
<Tag :color="getTagColor(image.type)">
{{ image.type || '未分类' }}
<div v-if="image.tags" class="absolute top-2 right-2 max-w-[calc(100%-16px)]">
<Tag
:color="getTagColor(image.category)"
class="max-w-full truncate"
:title="image.tags"
>
{{ image.tags }}
</Tag>
</div>
</div>
<div class="mt-2">
<div class="text-sm font-medium truncate" :title="image.filename">
{{ image.filename }}
{{ image.filename || '未命名' }}
</div>
<div class="text-xs text-gray-500 mt-1">
{{ image.uploadTime }}
@@ -0,0 +1,106 @@
<template>
<Modal
v-model:open="visible"
title="编辑图片信息"
@ok="handleOk"
@cancel="handleCancel"
>
<Form
ref="formRef"
:model="formData"
:label-col="{ span: 6 }"
:wrapper-col="{ span: 18 }"
>
<Form.Item label="标签" name="tags">
<Input
v-model:value="formData.tags"
placeholder="请输入标签,多个标签用逗号分隔"
/>
</Form.Item>
<Form.Item label="说明" name="remark">
<Input.TextArea
v-model:value="formData.remark"
placeholder="请输入图片说明"
:rows="3"
/>
</Form.Item>
</Form>
</Modal>
</template>
<script setup lang="ts">
import { ref, watch } from 'vue'
import { Modal, Form, Input, message } from 'ant-design-vue'
import { updateImageApi } from '#/api/media'
import type { ImageDTO, ImageVO } from '#/api/media/types'
defineOptions({ name: 'ImageEditModal' })
// Props
interface Props {
open: boolean
imageData?: ImageVO.Info | null
}
// Emits
interface Emits {
(e: 'update:open', value: boolean): void
(e: 'success'): void
(e: 'cancel'): void
}
const props = defineProps<Props>()
const emit = defineEmits<Emits>()
// 响应式数据
const visible = ref(false)
const formRef = ref()
const formData = ref<ImageDTO.Update>({
tags: '',
remark: '',
})
// 监听props变化
watch(() => props.open, (newVal) => {
visible.value = newVal
if (newVal && props.imageData) {
// 填充表单数据
formData.value = {
tags: props.imageData.tags,
remark: props.imageData.remark,
}
}
})
// 监听visible变化,同步到父组件
watch(visible, (newVal) => {
emit('update:open', newVal)
})
// 确认操作
const handleOk = async () => {
try {
await formRef.value?.validate()
if (props.imageData?.id) {
await updateImageApi(props.imageData.id, formData.value)
message.success('更新成功')
emit('success')
visible.value = false
}
} catch (error) {
message.error('更新失败')
}
}
// 取消操作
const handleCancel = () => {
emit('cancel')
visible.value = false
// 重置表单数据
formData.value = {
tags: '',
remark: '',
}
}
</script>
@@ -0,0 +1,272 @@
<template>
<div class="image-grid-view h-full">
<!-- 工具栏 -->
<div class="mb-4 flex justify-between items-center">
<div class="flex items-center gap-4">
<Upload v-bind="uploadProps">
<Button type="primary" :loading="uploadLoading">
<UploadIcon class="w-4 h-4 mr-2" />
上传图片
</Button>
</Upload>
<span class="text-gray-500">支持批量上传,单个图片最大10MB</span>
</div>
<div class="text-gray-500">
共 {{ total }} 张图片
</div>
</div>
<!-- 搜索区域 -->
<div class="mb-4 p-4 bg-white rounded-lg shadow-sm">
<Form :model="searchForm" layout="inline">
<Form.Item label="文件名">
<Input
v-model:value="searchForm.filename"
placeholder="请输入文件名"
style="width: 200px"
@press-enter="handleSearch"
/>
</Form.Item>
<Form.Item label="图片分类">
<Select
v-model:value="searchForm.category"
placeholder="请选择图片分类"
style="width: 150px"
allow-clear
>
<Select.Option
v-for="option in categoryOptions"
:key="option.value"
:value="option.value"
>
{{ option.label }}
</Select.Option>
</Select>
</Form.Item>
<Form.Item>
<Space>
<Button type="primary" @click="handleSearch">搜索</Button>
<Button @click="handleReset">重置</Button>
</Space>
</Form.Item>
</Form>
</div>
<!-- 网格内容 -->
<div class="bg-white rounded-lg shadow-sm p-4">
<Row :gutter="[16, 16]" v-loading="loading">
<Col
v-for="image in imageList"
:key="image.id"
:xs="12"
:sm="8"
:md="6"
:lg="4"
:xl="3"
>
<ImageCard
:image="image"
@download="handleDownload"
@edit="handleEdit"
@delete="handleDelete"
@preview="handlePreview"
/>
</Col>
</Row>
<!-- 空状态 -->
<div v-if="!loading && imageList.length === 0" class="text-center py-12">
<div class="text-gray-400 text-lg">暂无图片数据</div>
<div class="text-gray-400 text-sm mt-2">请上传图片或调整搜索条件</div>
</div>
<!-- 分页 -->
<div v-if="total > 0" class="mt-4 flex justify-center">
<Pagination
v-model:current="current"
v-model:page-size="pageSize"
:total="total"
:page-size-options="['12', '24', '48', '96']"
show-size-changer
show-quick-jumper
:show-total="(total, range) => `第 ${range[0]}-${range[1]} 条,共 ${total} 条`"
@change="handlePageChange"
/>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, watch } from 'vue'
import { Form, Input, Select, Button, Space, Row, Col, Pagination, Upload, message } from 'ant-design-vue'
import { createIconifyIcon } from '@vben/icons'
import { getImagePageApi, uploadImageApi, batchUploadImagesApi } from '#/api/media'
import type { ImageVO, ImageDTO } from '#/api/media/types'
import type { PageQueryDTO } from '#/types/common'
import ImageCard from './ImageCard.vue'
// 创建图标组件
const UploadIcon = createIconifyIcon('lucide:upload')
defineOptions({ name: 'ImageGridView' })
// Props
interface Props {
searchForm: {
filename: string
category?: string
}
categoryOptions: Array<{ label: string; value: string }>
}
// Emits
interface Emits {
(e: 'edit', image: ImageVO.Info): void
(e: 'delete', id: number): void
(e: 'download', image: ImageVO.Info): void
(e: 'preview', image: ImageVO.Info): void
}
const props = defineProps<Props>()
const emit = defineEmits<Emits>()
// 响应式数据
const loading = ref(false)
const uploadLoading = ref(false)
const imageList = ref<ImageVO.Info[]>([])
const total = ref(0)
const current = ref(1)
const pageSize = ref(24) // 网格视图默认24个
// 监听搜索表单变化
watch(() => props.searchForm, () => {
current.value = 1
loadImageList()
}, { deep: true })
// 加载图片列表
const loadImageList = async () => {
loading.value = true
try {
const params: PageQueryDTO<ImageDTO.Filters> = {
page: current.value,
pageSize: pageSize.value,
filters: {
filename: props.searchForm.filename || undefined,
category: props.searchForm.category || undefined,
}
}
const response = await getImagePageApi(params)
imageList.value = response.records
total.value = response.total
} catch (error) {
message.error('加载图片列表失败')
} finally {
loading.value = false
}
}
// 搜索
const handleSearch = () => {
current.value = 1
loadImageList()
}
// 重置
const handleReset = () => {
props.searchForm.filename = ''
props.searchForm.category = undefined
handleSearch()
}
// 分页变化
const handlePageChange = (page: number, size: number) => {
current.value = page
pageSize.value = size
loadImageList()
}
// 上传配置
const uploadProps = {
multiple: true,
showUploadList: false,
accept: 'image/*',
beforeUpload: (file: any) => {
const isImage = file.type.startsWith('image/');
if (!isImage) {
message.error('只能上传图片文件');
return false;
}
const isValidSize = file.size / 1024 / 1024 < 10; // 10MB
if (!isValidSize) {
message.error('图片大小不能超过 10MB');
return false;
}
return true;
},
customRequest: (options: any) => {
const { file } = options;
if (Array.isArray(file)) {
handleBatchUpload(file);
} else {
handleUpload(file);
}
},
};
// 处理上传
const handleUpload = async (file: File) => {
uploadLoading.value = true;
try {
await uploadImageApi(file);
message.success('图片上传成功');
loadImageList();
} catch (error) {
message.error('图片上传失败');
} finally {
uploadLoading.value = false;
}
};
// 处理批量上传
const handleBatchUpload = async (files: File[]) => {
uploadLoading.value = true;
try {
await batchUploadImagesApi(files);
message.success(`成功上传 ${files.length} 张图片`);
loadImageList();
} catch (error) {
message.error('批量上传失败');
} finally {
uploadLoading.value = false;
}
};
// 事件处理
const handleEdit = (image: ImageVO.Info) => {
emit('edit', image)
}
const handleDelete = (id: number) => {
emit('delete', id)
}
const handleDownload = (image: ImageVO.Info) => {
emit('download', image)
}
const handlePreview = (image: ImageVO.Info) => {
emit('preview', image)
}
// 初始化
loadImageList()
</script>
<style scoped>
.image-grid-view {
width: 100%;
}
</style>
@@ -1,256 +1,196 @@
<script lang="ts" setup>
import { h, ref, computed } from 'vue';
import { ref, computed } from 'vue';
import { Page } from '@vben/common-ui';
import {
Button,
Form,
Input,
Modal,
Select,
Table,
Upload,
message,
Tag,
Space,
Popconfirm,
Tooltip,
Image,
Row,
Col
} from 'ant-design-vue';
import { Button, message, Space, Tag, Upload, Image } from 'ant-design-vue';
import { createIconifyIcon } from '@vben/icons';
import ImageCard from './components/ImageCard.vue';
// 创建图标组件
const EyeIcon = createIconifyIcon('lucide:eye');
const DownloadIcon = createIconifyIcon('lucide:download');
const EditIcon = createIconifyIcon('lucide:edit');
const TrashIcon = createIconifyIcon('lucide:trash-2');
const UploadIcon = createIconifyIcon('lucide:upload');
const GridIcon = createIconifyIcon('lucide:grid-3x3');
const ListIcon = createIconifyIcon('lucide:list');
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import type { VxeGridProps } from '#/adapter/vxe-table';
import {
uploadImageApi,
batchUploadImagesApi,
updateImageApi,
deleteImageApi,
getImagePageApi,
type MediaImageVO,
type MediaImageDTO
} from '#/api/media';
import type { ImageVO, ImageDTO } from '#/api/media/types';
import type { PageQueryDTO } from '#/types/common';
import ImageEditModal from './components/ImageEditModal.vue';
import ImageGridView from './components/ImageGridView.vue';
// 创建图标组件
const UploadIcon = createIconifyIcon('lucide:upload');
const GridIcon = createIconifyIcon('lucide:grid-3x3');
const ListIcon = createIconifyIcon('lucide:list');
defineOptions({ name: 'ImageRepository' });
// 响应式数据
const loading = ref(false);
const imageList = ref<MediaImageVO.MediaImageInfoVO[]>([]);
const total = ref(0);
const current = ref(1);
const pageSize = ref(20);
const modalVisible = ref(false);
const modalTitle = ref('');
const isEdit = ref(false);
const currentImageId = ref<number | null>(null);
const formRef = ref();
const editModalVisible = ref(false);
const currentImageData = ref<ImageVO.Info | null>(null);
const uploadLoading = ref(false);
const viewMode = ref<'grid' | 'list'>('grid'); // 视图模式:网格或列表
const viewMode = ref<'grid' | 'list'>('grid'); // 默认使用网格视图
// 搜索表单
const searchForm = ref({
filename: '',
type: undefined as string | undefined,
});
// 表单数据
const formData = ref<MediaImageDTO.UpdateImageDTO>({
id: 0,
type: '',
tags: '',
remark: '',
category: undefined as string | undefined,
});
// 图片分类选项
const imageTypeOptions = [
{ label: '设计图', value: '设计图' },
{ label: '实物图', value: '实物图' },
{ label: '细节图', value: '细节图' },
{ label: '工艺图', value: '工艺图' },
{ label: '其他', value: '其他' },
const imageCategoryOptions = [
{ label: '普通图片', value: 'image' },
{ label: '头像', value: 'avatar' },
{ label: 'Logo', value: 'logo' },
];
// 表格列配置
const columns = [
{
title: '预览',
dataIndex: 'url',
key: 'preview',
width: 100,
customRender: ({ record }: { record: MediaImageVO.MediaImageInfoVO }) => {
return h(Image, {
src: record.url,
alt: record.filename,
width: 60,
height: 60,
style: { objectFit: 'cover', borderRadius: '4px' },
preview: true,
});
// VbenVxeGrid 表格配置
const gridOptions: VxeGridProps<any> = {
columns: [
{
type: 'seq' as const,
minWidth: 'auto',
title: '序号',
},
{
title: '预览',
minWidth: 'auto',
slots: { default: 'preview' },
},
{
field: 'filename',
title: '文件名',
minWidth: 'auto',
showOverflow: 'tooltip' as const,
},
{
title: '分类',
minWidth: 'auto',
slots: { default: 'category' },
},
{
title: '标签',
minWidth: 'auto',
slots: { default: 'tags' },
},
{
field: 'remark',
title: '说明',
minWidth: 'auto',
showOverflow: 'tooltip' as const,
},
{
field: 'uploadTime',
title: '上传时间',
minWidth: 'auto',
},
{
title: '操作',
minWidth: 'auto',
fixed: 'right' as const,
slots: { default: 'action' },
},
],
height: 'auto',
border: true,
stripe: true,
showOverflow: true,
size: 'small',
toolbarConfig: {
custom: true,
refresh: true,
zoom: true,
},
data: [],
pagerConfig: {
enabled: true,
pageSizes: [10, 20, 50, 100],
layouts: ['PrevJump', 'PrevPage', 'Number', 'NextPage', 'NextJump', 'Sizes', 'FullJump', 'Total'] as ('PrevJump' | 'PrevPage' | 'Number' | 'NextPage' | 'NextJump' | 'Sizes' | 'FullJump' | 'Total')[],
},
// 配置远程加载
proxyConfig: {
ajax: {
query: async ({ page }) => {
try {
loading.value = true;
const params: PageQueryDTO<ImageDTO.Filters> = {
page: page.currentPage,
pageSize: page.pageSize,
filters: {
filename: searchForm.value.filename || undefined,
category: searchForm.value.category || undefined,
},
};
const data = await getImagePageApi(params);
return {
items: data.records,
total: data.total,
};
} catch (error) {
console.error('获取图片列表失败:', error);
message.error('获取图片列表失败');
return {
items: [],
total: 0,
};
} finally {
loading.value = false;
}
},
},
},
{
title: '文件名',
dataIndex: 'filename',
key: 'filename',
width: 250,
customRender: ({ record }: { record: MediaImageVO.MediaImageInfoVO }) => {
return h('div', { style: 'display: flex; align-items: center; gap: 8px;' }, [
h('span', { style: 'font-weight: 500;' }, record.filename),
h(Tag, { color: 'purple', size: 'small' }, () => record.type || '未分类'),
]);
},
},
{
title: '分类',
dataIndex: 'type',
key: 'type',
width: 120,
customRender: ({ record }: { record: MediaImageVO.MediaImageInfoVO }) => {
return h(Tag, { color: 'purple' }, () => record.type || '未分类');
},
},
{
title: '标签',
dataIndex: 'tags',
key: 'tags',
width: 200,
customRender: ({ record }: { record: MediaImageVO.MediaImageInfoVO }) => {
if (!record.tags) return h('span', { style: 'color: #999;' }, '无标签');
const tags = record.tags.split(',').filter(tag => tag.trim());
return h('div', { style: 'display: flex; flex-wrap: wrap; gap: 4px;' },
tags.map(tag => h(Tag, { color: 'green', size: 'small' }, () => tag.trim()))
);
},
},
{
title: '说明',
dataIndex: 'remark',
key: 'remark',
width: 200,
customRender: ({ record }: { record: MediaImageVO.MediaImageInfoVO }) => {
if (!record.remark) return h('span', { style: 'color: #999;' }, '无说明');
return h(Tooltip, { title: record.remark }, {
default: () => h('span', {
style: 'display: block; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;'
}, record.remark)
});
},
},
{
title: '上传时间',
dataIndex: 'uploadTime',
key: 'uploadTime',
width: 180,
},
{
title: '操作',
key: 'action',
width: 200,
fixed: 'right' as const,
customRender: ({ record }: { record: MediaImageVO.MediaImageInfoVO }) => {
return h('div', { style: 'display: flex; gap: 8px;' }, [
h(Tooltip, { title: '预览' }, {
default: () => h(Button, {
type: 'text',
size: 'small',
onClick: () => handlePreview(record),
}, {
default: () => h(EyeIcon, { class: 'w-4 h-4' })
})
}),
h(Tooltip, { title: '下载' }, {
default: () => h(Button, {
type: 'text',
size: 'small',
onClick: () => handleDownload(record),
}, {
default: () => h(DownloadIcon, { class: 'w-4 h-4' })
})
}),
h(Tooltip, { title: '编辑' }, {
default: () => h(Button, {
type: 'text',
size: 'small',
onClick: () => handleEdit(record),
}, {
default: () => h(EditIcon, { class: 'w-4 h-4' })
})
}),
h(Tooltip, { title: '删除' }, {
default: () => h(Popconfirm, {
title: '确定要删除这张图片吗?',
onConfirm: () => handleDelete(record.id),
}, {
default: () => h(Button, {
type: 'text',
size: 'small',
danger: true,
}, {
default: () => h(TrashIcon, { class: 'w-4 h-4' })
})
})
}),
]);
},
},
];
};
// 计算属性 - 由于使用后端分页,不再需要前端过滤
const filteredImageList = computed(() => imageList.value);
// 搜索表单配置
const formOptions = computed(() => ({
schema: [
{
component: 'Input',
componentProps: {
placeholder: '请输入文件名',
},
fieldName: 'filename',
label: '文件名',
},
{
component: 'Select',
componentProps: {
placeholder: '请选择图片分类',
options: imageCategoryOptions,
allowClear: true,
},
fieldName: 'category',
label: '图片分类',
},
],
showDefaultActions: true,
collapsed: true,
collapsedRows: 1,
}));
// 方法
const loadImageList = async () => {
loading.value = true;
try {
const params: PageQueryDTO<MediaImageDTO.MediaImageFilterDTO> = {
page: current.value,
pageSize: pageSize.value,
filters: {
filename: searchForm.value.filename || undefined,
type: searchForm.value.type || undefined,
}
};
const response = await getImagePageApi(params);
imageList.value = response.records;
total.value = response.total;
} catch (error) {
message.error('加载图片列表失败');
} finally {
loading.value = false;
// 刷新表格数据
function refreshTable() {
if (gridApi) {
gridApi.reload();
}
};
}
const handleSearch = () => {
current.value = 1;
loadImageList();
};
const handleReset = () => {
searchForm.value = {
filename: '',
type: undefined,
};
handleSearch();
};
// 创建 VbenVxeGrid 实例
const [Grid, gridApi] = useVbenVxeGrid({
gridOptions,
formOptions: formOptions.value,
showSearchForm: true,
tableTitle: '图片管理',
});
// 处理上传
const handleUpload = async (file: File) => {
uploadLoading.value = true;
try {
await uploadImageApi(file);
message.success('图片上传成功');
loadImageList();
refreshTable();
} catch (error) {
message.error('图片上传失败');
} finally {
@@ -258,12 +198,13 @@ const handleUpload = async (file: File) => {
}
};
// 处理批量上传
const handleBatchUpload = async (files: File[]) => {
uploadLoading.value = true;
try {
await batchUploadImagesApi(files);
message.success(`成功上传 ${files.length} 张图片`);
loadImageList();
refreshTable();
} catch (error) {
message.error('批量上传失败');
} finally {
@@ -271,62 +212,42 @@ const handleBatchUpload = async (files: File[]) => {
}
};
const handleEdit = (record: MediaImageVO.MediaImageInfoVO) => {
isEdit.value = true;
modalTitle.value = '编辑图片信息';
currentImageId.value = record.id;
formData.value = {
id: record.id,
type: record.type,
tags: record.tags,
remark: record.remark,
};
modalVisible.value = true;
// 处理编辑
const handleEdit = (record: ImageVO.Info) => {
currentImageData.value = record;
editModalVisible.value = true;
};
const handlePreview = (record: MediaImageVO.MediaImageInfoVO) => {
// 处理预览
const handlePreview = (record: ImageVO.Info) => {
window.open(record.url, '_blank');
};
const handleDownload = (record: MediaImageVO.MediaImageInfoVO) => {
// 处理下载
const handleDownload = (record: ImageVO.Info) => {
const link = document.createElement('a');
link.href = record.url;
link.download = record.filename;
link.download = record.filename || '未命名';
link.click();
};
// 处理删除
const handleDelete = async (id: number) => {
try {
await deleteImageApi(id);
message.success('删除成功');
loadImageList();
refreshTable();
} catch (error) {
message.error('删除失败');
}
};
const handleModalOk = async () => {
try {
await formRef.value?.validate();
await updateImageApi(formData.value);
message.success('更新成功');
modalVisible.value = false;
loadImageList();
} catch (error) {
message.error('更新失败');
}
};
const handleModalCancel = () => {
modalVisible.value = false;
formData.value = {
id: 0,
type: '',
tags: '',
remark: '',
};
// 处理编辑成功
const handleEditSuccess = () => {
refreshTable();
};
// 切换视图模式
const toggleViewMode = () => {
viewMode.value = viewMode.value === 'grid' ? 'list' : 'grid';
};
@@ -359,62 +280,51 @@ const uploadProps = {
},
};
// 初始化
loadImageList();
// 获取分类标签颜色
const getCategoryColor = (category: string | undefined) => {
switch (category) {
case 'image':
return 'blue';
case 'avatar':
return 'green';
case 'logo':
return 'purple';
default:
return 'default';
}
};
// 获取分类显示文本
const getCategoryText = (category: string | undefined) => {
switch (category) {
case 'image':
return '普通图片';
case 'avatar':
return '头像';
case 'logo':
return 'Logo';
default:
return '未分类';
}
};
// 获取标签列表
const getTagList = (tags: string | undefined) => {
if (!tags) return [];
return tags.split(',').map(tag => tag.trim()).filter(tag => tag);
};
</script>
<template>
<Page>
<template #title>图片仓库</template>
<!-- 搜索区域 -->
<div class="mb-4 p-4 bg-white rounded-lg shadow-sm">
<Form :model="searchForm" layout="inline">
<Form.Item label="文件名">
<Input
v-model:value="searchForm.filename"
placeholder="请输入文件名"
style="width: 200px"
@press-enter="handleSearch"
/>
</Form.Item>
<Form.Item label="图片分类">
<Select
v-model:value="searchForm.type"
placeholder="请选择图片分类"
style="width: 150px"
allow-clear
>
<Select.Option
v-for="option in imageTypeOptions"
:key="option.value"
:value="option.value"
>
{{ option.label }}
</Select.Option>
</Select>
</Form.Item>
<Form.Item>
<Space>
<Button type="primary" @click="handleSearch">搜索</Button>
<Button @click="handleReset">重置</Button>
</Space>
</Form.Item>
</Form>
</div>
<!-- 操作区域 -->
<div class="mb-4 flex justify-between items-center">
<div class="flex items-center gap-4">
<Upload v-bind="uploadProps">
<Button type="primary" :loading="uploadLoading">
<UploadIcon class="w-4 h-4 mr-2" />
上传图片
</Button>
</Upload>
<span class="text-gray-500">支持批量上传,单个图片最大10MB</span>
<Page title="图片仓库" auto-content-height>
<template #description>
<div class="text-foreground/80 mt-2">
管理图片资源,支持上传、预览、编辑和分类管理
</div>
<div class="flex items-center gap-4">
</template>
<template #extra>
<Space>
<Button
:type="viewMode === 'grid' ? 'primary' : 'default'"
@click="toggleViewMode"
@@ -429,92 +339,95 @@ loadImageList();
<ListIcon class="w-4 h-4 mr-2" />
列表视图
</Button>
<span class="text-gray-500">
共 {{ total }} 张图片
</span>
</div>
</div>
<!-- 网格视图 -->
<div v-if="viewMode === 'grid'" class="bg-white rounded-lg shadow-sm p-4">
<Row :gutter="[16, 16]">
<Col
v-for="image in filteredImageList"
:key="image.id"
:xs="12"
:sm="8"
:md="6"
:lg="4"
:xl="3"
>
<ImageCard
:image="image"
@download="handleDownload"
@edit="handleEdit"
@delete="handleDelete"
/>
</Col>
</Row>
</div>
</Space>
</template>
<!-- 列表视图 -->
<div v-else class="bg-white rounded-lg shadow-sm">
<Table
:columns="columns"
:data-source="filteredImageList"
:loading="loading"
:pagination="{
current: current,
pageSize: pageSize,
total: total,
showSizeChanger: true,
showQuickJumper: true,
showTotal: (total, range) => `第 ${range[0]}-${range[1]} 条,共 ${total} 条`,
}"
row-key="id"
:scroll="{ x: 1200 }"
/>
</div>
<Grid
v-if="viewMode === 'list'"
:loading="loading"
>
<!-- 工具栏工具 -->
<template #toolbar-tools>
<Space>
<Upload v-bind="uploadProps">
<Button type="primary" :loading="uploadLoading">
<UploadIcon class="w-4 h-4 mr-2" />
上传图片
</Button>
</Upload>
<span class="text-gray-500">支持批量上传,单个图片最大10MB</span>
</Space>
</template>
<!-- 预览列 -->
<template #preview="{ row }: { row: any }">
<Image
:src="row.url"
:alt="row.filename"
width="60"
height="60"
style="object-fit: cover; border-radius: 4px;"
:preview="true"
/>
</template>
<!-- 分类列 -->
<template #category="{ row }: { row: any }">
<Tag :color="getCategoryColor(row.category)">
{{ getCategoryText(row.category) }}
</Tag>
</template>
<!-- 标签列 -->
<template #tags="{ row }: { row: any }">
<div v-if="row.tags" class="flex flex-wrap gap-1">
<Tag
v-for="tag in getTagList(row.tags)"
:key="tag"
size="small"
color="blue"
>
{{ tag }}
</Tag>
</div>
<span v-else class="text-gray-400">无标签</span>
</template>
<!-- 操作列 -->
<template #action="{ row }: { row: any }">
<Space>
<Button size="small" @click="handleDownload(row)">
下载
</Button>
<Button size="small" @click="handleEdit(row)">
编辑
</Button>
<Button size="small" danger @click="handleDelete(row.id)">
删除
</Button>
</Space>
</template>
</Grid>
<!-- 网格视图 -->
<ImageGridView
v-else
:search-form="searchForm"
:category-options="imageCategoryOptions"
@edit="handleEdit"
@delete="handleDelete"
@download="handleDownload"
@preview="handlePreview"
/>
<!-- 编辑弹窗 -->
<Modal
v-model:open="modalVisible"
:title="modalTitle"
@ok="handleModalOk"
@cancel="handleModalCancel"
>
<Form
ref="formRef"
:model="formData"
:label-col="{ span: 6 }"
:wrapper-col="{ span: 18 }"
>
<Form.Item label="图片分类" name="type">
<Select v-model:value="formData.type" placeholder="请选择图片分类">
<Select.Option
v-for="option in imageTypeOptions"
:key="option.value"
:value="option.value"
>
{{ option.label }}
</Select.Option>
</Select>
</Form.Item>
<Form.Item label="标签" name="tags">
<Input
v-model:value="formData.tags"
placeholder="请输入标签,多个标签用逗号分隔"
/>
</Form.Item>
<Form.Item label="说明" name="remark">
<Input.TextArea
v-model:value="formData.remark"
placeholder="请输入图片说明"
:rows="3"
/>
</Form.Item>
</Form>
</Modal>
<ImageEditModal
v-model:open="editModalVisible"
:image-data="currentImageData"
@success="handleEditSuccess"
@cancel="editModalVisible = false"
/>
</Page>
</template>
@@ -6,10 +6,10 @@ import { Modal, Form, Input, InputNumber, Switch, message } from 'ant-design-vue
import {
createOrderStatusApi,
updateOrderStatusApi,
type OrderStatusDTO,
type OrderStatusVO
} from '#/api/ecommerce';
import type { OrderStatusDTO, OrderStatusVO } from '#/api/ecommerce/types';
defineProps<{
visible?: boolean;
}>();
@@ -23,11 +23,10 @@ const emit = defineEmits<{
const visible = ref(false);
const loading = ref(false);
const isEdit = ref(false);
const currentRecord = ref<OrderStatusVO.OrderStatusInfoVO | null>(null);
const currentRecord = ref<OrderStatusVO.Info | null>(null);
// 表单数据
const formData = ref<Partial<OrderStatusDTO.CreateOrderStatusDTO>>({
statusCode: 0,
const formData = ref<Partial<OrderStatusDTO.Create>>({
statusName: '',
description: '',
isActive: 1,
@@ -36,7 +35,6 @@ const formData = ref<Partial<OrderStatusDTO.CreateOrderStatusDTO>>({
// 表单验证规则
const rules = {
statusCode: [{ required: true, message: '请输入状态码', trigger: 'blur' }],
statusName: [{ required: true, message: '请输入状态名称', trigger: 'blur' }],
sortOrder: [{ required: true, message: '请输入排序', trigger: 'blur' }],
};
@@ -45,7 +43,7 @@ const rules = {
const formRef = ref();
// 打开模态框
function open(edit: boolean, record?: OrderStatusVO.OrderStatusInfoVO) {
function open(edit: boolean, record?: OrderStatusVO.Info) {
isEdit.value = edit;
currentRecord.value = record || null;
visible.value = true;
@@ -53,7 +51,6 @@ function open(edit: boolean, record?: OrderStatusVO.OrderStatusInfoVO) {
if (edit && record) {
// 编辑模式,填充表单数据
formData.value = {
statusCode: record.statusCode,
statusName: record.statusName,
description: record.description || '',
isActive: record.isActive,
@@ -62,7 +59,6 @@ function open(edit: boolean, record?: OrderStatusVO.OrderStatusInfoVO) {
} else {
// 新增模式,重置表单
formData.value = {
statusCode: 0,
statusName: '',
description: '',
isActive: 1,
@@ -86,9 +82,8 @@ async function handleSubmit() {
if (isEdit.value && currentRecord.value) {
// 更新订单状态
const updateData: OrderStatusDTO.UpdateOrderStatusDTO = {
const updateData: OrderStatusDTO.Update = {
id: currentRecord.value.id,
statusCode: formData.value.statusCode!,
statusName: formData.value.statusName!,
description: formData.value.description,
isActive: formData.value.isActive,
@@ -98,8 +93,7 @@ async function handleSubmit() {
message.success('更新订单状态成功');
} else {
// 创建订单状态
const createData: OrderStatusDTO.CreateOrderStatusDTO = {
statusCode: formData.value.statusCode!,
const createData: OrderStatusDTO.Create = {
statusName: formData.value.statusName!,
description: formData.value.description,
isActive: formData.value.isActive,
@@ -112,8 +106,7 @@ async function handleSubmit() {
close();
emit('success');
} catch (error) {
console.error('提交订单状态失败:', error);
message.error('提交订单状态失败');
console.error('提交订单状态失败:', ( error as any).message );
} finally {
loading.value = false;
}
@@ -149,15 +142,6 @@ defineExpose({
layout="vertical"
>
<div class="grid grid-cols-2 gap-4">
<Form.Item label="状态码" name="statusCode">
<InputNumber
v-model:value="formData.statusCode"
placeholder="请输入状态码"
style="width: 100%"
:min="0"
/>
</Form.Item>
<Form.Item label="状态名称" name="statusName">
<Input
v-model:value="formData.statusName"
@@ -10,8 +10,8 @@ import type { VxeGridProps } from '#/adapter/vxe-table';
import {
deleteOrderStatusApi,
getAllOrderStatusListApi,
type OrderStatusVO
} from '#/api/ecommerce';
import type { OrderStatusVO } from '#/api/ecommerce/types';
import OrderStatusFormModal from './components/OrderStatusFormModal.vue';
// 创建图标组件
@@ -31,12 +31,6 @@ const gridOptions: VxeGridProps<any> = {
width: 80,
title: '序号',
},
{
field: 'statusCode',
title: '状态码',
minWidth: 'auto',
showOverflow: 'tooltip' as const,
},
{
field: 'statusName',
title: '状态名称',
@@ -167,12 +161,12 @@ function handleAdd() {
}
// 处理编辑订单状态
function handleEdit(record: OrderStatusVO.OrderStatusInfoVO) {
function handleEdit(record: OrderStatusVO.Info) {
orderStatusFormModalRef.value?.open(true, record);
}
// 处理删除订单状态
async function handleDelete(record: OrderStatusVO.OrderStatusInfoVO) {
async function handleDelete(record: OrderStatusVO.Info) {
try {
await deleteOrderStatusApi(record.id);
message.success('删除成功');
@@ -6,10 +6,10 @@ import { Modal, Form, Input, InputNumber, Select, Switch, message } from 'ant-de
import {
createPromotionFeeTypeApi,
updatePromotionFeeTypeApi,
type PromotionFeeTypeDTO,
type PromotionFeeTypeVO
} from '#/api/ecommerce';
import type { PromotionFeeTypeDTO, PromotionFeeTypeVO } from '#/api/ecommerce/types';
defineProps<{
visible?: boolean;
}>();
@@ -23,11 +23,10 @@ const emit = defineEmits<{
const visible = ref(false);
const loading = ref(false);
const isEdit = ref(false);
const currentRecord = ref<PromotionFeeTypeVO.PromotionFeeTypeInfoVO | null>(null);
const currentRecord = ref<PromotionFeeTypeVO.Info | null>(null);
// 表单数据
const formData = ref<Partial<PromotionFeeTypeDTO.CreatePromotionFeeTypeDTO>>({
typeCode: '',
const formData = ref<Partial<PromotionFeeTypeDTO.Create>>({
typeName: '',
description: '',
calculationMethod: 1,
@@ -54,7 +53,7 @@ const rules = {
const formRef = ref();
// 打开模态框
function open(edit: boolean, record?: PromotionFeeTypeVO.PromotionFeeTypeInfoVO) {
function open(edit: boolean, record?: PromotionFeeTypeVO.Info) {
isEdit.value = edit;
currentRecord.value = record || null;
visible.value = true;
@@ -62,7 +61,6 @@ function open(edit: boolean, record?: PromotionFeeTypeVO.PromotionFeeTypeInfoVO)
if (edit && record) {
// 编辑模式,填充表单数据
formData.value = {
typeCode: record.typeCode,
typeName: record.typeName,
description: record.description || '',
calculationMethod: record.calculationMethod || 1,
@@ -72,7 +70,6 @@ function open(edit: boolean, record?: PromotionFeeTypeVO.PromotionFeeTypeInfoVO)
} else {
// 新增模式,重置表单
formData.value = {
typeCode: '',
typeName: '',
description: '',
calculationMethod: 1,
@@ -97,9 +94,8 @@ async function handleSubmit() {
if (isEdit.value && currentRecord.value) {
// 更新推广费类型
const updateData: PromotionFeeTypeDTO.UpdatePromotionFeeTypeDTO = {
const updateData: PromotionFeeTypeDTO.Update = {
id: currentRecord.value.id,
typeCode: formData.value.typeCode!,
typeName: formData.value.typeName!,
description: formData.value.description,
calculationMethod: formData.value.calculationMethod,
@@ -110,8 +106,7 @@ async function handleSubmit() {
message.success('更新推广费类型成功');
} else {
// 创建推广费类型
const createData: PromotionFeeTypeDTO.CreatePromotionFeeTypeDTO = {
typeCode: formData.value.typeCode!,
const createData: PromotionFeeTypeDTO.Create = {
typeName: formData.value.typeName!,
description: formData.value.description,
calculationMethod: formData.value.calculationMethod,
@@ -125,8 +120,7 @@ async function handleSubmit() {
close();
emit('success');
} catch (error) {
console.error('提交推广费类型失败:', error);
message.error('提交推广费类型失败');
console.error('提交推广费类型失败:', ( error as any).message );
} finally {
loading.value = false;
}
@@ -162,12 +156,6 @@ defineExpose({
layout="vertical"
>
<div class="grid grid-cols-2 gap-4">
<Form.Item label="类型编码" name="typeCode">
<Input
v-model:value="formData.typeCode"
placeholder="请输入类型编码"
/>
</Form.Item>
<Form.Item label="类型名称" name="typeName">
<Input
@@ -10,8 +10,8 @@ import type { VxeGridProps } from '#/adapter/vxe-table';
import {
deletePromotionFeeTypeApi,
getAllPromotionFeeTypeListApi,
type PromotionFeeTypeVO
} from '#/api/ecommerce';
import type { PromotionFeeTypeVO } from '#/api/ecommerce/types';
import PromotionFeeTypeFormModal from './components/PromotionFeeTypeFormModal.vue';
// 创建图标组件
@@ -39,12 +39,6 @@ const gridOptions: VxeGridProps<any> = {
width: 80,
title: '序号',
},
{
field: 'typeCode',
title: '类型编码',
minWidth: 'auto',
showOverflow: 'tooltip' as const,
},
{
field: 'typeName',
title: '类型名称',
@@ -180,12 +174,12 @@ function handleAdd() {
}
// 处理编辑推广费类型
function handleEdit(record: PromotionFeeTypeVO.PromotionFeeTypeInfoVO) {
function handleEdit(record: PromotionFeeTypeVO.Info) {
promotionFeeTypeFormModalRef.value?.open(true, record);
}
// 处理删除推广费类型
async function handleDelete(record: PromotionFeeTypeVO.PromotionFeeTypeInfoVO) {
async function handleDelete(record: PromotionFeeTypeVO.Info) {
try {
await deletePromotionFeeTypeApi(record.id);
message.success('删除成功');
@@ -8,11 +8,10 @@ import {
createOrderApi,
updateOrderApi,
getActiveOrderStatusListApi,
type OrderDTO,
type OrderVO,
type OrderStatusVO
} from '#/api/ecommerce';
import { getShopPageApi, type ShopVO } from '#/api/shop';
import type { OrderDTO, OrderVO, OrderStatusVO } from '#/api/ecommerce/types';
import { getShopPageApi } from '#/api/shop';
import type { ShopVO } from '#/api/shop/types';
defineProps<{
visible?: boolean;
@@ -27,10 +26,10 @@ const emit = defineEmits<{
const visible = ref(false);
const loading = ref(false);
const isEdit = ref(false);
const currentRecord = ref<OrderVO.OrderInfoVO | null>(null);
const currentRecord = ref<OrderVO.Info | null>(null);
// 表单数据
const formData = ref<Partial<OrderDTO.CreateOrderDTO>>({
const formData = ref<Partial<OrderDTO.Create>>({
shopId: undefined,
platformOrderNo: '',
statusId: undefined,
@@ -39,7 +38,12 @@ const formData = ref<Partial<OrderDTO.CreateOrderDTO>>({
orderDate: dayjs().format('YYYY-MM-DD'),
productId: undefined,
productSpecId: undefined,
productName: '',
specName: '',
quantity: 1,
unitPrice: 0,
costPrice: 0,
costTotal: 0,
});
// 下拉选项数据
@@ -49,11 +53,15 @@ const orderStatusOptions = ref<{ label: string; value: number }[]>([]);
// 表单验证规则
const rules = {
shopId: [{ required: true, message: '请选择店铺', trigger: 'change' }],
statusId: [{ required: true, message: '请选择订单状态', trigger: 'change' }],
receivedAmount: [{ required: true, message: '请输入实收金额', trigger: 'blur' }],
orderDate: [{ required: true, message: '请选择下单时间', trigger: 'change' }],
productId: [{ required: true, message: '请输入商品ID', trigger: 'blur' }],
productSpecId: [{ required: true, message: '请输入商品规格ID', trigger: 'blur' }],
productName: [{ required: true, message: '请输入商品名称', trigger: 'blur' }],
quantity: [{ required: true, message: '请输入数量', trigger: 'blur' }],
unitPrice: [{ required: true, message: '请输入销售单价', trigger: 'blur' }],
costPrice: [{ required: true, message: '请输入成本价', trigger: 'blur' }],
costTotal: [{ required: true, message: '请输入成本小计', trigger: 'blur' }],
};
// 表单引用
@@ -68,7 +76,7 @@ async function fetchShopOptions() {
filters: {},
};
const data = await getShopPageApi(params);
shopOptions.value = data.records.map((shop: ShopVO.ShopInfoVO) => ({
shopOptions.value = data.records.map((shop: ShopVO.Info) => ({
label: shop.name,
value: shop.id,
}));
@@ -81,8 +89,8 @@ async function fetchShopOptions() {
async function fetchOrderStatusOptions() {
try {
const data = await getActiveOrderStatusListApi();
orderStatusOptions.value = data.map((status: OrderStatusVO.OrderStatusInfoVO) => ({
label: status.name,
orderStatusOptions.value = data.map((status: OrderStatusVO.Info) => ({
label: status.statusName,
value: status.id,
}));
} catch (error) {
@@ -91,7 +99,7 @@ async function fetchOrderStatusOptions() {
}
// 打开模态框
function open(edit: boolean, record?: OrderVO.OrderInfoVO) {
function open(edit: boolean, record?: OrderVO.Info) {
isEdit.value = edit;
currentRecord.value = record || null;
visible.value = true;
@@ -105,9 +113,14 @@ function open(edit: boolean, record?: OrderVO.OrderInfoVO) {
receivedAmount: record.receivedAmount,
shippingFee: record.shippingFee || 0,
orderDate: record.orderDate ? dayjs(record.orderDate).format('YYYY-MM-DD') : dayjs().format('YYYY-MM-DD'),
productId: record.orderItem?.productId,
productSpecId: record.orderItem?.productSpecId,
quantity: record.orderItem?.quantity || 1,
productId: record.productId,
productSpecId: record.productSpecId,
productName: record.productName,
specName: record.specName,
quantity: record.quantity,
unitPrice: record.unitPrice,
costPrice: record.costPrice,
costTotal: record.costTotal,
};
} else {
// 新增模式,重置表单
@@ -120,7 +133,12 @@ function open(edit: boolean, record?: OrderVO.OrderInfoVO) {
orderDate: dayjs().format('YYYY-MM-DD'),
productId: undefined,
productSpecId: undefined,
productName: '',
specName: '',
quantity: 1,
unitPrice: 0,
costPrice: 0,
costTotal: 0,
};
}
}
@@ -140,19 +158,27 @@ async function handleSubmit() {
if (isEdit.value && currentRecord.value) {
// 更新订单
const updateData: OrderDTO.UpdateOrderDTO = {
const updateData: OrderDTO.Update = {
shopId: formData.value.shopId!,
platformOrderNo: formData.value.platformOrderNo,
statusId: formData.value.statusId,
receivedAmount: formData.value.receivedAmount!,
shippingFee: formData.value.shippingFee,
orderDate: formData.value.orderDate!,
productId: formData.value.productId,
productSpecId: formData.value.productSpecId,
productName: formData.value.productName,
specName: formData.value.specName,
quantity: formData.value.quantity,
unitPrice: formData.value.unitPrice,
costPrice: formData.value.costPrice,
costTotal: formData.value.costTotal,
};
await updateOrderApi(currentRecord.value.id, updateData);
message.success('更新订单成功');
} else {
// 创建订单
const createData: OrderDTO.CreateOrderDTO = {
const createData: OrderDTO.Create = {
shopId: formData.value.shopId!,
platformOrderNo: formData.value.platformOrderNo,
statusId: formData.value.statusId!,
@@ -160,8 +186,13 @@ async function handleSubmit() {
shippingFee: formData.value.shippingFee,
orderDate: formData.value.orderDate!,
productId: formData.value.productId!,
productSpecId: formData.value.productSpecId!,
productSpecId: formData.value.productSpecId,
productName: formData.value.productName!,
specName: formData.value.specName,
quantity: formData.value.quantity!,
unitPrice: formData.value.unitPrice!,
costPrice: formData.value.costPrice!,
costTotal: formData.value.costTotal!,
};
await createOrderApi(createData);
message.success('创建订单成功');
@@ -257,13 +288,29 @@ defineExpose({
<Form.Item label="商品规格ID" name="productSpecId">
<InputNumber
v-model:value="formData.productSpecId"
placeholder="请输入商品规格ID"
placeholder="请输入商品规格ID(可选)"
style="width: 100%"
:min="1"
/>
</Form.Item>
</div>
<div class="grid grid-cols-2 gap-4">
<Form.Item label="商品名称" name="productName">
<Input
v-model:value="formData.productName"
placeholder="请输入商品名称"
/>
</Form.Item>
<Form.Item label="规格名称" name="specName">
<Input
v-model:value="formData.specName"
placeholder="请输入规格名称(可选)"
/>
</Form.Item>
</div>
<div class="grid grid-cols-3 gap-4">
<Form.Item label="数量" name="quantity">
<InputNumber
@@ -274,6 +321,38 @@ defineExpose({
/>
</Form.Item>
<Form.Item label="销售单价" name="unitPrice">
<InputNumber
v-model:value="formData.unitPrice"
placeholder="请输入销售单价"
style="width: 100%"
:min="0"
:precision="2"
/>
</Form.Item>
<Form.Item label="成本价" name="costPrice">
<InputNumber
v-model:value="formData.costPrice"
placeholder="请输入成本价"
style="width: 100%"
:min="0"
:precision="2"
/>
</Form.Item>
</div>
<div class="grid grid-cols-3 gap-4">
<Form.Item label="成本小计" name="costTotal">
<InputNumber
v-model:value="formData.costTotal"
placeholder="请输入成本小计"
style="width: 100%"
:min="0"
:precision="2"
/>
</Form.Item>
<Form.Item label="实收金额" name="receivedAmount">
<InputNumber
v-model:value="formData.receivedAmount"
@@ -10,12 +10,11 @@ import type { VxeGridProps } from '#/adapter/vxe-table';
import {
deleteOrderApi,
getOrderPageApi,
getActiveOrderStatusListApi,
type OrderVO,
type OrderDTO,
type OrderStatusVO
getActiveOrderStatusListApi
} from '#/api/ecommerce';
import { getShopPageApi, type ShopVO } from '#/api/shop';
import type { OrderVO, OrderDTO, OrderStatusVO } from '#/api/ecommerce/types';
import { getShopPageApi } from '#/api/shop';
import type { ShopVO } from '#/api/shop/types';
import type { PageQueryDTO } from '#/types/common';
import OrderFormModal from './components/OrderFormModal.vue';
@@ -125,7 +124,7 @@ const gridOptions: VxeGridProps<any> = {
query: async ({ page }) => {
try {
loading.value = true;
const params: PageQueryDTO<OrderDTO.OrderFilterDTO> = {
const params: PageQueryDTO<OrderDTO.Filters> = {
page: page.currentPage,
pageSize: page.pageSize,
filters: {
@@ -216,7 +215,7 @@ async function fetchShopOptions() {
filters: {},
};
const data = await getShopPageApi(params);
shopOptions.value = data.records.map((shop: ShopVO.ShopInfoVO) => ({
shopOptions.value = data.records.map((shop: ShopVO.Info) => ({
label: shop.name,
value: shop.id,
}));
@@ -229,7 +228,7 @@ async function fetchShopOptions() {
async function fetchOrderStatusOptions() {
try {
const data = await getActiveOrderStatusListApi();
orderStatusOptions.value = data.map((status: OrderStatusVO.OrderStatusInfoVO) => ({
orderStatusOptions.value = data.map((status: OrderStatusVO.Info) => ({
label: status.statusName,
value: status.id,
}));
@@ -257,12 +256,12 @@ function handleAdd() {
}
// 处理编辑订单
function handleEdit(record: OrderVO.OrderInfoVO) {
function handleEdit(record: OrderVO.Info) {
orderFormModalRef.value?.open(true, record);
}
// 处理删除订单
async function handleDelete(record: OrderVO.OrderInfoVO) {
async function handleDelete(record: OrderVO.Info) {
try {
await deleteOrderApi(record.id);
message.success('删除成功');
@@ -324,16 +323,16 @@ onMounted(async () => {
<!-- 商品信息列 -->
<template #productInfo="{ row }: { row: any }">
<div v-if="row.orderItem">
<div style="font-weight: bold;">{{ row.orderItem.productName }}</div>
<div style="color: #666; font-size: 12px;">{{ row.orderItem.specName }}</div>
<div v-if="row.productName">
<div style="font-weight: bold;">{{ row.productName }}</div>
<div v-if="row.specName" style="color: #666; font-size: 12px;">{{ row.specName }}</div>
</div>
<span v-else style="color: #999;">暂无商品信息</span>
</template>
<!-- 数量列 -->
<template #quantity="{ row }: { row: any }">
{{ row.orderItem?.quantity || 0 }}
{{ row.quantity || 0 }}
</template>
<!-- 实收金额列 -->
@@ -1,7 +1,7 @@
<script lang="ts" setup>
import { Card, Image, Tag, Button, Space, Popconfirm, Tooltip } from 'ant-design-vue';
import { createIconifyIcon } from '@vben/icons';
import type { ProductVO } from '#/api/shop';
import type { ProductVO } from '#/api/shop/types';
// 创建图标组件
const EditIcon = createIconifyIcon('lucide:edit');
@@ -10,32 +10,32 @@ const SettingsIcon = createIconifyIcon('lucide:settings');
const EyeIcon = createIconifyIcon('lucide:eye');
interface Props {
product: ProductVO.ProductInfoVO;
product: ProductVO.Info;
}
interface Emits {
(e: 'edit', product: ProductVO.ProductInfoVO): void;
(e: 'delete', product: ProductVO.ProductInfoVO): void;
(e: 'manage-specs', product: ProductVO.ProductInfoVO): void;
(e: 'view-details', product: ProductVO.ProductInfoVO): void;
(e: 'edit', product: ProductVO.Info): void;
(e: 'delete', product: ProductVO.Info): void;
(e: 'manage-specs', product: ProductVO.Info): void;
(e: 'view-details', product: ProductVO.Info): void;
}
defineProps<Props>();
const emit = defineEmits<Emits>();
const handleEdit = (product: ProductVO.ProductInfoVO) => {
const handleEdit = (product: ProductVO.Info) => {
emit('edit', product);
};
const handleDelete = (product: ProductVO.ProductInfoVO) => {
const handleDelete = (product: ProductVO.Info) => {
emit('delete', product);
};
const handleManageSpecs = (product: ProductVO.ProductInfoVO) => {
const handleManageSpecs = (product: ProductVO.Info) => {
emit('manage-specs', product);
};
const handleViewDetails = (product: ProductVO.ProductInfoVO) => {
const handleViewDetails = (product: ProductVO.Info) => {
emit('view-details', product);
};
@@ -149,10 +149,9 @@ import { createIconifyIcon } from '@vben/icons';
import {
createProductApi,
updateProductApi,
createProductWithSpecsApi,
type ProductVO,
type ProductDTO
createProductWithSpecsApi
} from '#/api/shop';
import type { ProductVO, ProductDTO } from '#/api/shop/types';
import { uploadImageApi } from '#/api/media';
interface Emits {
@@ -167,7 +166,7 @@ const CameraIcon = createIconifyIcon('mdi:camera');
// 内部状态管理
const visible = ref(false);
const isEdit = ref(false);
const currentProductData = ref<ProductVO.ProductInfoVO | Partial<ProductVO.ProductInfoVO> | null>(null);
const currentProductData = ref<ProductVO.Info | Partial<ProductVO.Info> | null>(null);
// 响应式数据
const formRef = ref();
@@ -186,7 +185,7 @@ const formData = ref({
});
// 规格数据
const specs = ref<ProductDTO.ProductSpecDTO[]>([]);
const specs = ref<ProductDTO.Spec[]>([]);
const showSpecs = ref(false);
// 模态框标题
@@ -237,7 +236,7 @@ function initFormData() {
// 如果有传入的规格信息,则自动填入
if (!isEdit.value && currentProductData.value && 'specs' in currentProductData.value && currentProductData.value.specs) {
specs.value = currentProductData.value.specs.map(spec => ({
name: (spec as any).specName || spec.specCode || '',
name: (spec as ProductVO.SpecInfo).name || spec.specCode || '',
specCode: spec.specCode || '',
costPrice: spec.costPrice || 0
}));
@@ -277,12 +276,12 @@ async function handleSubmit() {
// 调用API
if (isEdit.value && currentProductData.value && 'id' in currentProductData.value && currentProductData.value.id) {
await updateProductApi(currentProductData.value.id, submitData as ProductDTO.UpdateProductDTO);
await updateProductApi(currentProductData.value.id, submitData as ProductDTO.Update);
message.success('更新成功');
} else {
// 创建模式:如果有规格,使用一键创建接口
if (specs.value.length > 0) {
const createWithSpecsData: ProductDTO.CreateProductWithSpecsDTO = {
const createWithSpecsData: ProductDTO.CreateWithSpecs = {
name: submitData.name,
mainImageId: submitData.mainImageId,
specs: specs.value,
@@ -290,7 +289,7 @@ async function handleSubmit() {
await createProductWithSpecsApi(createWithSpecsData);
message.success('商品和规格创建成功');
} else {
await createProductApi(submitData as ProductDTO.CreateProductDTO);
await createProductApi(submitData as ProductDTO.Create);
message.success('创建成功');
}
}
@@ -311,7 +310,7 @@ function handleCancel() {
}
// 暴露给父组件的方法
function open(editMode: boolean = false, productData?: ProductVO.ProductInfoVO | Partial<ProductVO.ProductInfoVO> | null) {
function open(editMode: boolean = false, productData?: ProductVO.Info | Partial<ProductVO.Info> | null) {
isEdit.value = editMode;
currentProductData.value = productData || null;
@@ -94,10 +94,9 @@ import {
getProductSpecPageApi,
createProductSpecApi,
updateProductSpecApi,
deleteProductSpecApi,
type ProductVO,
type ProductDTO
deleteProductSpecApi
} from '#/api/shop';
import type { ProductVO, ProductDTO } from '#/api/shop/types';
import type { PageQueryDTO } from '#/types/common';
interface Emits {
@@ -108,12 +107,12 @@ const emit = defineEmits<Emits>();
// 内部状态管理
const visible = ref(false);
const currentProduct = ref<ProductVO.ProductInfoVO | null>(null);
const currentProduct = ref<ProductVO.Info | null>(null);
// 响应式数据
const loading = ref(false);
const specLoading = ref(false);
const specList = ref<ProductVO.ProductSpecInfoVO[]>([]);
const specList = ref<ProductVO.SpecInfo[]>([]);
const specTotal = ref(0);
const specCurrent = ref(1);
const specPageSize = ref(10);
@@ -158,7 +157,7 @@ const columns = [
dataIndex: 'costPrice',
key: 'costPrice',
width: 120,
customRender: ({ record }: { record: ProductVO.ProductSpecInfoVO }) => {
customRender: ({ record }: { record: ProductVO.SpecInfo }) => {
return `¥${record.costPrice.toFixed(2)}`;
},
},
@@ -173,7 +172,7 @@ const columns = [
key: 'action',
width: 150,
fixed: 'right' as const,
customRender: ({ record }: { record: ProductVO.ProductSpecInfoVO }) => {
customRender: ({ record }: { record: ProductVO.SpecInfo }) => {
return h('div', { style: 'display: flex; gap: 8px;' }, [
h(Button, {
size: 'small',
@@ -195,7 +194,7 @@ async function fetchSpecList() {
try {
specLoading.value = true;
const params: PageQueryDTO<ProductDTO.ProductSpecFilterDTO> = {
const params: PageQueryDTO<ProductDTO.SpecFilters> = {
page: specCurrent.value,
pageSize: specPageSize.value,
filters: {
@@ -233,7 +232,7 @@ function handleAddSpec() {
}
// 处理编辑规格
function handleEditSpec(record: ProductVO.ProductSpecInfoVO) {
function handleEditSpec(record: ProductVO.SpecInfo) {
isEditSpec.value = true;
currentSpecId.value = record.id;
specFormData.value = {
@@ -245,7 +244,7 @@ function handleEditSpec(record: ProductVO.ProductSpecInfoVO) {
}
// 处理删除规格
async function handleDeleteSpec(record: ProductVO.ProductSpecInfoVO) {
async function handleDeleteSpec(record: ProductVO.SpecInfo) {
try {
await deleteProductSpecApi(record.id);
message.success('删除成功');
@@ -263,7 +262,7 @@ async function handleSpecSubmit() {
specFormLoading.value = true;
if (isEditSpec.value && currentSpecId.value) {
await updateProductSpecApi(currentSpecId.value, specFormData.value as ProductDTO.UpdateProductSpecDTO);
await updateProductSpecApi(currentSpecId.value, specFormData.value as ProductDTO.UpdateSpec);
message.success('更新成功');
} else {
if (!currentProduct.value) {
@@ -271,7 +270,7 @@ async function handleSpecSubmit() {
return;
}
const createData: ProductDTO.CreateProductSpecDTO = {
const createData: ProductDTO.CreateSpec = {
productId: currentProduct.value.id,
...specFormData.value,
};
@@ -307,7 +306,7 @@ function handleCancel() {
}
// 暴露给父组件的方法
function open(product: ProductVO.ProductInfoVO) {
function open(product: ProductVO.Info) {
currentProduct.value = product;
specCurrent.value = 1;
specPageSize.value = 10;
@@ -165,10 +165,9 @@ import { createIconifyIcon } from '@vben/icons';
import {
deleteProductApi,
getProductPageApi,
type ProductVO,
type ProductDTO
getProductPageApi
} from '#/api/shop';
import type { ProductVO, ProductDTO } from '#/api/shop/types';
import type { PageQueryDTO } from '#/types/common';
import ProductFormModal from './components/ProductFormModal.vue';
// @ts-ignore
@@ -184,7 +183,7 @@ defineOptions({ name: 'ProductManagement' });
// 响应式数据
const loading = ref(false);
const productList = ref<ProductVO.ProductInfoVO[]>([]);
const productList = ref<ProductVO.Info[]>([]);
const total = ref(0);
const current = ref(1);
const pageSize = ref(10);
@@ -214,7 +213,7 @@ const columns = [
dataIndex: 'mainImage',
key: 'mainImage',
width: 100,
customRender: ({ record }: { record: ProductVO.ProductInfoVO }) => {
customRender: ({ record }: { record: ProductVO.Info }) => {
if (record.mainImage) {
return h('img', {
src: record.mainImage,
@@ -230,7 +229,7 @@ const columns = [
dataIndex: 'specs',
key: 'specs',
width: 100,
customRender: ({ record }: { record: ProductVO.ProductInfoVO }) => {
customRender: ({ record }: { record: ProductVO.Info }) => {
const specCount = record.specs?.length || 0;
return h(Tag, { color: specCount > 0 ? 'blue' : 'default' }, () => `${specCount} 个规格`);
},
@@ -252,7 +251,7 @@ const columns = [
key: 'action',
width: 200,
fixed: 'right' as const,
customRender: ({ record }: { record: ProductVO.ProductInfoVO }) => {
customRender: ({ record }: { record: ProductVO.Info }) => {
return h('div', { style: 'display: flex; gap: 8px;' }, [
h(Button, {
size: 'small',
@@ -276,7 +275,7 @@ const columns = [
async function fetchProductList() {
try {
loading.value = true;
const params: PageQueryDTO<ProductDTO.ProductFiltersDTO> = {
const params: PageQueryDTO<ProductDTO.Filters> = {
page: current.value,
pageSize: pageSize.value,
filters: {
@@ -335,12 +334,12 @@ function handleAdd() {
}
// 处理编辑商品
function handleEdit(record: ProductVO.ProductInfoVO) {
function handleEdit(record: ProductVO.Info) {
productFormModalRef.value?.open(true, record);
}
// 处理删除商品
async function handleDelete(record: ProductVO.ProductInfoVO) {
async function handleDelete(record: ProductVO.Info) {
try {
await deleteProductApi(record.id);
message.success('删除成功');
@@ -352,7 +351,7 @@ async function handleDelete(record: ProductVO.ProductInfoVO) {
}
// 处理管理规格
function handleManageSpecs(record: ProductVO.ProductInfoVO) {
function handleManageSpecs(record: ProductVO.Info) {
productSpecModalRef.value?.open(record);
}
@@ -80,9 +80,8 @@ import {
uploadShopLogoApi,
createShopApi,
updateShopApi,
type ShopVO,
type ShopDTO
} from '#/api/shop';
import type { ShopVO, ShopDTO } from '#/api/shop/types';
interface Emits {
(e: 'success'): void;
@@ -96,7 +95,7 @@ const CameraIcon = createIconifyIcon('mdi:camera');
// 内部状态管理
const visible = ref(false);
const isEdit = ref(false);
const currentShopData = ref<ShopVO.ShopInfoVO | Partial<ShopVO.ShopInfoVO> | null>(null);
const currentShopData = ref<ShopVO.Info | Partial<ShopVO.Info> | null>(null);
// 响应式数据
const formRef = ref();
@@ -188,10 +187,10 @@ async function handleSubmit() {
// 调用API
if (isEdit.value && currentShopData.value && 'id' in currentShopData.value && currentShopData.value.id) {
await updateShopApi(currentShopData.value.id, submitData as ShopDTO.UpdateShopDTO);
await updateShopApi(currentShopData.value.id, submitData as ShopDTO.Update);
message.success('更新成功');
} else {
await createShopApi(submitData as ShopDTO.CreateShopDTO);
await createShopApi(submitData as ShopDTO.Create);
message.success('创建成功');
}
@@ -211,7 +210,7 @@ function handleCancel() {
}
// 暴露给父组件的方法
function open(editMode: boolean = false, shopData?: ShopVO.ShopInfoVO | Partial<ShopVO.ShopInfoVO> | null) {
function open(editMode: boolean = false, shopData?: ShopVO.Info | Partial<ShopVO.Info> | null) {
isEdit.value = editMode;
currentShopData.value = shopData || null;
@@ -10,9 +10,8 @@ import type { VxeGridProps } from '#/adapter/vxe-table';
import {
deleteShopApi,
getShopPageApi,
type ShopVO ,
type ShopDTO
} from '#/api/shop';
import type { ShopVO, ShopDTO } from '#/api/shop/types';
import type { PageQueryDTO } from '#/types/common';
import ShopFormModal from './components/ShopFormModal.vue';
@@ -105,7 +104,7 @@ const gridOptions: VxeGridProps<any> = {
query: async ({ page }) => {
try {
loading.value = true;
const params: PageQueryDTO<ShopDTO.ShopFiltersDTO> = {
const params: PageQueryDTO<ShopDTO.Filters> = {
page: page.currentPage,
pageSize: page.pageSize,
filters: {
@@ -182,12 +181,12 @@ function handleAdd() {
}
// 处理编辑店铺
function handleEdit(record: ShopVO.ShopInfoVO) {
function handleEdit(record: ShopVO.Info) {
shopFormModalRef.value?.open(true, record);
}
// 处理删除店铺
async function handleDelete(record: ShopVO.ShopInfoVO) {
async function handleDelete(record: ShopVO.Info) {
try {
await deleteShopApi(record.id);
message.success('删除成功');