Commit 2d1d2d32d54ab3da7ecedb88e33a37aa3434a54b
Merge branch 'bugfix-0804' into bugfix-invoicestatus
Showing
2 changed files
with
79 additions
and
76 deletions
src/pages/Order/OrderList/OrderList.tsx
@@ -4872,8 +4872,8 @@ const OrderList = ({ paramsNew, searchShow, toolbarShow }) => { | @@ -4872,8 +4872,8 @@ const OrderList = ({ paramsNew, searchShow, toolbarShow }) => { | ||
4872 | if (paramsNew) { | 4872 | if (paramsNew) { |
4873 | setNewParams(paramsNew); | 4873 | setNewParams(paramsNew); |
4874 | console.log(newParams); | 4874 | console.log(newParams); |
4875 | + refreshTable(); | ||
4875 | } | 4876 | } |
4876 | - // refreshTable(); | ||
4877 | }, [paramsNew]); | 4877 | }, [paramsNew]); |
4878 | return ( | 4878 | return ( |
4879 | <div className="order-page-container"> | 4879 | <div className="order-page-container"> |
src/pages/Order/OrderWarning/index.tsx
@@ -5,26 +5,26 @@ import { | @@ -5,26 +5,26 @@ import { | ||
5 | import { downloadFile } from '@/services/order'; | 5 | import { downloadFile } from '@/services/order'; |
6 | import { getSalesCodeOptions } from '@/utils/order'; | 6 | import { getSalesCodeOptions } from '@/utils/order'; |
7 | import { getUserInfo } from '@/utils/user'; | 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 | import { Badge, Button, Radio, message } from 'antd'; | 9 | import { Badge, Button, Radio, message } from 'antd'; |
14 | import { format } from 'date-fns'; | 10 | import { format } from 'date-fns'; |
15 | -import React, { useEffect, useRef, useState } from 'react'; | 11 | +import { useEffect, useMemo, useRef, useState } from 'react'; |
16 | import OrderList from '../OrderList/OrderList'; | 12 | import OrderList from '../OrderList/OrderList'; |
17 | import './index.less'; | 13 | import './index.less'; |
18 | // import { useParams } from '@umijs/max'; | 14 | // import { useParams } from '@umijs/max'; |
19 | 15 | ||
16 | +// 定义参数类型 | ||
17 | +interface ParamsType { | ||
18 | + [key: string]: any; | ||
19 | +} | ||
20 | + | ||
20 | const OrderPage = () => { | 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 | const userInfo = getUserInfo(); | 24 | const userInfo = getUserInfo(); |
24 | 25 | ||
25 | const mainTableRef = useRef<ActionType>(); | 26 | const mainTableRef = useRef<ActionType>(); |
26 | - const mainTableFormRef = useRef<ProFormInstance>(); | ||
27 | - let [searchParams] = useState(Object); //表格的查询条件存储 | 27 | + let [searchParams] = useState<ParamsType>({}); //表格的查询条件存储 |
28 | console.log(searchParams); | 28 | console.log(searchParams); |
29 | const [messageApi] = message.useMessage(); | 29 | const [messageApi] = message.useMessage(); |
30 | console.log(messageApi); | 30 | console.log(messageApi); |
@@ -92,7 +92,8 @@ const OrderPage = () => { | @@ -92,7 +92,8 @@ const OrderPage = () => { | ||
92 | //选择天数 | 92 | //选择天数 |
93 | const [calDate, setCalDate] = useState<string | null>(null); | 93 | const [calDate, setCalDate] = useState<string | null>(null); |
94 | const [value1, setValue1] = useState(0); | 94 | const [value1, setValue1] = useState(0); |
95 | - const radioOnChange1 = ({ target: { value } }) => { | 95 | + const radioOnChange1 = (e: any) => { |
96 | + const { value } = e.target; | ||
96 | const currentDate = new Date(); | 97 | const currentDate = new Date(); |
97 | // 创建一个新的日期对象,并在当前日期的基础上加上 daysToAdd 天 | 98 | // 创建一个新的日期对象,并在当前日期的基础上加上 daysToAdd 天 |
98 | const newDate = new Date(currentDate); | 99 | const newDate = new Date(currentDate); |
@@ -101,7 +102,7 @@ const OrderPage = () => { | @@ -101,7 +102,7 @@ const OrderPage = () => { | ||
101 | setCalDate(formattedDate); | 102 | setCalDate(formattedDate); |
102 | setValue1(value); | 103 | setValue1(value); |
103 | }; | 104 | }; |
104 | - function setOriginTime(value) { | 105 | + function setOriginTime(value: number) { |
105 | const currentDate = new Date(); | 106 | const currentDate = new Date(); |
106 | // 创建一个新的日期对象,并在当前日期的基础上加上 daysToAdd 天 | 107 | // 创建一个新的日期对象,并在当前日期的基础上加上 daysToAdd 天 |
107 | const newDate = new Date(currentDate); | 108 | const newDate = new Date(currentDate); |
@@ -214,12 +215,70 @@ const OrderPage = () => { | @@ -214,12 +215,70 @@ const OrderPage = () => { | ||
214 | const formattedDate = format(newDate, 'yyyy-MM-dd HH:mm:ss'); | 215 | const formattedDate = format(newDate, 'yyyy-MM-dd HH:mm:ss'); |
215 | setCalDate(formattedDate); | 216 | setCalDate(formattedDate); |
216 | }, [activeTabKey]); | 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 | //biaojidown2 | 276 | //biaojidown2 |
218 | //取消单选,将时间设为null | 277 | //取消单选,将时间设为null |
219 | const handleSetNull = () => { | 278 | const handleSetNull = () => { |
220 | setCalDate(null); // 这应该会触发 useEffect | 279 | setCalDate(null); // 这应该会触发 useEffect |
221 | }; | 280 | }; |
222 | - const selectSalesCode = (value) => { | 281 | + const selectSalesCode = (value: string) => { |
223 | setSalesCodeSelect(value); // 这应该会触发 useEffect | 282 | setSalesCodeSelect(value); // 这应该会触发 useEffect |
224 | }; | 283 | }; |
225 | const warningOptions = [ | 284 | const warningOptions = [ |
@@ -310,10 +369,8 @@ const OrderPage = () => { | @@ -310,10 +369,8 @@ const OrderPage = () => { | ||
310 | <Radio | 369 | <Radio |
311 | key={option.value} | 370 | key={option.value} |
312 | value={option.value} | 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 | handleSetNull(); | 374 | handleSetNull(); |
318 | }} | 375 | }} |
319 | > | 376 | > |
@@ -331,15 +388,13 @@ const OrderPage = () => { | @@ -331,15 +388,13 @@ const OrderPage = () => { | ||
331 | <ProFormSelect | 388 | <ProFormSelect |
332 | name="salesCode" | 389 | name="salesCode" |
333 | key="salesCode" | 390 | key="salesCode" |
334 | - width="200px" | ||
335 | - actionRef={mainTableRef} | ||
336 | - formRef={mainTableFormRef} | 391 | + width={200} |
337 | initialValue={userInfo.username} | 392 | initialValue={userInfo.username} |
338 | showSearch | 393 | showSearch |
339 | label="销售代表" | 394 | label="销售代表" |
340 | placeholder="请输入销售代表" | 395 | placeholder="请输入销售代表" |
341 | options={salesCodeOptions} | 396 | options={salesCodeOptions} |
342 | - onChange={(_, option) => { | 397 | + onChange={(_, option: any) => { |
343 | if (option === undefined) { | 398 | if (option === undefined) { |
344 | selectSalesCode(userInfo.username); | 399 | selectSalesCode(userInfo.username); |
345 | } | 400 | } |
@@ -365,7 +420,7 @@ const OrderPage = () => { | @@ -365,7 +420,7 @@ const OrderPage = () => { | ||
365 | <Button | 420 | <Button |
366 | key="out" | 421 | key="out" |
367 | onClick={() => { | 422 | onClick={() => { |
368 | - let initialParams = {}; | 423 | + let initialParams: ParamsType = {}; |
369 | initialParams.isDeleteQueryOrder = false; | 424 | initialParams.isDeleteQueryOrder = false; |
370 | initialParams.flag = 50; | 425 | initialParams.flag = 50; |
371 | initialParams.current = 1; | 426 | initialParams.current = 1; |
@@ -454,59 +509,7 @@ const OrderPage = () => { | @@ -454,59 +509,7 @@ const OrderPage = () => { | ||
454 | }} | 509 | }} |
455 | searchShow={false} | 510 | searchShow={false} |
456 | toolbarShow={false} /> */} | 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 | </div> | 513 | </div> |
511 | ); | 514 | ); |
512 | }; | 515 | }; |