mh_jy_safe_web/src/components/CustomPages/SE/SE061ShowPrint.js

217 lines
9.6 KiB
JavaScript
Raw Normal View History

2025-08-25 10:08:30 +08:00
import { Button, Descriptions, Modal, Popconfirm, Row, Col, Form, Input, Select, Table, Icon } from 'antd';
import React from 'react';
import { initFilter, extendRule, extendInclude, setDataFieldValue, showApprove, guid, initQueryFilter, GetFileModel, showFiles } 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 '../../../components/CustomPages/HI/StepForm.css';
import config from '../../../config.js';
import FormPage from '../../FormPage'
class SE061ShowPrint extends React.Component {
constructor(props) {
super(props);
this.state = {
data: null,
btndisplay: 'none',
isCheck: false, //是否待办 审批
//弹窗参数
detailForm: {
isShow: false,
formCode: "SE061_PAPERPAGE",
title: "三级安全教育记录",
ID: ''
},
isShow1: "none",
isShow2: "none",
fileData: [],
fileForm: {
title: "",
visible: false,
},
}
}
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');
let Table = TableWrap.getElementsByTagName('table1')[0];
const wb = XLSX.utils.table_to_book(Table);
XLSX.writeFile(wb, this.props.record.Nav_Department.NAME + '.xlsx')
}
returnModel(level) {
let str = '';
if (level == undefined) {
return str;
}
if (level.indexOf('1') >= 0) {
str += '讲授法 ';
}
if (level.indexOf('2') >= 0) {
str += '视听法 ';
}
if (level.indexOf('3') >= 0) {
str += '研讨法 ';
}
if (level.indexOf('4') >= 0) {
str += '演示法 ';
}
return str;
}
//显示详情弹窗
showDetailModal = (ID) => {
const newtmpData = {
data: {
id: ID,
},
formCode: "SE061_PAPERPAGE",
};
this.setState({ tmpData: newtmpData }, () => {
var detailForm = {
isShow: true,
title: "查看成绩单",
};
this.setState({
detailForm: detailForm,
});
});
};
//详情弹窗关闭(隐藏)
detailFormClose = () => {
var detailForm = {
isShow: false,
};
this.setState({
detailForm: detailForm,
});
};
loadData = (id) => {
var orgId = this.props.login ? this.props.login.OrgId : '';
let json = initFilter(orgId);
extendRule(json, 'ID', 1, id);
extendInclude(json, 'Nav_Department')
extendInclude(json, 'Nav_User')
extendInclude(json, 'Nav_Content')
extendInclude(json, 'Nav_Files.Nav_ImgFile')
extendInclude(json, 'Nav_NewUserDetail.Nav_User')
extendInclude(json, 'Nav_NewUserDetail.Nav_Department')
extendInclude(json, 'Nav_NewUserDetail.Nav_Post')
extendInclude(json, 'Nav_NewUserDetail.Nav_Files.Nav_ImgFile')
this.props.dispatch({
type: 'app/getDataByPost',
payload: json,
url: 'SE/NewUsers/Get',
onComplete: (ret) => {
if (ret) {
this.setState({
data: ret,
})
if (ret.IS_CREATETEST) {
this.state.isShow1 = "table-cell";
} else {
this.state.isShow2 = "table-cell";
}
}
}
});
}
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} /></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 className={styles.showPrintHead}>三级安全教育记录</h1>
{
data ? <div style={{ width: '95%' }}>
<Descriptions title='' size='middle' bordered>
<Descriptions.Item label="发起部门">{data.Nav_Department.NAME}</Descriptions.Item>
<Descriptions.Item label="发起人">{data.Nav_User.NAME}</Descriptions.Item>
<Descriptions.Item label="培训层级">{enums.SEThreeLevelSafeTrainType.enums[data.TRAIN_STATUS]}</Descriptions.Item>
<Descriptions.Item label="开始时间">{data.START_TIME}</Descriptions.Item>
<Descriptions.Item label="截止时间">{data.END_TIME}</Descriptions.Item>
<Descriptions.Item label="培训学时">{data.TRAINNING_TIME}</Descriptions.Item>
<Descriptions.Item label="培训地点">{data.TAINNING_ADDR}</Descriptions.Item>
<Descriptions.Item label="培训老师">{data.TEACHER}</Descriptions.Item>
<Descriptions.Item label="培训形式">{data ? this.returnModel(data.TRAIN_MODEL) : null}</Descriptions.Item>
<Descriptions.Item label="培训内容" span="3">{data.Nav_Content.NAME}</Descriptions.Item>
<Descriptions.Item label="附件">{showFiles(data.Nav_Files, config.picServerHost, this)}</Descriptions.Item>
<Descriptions.Item label="是否触发考试">{data.IS_CREATETEST ? "是" : "否"}</Descriptions.Item>
</Descriptions>
</div> : null
}
{
(data?.Nav_NewUserDetail && data?.Nav_NewUserDetail.length > 0) ?
<table className={styles.PrintFormLight}>
<tbody>
<tr>
<td colSpan={10} className={styles.showPrintHead2}>三级安全教育详细</td>
</tr>
<tr className={styles.PrintFormLightTh}>
<td>工号</td>
<td>姓名</td>
<td>身份证号</td>
<td>入职时间</td>
<td>分数</td>
<td>部门</td>
<td>岗位</td>
<td>考核结果</td>
<td style={{ display: this.state.isShow1 }}>查看试卷</td>
<td style={{ display: this.state.isShow2 }}>附件</td>
</tr>
{data?.Nav_NewUserDetail?.map((item, i) => {
return <tr>
<td>{item.CODE} </td>
<td>{item.Nav_User?.NAME} </td>
<td>{item.ID_CARD_NUMBER} </td>
<td>{moment(item.IN_TIME).format('YYYY-MM-DD')} </td>
<td>{item.SCORE} </td>
<td>{item.Nav_Department?.NAME} </td>
<td>{item.Nav_Post?.NAME} </td>
<td>{enums.SEExaminationResultsEnum.enums[item.EXAMINATION_RESULTS]} </td>
<td style={{ display: this.state.isShow1 }}><div onClick={() => this.showDetailModal(item.ID)}><Icon type="eye" style={{ color: "#005b9b", cursor: "pointer" }} /></div></td>
<td style={{ display: this.state.isShow2 }}>{showFiles(item.Nav_Files, config.picServerHost, this)} </td>
</tr>
})}
</tbody>
</table>
: null
}
</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>
{
GetFileModel(Modal, FormPage, this, this.state.fileForm.visible)
}
</div>
}
}
export default connect(({ login, app }) => ({ login, app }))(SE061ShowPrint)