mh-sms-web/src/components/CustomPages/OH/OH006ShowPrint.js
2024-01-22 09:18:38 +08:00

201 lines
9.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { Checkbox, message, Radio } 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, showFiles, showApprove, showUserSign, showUsersSign } 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';
import FormPage from '../../FormPage'
class OH006ShowPrint extends React.Component {
constructor(props) {
super(props);
this.state = {
data: null,
item: null,
btndisplay: 'none',
isTaskSign: false, //是否待办 审批
JOINRESULT: 0, //10 参加 20 请假
NOTJOINREASON: '',//请假原因
isHasOpinion: false,//会议意见库
isMinutesDetail: false,//会议纪要落实
listSign: []//会议签到
}
}
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")
}
onClickApprove = (appVisible) => {
const newtmpData = {
data: { id: this.props.data.id, isShow: true, key: guid(), param: this.props.data.param, appVisible: appVisible, BtnAgreeDisplay: 'none' },
formCode: "PF123",
}
this.setState({
tmpData: newtmpData,
});
}
// //审批意见 改变
// NOTJOINREASONCHANGE = (val) => {
// this.state.NOTJOINREASON = val
// }
// //请假/参加
// sign = () => {
// let json = initFilter(this.props.login.OrgId, this.props.data.id, null, null, null, this.props.data.TaskID);
// this.props.dispatch({
// type: 'app/getDataByPost',
// payload: json,
// url: 'SC/SCMtMeetingMinutes/MeetingMinutesSign',
// onComplete: (ret) => {
// if (ret) {
// this.props.data.onCancel();
// }
// }
// });
// }
// //请假/参加
// sureCheck = (val) => {
// if (val && val == 20 && (this.state.NOTJOINREASON == undefined || this.state.NOTJOINREASON == null || this.state.NOTJOINREASON.length < 1)) {
// message.error("请填写请假备注!");
// return false
// }
// let json = initFilter(this.props.login.OrgId, this.props.data.id, null, null, null, this.props.data.TaskID, val, this.state.NOTJOINREASON);
// this.props.dispatch({
// type: 'app/getDataByPost',
// payload: json,
// url: 'SC/SCMTMeeting/PAllCheck',
// onComplete: (ret) => {
// if (ret) {
// this.props.data.onCancel();
// }
// }
// });
// }
//加载数据(传过来的参数都在props里面包括登录信息)
loadData = (id) => {
var taskID = this.props.data.TaskID
var loginID = this.props.login.user.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以结束的Like9包含
extendIgnoreDataRule(json)
let attendanceAry = [], leaveAry = [];
let that = this;
let btndisplay = 'none';
this.props.dispatch({
type: 'app/getDataByPost',
payload: json,
url: 'OH/OHHealthExamPlan/GetOH006',
onComplete: (ret) => { //返回查询结果ret
if (ret) { //判断是否有记录
this.setState({ //设置setState全局变量
data: ret, //将ret对象赋值给data, data供页面调用
})
}
}
});
}
//渲染页面
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><Button onClick={() => this.onClickApprove(true)} style={{ marginRight: '8px' }} icon="export">审批详情</Button></td>
<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>
{/* {isTaskSign ? <td><Button className={styles.sign} type={'primary'} icon={'check'} onClick={() => this.sign()} >签到</Button></td> : null} */}
</tr>
</table>
</div>
<FormPage {...this.state.tmpData} />
{/* 安全检查 */}
<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.NAME}</Descriptions.Item>
<Descriptions.Item label="年度">{data.YEAR}</Descriptions.Item>
<Descriptions.Item label="上报截止时间">{data.DUE_TIME}</Descriptions.Item>
<Descriptions.Item label="上报部门">{data.Nav_ListDepartment?.map((item, i) => {
return (i > 0 ? ',' : '') + item.Nav_Department.NAME
})}</Descriptions.Item>
<Descriptions.Item label="计划内容">{data.CONTENT}</Descriptions.Item>
</Descriptions>
</div> : null
}
{
data?.Nav_ListPlanRegister ?
<table className={styles.PrintFormLight}>
<tbody>
<tr>
{/* <td colSpan={10} style={{ fontSize: '25px', color: '#333', margin: '20px 0 20px 0' }}>体检计划人员登记</td> */}
<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>体检项目</td>
<td>体检类型</td>
</tr>
{data?.Nav_ListPlanRegister?.map((item, i) => {
return <tr>
<td>{item.Nav_Department?.NAME} </td>
{/* <td>{item.Nav_DepartmentWorkshop?.NAME} </td> */}
<td>{item.Nav_User?.NAME} </td>
<td>{item.Nav_User?.ID_CARD} </td>
<td>{enums.FMSexEnum.enums[item.Nav_User?.SEX]} </td>
<td>{item.Nav_SCPost?.NAME} </td>
<td>{item.WORKYEAR == 0 ? "" : item.WORKYEAR} </td>
<td>{item.Nav_ListHazard?.map((itemtype, j) => {
return (j > 0 ? '' : '') + itemtype?.Nav_Hazard.NAME
})}</td>
<td>{item.HEALTH_EXAM_CONTENT} </td>
<td>{enums.OHHealthExamType.enums[item.TYPE]} </td>
</tr>
})}
</tbody>
</table> : null
}
</div>
</div>
}
}
export default connect(({ login, app }) => ({ login, app }))(OH006ShowPrint)