237 lines
12 KiB
JavaScript
237 lines
12 KiB
JavaScript
import { message } from "antd/lib/index";
|
|
import { Button, Descriptions, Popconfirm, Row, Col, Form, Input, Select, Table ,Modal} from 'antd';
|
|
import React from 'react';
|
|
import { initFilter, extendRule, extendInclude, extendIgnoreDataRule, setDataFieldValue, guid, showFiles, GetFileModel } from "../../../utils/common";
|
|
import ReactToPrint from "react-to-print";
|
|
import config from "../../../config";
|
|
import XLSX from 'xlsx';
|
|
import { connect } from 'dva';
|
|
import stylesStep from '../HI/StepForm.css';
|
|
import FormPage from '../../../components/FormPage'
|
|
import moment from 'moment';
|
|
class SK041ShowPrint extends React.Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = {
|
|
data: null,
|
|
enumData: null,
|
|
BtnAgreeDisplay: 'none',
|
|
fileForm: {
|
|
title: "",
|
|
visible: false,
|
|
},
|
|
};
|
|
};
|
|
|
|
componentDidMount() {
|
|
if (this.props.data?.id)
|
|
this.loadData(this.props.data?.id, this.props.data?.TaskID);
|
|
}
|
|
|
|
componentWillReceiveProps(NextProps) {
|
|
if (NextProps.data?.id && this.props.data?.id != NextProps.data?.id) {
|
|
this.loadData(NextProps.data?.id, this.props.data?.TaskID);
|
|
}
|
|
}
|
|
|
|
BtnClose = () => {
|
|
if (typeof this.props.data.onCancel != "undefined" && typeof this.props.data.onCancel == 'function')
|
|
this.props.data.onCancel();
|
|
}
|
|
|
|
loadData = (dataId, taskID) => {
|
|
let json = initFilter(this.props.login.OrgId);
|
|
extendRule(json, 'ID', 1, dataId);
|
|
// extendRule(json, 'TASK_ID', 1, taskID);
|
|
// extendInclude(json, 'Nav_ApplyUser');
|
|
// extendInclude(json, 'Nav_ApplyDepartment');
|
|
// extendInclude(json, 'Nav_Require');
|
|
// extendInclude(json, 'Nav_Details');
|
|
// extendInclude(json, 'Nav_Details.Nav_Area');
|
|
// extendInclude(json, 'Nav_Details.Nav_Type');
|
|
// extendInclude(json, 'Nav_Details.Nav_DetailMeasures');
|
|
// extendInclude(json, 'Nav_Details.Nav_DetailDeparts.Nav_Department');
|
|
// extendInclude(json, 'Nav_Details.Nav_DetailDeparts.Nav_User');
|
|
// extendInclude(json, 'Nav_Details.Nav_DetailPosts.Nav_Post');
|
|
// extendInclude(json, 'Nav_Files');
|
|
// extendInclude(json, 'Nav_Files.Nav_ImgFile');
|
|
extendIgnoreDataRule(json)
|
|
this.props.dispatch({
|
|
type: 'app/getDataByPost',
|
|
payload: json,
|
|
url: 'SK/SKRiskEvaluationSummary/SKGet',
|
|
onComplete: (ret) => {
|
|
if (ret) {
|
|
if (this.props.data && this.props.data.loadDataDeal) {
|
|
this.props.data.loadDataDeal(1);
|
|
}
|
|
this.setState({ data: ret })
|
|
if (this.props.data.tableKey == "2" || this.props.data.tableKey == undefined) {
|
|
this.setState({ BtnAgreeDisplay: 'none' })
|
|
} else {
|
|
this.setState({ BtnAgreeDisplay: 'inline' })
|
|
}
|
|
this.onClickApprove(false);
|
|
}
|
|
else { message.error('请先尝试刷新,若仍然加载失败,请联系管理员排查!'); }
|
|
}
|
|
});
|
|
}
|
|
|
|
onTableBtnExport() {
|
|
let TableWrap = document.getElementById('tableId' + this.props.data.id);
|
|
let Table = TableWrap.getElementsByTagName('table')[0];
|
|
const wb = XLSX.utils.table_to_book(Table);
|
|
XLSX.writeFile(wb, "安全风险评估汇总表.xlsx")
|
|
}
|
|
onClickApprove = (appVisible) => {
|
|
const newtmpData = {
|
|
data: { id: this.props.data.id, isShow: true, key: guid(), param: this.props.data.param, appVisible: appVisible, BtnAgreeDisplay: 'inline' },
|
|
formCode: "PF123",
|
|
}
|
|
this.setState({
|
|
tmpData: newtmpData,
|
|
});
|
|
}
|
|
render() {
|
|
const { data } = this.state;
|
|
const enums = this.props.data.enums ? this.props.data.enums : this.props.app.enums;
|
|
return <div>
|
|
<div style={{ padding: '10px' }}>
|
|
<Button onClick={() => this.onClickApprove(true)} style={{ marginRight: '8px' }} icon="export">审批详情</Button>
|
|
<ReactToPrint
|
|
trigger={() => <Button type={'default'} icon={'printer'} style={{ marginLeft: '8px', display: data && data.STATUS === 30 ? "inline" : "none" }}>打印</Button>}
|
|
content={() => this.componentRef}
|
|
pageStyle=".printDIV { padding:0 40px;} img{width :120px}"
|
|
/>
|
|
<Button style={{ marginLeft: '8px', display: data && data.STATUS === 30 ? "inline" : "none" }} onClick={() => this.onTableBtnExport()} icon="export" >导出</Button>
|
|
</div>
|
|
<div ref={el => (this.componentRef = el)} style={{ padding: '20px' }} id={'tableId' + this.props.data.id}>
|
|
<h1 style={{ textAlign: 'center', margin: '15px' }}>安全风险评估汇总表</h1>
|
|
{
|
|
data ?
|
|
<div>
|
|
<Descriptions size="middle" bordered className={stylesStep.description}>
|
|
<Descriptions.Item label="发起时间">{moment(data.CREATE_TIME).format('YYYY-MM-DD')}</Descriptions.Item>
|
|
<Descriptions.Item label="发起部门">{data.Nav_ApplyDepartment ? data.Nav_ApplyDepartment.NAME : ''}</Descriptions.Item>
|
|
<Descriptions.Item label="发起人员">{data.Nav_ApplyUser ? data.Nav_ApplyUser.NAME : ''}</Descriptions.Item>
|
|
<Descriptions.Item label="评估年度">{data.YEAR}</Descriptions.Item>
|
|
<Descriptions.Item label="开始时间">{moment(data.START_DATE).format('YYYY-MM-DD')}</Descriptions.Item>
|
|
<Descriptions.Item label="结束时间">{moment(data.END_DATE).format('YYYY-MM-DD')}</Descriptions.Item>
|
|
<Descriptions.Item label="评价要求">{data.Nav_Require ? data.Nav_Require.NAME : ''}</Descriptions.Item>
|
|
|
|
<Descriptions.Item label="附件">{
|
|
showFiles(data?.Nav_Files, config.picServerHost, this)
|
|
}</Descriptions.Item>
|
|
</Descriptions>
|
|
</div> : null
|
|
}
|
|
<table style={{ tableLayout: 'fixed', width: '100%' }} className={stylesStep.PrintForm1}>
|
|
<tr>
|
|
<td className={stylesStep.fontBold}>序号</td>
|
|
<td className={stylesStep.fontBold}>生产单元</td>
|
|
<td className={stylesStep.fontBold}>辨识区域</td>
|
|
<td className={stylesStep.fontBold}>风险名称</td>
|
|
<td className={stylesStep.fontBold}>风险描述</td>
|
|
<td className={stylesStep.fontBold}>风险类别</td>
|
|
<td className={stylesStep.fontBold}>风险等级</td>
|
|
<td className={stylesStep.fontBold}>风险评价L</td>
|
|
<td className={stylesStep.fontBold}>风险评价E</td>
|
|
<td className={stylesStep.fontBold}>风险评价C</td>
|
|
<td className={stylesStep.fontBold}>分值D</td>
|
|
<td style={{ width: "200px" }} className={stylesStep.fontBold}>管控措施</td>
|
|
<td style={{ width: "200px" }} className={stylesStep.fontBold}>应急处置</td>
|
|
<td className={stylesStep.fontBold}>管控层级</td>
|
|
<td className={stylesStep.fontBold}>管控部门</td>
|
|
<td className={stylesStep.fontBold}>管控责任人</td>
|
|
</tr>
|
|
{
|
|
data?.Nav_Details && data.Nav_Details?.map((item, i) => {
|
|
return <tr>
|
|
<td>
|
|
{i + 1}
|
|
</td>
|
|
<td>
|
|
{item.Nav_ProductionUnit?.NAME}
|
|
</td>
|
|
<td>
|
|
{item.Nav_Area?.NAME}
|
|
</td>
|
|
<td>
|
|
{item.RISK_NAME}
|
|
</td>
|
|
<td>
|
|
{item.RISK_DESCRIPTION}
|
|
</td>
|
|
<td>
|
|
{item.Nav_Type?.NAME}
|
|
</td>
|
|
<td>
|
|
{enums.SKEvaluateLevelEnum.enums[item.EVALUATE_LEVEL]}
|
|
</td>
|
|
<td>
|
|
{item.Nav_SCOREL? item.Nav_SCOREL?.SCORE : 0}
|
|
</td>
|
|
<td>
|
|
{item.Nav_SCOREE? item.Nav_SCOREE?.SCORE : 0}
|
|
</td>
|
|
<td>
|
|
{item.Nav_SCOREC? item.Nav_SCOREC?.SCORE : 0}
|
|
</td>
|
|
<td>
|
|
{item.EVALUATE_SCORE}
|
|
</td>
|
|
<td>
|
|
{
|
|
//item.MEASURE
|
|
item?.Nav_DetailMeasures && item?.Nav_DetailMeasures.map((item2, i) => {
|
|
return <tr> {item2?.NUM +item2?.MEASURES_NAME}</tr>
|
|
})
|
|
}
|
|
</td>
|
|
<td>
|
|
{
|
|
item.EMERGENCY
|
|
// item?.Nav_DetailMeasures && item?.Nav_DetailMeasures.map((item2, i) => {
|
|
// return <tr> {item2?.EMERGENCY}</tr>
|
|
// })
|
|
}
|
|
</td>
|
|
<td>
|
|
{
|
|
//item.DEPARTMENT_TYPE
|
|
item?.Nav_DetailDeparts && item?.Nav_DetailDeparts.map((item2, i) => {
|
|
return <tr> {enums.FMDepartmentType.enums[item2.DEPARTMENT_TYPE]}</tr>
|
|
})
|
|
}
|
|
</td>
|
|
<td>
|
|
{
|
|
//item.IDENTIFY_DEPARTMENT
|
|
item?.Nav_DetailDeparts && item?.Nav_DetailDeparts.map((item2, i) => {
|
|
return <tr> {item2?.Nav_Department?.NAME}</tr>
|
|
})
|
|
}
|
|
</td>
|
|
<td>
|
|
{
|
|
//item.IDENTIFY_USER
|
|
item?.Nav_DetailDeparts && item?.Nav_DetailDeparts.map((item2, i) => {
|
|
return <tr> {item2?.Nav_User?.NAME}</tr>
|
|
})
|
|
}
|
|
</td>
|
|
</tr>
|
|
})
|
|
}
|
|
</table>
|
|
<FormPage {...this.state.tmpData} />
|
|
</div>
|
|
{
|
|
GetFileModel(Modal, FormPage, this, this.state.fileForm.visible)
|
|
}
|
|
</div>
|
|
}
|
|
|
|
}
|
|
export default connect(({ login, app }) => ({ login, app }))(SK041ShowPrint)
|