mh-sms-web/src/components/CustomPages/BI/CloseTasks.js
2024-01-22 09:18:38 +08:00

130 lines
5.8 KiB
JavaScript

import { message } from "antd/lib/index";
import { Button, Popconfirm, Row, Col, Form, Input, Select, Table } from 'antd';
import React from 'react';
import { initFilter, extendRule, extendInclude, setDataFieldValue, guid, initQueryFilter } from "../../../utils/common";
import styles from '../HI/StepForm.css';
import { connect } from 'dva';
class CloseTassks extends React.Component {
constructor(props) {
super(props);
this.state = {
data: null,
enumData: null,
BtnAgreeDisplay: 'none',
isFinished: 'none',
isMobile: false,
};
};
componentDidMount() {
if (window.navigator.userAgent.indexOf("Windows") < 1) {
this.setState({ isMobile: true })
}
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, '', null, null);
json.Parameter1 = this.state.data.TASK_IDS;
json.Parameter2 = this.props.data.TaskID;
json.IgnoreDataRule = true;
this.props.dispatch({
type: 'app/getDataByPost',
url: 'BI/BITask/ConfirmCloseTask',
payload: json,
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);
this.props.dispatch({
type: 'app/getDataByPost',
payload: json,
url: 'BI/CloseTasks/Get',
onComplete: (ret) => {
if (ret) {
this.setState({ data: ret })
this.state.data.taskNames=JSON.parse(this.state.data.TASK_NAMES);
console.log()
if (this.props.data.tableKey == "2" || this.props.data.tableKey == undefined) {
this.setState({ BtnAgreeDisplay: 'none' })
} else {
this.setState({ BtnAgreeDisplay: 'inline' })
}
} else { message.error('数据加载获取失败,请联系管理员排查!'); }
}
});
}
render() {
const { data, isMobile } = this.state;
return <div>
<div style={{ marginTop: '10px' }}>
<Button type="primary" style={{ marginLeft: isMobile ? '0' : '20px', display: this.state.BtnAgreeDisplay }} onClick={() => this.onTableBtnAgree()} icon="check" >同意关闭</Button>
</div>
<div ref={el => (this.componentRef = el)} id={'tableId' + this.props.data.id} style={{ padding: isMobile ? '0px 0px 20px 0px' : '20px' }}>
<h1 style={{ textAlign: 'center' }}>关闭待办申请</h1>
{
data ?
<div>
<table style={{ width: '100%', textAlign: 'center', borderTop: '1px solid #333', borderLeft: '1px solid #333' }} className={styles.PrintForm}>
<tbody>
<tr>
<td colSpan={2} rowSpan={1} className={styles.fontBold}>申请时间</td>
<td colSpan={3} rowSpan={1}>{data.CREATE_TIME}</td>
<td colSpan={2} rowSpan={1} className={styles.fontBold}>申请部门</td>
<td colSpan={3} rowSpan={1}>{data.DEPARTMENT_NAME}</td>
<td colSpan={2} rowSpan={1} className={styles.fontBold}>申请人</td>
<td colSpan={3} rowSpan={1}>{data.USER_NAME}</td>
</tr>
</tbody>
</table>
<h1 style={{ textAlign: 'center', margin: '15px' }}>待关闭待办</h1>
<table style={{ width: '100%', textAlign: 'center', border: '1px solid #888' }} className={styles.PrintForm}>
<tbody>
<tr>
<td colSpan={1} rowSpan={1} className={styles.fontBold}>序号</td>
<td colSpan={4} rowSpan={1} className={styles.fontBold}>待办名称</td>
<td colSpan={4} rowSpan={1} className={styles.fontBold}>开始时间</td>
<td colSpan={4} rowSpan={1} className={styles.fontBold}>结束时间</td>
</tr>
{
data && data.taskNames && data.taskNames.map((it, idx) => {
return <tr key={it.title}>
<td colSpan={1} rowSpan={1}>{idx + 1}</td>
<td colSpan={4} rowSpan={1}>{it.title}</td>
<td colSpan={4} rowSpan={1}>{it.startTime}</td>
<td colSpan={4} rowSpan={1}>{it.endTime}</td>
</tr>
})
}
</tbody>
</table>
</div>
: null
}
</div>
</div>
}
}
export default connect(({ login }) => ({ login }))(CloseTassks)