index.tsx
5.43 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
import {
postServiceOrderQueryReportFormsInformation,
postServiceOrderQuerySalesCode,
} from '@/services';
import { enumToSelect } from '@/utils';
import {
ProCard,
ProFormCheckbox,
ProFormDigit,
ProFormSelect,
QueryFilter,
} from '@ant-design/pro-components';
import { Form, Segmented, Space, Spin } from 'antd';
import { useEffect, useState } from 'react';
import { PRODUCT_BELONG_DEPARTMENT_OPTIONS } from '../Order/constant';
import OrderDualAxes from './components/OrderDualAxes';
import OrderStatisticCard from './components/OrderStatisticCard';
import './index.less';
const OrderReportPage = () => {
const [salesCodeOptions, setSalesCodeOptions] = useState([]);
/**
* 获取销售代码枚举,在复制和编辑的时候判断是否为旧的代码
*/
const getSalesCodeOptions = async () => {
const res = await postServiceOrderQuerySalesCode();
let options = res.data?.map((item) => {
return {
label: item.userName,
value: item.userName,
number: item.number,
};
});
setSalesCodeOptions(options);
};
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) => {
if (key === '本月') {
setStatisticsMethod('MONTH_STATISTICS');
}
if (key === '上月') {
setStatisticsMethod('LAST_MONTH_STATISTICS');
}
if (key === '本年') {
setStatisticsMethod('YEAR_STATISTICS');
}
};
/**
* 加载页面数据
*/
const loadData = async () => {
setLoading(true);
let body = {
statisticsMethod: '',
salesCode: form.getFieldValue('salesCode'),
productBelongBusiness: form.getFieldValue('productBelongBusiness'),
maxAccount: form.getFieldValue('maxAccount'),
includeExperimentalEquipment: form.getFieldValue(
'includeExperimentalEquipment',
),
// 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();
getSalesCodeOptions();
}, []);
// const items: TabsProps['items'] = [
// {
// key: 'MONTH_STATISTICS',
// label: '本月统计',
// children: '',
// },
// {
// key: 'YEAR_STATISTICS',
// label: '本年统计',
// children: '',
// },
// ];
return (
<div>
<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"
defaultCollapsed={false}
form={form}
onFinish={async () => {
loadData();
return true;
}}
>
<ProFormSelect
name="salesCode"
key="salesCode"
width="lg"
showSearch
label="销售代表"
placeholder="请选择销售代表"
options={salesCodeOptions}
/>
<ProFormSelect
key="productBelongBusiness"
placeholder="请输入所属事业部"
name="productBelongBusiness"
label="所属事业部"
options={enumToSelect(PRODUCT_BELONG_DEPARTMENT_OPTIONS)}
onChange={(val: any) => {
if (val === 'EXPERIMENTAL_EQUIPMENT') {
//勾选上包含设备事业部
form.setFieldValue('includeExperimentalEquipment', true);
}
}}
/>
<ProFormDigit label="排除大订单金额" name="maxAccount" min={0} />
<ProFormCheckbox
key="includeExperimentalEquipment"
name="includeExperimentalEquipment"
initialValue={false}
label="包含实验设备事业部汇总统计"
/>
</QueryFilter>
</ProCard>
<ProCard
id="order-dual-axes-card"
title="汇总统计"
tooltip="下方汇总统计未统计实验设备事业部数据,如需要请勾选包含实验设备事业部汇总统计"
extra={
<Segmented
options={['本月', '上月', '本年']}
onChange={(val: any) => {
onChange(val);
}}
/>
}
bordered
>
<Spin spinning={loading}>
<OrderDualAxes
data={statisticData}
statisticMethod={statisticsMethod}
/>
</Spin>
</ProCard>
</Space>
</div>
);
};
export default OrderReportPage;