diff --git a/src/api/safetyEvalBusiness/index.js b/src/api/safetyEvalBusiness/index.js index 5b07b9e..be8c2e2 100644 --- a/src/api/safetyEvalBusiness/index.js +++ b/src/api/safetyEvalBusiness/index.js @@ -358,7 +358,7 @@ export const evalProjectArchivePage = declareRequest( "Get > /safetyEval/institution/eval-project/archive-supervision-page", ); -/** 项目档案文件列表(监管端,分页参数为 pageIndex/pageSize,总数 totalCount) */ +/** 项目档案文件列表-监管端 */ export const evalProjectArchiveFilePage = declareRequest( "evalProjectArchiveFileLoading", "Get > /safetyEval/eval-project-archive-file/monitor/page", diff --git a/src/pages/Container/SafetyEvalBusiness/ProjectFlow/ArchiveContent.js b/src/pages/Container/SafetyEvalBusiness/ProjectFlow/ArchiveContent.js index 27ceddc..3b296a6 100644 --- a/src/pages/Container/SafetyEvalBusiness/ProjectFlow/ArchiveContent.js +++ b/src/pages/Container/SafetyEvalBusiness/ProjectFlow/ArchiveContent.js @@ -17,6 +17,7 @@ import { Connect } from "@cqsjjb/jjb-dva-runtime"; import TableAction from "@cqsjjb/jjb-react-admin-component/TableAction"; import { NS_SAFETY_EVAL_BUSINESS } from "~/enumerate/namespace"; import { tools } from "@cqsjjb/jjb-common-lib"; +import { useDebounce } from "~/utils"; import LayoutFooterPortal from "~/components/LayoutFooterPortal"; import PreviewUrlButton from "~/components/PreviewUrlButton"; import ArchiveSupplementModal from "./ArchiveSupplementModal"; @@ -77,9 +78,10 @@ const ArchiveContent = ({ readOnly, ...props }) => { fetchArchiveFiles(); }, [projectId]); - /** 本地筛选:来源 + 文件名称/档案类型关键字 */ + /** 本地筛选:来源 + 文件名称/档案类型关键字(防抖 400ms) */ + const debouncedKeyword = useDebounce(keyword, 400); const filteredArchiveFiles = useMemo(() => { - const kw = keyword.trim().toLowerCase(); + const kw = debouncedKeyword.trim().toLowerCase(); return archiveFiles.filter((item) => { const matchSource = !sourceFilter || item.recordSource === sourceFilter; const matchKeyword = @@ -90,7 +92,7 @@ const ArchiveContent = ({ readOnly, ...props }) => { (item.archiveType || "").toLowerCase().includes(kw); return matchSource && matchKeyword; }); - }, [archiveFiles, sourceFilter, keyword]); + }, [archiveFiles, sourceFilter, debouncedKeyword]); const isSignatureCompleted = processControl?.reviewerSignatureTaskStatus === "completed"; diff --git a/src/pages/Container/Supervision/EvalProjectDatabase/ArchiveModal.js b/src/pages/Container/Supervision/EvalProjectDatabase/ArchiveModal.js index b7e788b..ad17881 100644 --- a/src/pages/Container/Supervision/EvalProjectDatabase/ArchiveModal.js +++ b/src/pages/Container/Supervision/EvalProjectDatabase/ArchiveModal.js @@ -1,7 +1,8 @@ -import React, { useEffect, useState } from "react"; +import React, { useEffect, useMemo, useState } from "react"; import { Button, Flex, Input, Modal, Table, Tag, message } from "antd"; import TableAction from "@cqsjjb/jjb-react-admin-component/TableAction"; import PreviewUrlButton from "~/components/PreviewUrlButton"; +import { useDebounce } from "~/utils"; import { NODE_LABELS, ARCHIVE_TYPE_MAP, @@ -17,22 +18,30 @@ const resolveFileUrl = (raw) => { /** 项目档案查看弹窗(原型 modal-reg-project-archive) */ function ArchiveModal({ record, loading, fetchFiles, onClose }) { - const [query, setQuery] = useState({ pageIndex: 1, pageSize: 10, fileName: "" }); const [list, setList] = useState([]); - const [total, setTotal] = useState(0); + const [keyword, setKeyword] = useState(""); const [viewRecord, setViewRecord] = useState(null); - - useEffect(() => { if (!record?.id) return; - fetchFiles({ projectId: record.id, ...query }).then((res) => { + fetchFiles({ projectId: record.id, pageSize: 500 }).then((res) => { if (res?.success !== false) { setList(res?.data || []); - setTotal(res?.totalCount || 0); } }); - }, [record?.id, query]); + }, [record?.id]); + + const debouncedKeyword = useDebounce(keyword, 400); + const filteredList = useMemo(() => { + const kw = debouncedKeyword.trim().toLowerCase(); + if (!kw) return list; + return list.filter( + (item) => + (item.files || []).some((f) => + (f.name || "").toLowerCase().includes(kw), + ) || (item.archiveType || "").toLowerCase().includes(kw), + ); + }, [list, debouncedKeyword]); /** 单文件下载:跨域地址下 a.download 无效,fetch 转 blob 后再触发下载 */ const downloadArchiveFile = async (f) => { @@ -66,8 +75,7 @@ function ArchiveModal({ record, loading, fetchFiles, onClose }) { { title: "序号", width: 60, - render: (_, __, index) => - (query.pageIndex - 1) * query.pageSize + index + 1, + render: (_, __, index) => index + 1, }, { title: "文件名称", @@ -179,9 +187,10 @@ function ArchiveModal({ record, loading, fetchFiles, onClose }) { setQuery((q) => ({ ...q, fileName: v, pageIndex: 1 }))} + onChange={(e) => setKeyword(e.target.value)} + onSearch={setKeyword} className="epd-archive__search" /> @@ -189,19 +198,10 @@ function ArchiveModal({ record, loading, fetchFiles, onClose }) { rowKey="id" size="small" columns={columns} - dataSource={list} + dataSource={filteredList} loading={loading} scroll={{ x: 800, y: 400 }} - pagination={{ - total, - current: query.pageIndex, - pageSize: query.pageSize, - showSizeChanger: true, - showQuickJumper: true, - showTotal: (t) => `共 ${t} 条`, - onChange: (page, pageSize) => - setQuery((q) => ({ ...q, pageIndex: page, pageSize })), - }} + pagination={false} />