From 80dcfffbe1eb03b3863efdb644d0660219c3ccc4 Mon Sep 17 00:00:00 2001 From: tikkhun Date: Fri, 30 Jan 2026 10:28:39 +0800 Subject: [PATCH] =?UTF-8?q?fix(Product):=20=E7=A6=81=E7=94=A8=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E5=88=9B=E5=BB=BA=E5=A5=97=E8=A3=85=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E5=BD=93=E6=9C=AA=E9=80=89=E6=8B=A9=E8=A1=8C=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix(Order): 调整同步订单日期范围格式并添加调试日志 fix(Customer): 优化客户信息显示逻辑和空值处理 refactor(SyncForm): 重构同步表单初始值和日期处理逻辑 --- src/components/SyncForm.tsx | 33 +++++++++++++--------- src/pages/Customer/StatisticList/index.tsx | 8 +++--- src/pages/Order/List/index.tsx | 5 ++-- src/pages/Product/List/index.tsx | 4 ++- 4 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/components/SyncForm.tsx b/src/components/SyncForm.tsx index 9d5d260..32c5395 100644 --- a/src/components/SyncForm.tsx +++ b/src/components/SyncForm.tsx @@ -16,7 +16,7 @@ interface SyncFormProps { tableRef: React.MutableRefObject; onFinish: (values: any) => Promise; siteId?: string; - dateRange?: [dayjs.Dayjs, dayjs.Dayjs]; + initialValues?: any; } /** @@ -28,7 +28,10 @@ const SyncForm: React.FC = ({ tableRef, onFinish, siteId, - dateRange, + initialValues = { + // 默认一星期 + dateRange: [dayjs().subtract(1, 'week'), dayjs()], + }, }) => { // 使用 antd 的 App 组件提供的 message API const [loading, setLoading] = React.useState(false); @@ -57,9 +60,7 @@ const SyncForm: React.FC = ({ // 返回一个抽屉表单 return ( - initialValues={{ - dateRange: [dayjs().subtract(1, 'week'), dayjs()], - }} + initialValues={initialValues} title="同步订单" // 表单的触发器,一个带图标的按钮 trigger={ @@ -75,9 +76,20 @@ const SyncForm: React.FC = ({ destroyOnHidden: true, }} // 表单提交成功后的回调 - onFinish={onFinish} + onFinish={async (values) => { + const normalValues = { + ...values, + dateRange: values.dateRange + ? [ + dayjs(values.dateRange[0]).format('YYYY-MM-DDTHH:mm:s[Z]'), + dayjs(values.dateRange[1]).add(1, 'day').format('YYYY-MM-DDTHH:mm:s[Z]'), + ] + : [], + }; + await onFinish(normalValues); + }} > - + {/* 站点选择框 */} = ({ name="dateRange" label="同步日期范围" placeholder={['开始日期', '结束日期']} - transform={(value) => { - return { - dateRange: value, - }; - }} fieldProps={{ showTime: false, - style: { width: '100%' }, }} /> - ); }; diff --git a/src/pages/Customer/StatisticList/index.tsx b/src/pages/Customer/StatisticList/index.tsx index 09d098d..8ee1138 100644 --- a/src/pages/Customer/StatisticList/index.tsx +++ b/src/pages/Customer/StatisticList/index.tsx @@ -27,9 +27,9 @@ const ListPage: React.FC = () => { dataIndex: 'username', hideInSearch: true, render: (_, record) => { - if (record.billing.first_name || record.billing.last_name) - return record.billing.first_name + ' ' + record.billing.last_name; - return record.shipping.first_name + ' ' + record.shipping.last_name; + if (record.billing?.first_name || record.billing?.last_name) + return record.billing?.first_name + ' ' + record.billing?.last_name; + return record.shipping?.first_name + ' ' + record.shipping?.last_name; }, }, { @@ -132,7 +132,7 @@ const ListPage: React.FC = () => { title: '联系电话', dataIndex: 'phone', hideInSearch: true, - render: (_, record) => record?.billing.phone || record?.shipping.phone, + render: (_, record) => record.phone ?? record?.billing?.phone ?? record?.shipping?.phone ?? '-', }, { title: '账单地址', diff --git a/src/pages/Order/List/index.tsx b/src/pages/Order/List/index.tsx index 36fd5cb..27053ea 100644 --- a/src/pages/Order/List/index.tsx +++ b/src/pages/Order/List/index.tsx @@ -612,13 +612,14 @@ const ListPage: React.FC = () => { { try { + console.log('values',values); const { success, message: errMsg, data, } = await ordercontrollerSyncorders(values, { - after: values.dateRange?.[0] + 'T00:00:00Z', - before: values.dateRange?.[1] + 'T23:59:59Z', + after: values.dateRange?.[0], + before: values.dateRange?.[1], }); if (!success) { throw new Error(errMsg); diff --git a/src/pages/Product/List/index.tsx b/src/pages/Product/List/index.tsx index 3f8a35e..b7b9a7a 100644 --- a/src/pages/Product/List/index.tsx +++ b/src/pages/Product/List/index.tsx @@ -467,7 +467,9 @@ const List: React.FC = () => { 批量修改 , // 批量创建 bundle 产品按钮 - , // 批量同步按钮