index.tsx
5.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
import { postServiceOrderQueryReportFormsInformation } from '@/services';
import { enumToSelect } from '@/utils';
import { getUserInfo } from '@/utils/user';
import { EllipsisOutlined } from '@ant-design/icons';
import {
PageContainer,
ProCard,
ProFormDigit,
ProFormSelect,
QueryFilter,
} from '@ant-design/pro-components';
import { history } from '@umijs/max';
import {
Avatar,
Button,
Dropdown,
Flex,
Form,
Space,
Spin,
Tabs,
TabsProps,
Tag,
} from 'antd';
import { useEffect, useState } from 'react';
import {
PRODUCT_BELONG_DEPARTMENT_OPTIONS,
SALES_CODE_OPTIONS,
} from '../Order/constant';
import OrderDualAxes from './components/OrderDualAxes';
import OrderStatisticCard from './components/OrderStatisticCard';
import './index.less';
const userInfo = getUserInfo();
const OrderReportPage = () => {
const [form] = Form.useForm<{
salesCode: '';
productBelongBusiness: '';
dateRange: '';
}>();
const [statisticData, setStatisticData] = useState([]);
const [loading, setLoading] = useState(false);
const [statisticsMethod, setStatisticsMethod] = useState('MONTH_STATISTICS');
const onChange = (key: string) => {
setStatisticsMethod(key);
};
/**
* 加载页面数据
*/
const loadData = async () => {
setLoading(true);
let body = {
statisticsMethod: '',
salesCode: form.getFieldValue('salesCode'),
productBelongBusiness: form.getFieldValue('productBelongBusiness'),
maxAccount: form.getFieldValue('maxAccount'),
// beginTime:"",
// endTime:""
};
// if(form.getFieldValue("dateRange")!==undefined){
// body.beginTime=formatDate(form.getFieldValue("dateRange")[0]),
// body.endTime=formatDate(form.getFieldValue("dateRange")[1])
// }
body.statisticsMethod = statisticsMethod;
const { data } = await postServiceOrderQueryReportFormsInformation({
data: body,
});
if (data !== undefined) {
setStatisticData(data);
}
setLoading(false);
};
useEffect(() => {
loadData();
}, [statisticsMethod]);
useEffect(() => {
loadData();
}, []);
const items: TabsProps['items'] = [
{
key: 'MONTH_STATISTICS',
label: '本月统计',
children: '',
},
{
key: 'YEAR_STATISTICS',
label: '本年统计',
children: '',
},
];
return (
<PageContainer
header={{
title: '订单汇总',
extra: [
<Avatar key="0" style={{ verticalAlign: 'middle' }} size="large">
{userInfo?.username}
</Avatar>,
<Tag key="nickName">{userInfo?.nickName}</Tag>,
<Dropdown
key="dropdown"
trigger={['click']}
menu={{
items: [
{
label: '退出登录',
key: '1',
onClick: () => {
localStorage.removeItem('token');
history.push('/login');
},
},
// {
// label: '修改密码',
// key: '2',
// },
],
}}
>
<Button key="4" style={{ padding: '0 8px' }}>
<EllipsisOutlined />
</Button>
</Dropdown>,
],
}}
>
<Space direction="vertical" size="middle" className="flex">
<Spin spinning={loading}>
<OrderStatisticCard
data={statisticData}
statisticsMethod={statisticsMethod}
reFreshData={loadData}
/>
</Spin>
<ProCard tooltip="这是提示" bordered>
<QueryFilter
split
className="!p-0 order-statistic-search"
labelWidth="auto"
form={form}
onFinish={async () => {
loadData();
return true;
}}
>
<ProFormSelect
name="salesCode"
key="salesCode"
showSearch
label="销售代表"
placeholder="请输入销售代表"
options={SALES_CODE_OPTIONS}
/>
<ProFormSelect
key="productBelongBusiness"
placeholder="请输入所属事业部"
name="productBelongBusiness"
label="所属事业部"
options={enumToSelect(PRODUCT_BELONG_DEPARTMENT_OPTIONS)}
/>
<ProFormDigit label="排除大订单金额" name="maxAccount" min={0} />
{/* <ProFormDateRangePicker
key="dateRange"
name="dateRange"
label="时间"
/> */}
</QueryFilter>
</ProCard>
<ProCard
id="order-dual-axes-card"
title="统计图表"
extra={
<Flex>
<Tabs defaultActiveKey="1" items={items} onChange={onChange} />
</Flex>
}
bordered
>
<Spin spinning={loading}>
<OrderDualAxes
data={statisticData}
statisticMethod={statisticsMethod}
/>
</Spin>
</ProCard>
</Space>
</PageContainer>
);
};
export default OrderReportPage;