112 lines
		
	
	
		
			4.8 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
		
		
			
		
	
	
			112 lines
		
	
	
		
			4.8 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| 
								 | 
							
								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 WFViewComponent from '../../Lib/WFViewComponent'
							 | 
						||
| 
								 | 
							
								import XLSX from 'xlsx';
							 | 
						||
| 
								 | 
							
								import { connect } from 'dva';
							 | 
						||
| 
								 | 
							
								import moment from 'moment';
							 | 
						||
| 
								 | 
							
								import config from "../../../config";
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								class OG004View extends React.Component {
							 | 
						||
| 
								 | 
							
								    constructor(props) {
							 | 
						||
| 
								 | 
							
								        super(props);
							 | 
						||
| 
								 | 
							
								        this.state = {
							 | 
						||
| 
								 | 
							
								            data: null,
							 | 
						||
| 
								 | 
							
								            BtnAgreeDisplay: 'none',
							 | 
						||
| 
								 | 
							
								            assessUser: ''
							 | 
						||
| 
								 | 
							
								        };
							 | 
						||
| 
								 | 
							
								    };
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    componentDidMount() {
							 | 
						||
| 
								 | 
							
								        this.loadData();
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    onTableBtnAgree() {
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    BtnClose = () => {
							 | 
						||
| 
								 | 
							
								        if (typeof this.props.closeFn != "undefined")
							 | 
						||
| 
								 | 
							
								            this.props.closeFn();
							 | 
						||
| 
								 | 
							
								        else if (typeof this.props.data.closeTab == 'function') {
							 | 
						||
| 
								 | 
							
								            this.props.data.closeTab(this.props.data.id)
							 | 
						||
| 
								 | 
							
								        }  else if (typeof this.props.onCancel === "function"){
							 | 
						||
| 
								 | 
							
								            this.props.onCancel();
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								    loadData = () => {
							 | 
						||
| 
								 | 
							
								        let json = initFilter(this.props.login.OrgId);
							 | 
						||
| 
								 | 
							
								        extendRule(json, 'ID', 1, this.props.record.ID);
							 | 
						||
| 
								 | 
							
								        extendInclude(json, 'Nav_User');
							 | 
						||
| 
								 | 
							
								        extendInclude(json, 'Nav_SafePdtSignedPost');
							 | 
						||
| 
								 | 
							
								        extendInclude(json, 'Nav_SafePdtSignedPost.Nav_Post');
							 | 
						||
| 
								 | 
							
								        extendInclude(json, 'Nav_SafePdtSignedPost.Nav_Files');
							 | 
						||
| 
								 | 
							
								        extendInclude(json, 'Nav_SafePdtSignedPost.Nav_Files.Nav_File');
							 | 
						||
| 
								 | 
							
								        json.IgnoreDataRule = true;
							 | 
						||
| 
								 | 
							
								        this.props.dispatch({
							 | 
						||
| 
								 | 
							
								            type: 'app/getDataByPost',
							 | 
						||
| 
								 | 
							
								            payload: json,
							 | 
						||
| 
								 | 
							
								            url: 'OG/SafePdtSigned/Get',
							 | 
						||
| 
								 | 
							
								            onComplete: (ret) => {
							 | 
						||
| 
								 | 
							
								                if (ret) {
							 | 
						||
| 
								 | 
							
								                    this.setState({ data: ret })
							 | 
						||
| 
								 | 
							
								                }
							 | 
						||
| 
								 | 
							
								            }
							 | 
						||
| 
								 | 
							
								        });
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								    onTableBtnExport() {
							 | 
						||
| 
								 | 
							
								        let TableWrap = document.getElementById('tableId' + this.props.record.ID);
							 | 
						||
| 
								 | 
							
								        let Table = TableWrap.getElementsByTagName('table')[0];
							 | 
						||
| 
								 | 
							
								        const wb = XLSX.utils.table_to_book(Table);
							 | 
						||
| 
								 | 
							
								        XLSX.writeFile(wb, "安全生产责任制签订.xlsx")
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								    render() {
							 | 
						||
| 
								 | 
							
								        const { data } = this.state;
							 | 
						||
| 
								 | 
							
								        return <div>
							 | 
						||
| 
								 | 
							
								            <div style={{ padding: '10px' }}>
							 | 
						||
| 
								 | 
							
								                <ReactToPrint
							 | 
						||
| 
								 | 
							
								                    trigger={() => <Button type={'primary'} icon={'printer'} >打印</Button>}
							 | 
						||
| 
								 | 
							
								                    content={() => this.componentRef}
							 | 
						||
| 
								 | 
							
								                />
							 | 
						||
| 
								 | 
							
								                <Button style={{ marginLeft: '8px' }} onClick={() => this.onTableBtnExport()} icon="export" >导出</Button>
							 | 
						||
| 
								 | 
							
								            </div>
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								           {/* 安全生产责任制签订 */}
							 | 
						||
| 
								 | 
							
								           <div ref={el => (this.componentRef = el)} style={{ padding: '20px' }} id={'tableId' + this.props.record.ID}>
							 | 
						||
| 
								 | 
							
								                <h1 style={{ textAlign: 'center', margin: '15px' }}>安全生产责任制签订</h1>
							 | 
						||
| 
								 | 
							
								                {
							 | 
						||
| 
								 | 
							
								                    data ? <table style={{ width: '100%', textAlign: 'center', borderTop: '1px solid #333', borderLeft: '1px solid #333' }} className={styles.PrintForm}>
							 | 
						||
| 
								 | 
							
								                        <tr>
							 | 
						||
| 
								 | 
							
								                            <td colSpan={3} rowSpan={1} className={styles.fontBold}>签订人员</td>
							 | 
						||
| 
								 | 
							
								                            <td colSpan={21} rowSpan={1} >{data.Nav_User ? data.Nav_User.NAME : ''}</td>
							 | 
						||
| 
								 | 
							
								                        </tr>
							 | 
						||
| 
								 | 
							
								                        <tr>
							 | 
						||
| 
								 | 
							
								                            <td colSpan={4} rowSpan={1} className={styles.fontBold}>序号</td>
							 | 
						||
| 
								 | 
							
								                            <td colSpan={10} rowSpan={1} className={styles.fontBold}>岗位</td>
							 | 
						||
| 
								 | 
							
								                            <td colSpan={10} rowSpan={1} className={styles.fontBold}>附件</td>
							 | 
						||
| 
								 | 
							
								                        </tr>
							 | 
						||
| 
								 | 
							
								                        {
							 | 
						||
| 
								 | 
							
								                            data.Nav_SafePdtSignedPost ?  data.Nav_SafePdtSignedPost.map((items, index) => {
							 | 
						||
| 
								 | 
							
								                                return <tr >
							 | 
						||
| 
								 | 
							
								                                    <td colSpan={4} rowSpan={1}>{index + 1}</td>
							 | 
						||
| 
								 | 
							
								                                    <td colSpan={10} rowSpan={1}>{items.Nav_Post.NAME}</td>
							 | 
						||
| 
								 | 
							
								                                    <td colSpan={10} rowSpan={1}>{
							 | 
						||
| 
								 | 
							
								                                        items.Nav_Files && items.Nav_Files.map((item, i) => {
							 | 
						||
| 
								 | 
							
								                                            return <a width={'20%'} title={item.Nav_File.FILE_NAME} target='_blank' href={config.serviceHost + 'PF/File/GetFile?id=' + item.FILE_ID} >{item.Nav_File.FILE_NAME} </a>
							 | 
						||
| 
								 | 
							
								                                        })
							 | 
						||
| 
								 | 
							
								                                    }
							 | 
						||
| 
								 | 
							
								                                    </td>
							 | 
						||
| 
								 | 
							
								                                </tr>
							 | 
						||
| 
								 | 
							
								                            }) : null
							 | 
						||
| 
								 | 
							
								                        }
							 | 
						||
| 
								 | 
							
								                    </table> : null
							 | 
						||
| 
								 | 
							
								                }
							 | 
						||
| 
								 | 
							
								            </div>
							 | 
						||
| 
								 | 
							
								        </div>
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								export default connect(({ login, app }) => ({ login, app }))(OG004View) 
							 |