130 lines
4.9 KiB
JavaScript
130 lines
4.9 KiB
JavaScript
import { message } from "antd/lib/index";
|
|
import { Button, Descriptions, Row, Col, Form, Input, Select, Modal } from 'antd';
|
|
import React from 'react';
|
|
import { initFilter, extendRule, extendInclude, setDataFieldValue, guid, showFiles, GetFileModel } from "../../../utils/common";
|
|
import ReactToPrint from "react-to-print";
|
|
import styles from '../HI/StepForm.css';
|
|
import config from "../../../config";
|
|
import XLSX from 'xlsx';
|
|
import { connect } from 'dva';
|
|
import FormPage from '../../../components/FormPage'
|
|
|
|
class PF132ShowPrint extends React.Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = {
|
|
data: null,
|
|
enumData: null,
|
|
BtnAgreeDisplay: 'none',
|
|
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() {
|
|
this.props.dispatch({
|
|
type: 'app/getDataByPost',
|
|
url: 'FO/FOJobEventRecord/PersonalAgree',
|
|
payload: {
|
|
ID: this.props.data.id,
|
|
TaskID: this.props.data.TaskID,
|
|
},
|
|
onComplete: (ret) => {
|
|
if (ret) {
|
|
message.success('签字成功!');
|
|
this.setState({ BtnAgreeDisplay: 'none' })
|
|
this.BtnClose();
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
BtnClose = () => {
|
|
if (typeof this.props.data.onCancel != "undefined" && typeof this.props.data.onCancel == 'function')
|
|
this.props.data.onCancel();
|
|
}
|
|
|
|
loadData = (dataId) => {
|
|
let json = initFilter(this.props.login.OrgId);
|
|
extendRule(json, 'ID', 1, dataId);
|
|
extendInclude(json, 'Nav_Files');
|
|
extendInclude(json, 'Nav_Files.Nav_ImgFile');
|
|
extendInclude(json, 'Nav_Files.Nav_ImgFile');
|
|
this.props.dispatch({
|
|
type: 'app/getDataByPost',
|
|
payload: json,
|
|
url: 'PF/QuestionFeedback/Get',
|
|
onComplete: (ret) => {
|
|
if (ret) {
|
|
this.setState({ data: ret })
|
|
if (this.props.data.tableKey == "2" || this.props.data.tableKey == undefined) {
|
|
this.setState({ BtnAgreeDisplay: 'none' })
|
|
} else {
|
|
this.setState({ BtnAgreeDisplay: 'inline' })
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
onTableBtnExport() {
|
|
let TableWrap = document.getElementById('tableId' + this.props.data.id);
|
|
let Table = TableWrap.getElementsByTagName('table')[0];
|
|
const wb = XLSX.utils.table_to_book(Table);
|
|
XLSX.writeFile(wb, "问题反馈表.xlsx")
|
|
}
|
|
|
|
render() {
|
|
const { data } = this.state;
|
|
return <div>
|
|
<div style={{ padding: '10px' }}>
|
|
<ReactToPrint
|
|
trigger={() => <Button type={'primary'} icon={'printer'} >打印</Button>}
|
|
content={() => this.componentRef}
|
|
/>
|
|
<Button style={{ marginLeft: '8px' }} onClick={() => this.onTableBtnExport()} icon="export" >导出</Button>
|
|
<Button type="primary" style={{ marginLeft: '8px', display: this.state.BtnAgreeDisplay }} onClick={() => this.onTableBtnAgree()} icon="check" >签字</Button>
|
|
</div>
|
|
|
|
|
|
{/* 问题反馈表 */}
|
|
<div ref={el => (this.componentRef = el)} style={{ padding: '20px' }} id={'tableId' + this.props.data.id}>
|
|
|
|
<h1 style={{ textAlign: 'center', margin: '15px' }}>问题反馈表</h1>
|
|
{
|
|
data ? <div style={{ width: '95%' }}>
|
|
<Descriptions title="" size="middle" bordered>
|
|
<Descriptions.Item label="用户姓名">{data.USER_NAME}</Descriptions.Item>
|
|
<Descriptions.Item label="反馈时间">{data.FEEDBACK_TIME}</Descriptions.Item>
|
|
<Descriptions.Item label="部门名称">{data.DEAPARTMENT_NAME}</Descriptions.Item>
|
|
<Descriptions.Item label="问题描述" span={3}>{data.QUESTION_DESCRIPTION}</Descriptions.Item>
|
|
<Descriptions.Item label="附件">{
|
|
showFiles(data?.Nav_Files, config.picServerHost, this)
|
|
}</Descriptions.Item>
|
|
</Descriptions>
|
|
</div> : null
|
|
}
|
|
</div>
|
|
<FormPage {...this.state.tmpData} />
|
|
{
|
|
GetFileModel(Modal, FormPage, this, this.state.fileForm.visible)
|
|
}
|
|
</div>
|
|
}
|
|
|
|
}
|
|
export default connect(({ login, app }) => ({ login, app }))(PF132ShowPrint)
|