import { message } from "antd/lib/index"; import { Button, Popconfirm, Row, Col, Checkbox, Radio, Form, Input, Select, Table, Upload, Icon, PageHeader, Modal } from 'antd'; import React from 'react'; import { initFilter, extendRule, extendInclude, initFilterGroup, extendFilterGroup, extendGroupRule, 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'; class SE007AllView extends React.Component { constructor(props) { super(props); this.state = { ROWS: null, data: null, total: 0, reportCount: 0, }; }; componentDidMount() { this.loadData(); } BtnClose = () => { if (typeof this.props.data.onCancel != "undefined" && typeof this.props.data.onCancel == 'function') this.props.data.onCancel(); } loadData = () => { let json = initFilter(this.props.login.OrgId, '', null, null); json.PageIndex = 1; json.Limit = 100; json.Start = 0; json.Sort = 'CREATE_TIME'; json.Order = 1; let filter = initFilterGroup(true); let year = new Date().getFullYear(); extendGroupRule(filter, "CREATE_TIME", 6, `${year}-01-01`); extendGroupRule(filter, "CREATE_TIME", 3, `${year + 1}-01-01`); extendFilterGroup(json, filter); json.OrgType = 2; extendInclude(json, 'Nav_LaunchDepartment'); extendInclude(json, 'Nav_LaunchUser'); extendInclude(json, 'Nav_Points'); extendInclude(json, 'Nav_Points.Nav_Point'); extendInclude(json, 'Nav_JoinDepartment'); extendInclude(json, 'Nav_JoinDepartment.Nav_Department'); extendInclude(json, 'Nav_Demands'); extendInclude(json, 'Nav_Demands.Nav_User'); extendInclude(json, 'Nav_Demands.Nav_User.Nav_Department'); extendInclude(json, 'Nav_Demands.Nav_Department'); extendInclude(json, 'Nav_Demands.Nav_Items'); extendInclude(json, 'Nav_Demands.Nav_Items.Nav_DEMAND'); this.props.dispatch({ type: 'app/getDataByPost', payload: json, url: 'SE/TrainSurvey/OrderPaged', onComplete: (ret) => { if (!ret) return; this.updateData(ret); } }); } updateData(datas) { let r = {}; let ROWS = []; let total = 0; let reportCount = 0; datas.forEach(data => { data.Nav_Demands.forEach(it => { total++; if (it.OK) { reportCount++; } it.Nav_Items.forEach(d => { let idx = r[d.DEMAND_ID]; if (idx === undefined) { idx = ROWS.length r[d.DEMAND_ID] = idx; ROWS.push({ ID: d.DEMAND_ID, NAME: d.Nav_DEMAND.NAME, department: [], total: 0, report: 0, }) } let name = it.Nav_User.Nav_Department.NAME; if (name == '宁化行洛坑钨矿有限公司') { name = '公司领导'; } if (ROWS[idx].department.indexOf(name) == -1) { ROWS[idx].department.push(name); } ROWS[idx].total++; if (it.OK) { ROWS[idx].report++; } }) }); }) this.setState({ data: datas, ROWS, total, reportCount, }) } 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) } render() { const { data, reportCount, total } = this.state; const rate = total === 0 ? 0 : Math.round(reportCount * 100 / total); return
} content={() => this.componentRef} />
(this.componentRef = el)} style={{ padding: '20px' }} id={'tableId' + this.props.data.id}>

公司培训需求调查统计表

{ this.state.ROWS && this.state.ROWS.map((r, idx) => { return }) }
调查年度 {new Date().getFullYear()} 调查部门 {'全公司'} 调查份数 {total} 反馈份数 {reportCount} 反馈比例 {rate + '%'}
序号 培训需求 需求部门 需求人数
{idx + 1} {r.NAME} {r.department.join('、')} {r.report}
} } export default connect(({ login, app }) => ({ login, app }))(SE007AllView)