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

171 lines
7.2 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, Badge, Popconfirm, Row, Col, Form, Input, Select, Table } from 'antd';
import React from 'react';
import { initFilter, ShowDateTime, extendIgnoreDataRule, extendRule, extendInclude, setDataFieldValue, guid, initQueryFilter, showFiles, showApprove, extendFilterGroup, initFilterGroup } 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'
let ids = [];
class TI008ShowPrints extends React.Component {
constructor(props) {
super(props);
this.state = {
data: null,
item: null,
total: 0,
btndisplay: 'none'
}
}
componentDidMount() {
// if (this.props.data?.id)
// this.loadData(this.props.data?.id);
}
componentWillReceiveProps(NextProps) {
let nextIds = NextProps.data?.getTableSelectedRowKeys();
if (nextIds != ids) {
ids = nextIds;
this.loadData(nextIds);
}
}
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);
let group = initFilterGroup(false);
for (let i = 0; i < id.length; i++) {
let rule = {
Field: "ID",
Operate: 1,
Value: id[i]
}
group.Rules.push(rule);
}
extendFilterGroup(json, group);
// extendInclude(json, 'Nav_Department');
// extendInclude(json, 'Nav_User');
extendInclude(json, 'Nav_SafePdtCostRecordType.Nav_CostType');
extendIgnoreDataRule(json)
this.props.dispatch({
type: 'app/getDataByPost',
payload: json,
url: 'TI/TISafePdtCostRecord/OrderPaged',// url: 'SC/MtMeeting/Get',
onComplete: (ret) => { //返回查询结果ret
var total = 0
if (ret.length > 0) {
for (let i = 0; i < ret.length; i++) {
total += ret[i].USE_AMOUNT
}
}
total = parseFloat(total).toFixed(2)
this.setState({ //设置setState全局变量
data: ret, //将ret对象赋值给data, data供页面调用
total: total
})
}
});
}
//渲染页面
render() {
const { data, total } = 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>
{/*安全生产费用使用记录SSSSSSSS */}
{
data ?
<table className={styles.PrintFormLight}>
<tbody>
<tr className={styles.PrintFormLightTh}>
<td>序号</td>
<td>使用日期</td>
{/* <td>使用部门</td> */}
{/* <td>记录人</td> */}
<td>使用项目</td>
<td>费用类型</td>
<td>单位</td>
<td>数量</td>
<td>金额</td>
<td>物品名称</td>
<td>用途</td>
</tr>
{data?.map((item, i) => {
return <tr>
<td>{i + 1}</td>
<td>{ShowDateTime(item.USETIME)}</td>
{/* <td>{item.Nav_Department.NAME}</td> */}
{/* <td>{item.Nav_User.NAME}</td> */}
<td>{item.PROJECT}</td>
<td>{
item.Nav_SafePdtCostRecordType?.map((item, i) => {
return (i > 0 ? "" : "") + item.Nav_CostType.NAME
})
}</td>
<td>{item.UNIT}</td>
<td>{item.COUNT}</td>
<td>{item.USE_AMOUNT}</td>
<td>{item.PROCTNAME}</td>
<td>{item.PURPOSE}</td>
</tr>
})}
<tr className={styles.PrintFormLightTh}>
<td>总金额</td>
<td colSpan={7}>{total}</td>
</tr>
</tbody>
</table>
: null
}
</div>
</div>
}
}
export default connect(({ login, app }) => ({ login, app }))(TI008ShowPrints)