diff --git a/src/constants/index.ts b/src/constants/index.ts index a0ac530..3df107c 100644 --- a/src/constants/index.ts +++ b/src/constants/index.ts @@ -37,6 +37,21 @@ export const PRODUCT_STATUS_ENUM: ProSchemaValueEnumObj = { }, }; +export const PRODUCT_STOCK_STATUS_ENUM: ProSchemaValueEnumObj = { + instock: { + text: '上架', + status: 'instock', + }, + outofstock: { + text: 'out of stock', + status: 'outofstock', + }, + onbackorder: { + text: 'on back order', + status: 'onbackorder', + }, +}; + export const Purchase_Order_STATUS_ENUM: ProSchemaValueEnumObj = { draft: { text: '草稿', diff --git a/src/pages/Product/WpList/index.tsx b/src/pages/Product/WpList/index.tsx index cb7fb94..17f304e 100644 --- a/src/pages/Product/WpList/index.tsx +++ b/src/pages/Product/WpList/index.tsx @@ -1,4 +1,4 @@ -import { PRODUCT_STATUS_ENUM } from '@/constants'; +import { PRODUCT_STATUS_ENUM, PRODUCT_STOCK_STATUS_ENUM } from '@/constants'; import { productcontrollerProductbysku, productcontrollerSearchproducts, @@ -255,14 +255,17 @@ const UpdateStatus: React.FC<{ }} onFinish={async (values) => { console.log('values', values); - const { status } = values; + const { status, stock_status } = values; try { const { success, message: errMsg } = await wpproductcontrollerUpdatewpproductstate( { id: initialValues.id, }, - { status }, + { + status, + stock_status + }, ); if (!success) { throw new Error(errMsg); @@ -281,9 +284,13 @@ const UpdateStatus: React.FC<{ width="lg" name="status" valueEnum={PRODUCT_STATUS_ENUM} - > - - + /> + ); diff --git a/src/servers/api/typings.d.ts b/src/servers/api/typings.d.ts index 4a356ec..89b7b71 100644 --- a/src/servers/api/typings.d.ts +++ b/src/servers/api/typings.d.ts @@ -1474,6 +1474,8 @@ declare namespace API { | 'auto-draft' | 'future' | 'inherit'; + /** 上下架状态 */ + stockStatus?: 'instock' | 'outofstock' | 'onbackorder'; /** 常规价格 */ regular_price?: number; /** 销售价格 */