167 lines
8.8 KiB
JavaScript
167 lines
8.8 KiB
JavaScript
import { Button, Descriptions, Popconfirm, Row, Col, Form, Modal, Input, Select, Table } from 'antd';
|
|
import React from 'react';
|
|
import { initFilter, extendRule, extendInclude, extendIgnoreDataRule, setDataFieldValue, guid, initQueryFilter, approveView } from "../../../utils/common";
|
|
import ReactToPrint from "react-to-print";
|
|
import stylesStep from '../HI/StepForm.css';
|
|
import config from "../../../config";
|
|
import XLSX from 'xlsx';
|
|
import { connect } from 'dva';
|
|
import moment from 'moment';
|
|
import { message } from "antd/lib/index";
|
|
import FormPage from '../../../components/FormPage'
|
|
class SK043ShowPrint extends React.Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = {
|
|
data: null,
|
|
BtnAgreeDisplay: 'none',
|
|
tmpData: {},
|
|
};
|
|
};
|
|
|
|
componentDidMount() {
|
|
if (this.props.data?.id)
|
|
this.loadData(this.props.data?.id);
|
|
}
|
|
|
|
componentWillReceiveProps(NextProps) {
|
|
if (NextProps.data?.id && this.props.data?.id != NextProps.data?.id) {
|
|
this.loadData(NextProps.data?.id);
|
|
}
|
|
}
|
|
|
|
BtnClose = () => {
|
|
if (typeof this.props.data.onCancel != "undefined" && typeof this.props.data.onCancel == 'function')
|
|
this.props.data.onCancel();
|
|
}
|
|
|
|
loadData = (dataId) => {
|
|
let that = this;
|
|
let json = initFilter(that.props.login.OrgId);
|
|
json.Parameter22 = this.props.data.ORG_ID_HV;
|
|
extendRule(json, 'ID', 1, dataId);
|
|
extendInclude(json, 'Nav_Type');
|
|
extendInclude(json, 'Nav_Area');
|
|
extendInclude(json, 'Nav_Measures.Nav_Levels');
|
|
extendInclude(json, 'Nav_Contents.Nav_Contents');
|
|
extendInclude(json, 'Nav_Hiddens');
|
|
extendIgnoreDataRule(json)
|
|
that.props.dispatch({
|
|
type: 'app/getDataByPost',
|
|
payload: json,
|
|
url: 'SK/BasicLibraryTemp/Get',
|
|
onComplete: (ret) => {
|
|
if (ret) {
|
|
if (that.props.data && that.props.data.loadDataDeal) {
|
|
that.props.data.loadDataDeal(1);
|
|
}
|
|
that.setState({ data: ret });
|
|
if (that.props.data.tableKey === "2" || that.props.data.tableKey === undefined) {
|
|
that.setState({ BtnAgreeDisplay: 'none' })
|
|
} else {
|
|
that.setState({ BtnAgreeDisplay: 'inline' })
|
|
}
|
|
approveView(this, 'inline', false);
|
|
//归档才显示打印和导出按钮
|
|
// if(ret.PRE_MEETING_STATUS==5){
|
|
// this.setState({ isFinished: 'inline' })
|
|
// }
|
|
}
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
onTableBtnExport() {
|
|
const enums = this.props.data.enums ? this.props.data.enums : this.props.app.enums;
|
|
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")
|
|
}
|
|
|
|
render() {
|
|
const { data } = this.state;
|
|
const enums = this.props.data.enums ? this.props.data.enums : this.props.app.enums;
|
|
// let aaa = Math.random();
|
|
return <div>
|
|
|
|
<div style={{ padding: '10px' }}>
|
|
{/* <Button onClick={() => this.onClickApprove(true)} style={{ marginRight: '8px'}} icon="export">审批详情</Button> */}
|
|
<ReactToPrint
|
|
trigger={() => <Button style={{ marginLeft: '8px', display: data && data.STATUS === 30 ? "inline" : "none" }} type={'default'} icon={'printer'} >打印</Button>}
|
|
content={() => this.componentRef}
|
|
/>
|
|
<Button onClick={() => this.onTableBtnExport()} icon="export" style={{ marginLeft: '8px', display: data && data.STATUS === 30 ? "inline" : "none" }}>导出</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="生产单元"> {data.Nav_ProductionUnit?.NAME}</Descriptions.Item>
|
|
<Descriptions.Item label="辨识区域">{data.Nav_Area ? data.Nav_Area?.NAME : ''}</Descriptions.Item>
|
|
<Descriptions.Item label="风险名称">{data.RISK_NAME}</Descriptions.Item>
|
|
<Descriptions.Item label="风险描述">{data.RISK_DESCRIPTION}</Descriptions.Item>
|
|
<Descriptions.Item label="风险类别">{data.Nav_Type ? data.Nav_Type?.NAME : ''}</Descriptions.Item>
|
|
<Descriptions.Item label="风险评价L">{data.EVALUATE_L}</Descriptions.Item>
|
|
<Descriptions.Item label="风险评价E">{data.EVALUATE_E}</Descriptions.Item>
|
|
<Descriptions.Item label="风险评价C">{data.EVALUATE_C}</Descriptions.Item>
|
|
<Descriptions.Item label="分值D">{data.EVALUATE_SCORE}</Descriptions.Item>
|
|
<Descriptions.Item label="风险等级">{enums.SKEvaluateLevelEnum.enums[data.EVALUATE_LEVEL]}</Descriptions.Item>
|
|
|
|
</Descriptions>
|
|
<Descriptions size="middle" bordered className={stylesStep.description}>
|
|
<Descriptions.Item label="管控措施">
|
|
{
|
|
data?.Nav_Measures && data?.Nav_Measures.map((item, i) => {
|
|
return <tr>
|
|
<td>
|
|
{(i + 1) + "." + item?.MEASURES_NAME}
|
|
</td>
|
|
<td>
|
|
{item?.EMERGENCY}
|
|
</td>
|
|
<td>
|
|
{
|
|
item?.Nav_Levels && item?.Nav_Levels.map((item2, i) => {
|
|
return <tr> {enums.SKDepartmentTypeEnum.enums[item2?.DEPARTMENT_TYPE]}</tr>
|
|
})
|
|
}
|
|
</td>
|
|
</tr>
|
|
})
|
|
}
|
|
</Descriptions.Item>
|
|
</Descriptions>
|
|
<Descriptions size="middle" bordered className={stylesStep.description}>
|
|
<Descriptions.Item label="检查内容">{
|
|
data?.Nav_Contents && data?.Nav_Contents.map((item, i) => {
|
|
return <tr><td> {(i + 1) + "." + item?.CHECK_CONTENT}</td>
|
|
<td> {item?.CHECK_BASIC}</td>
|
|
<td> {item?.CHECK_STANDARD}</td>
|
|
</tr>
|
|
})
|
|
}</Descriptions.Item>
|
|
</Descriptions>
|
|
<Descriptions size="middle" bordered className={stylesStep.description}>
|
|
<Descriptions.Item label="隐患描述">{
|
|
data?.Nav_Hiddens && data?.Nav_Hiddens.map((item, i) => {
|
|
return <tr><td> {(i + 1) + "." + item?.HIDDEN_DESCRIPTION}</td>
|
|
<td> {enums.SKHiddenLevel.enums[item?.HIDDEN_LEVEL]}</td>
|
|
<td> {item?.RECTIFICATION_MEASURES}</td></tr>
|
|
})
|
|
}</Descriptions.Item>
|
|
</Descriptions>
|
|
</div> : null
|
|
}
|
|
|
|
<FormPage {...this.state.tmpData} />
|
|
</div>
|
|
</div>
|
|
}
|
|
|
|
}
|
|
|
|
export default connect(({ login, app }) => ({ login, app }))(SK043ShowPrint)
|