mh_jy_safe_web/src/components/CustomPages/WB/WB027ShowPrint.js

122 lines
5.3 KiB
JavaScript
Raw Normal View History

2025-08-25 10:08:30 +08:00
import { Button, Descriptions, Modal, Badge, Popconfirm, Row, Col, Form, Input, Select, Table } from 'antd';
import React from 'react';
import { initFilter, extendRule, extendInclude, setDataFieldValue, showApprove, guid, initQueryFilter, ShowDateTime, GetFileModel, 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 WB027ShowPrint extends React.Component {
constructor(props) {
super(props);
this.state = {
data: null,
btndisplay: 'none',
isCheck: false, //是否待办 审批
isSign: true,
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);
}
}
onTableBtnAgree() {
let json = initFilter(this.props.login.OrgId);
json.Parameter1 = this.props.data.id;
json.Parameter2 = this.props.data.TaskID;
json.Parameter3 = this.props.login.userId;
this.props.dispatch({
type: 'app/getDataByPost',
url: 'WB/WBDangerousJob/recordSign',
payload: json,
onComplete: (ret) => {
if (ret) {
message.success('确认成功!');
this.state.isSign = false;
this.BtnClose();
}
}
})
}
BtnClose = () => {
if (typeof this.props.data.onCancel != "undefined" && typeof this.props.data.onCancel == 'function')
this.props.data.onCancel();
}
loadData = (id) => {
var orgId = this.props.login ? this.props.login.OrgId : '';
let json = initFilter(orgId);
extendRule(json, 'ID', 1, id);
extendInclude(json, 'Nav_Project')
extendInclude(json, 'Nav_Files.Nav_ImgFile')
extendInclude(json, 'Nav_Photos.Nav_ImgFile')
json.IgnoreDataRule = true;
this.props.dispatch({
type: 'app/getDataByPost',
payload: json,
url: 'WB/SafeCheck/Get',
onComplete: (ret) => {
if (ret) {
this.setState({
data: ret,
})
}
}
});
}
render() {
const { data } = this.state; const enums = this.props.data.enums ? this.props.data.enums : this.props.app.enums; const tableKey = this.props.data.tableKey
return <div>
<div style={{ padding: '10px' }}>
<table>
<tr>
<td><ReactToPrint trigger={() => <Button type={'default'} icon={'printer'} >打印</Button>} content={() => this.componentRef} /></td>
{this.state.isSign && (tableKey != null && (tableKey == "1" || tableKey == "4")) && (
<>
<td><Button type={"primary"} style={{ marginLeft: '8px' }} onClick={() => this.onTableBtnAgree()} icon="check" >审阅</Button></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 style={{ width: '95%' }}>
<Descriptions title='' size='middle' bordered>
<Descriptions.Item label="项目名称">{data.Nav_Project.NAME}</Descriptions.Item>
<Descriptions.Item label="外包单位名称">{data.Nav_Project.UNIT_NAME}</Descriptions.Item>
<Descriptions.Item label="检查类别">{enums.WBCHECKCATAGORY.enums[data.CHECK_CATEGORY]}</Descriptions.Item>
<Descriptions.Item label="检查时间">{data.CHECK_TIME}</Descriptions.Item>
<Descriptions.Item label="发现隐患条数">{data.HIDDEN_DANGER_COUNT}</Descriptions.Item>
<Descriptions.Item label="检查照片">{showFiles(data.Nav_Photos, config.picServerHost, this)}</Descriptions.Item>
<Descriptions.Item label="附件">{showFiles(data.Nav_Files, config.picServerHost, this)}</Descriptions.Item>
</Descriptions>
</div> : null
}
</div>
{
GetFileModel(Modal, FormPage, this, this.state.fileForm.visible)
}
</div>
}
}
export default connect(({ login, app }) => ({ login, app }))(WB027ShowPrint)