fix(订单同步): 修复订单同步功能并添加日期范围选择
修复订单同步接口调用参数错误 在同步表单中添加日期范围选择器 调整订单来源统计接口名称拼写错误
This commit is contained in:
parent
d0097aec38
commit
af1cebe29d
|
|
@ -5,8 +5,10 @@ import {
|
||||||
DrawerForm,
|
DrawerForm,
|
||||||
ProForm,
|
ProForm,
|
||||||
ProFormSelect,
|
ProFormSelect,
|
||||||
|
ProFormDateRangePicker,
|
||||||
} from '@ant-design/pro-components';
|
} from '@ant-design/pro-components';
|
||||||
import { Button } from 'antd';
|
import { Button } from 'antd';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
// 定义SyncForm组件的props类型
|
// 定义SyncForm组件的props类型
|
||||||
|
|
@ -14,6 +16,7 @@ interface SyncFormProps {
|
||||||
tableRef: React.MutableRefObject<ActionType | undefined>;
|
tableRef: React.MutableRefObject<ActionType | undefined>;
|
||||||
onFinish: (values: any) => Promise<void>;
|
onFinish: (values: any) => Promise<void>;
|
||||||
siteId?: string;
|
siteId?: string;
|
||||||
|
dateRange?: [dayjs.Dayjs, dayjs.Dayjs];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -21,7 +24,7 @@ interface SyncFormProps {
|
||||||
* @param {SyncFormProps} props 组件属性
|
* @param {SyncFormProps} props 组件属性
|
||||||
* @returns {React.ReactElement} 抽屉表单
|
* @returns {React.ReactElement} 抽屉表单
|
||||||
*/
|
*/
|
||||||
const SyncForm: React.FC<SyncFormProps> = ({ tableRef, onFinish, siteId }) => {
|
const SyncForm: React.FC<SyncFormProps> = ({ tableRef, onFinish, siteId, dateRange }) => {
|
||||||
// 使用 antd 的 App 组件提供的 message API
|
// 使用 antd 的 App 组件提供的 message API
|
||||||
const [loading, setLoading] = React.useState(false);
|
const [loading, setLoading] = React.useState(false);
|
||||||
|
|
||||||
|
|
@ -49,7 +52,11 @@ const SyncForm: React.FC<SyncFormProps> = ({ tableRef, onFinish, siteId }) => {
|
||||||
// 返回一个抽屉表单
|
// 返回一个抽屉表单
|
||||||
return (
|
return (
|
||||||
<DrawerForm<API.ordercontrollerSyncorderParams>
|
<DrawerForm<API.ordercontrollerSyncorderParams>
|
||||||
title="同步订单"
|
initialValues={{
|
||||||
|
dateRange: [dayjs().subtract(1, 'week'), dayjs()],
|
||||||
|
}}
|
||||||
|
|
||||||
|
title="同步订单"
|
||||||
// 表单的触发器,一个带图标的按钮
|
// 表单的触发器,一个带图标的按钮
|
||||||
trigger={
|
trigger={
|
||||||
<Button key="syncSite" type="primary">
|
<Button key="syncSite" type="primary">
|
||||||
|
|
@ -67,6 +74,7 @@ const SyncForm: React.FC<SyncFormProps> = ({ tableRef, onFinish, siteId }) => {
|
||||||
onFinish={onFinish}
|
onFinish={onFinish}
|
||||||
>
|
>
|
||||||
<ProForm.Group>
|
<ProForm.Group>
|
||||||
|
|
||||||
{/* 站点选择框 */}
|
{/* 站点选择框 */}
|
||||||
<ProFormSelect
|
<ProFormSelect
|
||||||
name="siteId"
|
name="siteId"
|
||||||
|
|
@ -83,6 +91,22 @@ const SyncForm: React.FC<SyncFormProps> = ({ tableRef, onFinish, siteId }) => {
|
||||||
}));
|
}));
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<ProFormDateRangePicker
|
||||||
|
name="dateRange"
|
||||||
|
label="同步日期范围"
|
||||||
|
placeholder={['开始日期', '结束日期']}
|
||||||
|
|
||||||
|
transform={(value) => {
|
||||||
|
return {
|
||||||
|
dateRange: value,
|
||||||
|
};
|
||||||
|
}}
|
||||||
|
fieldProps={{
|
||||||
|
showTime: false,
|
||||||
|
style: { width: '100%' },
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</ProForm.Group>
|
</ProForm.Group>
|
||||||
</DrawerForm>
|
</DrawerForm>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -502,7 +502,7 @@ const ListPage: React.FC = () => {
|
||||||
success,
|
success,
|
||||||
message: errMsg,
|
message: errMsg,
|
||||||
data,
|
data,
|
||||||
} = await ordercontrollerSyncorders(values);
|
} = await ordercontrollerSyncorders(values,{after:values.dateRange?.[0]+'T00:00:00Z',before:values.dateRange?.[1]+'T23:59:59Z'});
|
||||||
if (!success) {
|
if (!success) {
|
||||||
throw new Error(errMsg);
|
throw new Error(errMsg);
|
||||||
}
|
}
|
||||||
|
|
@ -997,6 +997,7 @@ const Detail: React.FC<{
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* 显示 related order */}
|
{/* 显示 related order */}
|
||||||
<ProDescriptions.Item
|
<ProDescriptions.Item
|
||||||
label="关联"
|
label="关联"
|
||||||
|
|
@ -1506,16 +1507,16 @@ const Shipping: React.FC<{
|
||||||
<ProFormList
|
<ProFormList
|
||||||
label="发货产品"
|
label="发货产品"
|
||||||
name="sales"
|
name="sales"
|
||||||
// rules={[
|
// rules={[
|
||||||
// {
|
// {
|
||||||
// required: true,
|
// required: true,
|
||||||
// message: '至少需要一个商品',
|
// message: '至少需要一个商品',
|
||||||
// validator: (_, value) =>
|
// validator: (_, value) =>
|
||||||
// value && value.length > 0
|
// value && value.length > 0
|
||||||
// ? Promise.resolve()
|
//</Col> ? Promise.resolve()
|
||||||
// : Promise.reject('至少需要一个商品'),
|
// : Promise.reject('至少需要一个商品'),
|
||||||
// },
|
// },
|
||||||
// ]}
|
// ]}
|
||||||
>
|
>
|
||||||
<ProForm.Group>
|
<ProForm.Group>
|
||||||
<ProFormSelect
|
<ProFormSelect
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import React, { useEffect, useMemo, useRef, useState } from 'react';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
statisticscontrollerGetinativeusersbymonth,
|
statisticscontrollerGetinativeusersbymonth,
|
||||||
statisticscontrollerGetordersorce,
|
statisticscontrollerGetordersource,
|
||||||
} from '@/servers/api/statistics';
|
} from '@/servers/api/statistics';
|
||||||
import {
|
import {
|
||||||
ActionType,
|
ActionType,
|
||||||
|
|
@ -25,7 +25,7 @@ const ListPage: React.FC = () => {
|
||||||
country: ['CA'],
|
country: ['CA'],
|
||||||
};
|
};
|
||||||
function handleSubmit(values: typeof initialValues) {
|
function handleSubmit(values: typeof initialValues) {
|
||||||
statisticscontrollerGetordersorce({params: values}).then(({ data, success }) => {
|
statisticscontrollerGetordersource({params: values}).then(({ data, success }) => {
|
||||||
if (success) setData(data);
|
if (success) setData(data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue