import { message } from "antd/lib/index"; import { Button, Popconfirm, Row, Col, Form, Input, Select, Table } from 'antd'; import React from 'react'; import { initFilter, extendRule, extendInclude, setDataFieldValue, guid, initQueryFilter } from "../../../utils/common"; import ReactToPrint from "react-to-print"; import styles from '../../CustomPages/HI/StepForm.css'; import XLSX from 'xlsx'; import { connect } from 'dva'; import moment from 'moment'; import config from "../../../config"; const EduCardStatus = { '草稿': 0, '公司培训': 1, '部门培训': 2, '班组培训': 3, '员工签到': 4, '审阅中': 5, '归档': 6, } class SE015ShowPrint extends React.Component { constructor(props) { super(props); this.state = { data: null, Note: '', EduCardID: null, impl: null, impls: null, readOnly: true, depName: "", }; }; componentDidMount() { if (window.navigator.userAgent.indexOf("Windows") < 1) { this.setState({ isMobile: true }) } 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 = (dataId) => { let json = initFilter(this.props.login.OrgId); extendRule(json, 'ID', 1, dataId); extendInclude(json, 'Nav_LaunchDepartment'); extendInclude(json, 'Nav_LaunchUser'); extendInclude(json, 'Nav_Department'); extendInclude(json, 'Nav_Post'); extendInclude(json, 'Nav_User.Nav_Department.Nav_Parent.Nav_Parent'); extendInclude(json, 'Nav_TrainRecordList.Nav_User'); extendInclude(json, 'Nav_TrainRecordList.Nav_Department'); extendInclude(json, 'Nav_TrainRecordList.Nav_Content'); extendInclude(json, 'Nav_TrainRecordList.Nav_TrainRecordFile.Nav_ImgFile.Nav_File'); extendInclude(json, 'Nav_TrainRecordList.Nav_TrainSignatureFile.Nav_ImgFile.Nav_File'); extendInclude(json, 'Nav_User.Nav_UserSignFiles.Nav_ImgFile.Nav_File'); json.IgnoreDataRule = true; this.props.dispatch({ type: 'app/getDataByPost', payload: json, url: 'SE/SEThreeLevelSafeEduCard/Get', onComplete: (ret) => { if (ret) { if (ret?.Nav_TrainRecordList) { ret.Nav_TrainRecordList = ret.Nav_TrainRecordList.sort((a, b) => { return a.THREE_LEVEL_SAFE_TRAIN_TYPE - b.THREE_LEVEL_SAFE_TRAIN_TYPE }); ret.Nav_TrainRecordList = ret.Nav_TrainRecordList.filter(t=>t.SCORE!=undefined); } this.setState({ data: ret }) let top = ret.Nav_Department?.Nav_Parent?.Nav_Parent?.NAME; if (top != undefined) { this.state.depName = top + "/" + ret.Nav_Department?.Nav_Parent?.NAME + "/" + ret.Nav_Department?.NAME } else { this.state.depName = ret.Nav_Department?.Nav_Parent?.NAME + "/" + ret.Nav_Department?.NAME } } } }); } onTableBtnExport() { let TableWrap = document.getElementById('tableId' + this.props.data.id); let Table = TableWrap.getElementsByTagName('table')[0]; const wb = XLSX.utils.table_to_book(Table); let name = ''; if (this.state.data && this.state.data.CODE) name += this.state.data.CODE name += '三级安全教育卡.xlsx' XLSX.writeFile(wb, name) } onTableBtnApprove = () => { if (!this.state.data || this.state.data.STATUS !== EduCardStatus['审阅中']) return let json = initFilter(this.props.login.OrgId); json.Parameter1 = this.props.data.id; json.Parameter2 = this.props.data.TaskID; this.props.dispatch({ type: 'app/getDataByPost', url: 'SE/SEThreeLevelSafeEduCard/Approve', payload: json, onComplete: (ret) => { if (ret) { message.success('审阅成功'); this.setState({ EduCardID: null, }); this.BtnClose(); } } }) } personalApprove = () => { let json = initFilter(this.props.login.OrgId); json.Parameter1 = this.props.data.id; json.Parameter2 = this.props.data.TaskID; this.props.dispatch({ type: 'app/getDataByPost', url: 'SE/SEThreeLevelSafeTrainRecord/PersonalAgree', payload: json, onComplete: (ret) => { if (ret) { message.success('审阅成功'); this.setState({ EduCardID: null, }); this.BtnClose(); } } }) } fmtEnum(name, value) { const enums = this.props.app.enums; if (!enums || !enums[name]) return ''; return enums[name].enums[value] || ''; } fmtTopics = () => { let ret = []; if (this.state.data && this.state.data.Nav_Topics) { this.state.data.Nav_Topics.map(it => { if (it.Nav_Topic) { ret.push(it.Nav_Topic.NAME); } }) } return ret.join('、'); } fmtJoinUsers = () => { let ret = []; if (this.state.data && this.state.data.Nav_JoinUsers) { this.state.data.Nav_JoinUsers.map(it => { if (it.Nav_User) { ret.push(it.Nav_User.NAME); } }) } return ret.join('、') } 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; } render() { const { data } = this.state; return
} content={() => this.componentRef} /> { (data && data.STATUS === EduCardStatus['审阅中']) && this.props.data.tableKey != undefined && this.props.data.tableKey == "1" ? : null } { (data && (data.STATUS <= EduCardStatus['员工签到'])) && this.props.data.tableKey != undefined && this.props.data.tableKey == "1" ? : null }
(this.componentRef = el)} id={'tableId' + this.props.data.id} style={{ padding: '20px' }}>

三级安全教育卡

{ data ? { data.Nav_TrainRecordList && data.Nav_TrainRecordList.map(it => { return <> }) }
发起时间 {data.LAUNCH_TIME} 发起部门 {data.Nav_LaunchDepartment ? data.Nav_LaunchDepartment.NAME : null} 发起人员 {data.Nav_LaunchUser ? data.Nav_LaunchUser.NAME : null} 编号 {data.Nav_User.CODE}
姓名 {data.Nav_User.NAME} 身份证号 {data.ID_CARD_NUMBER} 入职时间 {moment(data.IN_TIME).format('YYYY-MM-DD')}
部门 {this.state.depName} 岗位 {data.Nav_Post.NAME}
{ this.fmtEnum('SEThreeLevelSafeTrainType', it.THREE_LEVEL_SAFE_TRAIN_TYPE) }
开始时间 {moment(it.START_TIME).format('YYYY-MM-DD')} 结束时间 {moment(it.END_TIME).format('YYYY-MM-DD')} 培训地点 {it.TAINNING_ADDR} 组织部门 {it.Nav_Department ? it.Nav_Department.NAME : null} 记录/考核人 {it.Nav_User ? it.Nav_User.NAME : null}
培训学时 {it.TRAINNING_TIME} 培训老师 {it.TEACHER} 培训形式 {this.returnModel(it.TRAIN_MODEL)} 考核结果 {this.fmtEnum('SEExaminationResultsEnum', it.EXAMINATION_RESULTS)} 考核分数 {it.SCORE}
培训内容 {it.Nav_Content.NAME}
签名 { data.Nav_User.Nav_UserSignFiles.length > 0 && it.STATUS == 1 ? {data.Nav_User.NAME} : null }
附件 { it.Nav_TrainRecordFile && it.Nav_TrainRecordFile.map((item, i) => { return {item.Nav_ImgFile.FILE_NAME} }) }
: null }
} } export default connect(({ login, app }) => ({ login, app }))(SE015ShowPrint)