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

188 lines
8.6 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 { Button, Descriptions, Badge, Popconfirm, Row, Col, Form, Input, Select, Table } from 'antd';
import React from 'react';
import { initFilter, extendRule, extendInclude, setDataFieldValue, showApprove, guid, initQueryFilter, ShowDateTime, showUsersSign, showFiles } from '../../../utils/common';
import ReactToPrint from 'react-to-print';
import { ExportToExcel } from '@woowalker/feui'
import XLSX from 'xlsx';
import { connect } from 'dva';
import moment from 'moment';
import { message } from 'antd/lib/index';
import styles from '../../../components/CustomPages/HI/StepForm.css';
import config from '../../../config.js';
import FormPage from '../../FormPage'
class TL037ShowPrint extends React.Component {
constructor(props) {
super(props);
this.state = {
data: null,
btndisplay: 'none',
isCheck: 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');
let Table = TableWrap.getElementsByTagName('table1')[0];
const wb = XLSX.utils.table_to_book(Table);
XLSX.writeFile(wb, this.props.record.Nav_Department.NAME + '.xlsx')
}
sureCheck = () => {
let json = initFilter(this.props.login.OrgId, this.props.data.id, null, null, null, this.props.data.TaskID);
extendRule(json, 'ID', 1, this.props.data.id);
extendRule(json, "Parameter1", 1, this.props.data.TaskID)
this.props.dispatch({
type: 'app/getDataByPost',
payload: json,
url: 'TL/TLWatchDayly/sendCheck',
onComplete: (ret) => {
this.BtnClose()
}
});
}
BtnClose = () => {
if (typeof this.props.data.onCancel != "undefined" && typeof this.props.data.onCancel == 'function')
this.props.data.onCancel();
}
loadData = (id) => {
var isCheck = (this.props.data.tableKey != undefined && this.props.data.tableKey == '1') ? true : false
var orgId = this.props.login ? this.props.login.OrgId : '';
let json = initFilter(orgId);
json.IgnoreDataRule = true;
extendRule(json, 'ID', 1, id);
// extendInclude(json, 'Nav_Tailing')
extendInclude(json, 'Nav_ListDetail.Nav_Item')
extendInclude(json, 'Nav_ListUser.Nav_User')
// extendInclude(json, 'Nav_ListDetail.Nav_ListUser.Nav_User')
this.props.dispatch({
type: 'app/getDataByPost',
payload: json,
url: 'TL/WatchDayly/Get',
onComplete: (ret) => {
if (ret) {
let users = []
let userID = []
if (ret.Nav_ListUser && ret.Nav_ListUser.length > 0) {
ret.Nav_ListUser.forEach(eu => {
if (eu.ISCHECK && eu.ISCHECK == true && userID.indexOf(eu.ID) == -1) {
userID.push(eu.ID)
users.push(eu)
}
})
}
ret.Nav_ListDetail = ret.Nav_ListDetail.filter(e => e.IS_DELETED == false)
this.setState({
data: ret,
isCheck: isCheck,
users: users
})
}
}
});
}
render() {
const { data } = this.state;
return <div>
<div style={{ padding: '10px' }}>
<table>
<tr>
<td><ReactToPrint trigger={() => <Button type={'default'} icon={'printer'} >打印</Button>} content={() => this.componentRef} /></td>
<td><ExportToExcel fileName='尾矿库日常观测记录表' tableId={'tableId' + this.props.data.id} /></td>
{
this.state.isCheck ? <td><Button type={'primary'} icon={'check'} onClick={() => this.sureCheck()} >确认</Button> </td> : null
}
</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.TAILING_NAME}</Descriptions.Item>
<Descriptions.Item label="观测时间">{data.DATETIME}</Descriptions.Item>
<Descriptions.Item label="观测人">{data.Nav_ListUser?.map((itemtype, j) => { return (j > 0 ? '' : '') + itemtype.Nav_User?.NAME })}</Descriptions.Item>
</Descriptions>
</div> : null
}
{
(data?.Nav_ListDetail && data?.Nav_ListDetail.length > 0) ?
<table className={styles.PrintFormLight}>
<tbody>
<tr>
<td colSpan={7} className={styles.showPrintHead2}>尾矿库日常观测记录明细</td>
</tr>
{/* <tr className={styles.PrintFormLightTh}>
<td>观测时间</td>
<td>干滩长度/m</td>
<td>库水位/m</td>
<td>降雨量/mm</td>
<td>滩顶高程/m</td>
<td>安全超高/m</td>
<td>观测人</td>
</tr>
{data?.Nav_ListDetail?.map((item, i) => {
return <tr>
<td>{item.DATE?.split(' ')[1]} </td>
<td>{item.LONG} </td>
<td>{item.WATERLINE} </td>
<td>{item.DREEP} </td>
<td>{item.HIGHTEST} </td>
<td>{item.HIGHT_MORE} </td>
<td>{item.Nav_ListUser?.map((itemtype, j) => { return (j > 0 ? '' : '') + itemtype.Nav_User.NAME })}</td>
</tr>
})} */}
<tr className={styles.PrintFormLightTh}>
<td>观测项</td>
<td>观测值</td>
<td>单位</td>
{/* <td>降雨量/mm</td>
<td>滩顶高程/m</td>
<td>安全超高/m</td>
<td>观测人</td> */}
</tr>
{data?.Nav_ListDetail?.map((item, i) => {
return <tr>
<td>{item.Nav_Item?.NAME} </td>
<td>{item.ITEM_VALUE} </td>
<td>{item.Nav_Item?.UNITE} </td>
{/* <td>{item.DREEP} </td>
<td>{item.HIGHTEST} </td>
<td>{item.HIGHT_MORE} </td>
<td>{item.Nav_ListUser?.map((itemtype, j) => { return (j > 0 ? '' : '') + itemtype.Nav_User.NAME })}</td> */}
</tr>
})}
<tr >
<td>签名</td>
<td colSpan={6}>{
showUsersSign(this.state.users, config.picServerHost)
}</td>
</tr>
</tbody>
</table>
: null
}
</div>
</div>
}
}
export default connect(({ login }) => ({ login }))(TL037ShowPrint)