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

173 lines
8.2 KiB
JavaScript
Raw Normal View History

2025-11-07 17:44:59 +08:00
import { Button, Descriptions, Modal, Badge, Popconfirm, Row, Col, Form, Input, Select, Table } from 'antd';
import React from 'react';
import { initFilter, extendRule, extendInclude, setDataFieldValue, showApprove, guid, initQueryFilter, ShowDateTime, ShowPrintClose, 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 SE071ShowPrint extends React.Component {
constructor(props) {
super(props);
this.state = {
data: null,
btndisplay: 'none',
isCheck: false, //是否待办 审批
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')
}
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,
});
}
loadData = (id) => {
var isCheck = (this.props.data.tableKey != undefined && this.props.data.tableKey == '1') ? true : false
var orgId = this.props.login ? this.props.login.OrgId : '';
let json = initFilter(orgId);
json.Parameter22 = this.props.data.ORG_ID_HV;
2025-11-07 17:44:59 +08:00
extendRule(json, 'ID', 1, id);
extendInclude(json, 'Nav_Department')
extendInclude(json, 'Nav_User')
extendInclude(json, 'Nav_Files.Nav_ImgFile.Nav_File')
extendInclude(json, 'Nav_ListPlanDetail.Nav_Department')
extendInclude(json, 'Nav_ListPlanDetail.Nav_ListDetailDepartment.Nav_Department')
extendInclude(json, 'Nav_ListPlanDetail.Nav_TrainTypeEnum')
this.props.dispatch({
type: 'app/getDataByPost',
payload: json,
url: 'SE/SETrainPlan/GetSuit',
onComplete: (ret) => {
if (ret) {
this.setState({
data: ret,
})
}
}
});
}
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} /></td>
<td><ExportToExcel fileName='年度培训计划' tableId={'tableId' + this.props.data.id} /></td>
</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>
<Descriptions title='' size='middle' bordered>
<Descriptions.Item label="计划年度">{data.YEAR}</Descriptions.Item>
<Descriptions.Item label="发起时间">{data.LAUNCH_TIME}</Descriptions.Item>
<Descriptions.Item label="发起部门">{data.Nav_Department.NAME}</Descriptions.Item>
<Descriptions.Item label="发起人员">{data.Nav_User?.NAME}</Descriptions.Item>
<Descriptions.Item label="计划名称">{data.PLAN_NAME}</Descriptions.Item>
<Descriptions.Item label="附件">{showFiles(data.Nav_Files, config.picServerHost, this)}</Descriptions.Item>
{
data.TYPE == 5 ?
<Descriptions.Item label="指导原则">{data.GUIDE_PRINCIPLE}</Descriptions.Item>
: null
}
{
data.TYPE == 5 ?
<Descriptions.Item label="培训要求">{data.TRAIN_REQUIREMENT}</Descriptions.Item>
: null
}
</Descriptions>
</div> : null
}
{
(data?.Nav_ListPlanDetail && data?.Nav_ListPlanDetail.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>培训组织</td>
{/* <td>培训老师</td> */}
{
data.TYPE != 5 ?
<td>被培训组织</td>
: null
}
</tr>
{data?.Nav_ListPlanDetail?.map((item, i) => {
return <tr>
<td>{item.MONTH} </td>
<td>{enums.TrainInOut.enums[item.IN_OUT]} </td>
<td>{item.Nav_TrainTypeEnum.NAME} </td>
<td>{item.NAME} </td>
<td>{item.OBJECT} </td>
<td>{enums.TrainType.enums[item.TRAINTYPE]} </td>
<td>{enums.PlanCheckType.enums[item.CHECKTYPE]} </td>
<td>{item.CLASSHOUR} </td>
<td>{item.Nav_Department.NAME} </td>
{
data.TYPE != 5 ?
<td>{item.Nav_ListDetailDepartment?.map((itemtype, j) => { return (j > 0 ? '' : '') + itemtype.Nav_Department.NAME })}</td>
: null
}
</tr>
})}
</tbody>
</table>
: null
}
</div>
{
GetFileModel(Modal, FormPage, this, this.state.fileForm.visible)
}
</div>
}
}
export default connect(({ login, app }) => ({ login, app }))(SE071ShowPrint)