Commit 4a30efb0edfb288784d595d32ae58792fbb4a06c
1 parent
a2a8a660
feat: update
Showing
1 changed file
with
138 additions
and
63 deletions
src/pages/OrderReport/components/OrderStatisticCard.tsx
1 | import { RESPONSE_CODE } from '@/constants/enum'; | 1 | import { RESPONSE_CODE } from '@/constants/enum'; |
2 | import { postServiceOrderUpdateReportFormsTarget } from '@/services'; | 2 | import { postServiceOrderUpdateReportFormsTarget } from '@/services'; |
3 | -import Icon, { | ||
4 | - CheckCircleTwoTone, | ||
5 | - CloseCircleTwoTone, | ||
6 | - EditTwoTone, | ||
7 | -} from '@ant-design/icons'; | ||
8 | -import { ProCard } from '@ant-design/pro-components'; | ||
9 | -import { Flex, InputNumber, message } from 'antd'; | ||
10 | -import { useEffect, useState } from 'react'; | 3 | +import Icon, { EditTwoTone } from '@ant-design/icons'; |
4 | +import { ModalForm, ProCard, ProFormDigit } from '@ant-design/pro-components'; | ||
5 | +import { Flex, Form, message } from 'antd'; | ||
6 | +import { useState } from 'react'; | ||
11 | 7 | ||
12 | export default ({ data, statisticsMethod, reFreshData }) => { | 8 | export default ({ data, statisticsMethod, reFreshData }) => { |
13 | const [edit, setEdit] = useState(false); | 9 | const [edit, setEdit] = useState(false); |
10 | + const [form] = Form.useForm<{ | ||
11 | + statisticsMethod: string; | ||
12 | + target: number; | ||
13 | + daysOfMonth: number; | ||
14 | + }>(); | ||
15 | + const [targetValue, setTargetValue] = useState(0); | ||
14 | 16 | ||
15 | const UpBig = () => ( | 17 | const UpBig = () => ( |
16 | <svg width="44" height="auto" fill="#d81e06" viewBox="0 0 1024 1024"> | 18 | <svg width="44" height="auto" fill="#d81e06" viewBox="0 0 1024 1024"> |
@@ -57,10 +59,11 @@ export default ({ data, statisticsMethod, reFreshData }) => { | @@ -57,10 +59,11 @@ export default ({ data, statisticsMethod, reFreshData }) => { | ||
57 | sameMonthPercentageChange = -1000, | 59 | sameMonthPercentageChange = -1000, |
58 | editable = false, | 60 | editable = false, |
59 | }) => { | 61 | }) => { |
60 | - const [targetValue, setTargetValue] = useState(0); | ||
61 | - useEffect(() => { | 62 | + //如果是可编辑的说明是指标,设置指标值,可用在弹窗中的回显 |
63 | + if (editable) { | ||
62 | setTargetValue(content); | 64 | setTargetValue(content); |
63 | - }, [content]); | 65 | + } |
66 | + | ||
64 | let trendIcon; | 67 | let trendIcon; |
65 | let trendPercentage; | 68 | let trendPercentage; |
66 | if (sameMonthPercentageChange > 0) { | 69 | if (sameMonthPercentageChange > 0) { |
@@ -102,7 +105,28 @@ export default ({ data, statisticsMethod, reFreshData }) => { | @@ -102,7 +105,28 @@ export default ({ data, statisticsMethod, reFreshData }) => { | ||
102 | <Flex align="center"> | 105 | <Flex align="center"> |
103 | <span className="text-base pr-1">{unit}</span> | 106 | <span className="text-base pr-1">{unit}</span> |
104 | <div style={{ width: 'max-content', display: 'flex' }}> | 107 | <div style={{ width: 'max-content', display: 'flex' }}> |
108 | + <span className="text-2xl"> | ||
109 | + {content} | ||
110 | + {editable ? ( | ||
111 | + <span className="text-xs pl-1"> | ||
112 | + {statisticsMethod === 'YEAR_STATISTICS' ? '每年' : '每月'} | ||
113 | + </span> | ||
114 | + ) : ( | ||
115 | + '' | ||
116 | + )} | ||
117 | + </span> | ||
105 | {editable ? ( | 118 | {editable ? ( |
119 | + <EditTwoTone | ||
120 | + style={{ fontSize: '20px' }} | ||
121 | + onClick={() => { | ||
122 | + setEdit(true); | ||
123 | + }} | ||
124 | + /> | ||
125 | + ) : ( | ||
126 | + '' | ||
127 | + )} | ||
128 | + | ||
129 | + {/* {editable ? ( | ||
106 | edit ? ( | 130 | edit ? ( |
107 | <InputNumber | 131 | <InputNumber |
108 | placeholder="请输入指标(¥)" | 132 | placeholder="请输入指标(¥)" |
@@ -130,9 +154,9 @@ export default ({ data, statisticsMethod, reFreshData }) => { | @@ -130,9 +154,9 @@ export default ({ data, statisticsMethod, reFreshData }) => { | ||
130 | </span> | 154 | </span> |
131 | ) : ( | 155 | ) : ( |
132 | '' | 156 | '' |
133 | - )} | 157 | + )} */} |
134 | 158 | ||
135 | - {editable ? ( | 159 | + {/* {editable ? ( |
136 | edit ? ( | 160 | edit ? ( |
137 | [ | 161 | [ |
138 | <CheckCircleTwoTone | 162 | <CheckCircleTwoTone |
@@ -171,7 +195,7 @@ export default ({ data, statisticsMethod, reFreshData }) => { | @@ -171,7 +195,7 @@ export default ({ data, statisticsMethod, reFreshData }) => { | ||
171 | ) | 195 | ) |
172 | ) : ( | 196 | ) : ( |
173 | '' | 197 | '' |
174 | - )} | 198 | + )} */} |
175 | </div> | 199 | </div> |
176 | </Flex> | 200 | </Flex> |
177 | {trendIcon} | 201 | {trendIcon} |
@@ -183,57 +207,108 @@ export default ({ data, statisticsMethod, reFreshData }) => { | @@ -183,57 +207,108 @@ export default ({ data, statisticsMethod, reFreshData }) => { | ||
183 | }; | 207 | }; |
184 | 208 | ||
185 | return ( | 209 | return ( |
186 | - <ProCard title="" ghost gutter={8}> | ||
187 | - <ProCard | ||
188 | - className="order-statictis-card" | ||
189 | - bordered | ||
190 | - title={<CardTitle title={'总收入'} />} | ||
191 | - > | ||
192 | - <CardContent | ||
193 | - unit="¥" | ||
194 | - content={data.totalPayment} | ||
195 | - sameMonthPercentageChange={data.totalPaymentTrend} | ||
196 | - /> | ||
197 | - </ProCard> | ||
198 | - <ProCard | ||
199 | - className="order-statictis-card" | ||
200 | - title={<CardTitle title={'指标'} />} | ||
201 | - bordered | ||
202 | - > | ||
203 | - <CardContent unit="¥" content={data.target} editable={true} /> | 210 | + <> |
211 | + <ProCard title="" ghost gutter={8}> | ||
212 | + <ProCard | ||
213 | + className="order-statictis-card" | ||
214 | + bordered | ||
215 | + title={<CardTitle title={'总收入'} />} | ||
216 | + > | ||
217 | + <CardContent | ||
218 | + unit="¥" | ||
219 | + content={data.totalPayment} | ||
220 | + sameMonthPercentageChange={data.totalPaymentTrend} | ||
221 | + /> | ||
222 | + </ProCard> | ||
223 | + <ProCard | ||
224 | + className="order-statictis-card" | ||
225 | + title={<CardTitle title={'指标'} />} | ||
226 | + bordered | ||
227 | + > | ||
228 | + <CardContent unit="¥" content={data.target} editable={true} /> | ||
229 | + </ProCard> | ||
230 | + <ProCard | ||
231 | + className="order-statictis-card" | ||
232 | + title={<CardTitle title={'总订单量'} />} | ||
233 | + bordered | ||
234 | + > | ||
235 | + <CardContent | ||
236 | + unit="单" | ||
237 | + content={data.totalOrderNumber} | ||
238 | + sameMonthPercentageChange={data.totalOrderNumberTrend} | ||
239 | + /> | ||
240 | + </ProCard> | ||
241 | + <ProCard | ||
242 | + className="order-statictis-card" | ||
243 | + title={<CardTitle title={'总子订单量'} />} | ||
244 | + bordered | ||
245 | + > | ||
246 | + <CardContent unit="单" content={data.subTotalOrderNumber} /> | ||
247 | + </ProCard> | ||
248 | + <ProCard | ||
249 | + className="order-statictis-card" | ||
250 | + title={<CardTitle title={'未审核订单'} />} | ||
251 | + bordered | ||
252 | + > | ||
253 | + <CardContent unit="单" content={data.unCheckOrderNumber} /> | ||
254 | + </ProCard> | ||
255 | + <ProCard | ||
256 | + className="order-statictis-card" | ||
257 | + title={<CardTitle title={'未发货订单'} />} | ||
258 | + bordered | ||
259 | + > | ||
260 | + <CardContent unit="单" content={data.unSendOrderNumber} /> | ||
261 | + </ProCard> | ||
204 | </ProCard> | 262 | </ProCard> |
205 | - <ProCard | ||
206 | - className="order-statictis-card" | ||
207 | - title={<CardTitle title={'总订单量'} />} | ||
208 | - bordered | 263 | + |
264 | + <ModalForm<{ | ||
265 | + statisticsMethod: string; | ||
266 | + target: number; | ||
267 | + daysOfMonth: number; | ||
268 | + }> | ||
269 | + title="编辑指标" | ||
270 | + width={500} | ||
271 | + form={form} | ||
272 | + open={edit} | ||
273 | + autoFocusFirstInput | ||
274 | + modalProps={{ | ||
275 | + destroyOnClose: true, | ||
276 | + onCancel: () => setEdit(false), | ||
277 | + }} | ||
278 | + onFinish={async (values) => { | ||
279 | + values.statisticsMethod = statisticsMethod; | ||
280 | + let res = await postServiceOrderUpdateReportFormsTarget({ | ||
281 | + data: values, | ||
282 | + }); | ||
283 | + if (res.result === RESPONSE_CODE.SUCCESS) { | ||
284 | + message.success(res.message); | ||
285 | + setEdit(false); | ||
286 | + reFreshData(); | ||
287 | + } | ||
288 | + }} | ||
209 | > | 289 | > |
210 | - <CardContent | ||
211 | - unit="单" | ||
212 | - content={data.totalOrderNumber} | ||
213 | - sameMonthPercentageChange={data.totalOrderNumberTrend} | 290 | + <ProFormDigit |
291 | + width="md" | ||
292 | + name="target" | ||
293 | + label="指标(¥)" | ||
294 | + min={0} | ||
295 | + initialValue={targetValue} | ||
296 | + placeholder="请输入指标" | ||
297 | + rules={[{ required: true, message: '指标必填' }]} | ||
214 | /> | 298 | /> |
215 | - </ProCard> | ||
216 | - <ProCard | ||
217 | - className="order-statictis-card" | ||
218 | - title={<CardTitle title={'总子订单量'} />} | ||
219 | - bordered | ||
220 | - > | ||
221 | - <CardContent unit="单" content={data.subTotalOrderNumber} /> | ||
222 | - </ProCard> | ||
223 | - <ProCard | ||
224 | - className="order-statictis-card" | ||
225 | - title={<CardTitle title={'未审核订单'} />} | ||
226 | - bordered | ||
227 | - > | ||
228 | - <CardContent unit="单" content={data.unCheckOrderNumber} /> | ||
229 | - </ProCard> | ||
230 | - <ProCard | ||
231 | - className="order-statictis-card" | ||
232 | - title={<CardTitle title={'未发货订单'} />} | ||
233 | - bordered | ||
234 | - > | ||
235 | - <CardContent unit="单" content={data.unSendOrderNumber} /> | ||
236 | - </ProCard> | ||
237 | - </ProCard> | 299 | + <ProFormDigit |
300 | + width="md" | ||
301 | + name="daysOfMonth" | ||
302 | + label={ | ||
303 | + statisticsMethod === 'YEAR_STATISTICS' | ||
304 | + ? '每月工作日天数' | ||
305 | + : '本月工作日天数' | ||
306 | + } | ||
307 | + min={0} | ||
308 | + placeholder="工作日天数" | ||
309 | + rules={[{ required: true, message: '工作日天数必填' }]} | ||
310 | + /> | ||
311 | + </ModalForm> | ||
312 | + </> | ||
238 | ); | 313 | ); |
239 | }; | 314 | }; |