From 70f2e96e2b5501e82620ccaaa534ffd2ef4bf2bf Mon Sep 17 00:00:00 2001
From: puzvv <1@>
Date: Mon, 29 Dec 2025 18:38:40 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=BA=86=E5=88=86=E7=B1=BB?=
=?UTF-8?q?=E7=AE=A1=E7=90=86=E7=95=8C=E9=9D=A2=E7=BC=96=E5=86=99?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/apis/product.ts | 27 ++
src/pages/admin/CategoryPage.vue | 502 +++++++++++++++++++++++++++++++
src/types/product.ts | 13 +-
3 files changed, 541 insertions(+), 1 deletion(-)
create mode 100644 src/pages/admin/CategoryPage.vue
diff --git a/src/apis/product.ts b/src/apis/product.ts
index 62fdb2a..4e0dc13 100644
--- a/src/apis/product.ts
+++ b/src/apis/product.ts
@@ -6,6 +6,7 @@ import type {
ProductDTO,
ProductPageParams,
ProductPageResponse,
+ ProductCategoryDTO,
} from "@/types/product";
// 获取商品列表
@@ -66,3 +67,29 @@ export const updateProductStatus = (id: number, status: number) => {
method: "put",
});
};
+
+// 新增商品分类
+export const addProductCategory = (data: ProductCategoryDTO) => {
+ return http({
+ url: "/product/category",
+ method: "post",
+ data,
+ });
+};
+
+// 更新商品分类
+export const updateProductCategory = (data: ProductCategoryDTO) => {
+ return http({
+ url: "/product/category",
+ method: "put",
+ data,
+ });
+};
+
+// 删除商品分类
+export const deleteProductCategory = (id: number) => {
+ return http({
+ url: `/product/category/${id}`,
+ method: "delete",
+ });
+};
diff --git a/src/pages/admin/CategoryPage.vue b/src/pages/admin/CategoryPage.vue
new file mode 100644
index 0000000..73fd356
--- /dev/null
+++ b/src/pages/admin/CategoryPage.vue
@@ -0,0 +1,502 @@
+
+
+
+
+
+
+
+
+
+
+
+ 搜索
+
+
+ 添加分类
+
+
+
+
+
+
+
+
+
+
+ {{ getLevelText(row.level) }}
+
+
+
+
+
+
+ {{ row.parentId === 0 ? "无(一级分类)" : row.parentId }}
+
+
+
+
+ {{ formatDate(row.createTime) }}
+
+
+
+
+ 编辑
+
+ 添加子分类
+
+
+ 删除
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/types/product.ts b/src/types/product.ts
index 199f627..e119091 100644
--- a/src/types/product.ts
+++ b/src/types/product.ts
@@ -15,7 +15,7 @@ export interface ProductListItem {
// 商品详情
export interface ProductDetail {
id: number;
- userId?: number;
+ userId?: number; //商家ID
categoryId: number;
categoryName: string;
name: string;
@@ -89,3 +89,14 @@ export interface ProductDTO {
sort?: number; // 排序
skuList?: ProductSku[]; // 规格列表
}
+
+// 商品分类DTO (用于创建和更新)
+export interface ProductCategoryDTO {
+ id?: number; // 分类ID(修改时使用)
+ parentId: number; // 父分类ID
+ name: string; // 分类名称
+ sort: number; // 排序
+ icon?: string; // 图标URL
+ level: number; // 层级
+ status?: number; // 状态
+}