Commit 6aeca0695b41470cba9b007b93dda94b3485f4d4
1 parent
0f992b9d
fix: 修改预警错误
Showing
2 changed files
with
79 additions
and
76 deletions
src/pages/Order/OrderList/OrderList.tsx
... | ... | @@ -4796,8 +4796,8 @@ const OrderList = ({ paramsNew, searchShow, toolbarShow }) => { |
4796 | 4796 | if (paramsNew) { |
4797 | 4797 | setNewParams(paramsNew); |
4798 | 4798 | console.log(newParams); |
4799 | + refreshTable(); | |
4799 | 4800 | } |
4800 | - // refreshTable(); | |
4801 | 4801 | }, [paramsNew]); |
4802 | 4802 | return ( |
4803 | 4803 | <div className="order-page-container"> | ... | ... |
src/pages/Order/OrderWarning/index.tsx
... | ... | @@ -5,26 +5,26 @@ import { |
5 | 5 | import { downloadFile } from '@/services/order'; |
6 | 6 | import { getSalesCodeOptions } from '@/utils/order'; |
7 | 7 | import { getUserInfo } from '@/utils/user'; |
8 | -import { | |
9 | - ActionType, | |
10 | - ProFormInstance, | |
11 | - ProFormSelect, | |
12 | -} from '@ant-design/pro-components'; | |
8 | +import { ActionType, ProFormSelect } from '@ant-design/pro-components'; | |
13 | 9 | import { Badge, Button, Radio, message } from 'antd'; |
14 | 10 | import { format } from 'date-fns'; |
15 | -import React, { useEffect, useRef, useState } from 'react'; | |
11 | +import { useEffect, useMemo, useRef, useState } from 'react'; | |
16 | 12 | import OrderList from '../OrderList/OrderList'; |
17 | 13 | import './index.less'; |
18 | 14 | // import { useParams } from '@umijs/max'; |
19 | 15 | |
16 | +// 定义参数类型 | |
17 | +interface ParamsType { | |
18 | + [key: string]: any; | |
19 | +} | |
20 | + | |
20 | 21 | const OrderPage = () => { |
21 | - const [salesCodeOptions, setSalesCodeOptions] = useState([]); | |
22 | - const [salesCodeSelect, setSalesCodeSelect] = useState(); | |
22 | + const [salesCodeOptions, setSalesCodeOptions] = useState<any[]>([]); | |
23 | + const [salesCodeSelect, setSalesCodeSelect] = useState<string>(); | |
23 | 24 | const userInfo = getUserInfo(); |
24 | 25 | |
25 | 26 | const mainTableRef = useRef<ActionType>(); |
26 | - const mainTableFormRef = useRef<ProFormInstance>(); | |
27 | - let [searchParams] = useState(Object); //表格的查询条件存储 | |
27 | + let [searchParams] = useState<ParamsType>({}); //表格的查询条件存储 | |
28 | 28 | console.log(searchParams); |
29 | 29 | const [messageApi] = message.useMessage(); |
30 | 30 | console.log(messageApi); |
... | ... | @@ -92,7 +92,8 @@ const OrderPage = () => { |
92 | 92 | //选择天数 |
93 | 93 | const [calDate, setCalDate] = useState<string | null>(null); |
94 | 94 | const [value1, setValue1] = useState(0); |
95 | - const radioOnChange1 = ({ target: { value } }) => { | |
95 | + const radioOnChange1 = (e: any) => { | |
96 | + const { value } = e.target; | |
96 | 97 | const currentDate = new Date(); |
97 | 98 | // 创建一个新的日期对象,并在当前日期的基础上加上 daysToAdd 天 |
98 | 99 | const newDate = new Date(currentDate); |
... | ... | @@ -101,7 +102,7 @@ const OrderPage = () => { |
101 | 102 | setCalDate(formattedDate); |
102 | 103 | setValue1(value); |
103 | 104 | }; |
104 | - function setOriginTime(value) { | |
105 | + function setOriginTime(value: number) { | |
105 | 106 | const currentDate = new Date(); |
106 | 107 | // 创建一个新的日期对象,并在当前日期的基础上加上 daysToAdd 天 |
107 | 108 | const newDate = new Date(currentDate); |
... | ... | @@ -214,12 +215,70 @@ const OrderPage = () => { |
214 | 215 | const formattedDate = format(newDate, 'yyyy-MM-dd HH:mm:ss'); |
215 | 216 | setCalDate(formattedDate); |
216 | 217 | }, [activeTabKey]); |
218 | + | |
219 | + // 使用 useMemo 让参数能够响应状态变化 | |
220 | + const paramsNew = useMemo(() => { | |
221 | + // 初始化参数 | |
222 | + let initialParams: ParamsType = {}; | |
223 | + initialParams.isDeleteQueryOrderNow = false; | |
224 | + initialParams.salesCode = userInfo.username; | |
225 | + if (salesCodePermission) { | |
226 | + if (salesCodeSelect !== undefined && salesCodeSelect !== null) { | |
227 | + initialParams.salesCode = salesCodeSelect; | |
228 | + } else { | |
229 | + initialParams.salesCode = userInfo.username; | |
230 | + } | |
231 | + } | |
232 | + // 根据activeTabKey动态扩展参数 | |
233 | + if (activeTabKey === 1) { | |
234 | + initialParams = { | |
235 | + ...initialParams, | |
236 | + orderStatus: 'SHIPPED', | |
237 | + warningStatus: 'waitConfirmReicept', | |
238 | + statusDatetimeLe: calDate, | |
239 | + }; | |
240 | + } else if (activeTabKey === 2) { | |
241 | + initialParams = { | |
242 | + ...initialParams, | |
243 | + warningStatus: 'invoicingWarning', | |
244 | + confirmReceiptDatetimeLe: calDate, | |
245 | + }; | |
246 | + } else if (activeTabKey === 3) { | |
247 | + initialParams = { | |
248 | + ...initialParams, | |
249 | + warningStatus: 'waitFeedbackWarning', | |
250 | + confirmReceiptDatetimeLe: calDate, | |
251 | + }; | |
252 | + } else if (activeTabKey === 4) { | |
253 | + initialParams = { | |
254 | + ...initialParams, | |
255 | + warningStatus: 'invoiceConfirmWarning', | |
256 | + invoicingEndTime: calDate, | |
257 | + }; | |
258 | + } else if (activeTabKey === 5) { | |
259 | + initialParams = { | |
260 | + ...initialParams, | |
261 | + warningStatus: 'paymentReceiptStatusWarning', | |
262 | + paymentNotReceipt: true, | |
263 | + applyTimeLe: calDate, | |
264 | + }; | |
265 | + } | |
266 | + // 返回完整的参数对象 | |
267 | + return initialParams; | |
268 | + }, [ | |
269 | + activeTabKey, | |
270 | + calDate, | |
271 | + salesCodeSelect, | |
272 | + salesCodePermission, | |
273 | + userInfo.username, | |
274 | + ]); | |
275 | + | |
217 | 276 | //biaojidown2 |
218 | 277 | //取消单选,将时间设为null |
219 | 278 | const handleSetNull = () => { |
220 | 279 | setCalDate(null); // 这应该会触发 useEffect |
221 | 280 | }; |
222 | - const selectSalesCode = (value) => { | |
281 | + const selectSalesCode = (value: string) => { | |
223 | 282 | setSalesCodeSelect(value); // 这应该会触发 useEffect |
224 | 283 | }; |
225 | 284 | const warningOptions = [ |
... | ... | @@ -310,10 +369,8 @@ const OrderPage = () => { |
310 | 369 | <Radio |
311 | 370 | key={option.value} |
312 | 371 | value={option.value} |
313 | - onClick={(e) => { | |
314 | - radioOnChange1( | |
315 | - e as unknown as React.ChangeEvent<HTMLInputElement>, | |
316 | - ); | |
372 | + onClick={(e: any) => { | |
373 | + radioOnChange1(e); | |
317 | 374 | handleSetNull(); |
318 | 375 | }} |
319 | 376 | > |
... | ... | @@ -331,15 +388,13 @@ const OrderPage = () => { |
331 | 388 | <ProFormSelect |
332 | 389 | name="salesCode" |
333 | 390 | key="salesCode" |
334 | - width="200px" | |
335 | - actionRef={mainTableRef} | |
336 | - formRef={mainTableFormRef} | |
391 | + width={200} | |
337 | 392 | initialValue={userInfo.username} |
338 | 393 | showSearch |
339 | 394 | label="销售代表" |
340 | 395 | placeholder="请输入销售代表" |
341 | 396 | options={salesCodeOptions} |
342 | - onChange={(_, option) => { | |
397 | + onChange={(_, option: any) => { | |
343 | 398 | if (option === undefined) { |
344 | 399 | selectSalesCode(userInfo.username); |
345 | 400 | } |
... | ... | @@ -365,7 +420,7 @@ const OrderPage = () => { |
365 | 420 | <Button |
366 | 421 | key="out" |
367 | 422 | onClick={() => { |
368 | - let initialParams = {}; | |
423 | + let initialParams: ParamsType = {}; | |
369 | 424 | initialParams.isDeleteQueryOrder = false; |
370 | 425 | initialParams.flag = 50; |
371 | 426 | initialParams.current = 1; |
... | ... | @@ -454,59 +509,7 @@ const OrderPage = () => { |
454 | 509 | }} |
455 | 510 | searchShow={false} |
456 | 511 | toolbarShow={false} /> */} |
457 | - <OrderList | |
458 | - paramsNew={(function () { | |
459 | - // 初始化参数 | |
460 | - let initialParams = {}; | |
461 | - initialParams.isDeleteQueryOrderNow = false; | |
462 | - initialParams.salesCode = userInfo.username; | |
463 | - if (salesCodePermission) { | |
464 | - if (salesCodeSelect !== undefined && salesCodeSelect !== null) { | |
465 | - initialParams.salesCode = salesCodeSelect; | |
466 | - } else { | |
467 | - initialParams.salesCode = userInfo.username; | |
468 | - } | |
469 | - } | |
470 | - // 根据activeTabKey动态扩展参数 | |
471 | - if (activeTabKey === 1) { | |
472 | - initialParams = { | |
473 | - ...initialParams, | |
474 | - orderStatus: 'SHIPPED', | |
475 | - warningStatus: 'waitConfirmReicept', | |
476 | - statusDatetimeLe: calDate, | |
477 | - }; | |
478 | - } else if (activeTabKey === 2) { | |
479 | - initialParams = { | |
480 | - ...initialParams, | |
481 | - warningStatus: 'invoicingWarning', | |
482 | - confirmReceiptDatetimeLe: calDate, | |
483 | - }; | |
484 | - } else if (activeTabKey === 3) { | |
485 | - initialParams = { | |
486 | - ...initialParams, | |
487 | - warningStatus: 'waitFeedbackWarning', | |
488 | - confirmReceiptDatetimeLe: calDate, | |
489 | - }; | |
490 | - } else if (activeTabKey === 4) { | |
491 | - initialParams = { | |
492 | - ...initialParams, | |
493 | - warningStatus: 'invoiceConfirmWarning', | |
494 | - invoicingEndTime: calDate, | |
495 | - }; | |
496 | - } else if (activeTabKey === 5) { | |
497 | - initialParams = { | |
498 | - ...initialParams, | |
499 | - warningStatus: 'paymentReceiptStatusWarning', | |
500 | - paymentNotReceipt: true, | |
501 | - applyTimeLe: calDate, | |
502 | - }; | |
503 | - } | |
504 | - // 返回完整的参数对象 | |
505 | - return initialParams; | |
506 | - })()} | |
507 | - searchShow={false} | |
508 | - toolbarShow={false} | |
509 | - /> | |
512 | + <OrderList paramsNew={paramsNew} searchShow={false} toolbarShow={false} /> | |
510 | 513 | </div> |
511 | 514 | ); |
512 | 515 | }; | ... | ... |