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

171 lines
7.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, getMineTypeShow } from '../../../utils/common';
import ReactToPrint from 'react-to-print';
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 WB029ShowPrint extends React.Component {
constructor(props) {
super(props);
this.state = {
data: null,
btndisplay: 'none',
isCheck: false, //是否待办 审批
isSign: true
}
}
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);
}
}
returnModel(level) {
let str = '';
// if (level == undefined) {
// return str;
// }
// if (level.indexOf('0') >= 0) {
// str += '全公司 ';
// }
// if (level.indexOf('10') >= 0) {
// str += '选矿厂 ';
// }
// if (level.indexOf('20') >= 0) {
// str += '尾矿库 ';
// }
// if (level.indexOf('30') >= 0) {
// str += '露天矿 ';
// }
// if (level.indexOf('31') >= 0) {
// str += '职能口 ';
// }
// if (level.indexOf('40') >= 0) {
// str += '地下矿 ';
// }
return str;
}
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_CheckType')
extendInclude(json, 'Nav_ListArea.Nav_CheckArea')
extendInclude(json, 'Nav_Details.Nav_User')
extendInclude(json, 'Nav_Details.Nav_Users.Nav_User')
json.IgnoreDataRule = true;
this.props.dispatch({
type: 'app/getDataByPost',
payload: json,
url: 'WB/SafeCheckTask/Get',
onComplete: (ret) => {
if (ret) {
//Nav_Details 按 ROW_NUM 排序下
this.setState({
data: ret,
})
}
}
});
}
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/WBSafeCheckTask/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();
}
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.CHECK_TIME}</Descriptions.Item>
<Descriptions.Item label="检查类型">{data.Nav_CheckType?.NAME}</Descriptions.Item>
{/* <Descriptions.Item label="生产单元">{this.returnModel(data.MineType)}</Descriptions.Item> */}
<Descriptions.Item label="生产单元">{getMineTypeShow(enums.BSMineTypeEnum.enums, null, data.MineType)}</Descriptions.Item>
{/* <Descriptions.Item label="检查区域">{data.Nav_CheckArea.AREA}</Descriptions.Item> */}
<Descriptions.Item label="检查区域">{data.Nav_ListArea.map((item, i) => { return (i > 0 ? '' : '') + item.Nav_CheckArea?.AREA })}</Descriptions.Item>
</Descriptions>
</div> : null
}
{
(data?.Nav_Details && data?.Nav_Details.length > 0) ?
<table className={styles.PrintFormLight}>
<tbody>
{/* <tr>
<td colSpan={6} className={styles.showPrintHead2}>导航:任务明细</td>
</tr> */}
<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>{item.Nav_Users?.map((itemtype, j) => { return (j > 0 ? '' : '') + itemtype.Nav_User.NAME })}</td>
<td>{item.Nav_User.NAME}</td>
{/* <td>{this.returnModel(item.MineType)} </td> */}
<td>{enums.BSMineTypeEnum.enums[item.MineType]} </td>
<td>{item.Nav_Area?.AREA} </td>
<td>{item.CHECK_CONTENT} </td>
<td>{item.CHECK_BASIS} </td>
</tr>
})}
</tbody>
</table>
: null
}
</div>
</div>
}
}
export default connect(({ login, app }) => ({ login, app }))(WB029ShowPrint)