175 lines
8.6 KiB
JavaScript
175 lines
8.6 KiB
JavaScript
import { message } from "antd/lib/index";
|
||
import { Button, Descriptions, Badge, Popconfirm, Row, Col, Form, Input, Select, Table } from 'antd';
|
||
import React from 'react';
|
||
import { initFilter, extendRule, extendIgnoreDataRule, extendInclude, setDataFieldValue, guid, initQueryFilter } from "../../../utils/common";
|
||
import { ExportToExcel } from '@woowalker/feui'
|
||
import styles from '../HI/StepForm.css';
|
||
import ReactToPrint from "react-to-print";
|
||
import moment from 'moment';
|
||
import config from "../../../config.js";
|
||
import XLSX from 'xlsx';
|
||
import { connect } from 'dva';
|
||
|
||
class BS026ShowPrint extends React.Component {
|
||
constructor(props) {
|
||
super(props);
|
||
this.state = {
|
||
data: null,
|
||
item: null,
|
||
enumData: null,
|
||
btndisplay: '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);
|
||
}
|
||
}
|
||
|
||
onTableBtnExport() {
|
||
// let TableWrap = document.getElementById('table1' + this.props.record.ID);
|
||
let TableWrap = document.getElementById('table1');
|
||
let Table = TableWrap.getElementsByTagName('table1')[0];
|
||
const wb = XLSX.utils.table_to_book(Table);
|
||
XLSX.writeFile(wb, this.props.record.Nav_Department.NAME + ".xlsx")
|
||
}
|
||
|
||
// onTableBtnAgree() {
|
||
// this.props.dispatch({
|
||
// type: 'app/getDataByPost',
|
||
// //url: 'FO/FOTeamActivity/TeamActivityUserUpdate',
|
||
// url: 'BS/BSCheckMain/Get',
|
||
// payload: {
|
||
// ID: this.props.data.id,
|
||
// //ORG_ID: this.props.data.OrgId,
|
||
// TaskID: this.props.data.TaskID, //传参到后端(消息表ID)
|
||
// },
|
||
// onComplete: (ret) => {
|
||
// if (ret) {
|
||
// message.success('签到成功!');
|
||
// this.BtnClose();
|
||
// }
|
||
// }
|
||
// })
|
||
// }
|
||
|
||
// BtnClose = () => {
|
||
// if (typeof this.props.data.onCancel != "undefined" && typeof this.props.data.onCancel == 'function')
|
||
// this.props.data.onCancel();
|
||
// }
|
||
|
||
//加载数据(传过来的参数都在props里面,包括登录信息)
|
||
loadData = (id) => {
|
||
var orgId = this.props.login ? this.props.login.OrgId : ''; //登录后有存储登录信息
|
||
let json = initFilter(orgId);
|
||
extendRule(json, 'ID', 1, id); //ID=‘’,字段,等于,条件值, 1代表=,2代表不等于,3小于,4小于等于,5大于,6大于等于,7以开始的Like,8以结束的Like,9包含
|
||
extendInclude(json, 'Nav_CheckProject');
|
||
extendInclude(json, 'Nav_CheckProjectCategory');
|
||
extendInclude(json, 'Nav_CheckQuestion');
|
||
extendInclude(json, 'Nav_CheckType');
|
||
extendInclude(json, 'Nav_CheckTypeLevel.Nav_Enums');
|
||
extendInclude(json, 'Nav_RiskArea');
|
||
extendInclude(json, 'Nav_ListMainDep.Nav_Department');
|
||
extendIgnoreDataRule(json)
|
||
let attendanceAry = [], leaveAry = [];
|
||
let that = this;
|
||
let btndisplay = 'none';
|
||
this.props.dispatch({
|
||
type: 'app/getDataByPost',
|
||
payload: json,
|
||
//url: 'FO/TeamActivity/Get',
|
||
url: 'BS/BSCheckMain/Get',
|
||
onComplete: (ret) => { //返回查询结果ret
|
||
if (ret) { //判断是否有记录
|
||
//data?.Nav_TeamActivityUser.map(item => { //当data有值时遍历(map)data记录集
|
||
// ret?.Nav_TeamActivityUser.forEach(item => { //当data有值时遍历(forEach)data记录集
|
||
// if (item.ATTEND_STATUS === 1) { //参会人员
|
||
// attendanceAry.push(item.Nav_User.NAME); //将人员添加到attendanceAry数组
|
||
// } else if (item.ATTEND_STATUS === 2) { //缺席人员,
|
||
// leaveAry.push(item.Nav_User.NAME); //将人员添加到attendanceAry数组
|
||
// }
|
||
// //if (item.Nav_User.ID.toLowerCase() == that.props.login.userId.toLowerCase() && item.TA_STATUS===1 && item.ATTEND_STATUS === 1 && item.SIGN_IN_STATUS === 0) {
|
||
// if (item.Nav_User.ID.toLowerCase() == that.props.login.userId.toLowerCase() && item.ATTEND_STATUS === 1 && item.SIGN_IN_STATUS === 0) {
|
||
// btndisplay = 'inline'; //签到按扭显示变量
|
||
// }
|
||
// })
|
||
this.setState({ //设置setState全局变量
|
||
data: ret, //将ret对象赋值给data, data供页面调用
|
||
attendance: attendanceAry,
|
||
leave: leaveAry,
|
||
btndisplay: btndisplay
|
||
})
|
||
}
|
||
}
|
||
});
|
||
}
|
||
|
||
//渲染页面
|
||
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' }}>
|
||
<table>
|
||
<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>
|
||
</table>
|
||
</div>
|
||
|
||
{/* 安全检查 */}
|
||
<div ref={el => (this.componentRef = el)} style={{ padding: '20px', paddingTop: '20px' }} id={'tableId' + this.props.data.id}>
|
||
<h1 style={{ textAlign: 'center', margin: '15px' }}>安全检查</h1>
|
||
{
|
||
// paddingLeft: '50px'
|
||
data ? <div>
|
||
<Descriptions title="" size="middle" bordered>
|
||
<Descriptions.Item label="检查范围">{data.CHECKOBJECT_DESCRIPTION}</Descriptions.Item>
|
||
<Descriptions.Item label="检查类型">{data.Nav_CheckType?.NAME}</Descriptions.Item>
|
||
<Descriptions.Item label="检查层级">{data.Nav_CheckTypeLevel?.Nav_Enums.NAME}</Descriptions.Item>
|
||
<Descriptions.Item label="检查区域">{data.Nav_RiskArea?.NAME}</Descriptions.Item>
|
||
<Descriptions.Item label="检查项目">{data.Nav_CheckProject?.NAME}</Descriptions.Item>
|
||
<Descriptions.Item label="检查项目分类">{data.Nav_CheckProjectCategory?.NAME}</Descriptions.Item>
|
||
<Descriptions.Item label="检查内容">{data.CHECKCONTENT}</Descriptions.Item>
|
||
{/* <Descriptions.Item label="检查依据">{data.CHECKPROOF}</Descriptions.Item> */}
|
||
<Descriptions.Item label="检查问题描述">{data.Nav_CheckQuestion?.DESCREPTION}</Descriptions.Item>
|
||
<Descriptions.Item label="整改建议与措施">{data.Nav_CheckQuestion?.DEMAND}</Descriptions.Item>
|
||
<Descriptions.Item label="问题等级">{data.QUESTION_LEVE_DESCRIPTION}</Descriptions.Item>
|
||
<Descriptions.Item label="是否重大隐患">{data.SERIOUS_RISK_DESCRIPTION}</Descriptions.Item>
|
||
</Descriptions>
|
||
</div> : null
|
||
}
|
||
|
||
|
||
|
||
{
|
||
data ? <table className={styles.PrintFormLight}>
|
||
<tbody>
|
||
<tr className={styles.PrintFormLightTh}>
|
||
<td style={{ width: '100px' }}>序号</td>
|
||
<td>责任部门</td>
|
||
<td>责任对象</td>
|
||
</tr>
|
||
{data.Nav_ListMainDep.map((item, i) => {
|
||
return <tr>
|
||
<td>{i + 1}</td>
|
||
<td >{item.Nav_Department?.NAME}</td>
|
||
<td>{enums.BSPLANCHECKOBJECTEnum.enums[item.RESPONOBJECT]}</td>
|
||
</tr>
|
||
})}
|
||
</tbody>
|
||
</table> : null
|
||
}
|
||
|
||
</div>
|
||
</div>
|
||
}
|
||
}
|
||
export default connect(({ login, app }) => ({ login, app }))(BS026ShowPrint)
|