From 25f3979f6edeeca479f9fde6420ed7156ce105c0 Mon Sep 17 00:00:00 2001 From: powersir <1576775122@qq.com> Date: Tue, 24 Oct 2023 18:33:13 +0800 Subject: [PATCH] update: rename ShopeeTemplateVO to TemplateInfoVO, add:platform template api --- src/models/index.ts | 2 +- src/models/template.data.ts | 325 ++++++++++++++++++++- src/pages/custom/template/shopee/index.tsx | 95 +++--- src/request/service/platform-template.ts | 35 +++ 4 files changed, 404 insertions(+), 53 deletions(-) create mode 100644 src/request/service/platform-template.ts diff --git a/src/models/index.ts b/src/models/index.ts index fd8c8b9..518de7d 100644 --- a/src/models/index.ts +++ b/src/models/index.ts @@ -16,7 +16,7 @@ export * from './category.data.ts' export * from './material-classify.data.ts' export * from './goods-classify.data.ts' export * from './goods-attr.data.ts' -export * from './shopee-product.data.ts' +export * from './platform-template.data.ts' export interface ResponseDTO{ code: number; diff --git a/src/models/template.data.ts b/src/models/template.data.ts index 354253c..187f006 100644 --- a/src/models/template.data.ts +++ b/src/models/template.data.ts @@ -1,4 +1,3 @@ - //数据字典 export interface DataDictVO{ description: string; @@ -16,13 +15,325 @@ export interface DataDictDetailVO { } -export interface ShopeeTemplateVO { +/** + * TemplateInfoVO,模板数据 + */ +export interface TemplateInfoVO { + /** + * 背景ids + */ + backgroupIds?: number[]; + /** + * 类别 + */ + catePubId: string; + /** + * 每天最大刊登量 + */ + dayMaxPublishNumber?: number; + /** + * 模版id + */ id: number; - categoryName: string; - createName: string; - createTime: string; + /** + * 图片信息 + */ + imageInfo: TemplateImgVO[]; + /** + * 物流渠道 + */ + logistics: TemplateLogisticsVO[]; + /** + * 素材组ids + */ + materialClassifyIds?: number[]; + /** + * 店铺最大上架数量 + */ + maxPrintCount: number; + /** + * 产品价格 + */ + originalPrice: number; + /** + * 平台编码 + */ platformCode: string; - remark: string; - shopName: string; + /** + * 单价折扣 + */ + priceDiscount?: number; + /** + * 变种比例 + */ + proportion?: number; + /** + * 模板备注 + */ + remark?: string; + /** + * 店铺id + */ + shopId: number; + /** + * 类目属性 + */ + templateAttrs: TemplateAttrInfoVO[]; + templateDimension: TemplateDimensionVO; + /** + * 模板名称编码 + */ templateName: string; + templateProduct: TemplateProductVO; + templateSkuSpace?: TemplateSkuSpaceVO; + /** + * 图片信息 + */ + videoInfo: TemplateVideoVO[]; +} + +/** + * TemplateImgVO,模板图片信息 + */ +export interface TemplateImgVO { + /** + * 图片id + */ + id?: number; + /** + * 图片Url信息 + */ + url: string; +} + +/** + * TemplateLogisticsVO,模板物流通道 + */ +export interface TemplateLogisticsVO { + /** + * 是否为此项目启用通道(0.否 1.是) + */ + enabled: number; + /** + * 是否为买家支付运费(0.否 1.是) + */ + isFree?: number; + /** + * 频道的 ID + */ + logisticId: number; + /** + * 运费 + */ + shippingFee?: number; + /** + * 大小 ID + */ + sizeId?: number; +} + +/** + * TemplateAttrInfoVO,模板属性信息封装VO + */ +export interface TemplateAttrInfoVO { + templateAttr: TemplateAttrVO; + /** + * 模板属性值信息 + */ + templateAttrVals: TemplateAttrValVO[]; +} + +/** + * TemplateAttrVO,模板属性信息 + */ +export interface TemplateAttrVO { + /** + * 属性ID + */ + attrId: number; + /** + * 属性名称 + */ + attrName: string; +} + +/** + * TemplateAttrValVO,模板属性值信息 + */ +export interface TemplateAttrValVO { + /** + * 属性值ID + */ + attrValId: number; + /** + * 属性值名称 + */ + attrValName: string; + /** + * 价值单位(仅限定量属性) + */ + valueUnit?: string; +} + +/** + * TemplateDimensionVO,模板包装尺寸 + */ +export interface TemplateDimensionVO { + /** + * 包装高度,单位为厘米 + */ + packageHeight: number; + /** + * 包装长度,单位为厘米 + */ + packageLength: number; + /** + * 包装宽度,单位为厘米 + */ + packageWidth: number; + /** + * 重量,单位为千克 + */ + weight: number; +} + +/** + * TemplateProductVO,模板产品信息 + */ +export interface TemplateProductVO { + /** + * 品牌ID + */ + brandId?: number; + /** + * 品牌名称 + */ + brandName?: string; + /** + * 项目的状况,可以是二手的或新的 + */ + conditionVal?: string; + /** + * 保证发货数量 + */ + daysToShip?: number; + /** + * 描述数据字典ID + */ + description: string; + /** + * 产品Id + */ + id: number; + /** + * 商品是否为预购商品(0.否 1.是) + */ + isPreOrder: number; + /** + * 产品名称数据字典ID + */ + itemName: string; + /** + * 产品状态 + */ + itemStatus: string; +} + +/** + * TemplateSkuSpaceVO,模板sku + */ +export interface TemplateSkuSpaceVO { + /** + * 销售数量 + */ + inventory?: number; + /** + * 价格 + */ + originalPrice?: number; + /** + * 尺码 + */ + sizeId?: number; + /** + * 批发价格 + */ + templateWholesale?: TemplateWholesaleVO[]; +} + +/** + * TemplateWholesaleVO,模板批发价格 + */ +export interface TemplateWholesaleVO { + /** + * 此层的最大计数 + */ + maxCount: number; + /** + * 此层的最小计数 + */ + minCount: number; + /** + * 价格 + */ + unitPrice: number; +} + +/** + * TemplateVideoVO,模板视频信息 + */ +export interface TemplateVideoVO { + /** + * 视频id + */ + id?: number; + /** + * 视频信息 + */ + url: string; +} + + +//模板分页请求参数 +export interface TemplateInfoPageReqVO extends PageParam { + /** + * 背景id(a,b,c) + */ + backgroupIds?: string; + /** + * 类目id + */ + catePubId?: string; + /** + * 创建时间 + */ + createTime?: string[]; + /** + * 素材id(a,b,c) + */ + materialClassifyIds?: string; + /** + * 最大上刊数量 + */ + maxPrintCount?: number; + /** + * 平台编码 + */ + platformCode?: string; + /** + * 变种比例 + */ + proportion?: number; + /** + * 备注 + */ + remark?: string; + /** + * 店铺id + */ + shopId?: number; + /** + * 模板名称 + */ + templateName?: string; } diff --git a/src/pages/custom/template/shopee/index.tsx b/src/pages/custom/template/shopee/index.tsx index 1f8fe1a..84b9a70 100644 --- a/src/pages/custom/template/shopee/index.tsx +++ b/src/pages/custom/template/shopee/index.tsx @@ -1,7 +1,7 @@ +import React, { useState, useEffect } from 'react'; import { Space, Table, Form, Button, Card, Input, TreeSelect } from 'antd'; import type { ColumnsType } from 'antd/es/table'; import { t } from '@/utils/i18n'; -import React, { useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { ExclamationCircleFilled, @@ -11,7 +11,10 @@ import { UndoOutlined } from '@ant-design/icons'; import { antdUtils } from '@/utils/antd'; -import { ShopeeTemplateVO } from '@/models'; +import { useSetState } from 'ahooks'; +import { useRequest } from '@/hooks/use-request'; +import platformShopService from '@/request/service/platform-template'; +import { TemplateInfoVO, TemplateInfoPageReqVO } from '@/models'; const treeData = [ { @@ -53,42 +56,38 @@ const treeData = [ ]; export default () => { - const data: ShopeeTemplateVO[] = [ - { - "id": 78, - "platformCode": "Shopee", - "shopName": "Trista", - "categoryName": "T-Shirts", - "templateName": "T-SHIRT", - "remark": "1", - "createName": "admin", - "createTime": "2023-06-15 14:45:15" - }, - { - "id": 77, - "platformCode": "Shopee", - "shopName": "Trista", - "categoryName": "T-Shirts", - "templateName": "T-SHIRT", - "remark": "1", - "createName": "admin", - "createTime": "2023-06-15 14:44:46" - }, - { - "id": 76, - "platformCode": "Shopee", - "shopName": "Trista", - "categoryName": "T-Shirts", - "templateName": "T-SHIRT", - "remark": "", - "createName": "admin", - "createTime": "2023-06-15 14:42:24" + + const [dataSource, setDataSource] = useState([]); + const [total, setTotal] = useState(0); + const [searchFrom] = Form.useForm(); + const [searchState, setSearchState] = useSetState({ + pageNo: 1, + pageSize: 10 + }); + + const [treeLine, setTreeLine] = useState(true); + const [showLeafIcon, setShowLeafIcon] = useState(false); + const [showIcon, setShowIcon] = useState(false); + + //获取分页数据 + const { runAsync: getPageApi } = useRequest(platformShopService.pageApi, { manual: true }); + //删除数据 + const { runAsync: deleteApi } = useRequest(platformShopService.deleteApi, { manual: true }); + + //加载数据 + const load = async () => { + const [error, { code, data, msg }] = await getPageApi(searchState); + if (error || code !== 0) { + antdUtils.message?.open({ type: 'error', content: msg ?? '操作失败' }) + } else { + setDataSource(data.list); + setTotal(data.total); } - ]; + }; - const showDeleteConfirm = (item: ShopeeTemplateVO) => { + const showDeleteConfirm = (item: TemplateInfoVO) => { antdUtils.modal?.confirm({ - title: `确认删除标题为: ${item.shopName} 的模板吗?`, + title: `确认删除标题为: ${item.templateName} 的模板吗?`, icon: , content: `请注意删除以后不可恢复!`, okText: '删除', @@ -114,7 +113,7 @@ export default () => { }); }; - const columns: ColumnsType = [ + const columns: ColumnsType = [ { title: '店铺', dataIndex: 'shopName', @@ -162,13 +161,9 @@ export default () => { }, ]; - const [searchFrom] = Form.useForm(); - const navigate = useNavigate(); - - - const [treeLine, setTreeLine] = useState(true); - const [showLeafIcon, setShowLeafIcon] = useState(false); - const [showIcon, setShowIcon] = useState(false); + useEffect(() => { + load(); + }, []) return (
@@ -204,8 +199,18 @@ export default () => {
- diff --git a/src/request/service/platform-template.ts b/src/request/service/platform-template.ts new file mode 100644 index 0000000..62dd8f4 --- /dev/null +++ b/src/request/service/platform-template.ts @@ -0,0 +1,35 @@ +import request from '@/request'; +import { + TemplateInfoVO, + TemplateInfoPageReqVO, + PageData +} from '@/models'; + +const BASE_URL = '/admin-api/template/platform'; + +export default { + //获得模版分页 + pageApi: (params: TemplateInfoPageReqVO) => { + return request.get>(`${BASE_URL}/page`, { params }); + }, + + //创建模版 + createApi: (data: TemplateInfoVO) => { + return request.post(`${BASE_URL}`, data); + }, + + //修改模版 + updateApi: (data: TemplateInfoVO) => { + return request.put(`${BASE_URL}`, data); + }, + + //获得模版 + getApi: (id: number) => { + return request.get(`${BASE_URL}/get?id=${id}`); + }, + + //删除模版 + deleteApi: (id: number) => { + return request.delete(`${BASE_URL}/delete?id=${id}`); + }, +}