refactor(inspection): 优化检测列表数据获取与计数逻辑
- 将 useTable 初始化移至 useEffect 之后,确保依赖顺序合理 - 在表格数据获取前清空统计计数,避免显示旧数据 - 修正获取查询时间区间时的字段访问错误 - 调整 getCount 调用时机,确保数据同步更新 - 删除冗余的 useEffect 调用,简化组件逻辑master
parent
e6afa416bf
commit
9b7cca22a5
|
|
@ -2,7 +2,7 @@ import { Permission } from "@cqsjjb/jjb-common-decorator/permission";
|
||||||
|
|
||||||
import { Connect } from "@cqsjjb/jjb-dva-runtime";
|
import { Connect } from "@cqsjjb/jjb-dva-runtime";
|
||||||
import { Button, Form, message, Modal, Space, Spin } from "antd";
|
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 ExportIcon from "zy-react-library/components/Icon/ExportIcon";
|
||||||
import Page from "zy-react-library/components/Page";
|
import Page from "zy-react-library/components/Page";
|
||||||
import Search from "zy-react-library/components/Search";
|
import Search from "zy-react-library/components/Search";
|
||||||
|
|
@ -35,6 +35,20 @@ function List(props) {
|
||||||
});
|
});
|
||||||
|
|
||||||
const [form] = Form.useForm();
|
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"], {
|
const { tableProps, getData } = useTable(props["inspectionList"], {
|
||||||
form,
|
form,
|
||||||
transform: formData => ({
|
transform: formData => ({
|
||||||
|
|
@ -45,26 +59,13 @@ function List(props) {
|
||||||
entrance: "0",
|
entrance: "0",
|
||||||
corpId: query.corpId,
|
corpId: query.corpId,
|
||||||
},
|
},
|
||||||
|
onBefore: () => {
|
||||||
|
setCount({});
|
||||||
|
},
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
getCount();
|
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) => {
|
const onDelete = (id) => {
|
||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue