import { message } from "antd/lib/index"; import {Button, Popconfirm, Row, Col,Checkbox,Radio, Form, Input, Select, Table,Upload, Icon, PageHeader,Modal,Spin } 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 Option = Select.Option; const answer = { color: 'blue', textDecoration: 'underline', } class SE005ReportEdit extends React.Component { constructor(props) { super(props); let ALL = props.formCode === 'SE005_ALLREPORT'; this.state = { ALL, list: null, taskid: null, surveyid: !ALL && this.props.data.id, data: null, type: '部门', loading: false, }; }; componentDidMount() { if (this.state.ALL){ this.loadList(); }else{ this.loadData(); } } BtnClose = () => { if (typeof this.props.data.onCancel != "undefined" && typeof this.props.data.onCancel == 'function') this.props.data.onCancel(); } loadList = () => { let json = initFilter(this.props.login.OrgId); json.OrgType = 2; this.setState({loading: true}) this.props.dispatch({ type: 'app/getDataByPost', payload: json, url: 'SE/SESafeSurvey/GetReportList', onComplete: (ret) => { this.setState({loading: false}) if (!ret) return; if (ret.length == 0){ message.warn("当年未查到有效的公司调查问卷报表"); return; } let taskid = this.props.data.id; if (!ret.find(it => it.Key === taskid)){ taskid = ret[0].Key; } this.setState({ list: ret, taskid, }) this.loadData(); } }); } loadData = () => { let json = initFilter(this.props.login.OrgId); json.OrgType = 2; json.Parameter3 = this.state.type; if (this.state.ALL){ if (!this.state.taskid) return; json.Parameter2 = this.state.taskid; }else{ if (!this.state.surveyid) return; json.Parameter1 = this.state.surveyid; } this.setState( { data: null, loading: true }); this.props.dispatch({ type: 'app/getDataByPost', payload: json, url: 'SE/SESafeSurvey/GetReport', onComplete: (ret) => { this.setState({loading: false}) if (!ret){ return; } this.setState({data: ret}) } }); } onApprove = ()=>{ const { ALL,data } = this.state; let json = { Parameter1: data.SURVEY[0].ID, Parameter2: this.props.data.TaskID, } this.props.dispatch({ type: 'app/getDataByPost', payload: json, url: 'SE/SESafeSurvey/Approve', onComplete: (ret) => { message.success("审阅完成"); this.BtnClose(); } }); } fmtEnum(name,value){ const enums = this.props.app.enums; if (!enums || !enums[name]) return ''; return enums[name].enums[value] || ''; } 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 = '安全意识调查问卷'; name += '.xlsx'; XLSX.writeFile(wb, name) } getJoinDepartment(depart){ let arr = []; for(let it of depart){ if (it.Nav_Department){ if (it.Nav_Department.NAME == "宁化行洛坑钨矿有限公司"){ arr.push("公司领导") }else{ arr.push(it.Nav_Department.NAME) } } } return arr; } render() { const { ALL,data,list,loading } = this.state; const count = data && data.ROWS && data.ROWS.length > 0 && data.ROWS[0].length || 1; const SPAN = Math.floor(24 / count) || 1; const TITLE_SPAN = Math.max(24 - count * SPAN,0) + SPAN; const canApprove = this.props.data.tableKey == "1" return
} content={() => this.componentRef} /> { ALL && } { canApprove && }
(this.componentRef = el)} id={'tableId' + this.props.data.id} style={{ padding: '20px' }}>

{this.state.ALL ? '安全意识调查问卷公司报表' : '安全意识调查问卷部门报表'}

{ data && <> { data.SURVEY && data.SURVEY.map(SURVEY =>{ return <> }) } { data.ROWS && data.ROWS.map((row,ridx) =>{ return { row.map((col,cidx) =>{ return }) } }) }
调查名称 {SURVEY.NAME }
发起时间 {SURVEY.LAUNCH_TIME} 发起部门 {SURVEY.Nav_LaunchDepartment && SURVEY.Nav_LaunchDepartment.NAME} 发起人员 {SURVEY.Nav_LaunchUser && SURVEY.Nav_LaunchUser.NAME} 截止时间 {SURVEY.END_TIME}
参与人员 {this.getJoinDepartment(SURVEY.Nav_JoinDepartment).join('、')}
调查内容 { SURVEY.Nav_Points && SURVEY.Nav_Points.map(it => it.Nav_Point.NAME).join('、')}
答案正确率(百分比)
{col}{ridx == 0 || cidx == 0 ? null : "%"}
} { !data && !loading &&
暂未查到有效数据
}
} } export default connect(({ login, app }) => ({ login, app }))(SE005ReportEdit)