diff --git a/src/constants/index.ts b/src/constants/index.ts index 0360a09..a0ac530 100644 --- a/src/constants/index.ts +++ b/src/constants/index.ts @@ -9,23 +9,23 @@ export const PRODUCT_STATUS_ENUM: ProSchemaValueEnumObj = { }, draft: { text: '草稿', - status: 'default', + status: 'draft', }, pending: { text: '待审核', - status: 'warning', + status: 'pending', }, private: { text: '私有', - status: 'warning', + status: 'private', }, trash: { text: '已删除', status: 'error', }, 'auto-draft': { - text: '字段草稿', - status: 'default', + text: '自动草稿', + status: 'auto-draft', }, future: { text: '定时发布', @@ -33,7 +33,7 @@ export const PRODUCT_STATUS_ENUM: ProSchemaValueEnumObj = { }, inherit: { text: '继承状态', - status: 'default', + status: 'inherit', }, }; diff --git a/src/pages/Product/WpList/index.tsx b/src/pages/Product/WpList/index.tsx index a23dc3a..cb7fb94 100644 --- a/src/pages/Product/WpList/index.tsx +++ b/src/pages/Product/WpList/index.tsx @@ -10,6 +10,7 @@ import { wpproductcontrollerSyncproducts, wpproductcontrollerUpdateproduct, wpproductcontrollerUpdatevariation, + wpproductcontrollerUpdatewpproductstate, } from '@/servers/api/wpProduct'; import { EditOutlined } from '@ant-design/icons'; import { @@ -86,6 +87,7 @@ const List: React.FC = () => { render: (_, record) => ( <> + {record.type === 'simple' && record.sku ? ( <> @@ -232,6 +234,62 @@ const SyncForm: React.FC<{ ); }; +const UpdateStatus: React.FC<{ + tableRef: React.MutableRefObject; + values: API.WpProductDTO; +}> = ({ tableRef, values: initialValues }) => { + const { message } = App.useApp(); + return ( + + title="修改产品上下架状态" + initialValues={initialValues} + trigger={ + + } + autoFocusFirstInput + drawerProps={{ + destroyOnHidden: true, + }} + onFinish={async (values) => { + console.log('values', values); + const { status } = values; + try { + const { success, message: errMsg } = + await wpproductcontrollerUpdatewpproductstate( + { + id: initialValues.id, + }, + { status }, + ); + if (!success) { + throw new Error(errMsg); + } + message.success('提交成功'); + tableRef.current?.reload(); + return true; + } catch (error: any) { + message.error(error.message); + } + }} + > + + + + + + + ); +}; + + const UpdateForm: React.FC<{ tableRef: React.MutableRefObject; values: API.WpProductDTO; diff --git a/src/servers/api/typings.d.ts b/src/servers/api/typings.d.ts index 15a98be..4a356ec 100644 --- a/src/servers/api/typings.d.ts +++ b/src/servers/api/typings.d.ts @@ -299,6 +299,7 @@ declare namespace API { type ordercontrollerGetordersalesParams = { isSource?: boolean; + exceptPackage?: boolean; /** 页码 */ current?: number; /** 每页大小 */ @@ -501,7 +502,7 @@ declare namespace API { /** sku */ sku?: string; quantity?: number; - exceptPackage?: boolean; + isPackage?: boolean; isYoone?: boolean; isZex?: boolean; size?: number; @@ -522,7 +523,7 @@ declare namespace API { /** sku */ sku?: string; quantity?: number; - exceptPackage?: boolean; + isPackage?: boolean; isYoone?: boolean; isZex?: boolean; size?: number; @@ -856,6 +857,7 @@ declare namespace API { type QueryOrderSalesDTO = { isSource?: boolean; + exceptPackage?: boolean; /** 页码 */ current?: number; /** 每页大小 */ @@ -1447,6 +1449,10 @@ declare namespace API { siteId: string; }; + type wpproductcontrollerUpdatewpproductstateParams = { + id: number; + }; + type WpProductDTO = { /** ID */ id: number; diff --git a/src/servers/api/wpProduct.ts b/src/servers/api/wpProduct.ts index c1bcb06..bb2e9c1 100644 --- a/src/servers/api/wpProduct.ts +++ b/src/servers/api/wpProduct.ts @@ -98,3 +98,22 @@ export async function wpproductcontrollerSyncproducts( ...(options || {}), }); } + +/** 此处后端没有提供注释 POST /wp_product/updateState/${param0} */ +export async function wpproductcontrollerUpdatewpproductstate( + // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) + params: API.wpproductcontrollerUpdatewpproductstateParams, + body: Record, + options?: { [key: string]: any }, +) { + const { id: param0, ...queryParams } = params; + return request(`/wp_product/updateState/${param0}`, { + method: 'POST', + headers: { + 'Content-Type': 'text/plain', + }, + params: { ...queryParams }, + data: body, + ...(options || {}), + }); +}