import React, { useCallback, useEffect, useMemo, useRef, useState, } from "react"; import styles from "./index.module.scss"; import { Button, Cascader, Input, Select, Table, Tooltip } from "antd"; import { useSelector } from "react-redux"; import { RootState } from "@/store"; import { A1_APIIdowns, A1_APIIgetIresList, A1_APIIgetList, } from "@/store/action/A1Project"; import { A1ItableType } from "@/types"; import { authFilesLookFu, urlChangeFu } from "@/utils/authFilesLook"; import A1IRemove from "./A1IRemove"; import A1ILack from "./A1ILack"; import A1IAudit from "./A1IAudit"; import A1IupFile from "./A1IupFile"; import { baseUpUrl } from "@/utils/http"; import { A2Tab2Type } from "@/types/api/A2Dict"; import AuthCom from "@/components/AuthCom"; type FromType = { searchKey: string; attrId: number | ""; deptId: any; auditStatus: 0 | 1 | 2 | ""; projectId: number; }; type Props = { projectId: number; myTitle: string; projectName: string; }; function A1Inner({ projectId, myTitle, projectName }: Props) { // 表单数据 const [fromData, setFromData] = useState({ searchKey: "", attrId: "", deptId: [""], auditStatus: "", projectId, }); // 关于表格的多选 const [selectedRowKeys, setSelectedRowKeys] = useState([]); const getListFu = useCallback(async () => { // 处理级联为最后一级的id let deptId: "" | number = ""; if (fromData.deptId && fromData.deptId[0]) { deptId = Number(fromData.deptId[fromData.deptId.length - 1]); } const obj = { ...fromData, deptId, }; const res = await A1_APIIgetList(obj); if (res.code === 0) { // 清空选中 setSelectedRowKeys([]); setData(res.data); } }, [fromData]); useEffect(() => { getListFu(); }, [getListFu]); const fromTime = useRef(-1); // 搜索项 的输入 const searchKeyChange = useCallback( (e: React.ChangeEvent) => { clearTimeout(fromTime.current); fromTime.current = window.setTimeout(() => { setFromData({ ...fromData, searchKey: e.target.value, }); }, 500); }, [fromData] ); // 获取 内控文件属性 下拉 数据(已过滤权限) const [iResList, setIResList] = useState([]); const getIresListFu = useCallback(async () => { const res = await A1_APIIgetIresList(); if (res.code === 0) { setIResList(res.data); } }, []); useEffect(() => { getIresListFu(); }, [getIresListFu]); // 从仓库获取部门 级联 信息 const deptList = useSelector((state: RootState) => state.A5Section.tableList); // 表格信息 const [data, setData] = useState([]); // 点击批量下载 const downSelectFu = useCallback(async () => { const res = await A1_APIIdowns(selectedRowKeys.join(",")); if (res.code === 0) { // console.log(123,res.data); urlChangeFu(res.data, true, undefined, projectName + "(内)"); // 清空选中 setSelectedRowKeys([]); } }, [projectName, selectedRowKeys]); // 删除的弹窗数据 const [delInfo, setDelInfo] = useState({ id: 0, name: "" }); // 权限 const authArr = useSelector((state: RootState) => state.A4Role.A4RoleAll); // 关于 审核 const adidtDom = useCallback( (item: A1ItableType) => { const num = item.auditStatus; const txt = num === 0 ? "待审批" : num === 1 ? "审批通过" : "审批驳回"; const dom = item.auditDesc && num !== 0 ? (
setAuditInfo({ id: item.id, sta: num, txt: item.auditDesc || "", }) } > {txt} 
?
) : (
setAuditInfo({ id: item.id, sta: num, txt: item.auditDesc || "" }) } > {txt}
); if (authArr.includes("1104")) return dom; else return txt; }, [authArr] ); const columns = useMemo(() => { return [ { title: "所属阶段", dataIndex: "stageName", }, { title: "文件类别", dataIndex: "attrName", }, { title: "责任部门", dataIndex: "deptName", }, { title: "文件名称", render: (item: A1ItableType) => item.hasLack === 1 ? ( <> {item.description === "-未填信息" ? ( "无法提供" ) : (
无法提供 
?
)} ) : ( item.fileName ), }, { title: "上传人", dataIndex: "uploadName", }, { title: "上传时间", dataIndex: "updateTime", }, { title: "审批状态", render: (item: A1ItableType) => adidtDom(item), }, { title: "审核人", render: (item: A1ItableType) => item.auditorName ? item.auditorName : "(空)", }, { title: "审核时间", render: (item: A1ItableType) => item.auditTime ? item.auditTime : "(空)", }, { title: "操作", render: (item: A1ItableType) => item.hasLack === 1 ? ( "-" ) : ( <> {authFilesLookFu(item.fileName) ? ( ) : null} ), }, ]; }, [adidtDom]); // 登记缺失文件的开启和关闭 const [lack, setLack] = useState(false); // 审批状态的开启和关闭 const [auditInfo, setAuditInfo] = useState<{ id: number; sta: 0 | 1 | 2; txt: string; }>({ id: 0, sta: 0, txt: "", }); // 批量上传的弹窗 const [upFileOpen, setUpFileOpen] = useState(false); return (
搜索项: searchKeyChange(e)} />
文件类别: setFromData({ ...fromData, auditStatus: e })} options={[ { value: "", label: "全部" }, { value: 0, label: "待审批" }, { value: 1, label: "审批通过" }, { value: 2, label: "审批驳回" }, ]} />
责任部门: setFromData({ ...fromData, deptId: e })} fieldNames={{ label: "name", value: "id" }} placeholder="请选择" />
{ setSelectedRowKeys(selectedRowKeys); }, // 禁用 getCheckboxProps: (item) => ({ disabled: item.hasLack === 1, // 配置无法勾选的列 }), }} scroll={{ y: 610 }} dataSource={data} columns={columns} rowKey="id" pagination={false} /> {/* 点击删除出来的弹窗 */} {delInfo.id ? ( setDelInfo({ id: 0, name: "" })} delSuFu={() => getListFu()} /> ) : null} {/* 点击登记缺失文件出来的弹窗 */} {lack ? ( setLack(false)} addSuFu={() => getListFu()} /> ) : null} {/* 点击审批出来的弹窗 */} {auditInfo.id ? ( setAuditInfo({ id: 0, sta: 0, txt: "" })} editSuFu={() => getListFu()} /> ) : null} {upFileOpen ? ( getListFu()} closeFu={() => setUpFileOpen(false)} myTitle={myTitle} projectId={projectId} typeData={iResList} /> ) : null} ); } const MemoA1Inner = React.memo(A1Inner); export default MemoA1Inner;