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