mh_jy_safe_web/src/components/CustomPages/TI/TI010ShowPrint.js

179 lines
8.1 KiB
JavaScript
Raw Normal View History

2025-08-25 10:08:30 +08:00
import { Checkbox, message, Radio } from "antd/lib/index";
import { Button, Descriptions, Modal, Popconfirm, Row, Col, Form, Input, Select, Table } from 'antd';
import React from 'react';
import { initFilter, extendRule, extendInclude, extendIgnoreDataRule, GetFileModel, guid, initQueryFilter, showFiles, showApprove } from "../../../utils/common";
import { ExportToExcel } from '@woowalker/feui'
import styles from '../HI/StepForm.css';
import ReactToPrint from "react-to-print";
import moment from 'moment';
import config from "../../../config.js";
import XLSX from 'xlsx';
import { connect } from 'dva';
import FormPage from '../../FormPage'
class TI010ShowPrint extends React.Component {
constructor(props) {
super(props);
this.state = {
data: null,
item: null,
btndisplay: 'none',
fileData: [],
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' + this.props.record.ID);
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,
});
}
//审批意见 改变
NOTJOINREASONCHANGE = (val) => {
this.state.NOTJOINREASON = val
}
//加载数据(传过来的参数都在props里面包括登录信息)
loadData = (id) => {
var taskID = this.props.data.TaskID
// var loginID = this.props.login.user.ID
var orgId = this.props.login ? this.props.login.OrgId : ''; //登录后有存储登录信息
let json = initFilter(orgId);
extendRule(json, 'ID', 1, id); //ID=‘’,字段,等于,条件值, 1代表=2代表不等于3小于4小于等于5大于6大于等于7以开始的Like,8以结束的Like9包含
extendInclude(json, 'Nav_Department');
extendInclude(json, 'Nav_User');
extendInclude(json, 'Nav_Sources.Nav_Source');
extendInclude(json, 'Nav_Ranges.Nav_Range');
extendInclude(json, 'Nav_Files.Nav_ImgFile');
extendInclude(json, 'Nav_ListProject.Nav_Manger');
// extendInclude(json, 'Nav_Approve.Nav_ApproveDetails.Nav_ApproveUser');
extendIgnoreDataRule(json)
this.props.dispatch({
type: 'app/getDataByPost',
payload: json,
url: 'TI/Plan/Get',// url: 'SC/MtMeeting/Get',
onComplete: (ret) => { //返回查询结果ret
this.setState({ //设置setState全局变量
data: ret, //将ret对象赋值给data, data供页面调用
})
}
});
}
//渲染页面
render() {
const { data, isTaskCheck, isHasOpinion } = this.state;
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} pageStyle={"#tableId" + this.props.data.id + " { padding:0 40px;} img{width :120px}"} /></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.BEGINTIME}</Descriptions.Item>
<Descriptions.Item label="发起部门">{data.Nav_Department.NAME}</Descriptions.Item>
<Descriptions.Item label="发起人">{data.Nav_User.NAME}</Descriptions.Item>
<Descriptions.Item label="计划年度" >{data.YEAR}</Descriptions.Item>
<Descriptions.Item label="项目来源">{
data.Nav_Sources?.map((item, i) => {
return (i > 0 ? "" : "") + item.Nav_Source.NAME
})
}</Descriptions.Item>
<Descriptions.Item label="项目范围">{
data.Nav_Ranges?.map((item, i) => {
return (i > 0 ? "" : "") + item.Nav_Range.NAME
})
}</Descriptions.Item>
<Descriptions.Item label="附件" span={3}>{
showFiles(data.Nav_Files, config.picServerHost, this)
}</Descriptions.Item>
{/* {
data.STATUS > 20 ?
<Descriptions.Item label="审阅意见" span={3}>{
showApprove(data.Nav_Approve?.Nav_ApproveDetails, this.props.app.enums.NodeApproveStatus.enums, config.picServerHost,100,50)
}</Descriptions.Item>
: null
} */}
</Descriptions>
</div> : null
}
{
(data?.Nav_ListProject && data?.Nav_ListProject.length > 0) ?
<table className={styles.PrintFormLight}>
<tbody>
<tr>
<td colSpan={5} className={styles.showPrintHead2}>安全科技计划明细</td>
</tr>
<tr className={styles.PrintFormLightTh}>
<td>项目编号</td>
<td>项目名称</td>
<td>申报经费</td>
<td>是否涉外</td>
<td>项目负责人</td>
</tr>
{data?.Nav_ListProject?.map((item, i) => {
return <tr>
<td>{item.CODE} </td>
<td>{item.NAME} </td>
<td>{item.MONEY} </td>
<td>{item?.IS_FOREIGN == true ? "是" : "否"} </td>
<td>{item.Nav_Manger.NAME} </td>
</tr>
})}
</tbody>
</table>
: null
}
</div >
{
GetFileModel(Modal, FormPage, this, this.state.fileForm.visible)
}
</div >
}
}
export default connect(({ login, app }) => ({ login, app }))(TI010ShowPrint)