From 9b7cca22a590d281193ce973d020ce49331d7d9d Mon Sep 17 00:00:00 2001 From: LiuJiaNan <15703339975@163.com> Date: Fri, 28 Aug 2026 17:35:27 +0800 Subject: [PATCH] =?UTF-8?q?refactor(inspection):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=A3=80=E6=B5=8B=E5=88=97=E8=A1=A8=E6=95=B0=E6=8D=AE=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E4=B8=8E=E8=AE=A1=E6=95=B0=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 useTable 初始化移至 useEffect 之后,确保依赖顺序合理 - 在表格数据获取前清空统计计数,避免显示旧数据 - 修正获取查询时间区间时的字段访问错误 - 调整 getCount 调用时机,确保数据同步更新 - 删除冗余的 useEffect 调用,简化组件逻辑 --- .../Inspection/Records/List/index.js | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/pages/Container/BranchCompany/Inspection/Records/List/index.js b/src/pages/Container/BranchCompany/Inspection/Records/List/index.js index 5354f51..d0a1eed 100644 --- a/src/pages/Container/BranchCompany/Inspection/Records/List/index.js +++ b/src/pages/Container/BranchCompany/Inspection/Records/List/index.js @@ -2,7 +2,7 @@ import { Permission } from "@cqsjjb/jjb-common-decorator/permission"; import { Connect } from "@cqsjjb/jjb-dva-runtime"; import { Button, Form, message, Modal, Space, Spin } from "antd"; -import { useEffect, useState } from "react"; +import { useState } from "react"; import ExportIcon from "zy-react-library/components/Icon/ExportIcon"; import Page from "zy-react-library/components/Page"; import Search from "zy-react-library/components/Search"; @@ -35,6 +35,20 @@ function List(props) { }); const [form] = Form.useForm(); + + const getCount = async () => { + const { data } = await props["inspectionCount"]({ + menuPath: window.location.pathname, + status: "", + entrance: "0", + corpId: query.corpId, + checkStartTime: query.checkStartTime || form.getFieldValue("checkTime")?.[0], + checkEndTime: query.checkEndTime || form.getFieldValue("checkTime")?.[1], + planType: query.planType, + ...form.getFieldsValue(), + }); + setCount(data); + }; const { tableProps, getData } = useTable(props["inspectionList"], { form, transform: formData => ({ @@ -45,26 +59,13 @@ function List(props) { entrance: "0", corpId: query.corpId, }, + onBefore: () => { + setCount({}); + }, onSuccess: () => { getCount(); }, }); - const getCount = async () => { - const { data } = await props["inspectionCount"]({ - menuPath: window.location.pathname, - status: "", - entrance: "0", - corpId: query.corpId, - checkStartTime: query.checkStartTime || form.getFieldValue("checkTime")?.[0], - checkEndTime: query.checkEndTime || form.getFieldValue("checkTime").checkTime?.[1], - planType: query.planType, - ...form.getFieldsValue(), - }); - setCount(data); - }; - useEffect(() => { - getCount(); - }, []); const onDelete = (id) => { Modal.confirm({