mh_jy_safe_web/src/components/CustomPages/TI/TI016ShowPrint.js
2025-08-25 10:08:30 +08:00

172 lines
7.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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, setDataFieldValue, guid, initQueryFilter, showFiles, GetFileModel } 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 TI016ShowPrint extends React.Component {
constructor(props) {
super(props);
this.state = {
data: null,
item: null,
btndisplay: 'none',
ALLTOTAL: 0,
ALLUSE: 0,
ALLLEFT: 0,
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_Project.Nav_Manger');
extendInclude(json, 'Nav_Details.Nav_Files.Nav_ImgFile');
extendIgnoreDataRule(json)
this.props.dispatch({
type: 'app/getDataByPost',
payload: json,
url: 'TI/ProjectMoney/Get',
onComplete: (ret) => { //返回查询结果ret
var allTOTAL = 0
var allUSE = 0
var allLEFT = 0
if (ret.Nav_Details != null && ret.Nav_Details.length > 0) {
for (let i = 0; i < ret.Nav_Details.length; i++) {
allTOTAL += ret.Nav_Details[i].TOTAL
allUSE += ret.Nav_Details[i].USE
allLEFT += ret.Nav_Details[i].LEFT
}
}
this.setState({ //设置setState全局变量
data: ret, //将ret对象赋值给data, data供页面调用
ALLTOTAL: allTOTAL,
ALLUSE: allUSE,
ALLLEFT: allLEFT
})
}
});
}
//渲染页面
render() {
const { data, ALLTOTAL, ALLUSE, ALLLEFT } = this.state;
const enums = this.props.data.enums ? this.props.data.enums : this.props.app.enums;
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.Nav_Project.NAME}</Descriptions.Item>
<Descriptions.Item label="项目编号">{data.Nav_Project.CODE}</Descriptions.Item>
<Descriptions.Item label="项目负责人" >{data.Nav_Project.Nav_Manger.NAME}</Descriptions.Item>
<Descriptions.Item label="专项经费合计">{ALLTOTAL}</Descriptions.Item>
<Descriptions.Item label="支出经费合计">{ALLUSE}</Descriptions.Item>
<Descriptions.Item label="剩余经费">{ALLLEFT}</Descriptions.Item>
</Descriptions>
</div> : null
}
{
data?.Nav_Details ?
<table className={styles.PrintFormLight}>
<tbody>
<tr className={styles.PrintFormLightTh}>
<td>序号</td>
<td>科目名称</td>
<td>专项经费</td>
<td>支出经费</td>
<td>剩余经费</td>
<td>凭单上传</td>
</tr>
{data.Nav_Details?.map((item, i) => {
return <tr>
<td>{i + 1}</td>
<td>{item.NAME}</td>
<td>{item.TOTAL}</td>
<td>{item.USE}</td>
<td>{item.LEFT}</td>
<td>{
showFiles(item.Nav_Files, config.picServerHost, this)
}</td>
</tr>
})}
</tbody>
</table>
: null
}
</div>
{
GetFileModel(Modal, FormPage, this, this.state.fileForm.visible)
}
</div>
}
}
export default connect(({ login, app }) => ({ login, app }))(TI016ShowPrint)