import React, { useEffect, useState } from "react"; import ProTable, { ProColumns, } from "@ant-design/pro-table"; import { Button, Card, message, Modal, Progress, Spin } from "antd"; import { getRoomId, } from '@/utils/session'; import { getList, jieMi, jmRate } from "./service"; import { ipassDecrypt } from "@/utils/IpassVerification"; import { AsymDecrypt } from "@/utils/zwPlugin"; const FileDecode: React.FC<{}> = () => { const [spin, spinSet] = useState(false); const [dis, disSet] = useState(false); const [count, countSet] = useState(0); const [tdocId, tdocIdSet] = useState('');//tdocId const [rateVis, handleRateVis] = useState(false); //进度显隐 const [rateCount, rateCountSet] = useState(0); //查询进度启动器 const [jmFileCount, jmFileCountSet] = useState(0);//文件总数 const [jmComplete, jmCompleteSet] = useState(0);//已解密成功 const [jm, jmSet] = useState();//是否解密 控制解密按钮 const [jmWait, jmWaitSet] = useState(0);//未解密 const [jmFail, jmFailSet] = useState(0);//解密失败 const [dataSource, dataSourceSet] = useState([{}]); //页面加载 useEffect(() => { if (!rateVis) { getPage(); setTimeout(async () => { countSet(count + 1); }, 2000); } }, [count]); //查询进度 useEffect(() => { if (rateVis) { queryRate(); setTimeout(async () => { rateCountSet(rateCount + 1); }, 2000); } }, [rateCount]); //查页面数据 async function getPage() { let tdocIdT = ''; let jm = false; await getList({ assessRoomId: getRoomId(), type: 1 }).then((res) => { if (res?.code == 200 && res?.data != undefined) { dataSourceSet(res.data); jmSet(res.data[res.data.length - 1].decryptStatus); tdocIdT = res.data[res.data.length - 1].id; } }) if (!rateVis) { let all: number, comp: number, fail: number, wait: number = 0; await jmRate({ tdocId: tdocIdT }).then((res) => { if (res?.code == 200) { let data = res.data; all = data['-1'] != undefined ? parseInt(data['-1']) : 0; comp = data['1'] != undefined ? parseInt(data['1']) : 0; fail = data['2'] != undefined ? parseInt(data['2']) : 0; wait = data['0'] != undefined ? parseInt(data['0']) : 0; } jmCompleteSet(comp); jmFailSet(fail); jmFileCountSet(all); jmWaitSet(wait); }); } spinSet(false); } //查询解密进度 async function queryRate() { let all: number, comp: number, fail: number, wait: number = 0; await jmRate({ tdocId: tdocId }).then((res) => { if (res?.code == 200) { let data = res.data; all = data['-1'] != undefined ? parseInt(data['-1']) : 0; comp = data['1'] != undefined ? parseInt(data['1']) : 0; fail = data['2'] != undefined ? parseInt(data['2']) : 0; wait = data['0'] != undefined ? parseInt(data['0']) : 0; } jmCompleteSet(comp); jmFailSet(fail); jmFileCountSet(all); jmWaitSet(wait); }); } const columns: ProColumns[] = [ { title: '序号', dataIndex: 'index', valueType: 'index', width: 80 }, { title: '应答轮次', width: 80, render: (_: any, record: any) => { if (JSON.stringify(record) == "{}") { return ''; } else { return record?.registerInfoVOList[0].reviewTurnSort; } } }, { title: '解密状态', width: 80, render: (_: any, record: any) => { if (JSON.stringify(record) == "{}") { return ''; } else { const status = record?.registerInfoVOList[0].decryptStatus; if (status == null || status === '1') { return '未解密' } else if (status === '2') { return '解密成功' } else if (status === '3') { return '解密失败' } else { return '' } } } }, { title: '解密截止时间', dataIndex: 'decryptEndDate', valueType: 'dateTime', width: 80 }, { title: '解密时间', valueType: 'dateTime', width: 80, render: (_: any, record: any) => { if (JSON.stringify(record) == "{}") { return ''; } else { const date = record?.registerInfoVOList[0].decryptTime; return date; } } }, { title: '操作', width: 80, render: (_: any, record: any) => { if (JSON.stringify(record) !== "{}" && jm) { const status = record?.registerInfoVOList[0].decryptStatus; if (record?.decryptEndDate !== '' && record?.decryptEndDate !== null && status !== '2') { return } else { if (status === '2') { return '' } else { return '请等待项目经理开启解密' } } } else { return '' } } }, ]; //解密进度 const jmjd = () => { return ( { spinSet(true); countSet(count + 1); handleRateVis(false); }} > {jmComplete + jmFail == jmFileCount ? `解 密 结 束` : `正 在 解 密...`}
文件总数:{jmFileCount}
解密成功:{jmComplete} 个, {/* 排队解密中:{100 - rate} 个, */} 尚未解密:{jmWait} 个, 解密失败:{jmFail}
) } return ( {/* {ipassDecode ? : null} */} {jmjd()} ) } export default FileDecode;