mh-sms-web/src/components/CustomPages/BS/BS064ShowPrint.js

116 lines
4.6 KiB
JavaScript
Raw Normal View History

2024-01-22 09:18:38 +08:00
import { Button, 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',
};
};
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")
}
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>
</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>
</tr>
})
}
</tbody>
</table>
</div>
</div>
}
}
export default connect(({ login, app }) => ({ login, app }))(BS064ShowPrint)