diff --git a/src/api/safetyEvalBusiness/index.js b/src/api/safetyEvalBusiness/index.js index 6316d17..5b07b9e 100644 --- a/src/api/safetyEvalBusiness/index.js +++ b/src/api/safetyEvalBusiness/index.js @@ -301,10 +301,10 @@ export const evalProcessControlFiles = declareRequest( "processControlFiles: [] | res.data || []", ); -/** 项目档案文件列表-机构端分页(分页参数 pageIndex/pageSize,总数 totalCount) */ +/** 项目档案文件列表-机构端 */ export const evalProjectArchiveFileOrgPage = declareRequest( "evalProjectArchiveFileOrgLoading", - "Get > /safetyEval/eval-project-archive-file/org/page", + "Get > /safetyEval/eval-project-archive-file/org/list", ); /** 新增项目档案文件(机构补充上传) */ diff --git a/src/enumerate/constant/index.js b/src/enumerate/constant/index.js index 7c00460..c542f25 100644 --- a/src/enumerate/constant/index.js +++ b/src/enumerate/constant/index.js @@ -444,11 +444,11 @@ export const WARING_STATUS_OPTIONS = [ export const NODE_LABELS = { RISK_ANALYSIS: "风险分析", - BUSINESS_CONTRACT: "商务合同", + BUSINESS_CONTRACT: "业务合同", PROJECT_GROUP: "项目组", - SITE_SURVEY: "现场勘查", + SITE_SURVEY: "现场踏勘", REPORT_PREPARATION: "报告编制", - INTERNAL_REVIEW: "内审", + INTERNAL_REVIEW: "内部审核", TECHNICAL_REVIEW: "技术审核", PROCESS_CONTROL: "过程控制", ARCHIVE: "项目归档", diff --git a/src/pages/Container/SafetyEvalBusiness/ProjectFlow/ArchiveContent.js b/src/pages/Container/SafetyEvalBusiness/ProjectFlow/ArchiveContent.js index 0a1b326..27ceddc 100644 --- a/src/pages/Container/SafetyEvalBusiness/ProjectFlow/ArchiveContent.js +++ b/src/pages/Container/SafetyEvalBusiness/ProjectFlow/ArchiveContent.js @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from "react"; +import React, { useState, useEffect, useMemo } from "react"; import { Button, Table, @@ -9,6 +9,7 @@ import { Col, DatePicker, Form, + Modal, message, } from "antd"; import dayjs from "dayjs"; @@ -20,7 +21,7 @@ import LayoutFooterPortal from "~/components/LayoutFooterPortal"; import PreviewUrlButton from "~/components/PreviewUrlButton"; import ArchiveSupplementModal from "./ArchiveSupplementModal"; import { - + NODE_LABELS, ARCHIVE_RECORD_SOURCE_OPTIONS, ARCHIVE_RECORD_SOURCE_BADGE_MAP, } from "~/enumerate/constant"; @@ -35,13 +36,10 @@ const ArchiveContent = ({ readOnly, ...props }) => { const [archiveForm] = Form.useForm(); const [archiveFiles, setArchiveFiles] = useState([]); - const [archiveTotal, setArchiveTotal] = useState(0); - const [archiveQuery, setArchiveQuery] = useState({ - pageIndex: 1, - pageSize: 10, - recordSource: "", - }); + const [sourceFilter, setSourceFilter] = useState(""); + const [keyword, setKeyword] = useState(""); const [supplementOpen, setSupplementOpen] = useState(false); + const [viewRecord, setViewRecord] = useState(null); const fetchDetail = () => { props.evalProcessControlDetail({ projectId }); @@ -67,25 +65,32 @@ const ArchiveContent = ({ readOnly, ...props }) => { }, [processControlDetail]); const fetchArchiveFiles = () => { - props - .evalProjectArchiveFileOrgPage({ - projectId, - pageIndex: archiveQuery.pageIndex, - pageSize: archiveQuery.pageSize, - recordSource: archiveQuery.recordSource || undefined, - }) - .then((res) => { - if (res?.success !== false) { - setArchiveFiles(res?.data || []); - setArchiveTotal(res?.totalCount || 0); - } - }); + props.evalProjectArchiveFileOrgPage({ projectId }).then((res) => { + if (res?.success !== false) { + setArchiveFiles(res?.data || []); + } + }); }; useEffect(() => { if (!projectId) return; fetchArchiveFiles(); - }, [projectId, archiveQuery]); + }, [projectId]); + + /** 本地筛选:来源 + 文件名称/档案类型关键字 */ + const filteredArchiveFiles = useMemo(() => { + const kw = keyword.trim().toLowerCase(); + return archiveFiles.filter((item) => { + const matchSource = !sourceFilter || item.recordSource === sourceFilter; + const matchKeyword = + !kw || + (item.files || []).some((f) => + (f.name || "").toLowerCase().includes(kw), + ) || + (item.archiveType || "").toLowerCase().includes(kw); + return matchSource && matchKeyword; + }); + }, [archiveFiles, sourceFilter, keyword]); const isSignatureCompleted = processControl?.reviewerSignatureTaskStatus === "completed"; @@ -109,35 +114,54 @@ const ArchiveContent = ({ readOnly, ...props }) => { return /^https?:\/\//i.test(u) ? u : `${window.fileUrl || ""}${u}`; }; - const handleDownload = (file) => { - const url = resolveFileUrl(file.fileUrl); + /** 单文件下载:跨域地址下 a.download 无效,fetch 转 blob 后再触发下载 */ + const downloadArchiveFile = async (f) => { + const url = resolveFileUrl(f.url); if (!url) return; - const a = document.createElement("a"); - a.href = url; - a.download = file.fileName || ""; - a.target = "_blank"; - document.body.appendChild(a); - a.click(); - document.body.removeChild(a); + const res = await fetch(url); + if (!res.ok) throw new Error(`HTTP ${res.status}`); + const blobUrl = window.URL.createObjectURL(await res.blob()); + const link = document.createElement("a"); + link.href = blobUrl; + link.download = f.name || ""; + link.style.display = "none"; + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + window.URL.revokeObjectURL(blobUrl); + }; + + /** 批量下载 files 数组(逐个串行下载,失败不影响其余文件) */ + const handleBatchDownload = async (files) => { + for (const f of files || []) { + try { + await downloadArchiveFile(f); + } catch { + message.error(`文件下载失败:${f.name || f.url}`); + } + } }; const archiveColumns = [ { title: "序号", width: 60, - render: (_, __, index) => - (archiveQuery.pageIndex - 1) * archiveQuery.pageSize + index + 1, + render: (_, __, index) => index + 1, }, { title: "文件名称", - dataIndex: "fileName", + dataIndex: "files", ellipsis: true, - render: (v) => v || "-", + render: (v) => { + if(Array.isArray(v)){ + return v.map(v=>v.name).join(',') + } + }, }, { title: "档案类型", dataIndex: "archiveType", - width: 130, + width: 180, }, { @@ -152,7 +176,7 @@ const ArchiveContent = ({ readOnly, ...props }) => { > {ARCHIVE_RECORD_SOURCE_BADGE_MAP[v] || v || "-"} - {r.businessNode || "-"} + {NODE_LABELS[r.businessNode] || "-"} ), }, @@ -165,8 +189,7 @@ const ArchiveContent = ({ readOnly, ...props }) => { { title: "形成时间", dataIndex: "createTime", - width: 160, - align: "right", + width: 200, render: (v) => v || "-", }, { @@ -174,12 +197,19 @@ const ArchiveContent = ({ readOnly, ...props }) => { width: 110, render: (_, r) => ( - 查看 + @@ -194,12 +224,17 @@ const ArchiveContent = ({ readOnly, ...props }) => { > - + + setKeyword(e.target.value)} + onSearch={setKeyword} + className="pf-archive__keyword-input" + />