323 lines
		
	
	
		
			17 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			323 lines
		
	
	
		
			17 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
import { message } from "antd/lib/index";
 | 
						||
import { Button, Popconfirm, Row, Col, Form, Input, Select, Table, Modal} from 'antd';
 | 
						||
import React from 'react';
 | 
						||
import { initFilter, extendRule, extendInclude, showFiles, GetFileModel } from "../../../utils/common";
 | 
						||
import ReactToPrint from "react-to-print";
 | 
						||
import styles from '../HI/StepForm.css';
 | 
						||
import config from "../../../config";
 | 
						||
import XLSX from 'xlsx';
 | 
						||
import { connect } from 'dva';
 | 
						||
import FormPage from '../../../components/FormPage'
 | 
						||
 | 
						||
class FO003ShowPrintJD extends React.Component {
 | 
						||
    constructor(props) {
 | 
						||
        super(props);
 | 
						||
        this.state = {
 | 
						||
            data: null,
 | 
						||
            enumData: null,
 | 
						||
            BtnAgreeDisplay: 'none',
 | 
						||
            isFinished: 'none',
 | 
						||
            isMobile: false,
 | 
						||
            fileForm: {
 | 
						||
                title: "",
 | 
						||
                visible: false,
 | 
						||
            },
 | 
						||
        };
 | 
						||
    };
 | 
						||
 | 
						||
    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);
 | 
						||
        }
 | 
						||
    }
 | 
						||
 | 
						||
 | 
						||
    onTableBtnAgree() {
 | 
						||
        this.props.dispatch({
 | 
						||
            type: 'app/getDataByPost',
 | 
						||
            url: 'FO/FOPreShiftMeetingRecord/PersonalAgree',
 | 
						||
            payload: {
 | 
						||
                ID: this.props.data.id,
 | 
						||
                TaskID: this.props.data.TaskID,
 | 
						||
                IgnoreDataRule: true
 | 
						||
            },
 | 
						||
            onComplete: (ret) => {
 | 
						||
                if (ret) {
 | 
						||
                    message.success('签到成功!');
 | 
						||
                    this.setState({ BtnAgreeDisplay: 'none' })
 | 
						||
                    this.BtnClose();
 | 
						||
                }
 | 
						||
            }
 | 
						||
        })
 | 
						||
    }
 | 
						||
 | 
						||
    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_Team');
 | 
						||
        extendInclude(json, 'Nav_Class');
 | 
						||
        extendInclude(json, 'Nav_User');
 | 
						||
        extendInclude(json, 'Nav_Monitor');
 | 
						||
        extendInclude(json, 'Nav_Record');
 | 
						||
        extendInclude(json, 'Nav_Users.Nav_User');
 | 
						||
        extendInclude(json, 'Nav_Files.Nav_ImgFile.Nav_File');
 | 
						||
        extendInclude(json, 'Nav_Details.Nav_DetailPosts.Nav_Post');
 | 
						||
        this.props.dispatch({
 | 
						||
            type: 'app/getDataByPost',
 | 
						||
            payload: json,
 | 
						||
            url: 'FO/PreShiftMeetingRecord/Get',
 | 
						||
            onComplete: (ret) => {
 | 
						||
                if (ret) {
 | 
						||
                    this.setState({ data: ret })
 | 
						||
                    if (this.props.data.tableKey == "2" || this.props.data.tableKey == undefined) {
 | 
						||
                        this.setState({ BtnAgreeDisplay: 'none' })
 | 
						||
                    } else {
 | 
						||
                        this.setState({ BtnAgreeDisplay: 'inline' })
 | 
						||
                    }
 | 
						||
                    //归档才显示打印和导出按钮
 | 
						||
                    if (ret.PRE_MEETING_STATUS == 5) {
 | 
						||
                        this.setState({ isFinished: 'inline' })
 | 
						||
                    }
 | 
						||
                } else { message.error('数据加载获取失败,请联系管理员排查!'); }
 | 
						||
            }
 | 
						||
        });
 | 
						||
    }
 | 
						||
 | 
						||
    onTableBtnExport() {
 | 
						||
        let TableWrap = document.getElementById('tableId' + this.props.data.id);
 | 
						||
        let Table = TableWrap.getElementsByTagName('table')[0];
 | 
						||
        const wb = XLSX.utils.table_to_book(Table);
 | 
						||
        XLSX.writeFile(wb, this.state.data.Nav_Team.NAME + ".xlsx")
 | 
						||
    }
 | 
						||
 | 
						||
    render() {
 | 
						||
        const { data, isMobile } = this.state;
 | 
						||
        return <div>
 | 
						||
            <div style={{ marginTop: '10px' }}>
 | 
						||
                <ReactToPrint
 | 
						||
                    trigger={() => <Button type={'default'} icon={'printer'} style={{ marginLeft: '20px', display: this.state.isFinished }} >打印</Button>}
 | 
						||
                    content={() => this.componentRef}
 | 
						||
                    pageStyle=".printDIV { padding:0 40px;} img{width :120px}"
 | 
						||
                />
 | 
						||
                <Button style={{ marginLeft: '20px', display: this.state.isFinished }} onClick={() => this.onTableBtnExport()} icon="export" >导出</Button>
 | 
						||
                <Button style={{ marginLeft: isMobile ? '0' : '20px', display: this.state.BtnAgreeDisplay }} onClick={() => this.onTableBtnAgree()} icon="check" >签到</Button>
 | 
						||
            </div>
 | 
						||
 | 
						||
 | 
						||
            <FormPage {...this.state.tmpData} />
 | 
						||
            {/* 班前会议记录表 */}
 | 
						||
            <div ref={el => (this.componentRef = el)} id={'tableId' + this.props.data.id} style={{ padding: isMobile ? '0px 0px 20px 0px' : '20px' }} className="printDIV">
 | 
						||
 | 
						||
                <h1 style={{ textAlign: 'center' }}>班前会议记录表</h1>
 | 
						||
                {
 | 
						||
                    data ? <table style={{ width: '100%', textAlign: 'center', borderTop: '1px solid #333', borderLeft: '1px solid #333' }} className={styles.PrintForm}>
 | 
						||
                        <tbody>
 | 
						||
                            <tr>
 | 
						||
                                <td colSpan={1} rowSpan={1} className={styles.fontBold}>班组</td>
 | 
						||
                                <td colSpan={3} rowSpan={1}>{data.Nav_Team ? data.Nav_Team.NAME : ''}</td>
 | 
						||
                                <td colSpan={1} rowSpan={1} className={styles.fontBold}>班长</td>
 | 
						||
                                <td colSpan={2} rowSpan={1}>{data.Nav_Monitor ? data.Nav_Monitor.NAME : ''}</td>
 | 
						||
                                <td colSpan={2} rowSpan={1} className={styles.fontBold}>会议时间</td>
 | 
						||
                                <td colSpan={3} rowSpan={1}>{data.MEETING_TIME.substring(0, 10)}</td>
 | 
						||
                                <td colSpan={2} rowSpan={1} className={styles.fontBold}>班次</td>
 | 
						||
                                <td colSpan={3} rowSpan={1}>{data.Nav_Class ? data.Nav_Class.NAME : ''}</td>
 | 
						||
                                <td colSpan={2} rowSpan={1} className={styles.fontBold}>地点</td>
 | 
						||
                                <td colSpan={3} rowSpan={1}>{data.LOCATION}</td>
 | 
						||
                                <td colSpan={2} rowSpan={1} className={styles.fontBold}>主持人</td>
 | 
						||
                                <td colSpan={2} rowSpan={1}>{data.Nav_User ? data.Nav_User.NAME : ''}</td>
 | 
						||
                                <td colSpan={2} rowSpan={1} className={styles.fontBold}>记录人</td>
 | 
						||
                                <td colSpan={2} rowSpan={1}>{data.Nav_Record ? data.Nav_Record.NAME : ''}</td>
 | 
						||
                            </tr>
 | 
						||
                            <tr>
 | 
						||
                            <td colSpan={2} rowSpan={1} className={styles.fontBold}>参会人员</td>
 | 
						||
                                <td colSpan={28} rowSpan={1} >{
 | 
						||
                                    data.Nav_Users && data.Nav_Users.map((item, i) => {
 | 
						||
                                        if (i == (data.Nav_Users.length - 1)) {
 | 
						||
                                            if (item.DEAL_STATUS == 0)
 | 
						||
                                                return <label style={{ color: 'red' }} title='未签到'> {item.Nav_User.NAME}</label>
 | 
						||
                                            else
 | 
						||
                                                return item.Nav_User.NAME
 | 
						||
                                        } else {
 | 
						||
                                            if (item.DEAL_STATUS == 0)
 | 
						||
                                                return <label style={{ color: 'red' }} title='未签到'>{item.Nav_User.NAME + '  '}</label>
 | 
						||
                                            else
 | 
						||
                                                return item.Nav_User.NAME + '  '
 | 
						||
                                        }
 | 
						||
                                    })
 | 
						||
                                }</td>
 | 
						||
                            </tr>
 | 
						||
                            <tr>
 | 
						||
                            <td colSpan={2} rowSpan={1} className={styles.fontBold}>应出勤人数</td>
 | 
						||
                                <td colSpan={3} rowSpan={1}>{data.SHOULD_QTY}</td>
 | 
						||
                                <td colSpan={2} rowSpan={1} className={styles.fontBold}>实际出勤人数</td>
 | 
						||
                                <td colSpan={3} rowSpan={1}>{data.ACTUAL_QTY}</td>
 | 
						||
                                <td colSpan={2} rowSpan={1} className={styles.fontBold}>迟到人数</td>
 | 
						||
                                <td colSpan={3} rowSpan={1}>{data.LATE_QTY}</td>
 | 
						||
                                <td colSpan={2} rowSpan={1} className={styles.fontBold}>请假人数</td>
 | 
						||
                                <td colSpan={3} rowSpan={1}>{data.LEAVE_QTY}</td>
 | 
						||
                                <td colSpan={2} rowSpan={1} className={styles.fontBold}>异常原因</td>
 | 
						||
                                <td colSpan={8} rowSpan={1}>{data.ABNORMAL_CAUSE}</td>
 | 
						||
                            </tr>
 | 
						||
                            <tr>
 | 
						||
                                <td colSpan={2} rowSpan={1} className={styles.fontBold}>问候语</td>
 | 
						||
                                <td colSpan={28} rowSpan={1}>{data.GREETING}</td>
 | 
						||
                            </tr>
 | 
						||
                            <tr>
 | 
						||
                                <td colSpan={2} rowSpan={1} className={styles.fontBold}>班组口号</td>
 | 
						||
                                <td colSpan={28} rowSpan={1}>{data.SLOGAN}</td>
 | 
						||
                            </tr>
 | 
						||
                            <tr>
 | 
						||
                                <td colSpan={2} rowSpan={1} className={styles.fontBold}>欢迎新同事</td>
 | 
						||
                                <td colSpan={28} rowSpan={1}>{data.WELCOME}</td>
 | 
						||
                            </tr>
 | 
						||
                            <tr>
 | 
						||
                                <td colSpan={2} rowSpan={1} className={styles.fontBold}>附件</td>
 | 
						||
                                <td colSpan={28} rowSpan={1}>{
 | 
						||
                                    showFiles(data?.Nav_Files, config.picServerHost, this)
 | 
						||
                                }
 | 
						||
                                </td>
 | 
						||
                            </tr>
 | 
						||
                        </tbody>
 | 
						||
                    </table> : null
 | 
						||
                }
 | 
						||
                 {
 | 
						||
                    data ? <table style={{ width: '100%', textAlign: 'center', marginTop: '10px', borderTop: '1px solid #333', borderLeft: '1px solid #333' }} className={styles.PrintForm}>
 | 
						||
                        <tbody>
 | 
						||
                            <tr>
 | 
						||
                                <td width="100px" className={styles.fontBold}>序号</td>
 | 
						||
                                <td colSpan={7} className={styles.fontBold}>指标</td>
 | 
						||
                                <td width="100px" className={styles.fontBold}>目标</td>
 | 
						||
                                <td colSpan={2} className={styles.fontBold}>实际</td>
 | 
						||
                                <td colSpan={2} className={styles.fontBold}>达成率</td>
 | 
						||
                                <td colSpan={2} className={styles.fontBold}>原因</td>
 | 
						||
                                <td colSpan={2} className={styles.fontBold}>改善对策</td>
 | 
						||
                                <td colSpan={8} className={styles.fontBold}>涉及岗位</td>
 | 
						||
                            </tr>
 | 
						||
 | 
						||
 | 
						||
                            {
 | 
						||
                                data.Nav_Details && data.Nav_Details.map((item, i) => {
 | 
						||
                                    return <tr>
 | 
						||
                                        <td width="100px" >
 | 
						||
                                            {i + 1}
 | 
						||
                                        </td>
 | 
						||
                                        <td colSpan={7} >
 | 
						||
                                            {item.QUOTA}
 | 
						||
                                        </td>
 | 
						||
                                        <td width="100px" >
 | 
						||
                                            {item.PURPOSE}
 | 
						||
                                        </td>
 | 
						||
                                        <td colSpan={2} >
 | 
						||
                                            {item.ACTUAL}
 | 
						||
                                        </td>
 | 
						||
                                        <td colSpan={2} >
 | 
						||
                                            {
 | 
						||
                                                item.RATE
 | 
						||
                                            }
 | 
						||
                                        </td>
 | 
						||
                                        <td colSpan={2} >
 | 
						||
                                            {
 | 
						||
                                                item.REASON
 | 
						||
                                            }
 | 
						||
                                        </td>
 | 
						||
                                        <td colSpan={2} >
 | 
						||
                                            {
 | 
						||
                                                item.IMPROVE
 | 
						||
                                            }
 | 
						||
                                        </td>
 | 
						||
                                        <td colSpan={8} rowSpan={1}>{
 | 
						||
                                        item.Nav_DetailPosts && item.Nav_DetailPosts.map((item1, i) => {
 | 
						||
                                            return item1.Nav_Post?.NAME + '  '
 | 
						||
                                    })
 | 
						||
                                }
 | 
						||
                                </td>
 | 
						||
                                    </tr>
 | 
						||
                                })
 | 
						||
                            }
 | 
						||
 | 
						||
                        </tbody>
 | 
						||
                    </table> : null
 | 
						||
                }
 | 
						||
                {
 | 
						||
                    data ? <table style={{ width: '100%', textAlign: 'center', borderTop: '1px solid #333', borderLeft: '1px solid #333' }} className={styles.PrintForm}>
 | 
						||
                        <tbody>
 | 
						||
                           
 | 
						||
                            <tr>
 | 
						||
                                <td colSpan={2} rowSpan={1} className={styles.fontBold}>今日计划及关注点</td>
 | 
						||
                                <td colSpan={8} rowSpan={1}>{data.TODAY_PLAN}</td>
 | 
						||
                            </tr>
 | 
						||
                            <tr>
 | 
						||
                                <td colSpan={2} rowSpan={1} className={styles.fontBold}>公司信息传递及学习内容</td>
 | 
						||
                                <td colSpan={8} rowSpan={1}>{data.LEARNING}</td>
 | 
						||
                            </tr>
 | 
						||
                            <tr>
 | 
						||
                                <td colSpan={2} rowSpan={1} className={styles.fontBold}>其他事项</td>
 | 
						||
                                <td colSpan={8} rowSpan={1}>{data.OTHER_CONTENT}</td>
 | 
						||
                            </tr>
 | 
						||
                            <tr>
 | 
						||
                                <td colSpan={2} rowSpan={1} className={styles.fontBold}>一分钟表扬</td>
 | 
						||
                                <td colSpan={8} rowSpan={1}>{data.PRAISE}</td>
 | 
						||
                            </tr>
 | 
						||
                            <tr>
 | 
						||
                                <td colSpan={2} rowSpan={1} className={styles.fontBold}>优秀员工分享</td>
 | 
						||
                                <td colSpan={8} rowSpan={1}>{data.SHARE}</td>
 | 
						||
                            </tr>
 | 
						||
                            <tr>
 | 
						||
                                <td colSpan={2} rowSpan={1} className={styles.fontBold}>安全环保事项(危险识别)</td>
 | 
						||
                                <td colSpan={8} rowSpan={1}>{data.DANGER}</td>
 | 
						||
                            </tr>
 | 
						||
                            <tr>
 | 
						||
                                <td colSpan={2} rowSpan={1} className={styles.fontBold}>员工提出困难或建议</td>
 | 
						||
                                <td colSpan={8} rowSpan={1}>{data.DIFFICULTY}</td>
 | 
						||
                            </tr>
 | 
						||
                            <tr>
 | 
						||
                                <td colSpan={2} rowSpan={1} className={styles.fontBold}>安全宣誓</td>
 | 
						||
                                <td colSpan={8} rowSpan={1}>{data.SAFETY_OATH}</td>
 | 
						||
                            </tr>
 | 
						||
                            <tr>
 | 
						||
                                <td colSpan={2} rowSpan={1} className={styles.fontBold}>附件</td>
 | 
						||
                                <td colSpan={8} rowSpan={1}>{
 | 
						||
                                    showFiles(data?.Nav_Files, config.picServerHost, this)
 | 
						||
                                }
 | 
						||
                                </td>
 | 
						||
                            </tr>
 | 
						||
                            <tr>
 | 
						||
                                <td colSpan={2} rowSpan={1} className={styles.fontBold}>会议签到区</td>
 | 
						||
                                <td colSpan={8} rowSpan={1}>{
 | 
						||
                                    // showUsersSign(data?.Nav_Users, config.picServerHost, 150, 150)
 | 
						||
                                    data.Nav_Users && data.Nav_Users.map((item, i) => {
 | 
						||
                                        if (item.DEAL_STATUS == 1) {
 | 
						||
                                            if (item.Nav_User != null && item.Nav_User.FILE_PATH != null && item.Nav_User.FILE_PATH.length > 0)
 | 
						||
                                                return <img width={'150px'} alt={item.Nav_User.NAME} src={config.picServerHost + item.Nav_User.FILE_PATH} />
 | 
						||
                                            else
 | 
						||
                                                return <img width={'150px'} title={item.Nav_User.NAME} />
 | 
						||
                                        }
 | 
						||
                                    })
 | 
						||
                                }
 | 
						||
                                </td>
 | 
						||
                            </tr>
 | 
						||
                        </tbody>
 | 
						||
                    </table> : null
 | 
						||
                }
 | 
						||
            </div>
 | 
						||
            {
 | 
						||
                GetFileModel(Modal, FormPage, this, this.state.fileForm.visible)
 | 
						||
            }
 | 
						||
        </div>
 | 
						||
    }
 | 
						||
 | 
						||
}
 | 
						||
export default connect(({ login }) => ({ login }))(FO003ShowPrintJD) 
 |