2022-03-10 14:24:13 +08:00
|
|
|
import React, { useEffect, useState } from 'react';
|
|
|
|
import { Button, Card, Col, Empty, Modal, Row } from 'antd';
|
2022-04-01 20:06:34 +08:00
|
|
|
import { getDefId, getRoomId } from '@/utils/session';
|
|
|
|
import { getAssessRoomData, getReportList } from './service';
|
2022-03-10 14:24:13 +08:00
|
|
|
|
|
|
|
const ReportPrint: React.FC<{}> = () => {
|
|
|
|
//存储list
|
|
|
|
const [reportPrintList, setReportPrintList] = useState<any>();
|
2022-04-01 20:06:34 +08:00
|
|
|
//评审室id
|
|
|
|
const roomId = getRoomId();
|
|
|
|
//流程id
|
|
|
|
const defId = getDefId();
|
2022-03-10 14:24:13 +08:00
|
|
|
|
|
|
|
useEffect(() => {
|
2022-04-01 20:06:34 +08:00
|
|
|
//获取评审室基本信息
|
|
|
|
getAssessRoomData(roomId).then(response => {
|
|
|
|
if (response?.code == 200) {
|
|
|
|
//初始化遍历
|
|
|
|
getReportList(roomId).then((res) => {
|
|
|
|
let list = res.data;
|
|
|
|
let arr = Object.keys(list);
|
|
|
|
let report: any[] = [];
|
|
|
|
if (arr.length == 0) {
|
|
|
|
let e = <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />;
|
|
|
|
report.push(e);
|
|
|
|
} else {
|
|
|
|
for (const key in list) {
|
|
|
|
let e = (
|
|
|
|
<div>
|
|
|
|
<Card title={key} style={{ marginBottom: 8 }}>
|
|
|
|
<Row>
|
|
|
|
{list[key]?.map((item: any, index: any) => (
|
|
|
|
<Col span={6}>
|
|
|
|
<Button
|
|
|
|
type="text"
|
|
|
|
key={item.id}
|
2022-04-18 20:53:41 +08:00
|
|
|
onClick={() => onClickLink(item.url, item.dicName, item.queryType, response?.data)}
|
2022-04-01 20:06:34 +08:00
|
|
|
style={{ color: '#b30000', background: 'rgba(0, 0, 0, 0)' }}
|
|
|
|
>
|
|
|
|
{index + 1}、{item.dicName}
|
|
|
|
</Button>
|
|
|
|
</Col>
|
|
|
|
))}
|
|
|
|
</Row>
|
|
|
|
</Card>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
report.push(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setReportPrintList(report);
|
|
|
|
});
|
2022-03-10 14:24:13 +08:00
|
|
|
}
|
2022-04-01 20:06:34 +08:00
|
|
|
})
|
2022-03-10 14:24:13 +08:00
|
|
|
}, []);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
window.addEventListener('message', receiveMessage, false); // 监听message事件,用于接收从子页面返回的参数
|
|
|
|
return () => window.removeEventListener('message', receiveMessage);
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
//点击按钮后的弹窗遮罩
|
|
|
|
const editLoading = () => {
|
|
|
|
Modal.info({
|
|
|
|
title: `文档编辑器打开中,请在弹出窗口打印报表`,
|
|
|
|
okText: <></>,
|
|
|
|
okButtonProps: { hidden: true },
|
|
|
|
cancelButtonProps: { hidden: true },
|
|
|
|
centered: true,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
//接收子页面返回参数方法
|
|
|
|
const receiveMessage = async (event: any) => {
|
|
|
|
if (event !== undefined && event?.data) {
|
|
|
|
/*文件保存状态*/
|
|
|
|
if (event?.data != null && event?.data != undefined) {
|
|
|
|
let FileMsg = event?.data;
|
|
|
|
if (
|
|
|
|
FileMsg?.type == 'FROM_NTKO_CLOSE' &&
|
|
|
|
FileMsg?.text == window.ntkoBrowser.thisNTKOGUID
|
|
|
|
) {
|
|
|
|
Modal.destroyAll();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-04-18 20:53:41 +08:00
|
|
|
const onClickLink = (url: string, name: string, type: string, data: any) => {
|
2022-03-10 14:24:13 +08:00
|
|
|
editLoading();
|
2022-04-18 20:53:41 +08:00
|
|
|
window.ntkoBrowser.openWindow('/Weboffice4Path.html?path=' + encodeURIComponent(url) + '&fileType=' + type + '&fileName=' + `${data.sectionName}-${data.sectionNum}-${data.roomType == 1 ? '预审' : ''}${name}${defId == 'recruit_multi' ? `第${data.roomSort}轮` : ''}${data.reviewMark == 1 ? `(第${data.reviewSort}次重新评审)` : ''}`);
|
2022-03-10 14:24:13 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Card bordered={false}>
|
|
|
|
{reportPrintList}
|
|
|
|
</Card>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ReportPrint;
|