169 lines
6.4 KiB
JavaScript
169 lines
6.4 KiB
JavaScript
import { Button, Icon,Modal, Descriptions, Badge, Popconfirm, Row, Col, Form, Input, Select, Table } from 'antd';
|
||
import React from 'react';
|
||
import { initFilter, extendRule, extendIgnoreDataRule, extendInclude, setDataFieldValue, showApprove, guid, initQueryFilter } from "../../../utils/common";
|
||
import ReactToPrint from "react-to-print";
|
||
import { ExportToExcel } from '@woowalker/feui'
|
||
import XLSX from 'xlsx';
|
||
import { connect } from 'dva';
|
||
import moment from 'moment';
|
||
import { message } from "antd/lib/index";
|
||
import styles from '../HI/StepForm.css';
|
||
import config from "../../../config.js";
|
||
import FormPage from '../../../components/FormPage'
|
||
|
||
|
||
class BS064ShowPrint extends React.Component {
|
||
constructor(props) {
|
||
super(props);
|
||
this.state = {
|
||
data: null,
|
||
BtnAgreeDisplay: 'none',
|
||
//弹窗参数
|
||
detailForm: {
|
||
isShow: false,
|
||
formCode:"BS044_SHOWPRINT",
|
||
title: "隐患整改单",
|
||
ID:''
|
||
},
|
||
};
|
||
};
|
||
|
||
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 = () => {
|
||
let json = initFilter(this.props.login.OrgId);
|
||
extendRule(json, 'ID', 1, this.props.data.id);
|
||
extendIgnoreDataRule(json)
|
||
this.props.dispatch({
|
||
type: 'app/getDataByPost',
|
||
payload: json,
|
||
url: 'BS/BSRiskSubmit/GetListRiskDetail',//RiskSubmitNotice RiskSubmit
|
||
onComplete: (ret) => {
|
||
if (ret) {
|
||
this.setState({ //设置setState全局变量
|
||
data: ret, //将ret对象赋值给data, data供页面调用
|
||
})
|
||
}
|
||
}
|
||
});
|
||
}
|
||
|
||
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")
|
||
}
|
||
|
||
|
||
//显示详情弹窗
|
||
showDetailModal = (SUBMIT_CONTENT_ID) => {
|
||
const newtmpData = {
|
||
data: {
|
||
id: SUBMIT_CONTENT_ID,//必须动态参数 这个会影响页面去后台操作数据 '00000000-0000-0000-0000-000000000000' 或者 ''都不行
|
||
SUBMIT_CONTENT_ID: SUBMIT_CONTENT_ID,
|
||
},
|
||
formCode: "BS044_SHOWPRINT",
|
||
};
|
||
this.setState({ tmpData: newtmpData }, () => {
|
||
var detailForm = {
|
||
isShow: true,
|
||
title: "隐患整改单",
|
||
};
|
||
this.setState({
|
||
detailForm: detailForm,
|
||
});
|
||
});
|
||
};
|
||
|
||
//详情弹窗关闭(隐藏)
|
||
detailFormClose = () => {
|
||
var detailForm = {
|
||
isShow: false,
|
||
};
|
||
this.setState({
|
||
detailForm: detailForm,
|
||
});
|
||
};
|
||
|
||
render() {
|
||
const { data } = this.state;
|
||
return <div>
|
||
<div style={{ padding: '10px' }}>
|
||
<table>
|
||
<tbody>
|
||
<tr>
|
||
<td><ReactToPrint trigger={() => <Button type={'default'} icon={'printer'} >打印</Button>} content={() => this.componentRef} pageStyle={"#tableId" + this.props.data.id + " { padding:0 40px;} img{width :120px}"} /></td>
|
||
<td><ExportToExcel fileName='隐患明细' tableId={'tableId' + this.props.data.id} /></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
|
||
{/* 检查表制定 */}
|
||
<div ref={el => (this.componentRef = el)} style={{ padding: '20px', paddingTop: '20px' }} id={'tableId' + this.props.data.id}>
|
||
<h1 className={styles.showPrintHead} >隐患明细</h1>
|
||
<table className={styles.PrintFormLight}>
|
||
<tbody>
|
||
<tr className={styles.PrintFormLightTh}>
|
||
<td>序号</td>
|
||
<td>检查发起部门</td>
|
||
<td>检查类型</td>
|
||
<td>检查时间</td>
|
||
<td>检查人员</td>
|
||
<td>隐患地点</td>
|
||
<td>整改完成时间(归档时间)</td>
|
||
<td>整改人</td>
|
||
<td>操作</td>
|
||
</tr>
|
||
{
|
||
data?.map((item, i) => {
|
||
return <tr>
|
||
<td>{i + 1}</td>
|
||
<td>{item.DEPARTMENT_NAME}</td>
|
||
<td>{item.CHECKTYPE_NAME}</td>
|
||
<td>{item.CHECKTYPE_TIME}</td>
|
||
<td>{item.CHECKTYPE_USERS}</td>
|
||
<td>{item.ADDRESS}</td>
|
||
<td>{item.FINISH_TIME}</td>
|
||
<td>{item.ACTURE_USERNAME}</td>
|
||
<td><div onClick={() => this.showDetailModal(item.SUBMIT_CONTENT_ID)}><Icon type="eye" style={{ color: "#005b9b", cursor: "pointer" }} /></div></td>
|
||
</tr>
|
||
})
|
||
}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<br />
|
||
<div style={{ display: "inline-block" }}>
|
||
<Modal
|
||
visible={this.state.detailForm.isShow}
|
||
title={this.state.detailForm.title}
|
||
maskClosable={false}
|
||
closeModal={this.detailFormClose}
|
||
onCancel={this.detailFormClose}
|
||
footer={null}
|
||
width="95%">
|
||
<FormPage {...this.state.tmpData} />
|
||
</Modal>
|
||
</div>
|
||
</div>
|
||
}
|
||
|
||
}
|
||
|
||
export default connect(({ login, app }) => ({ login, app }))(BS064ShowPrint)
|