import { message } from "antd/lib/index";
import { Layout,Descriptions, Tabs, Steps, Button, Popconfirm, Row, Col, Form, Input, Select, Table, Drawer ,Icon} from 'antd';
import React from 'react';
import { PlusOutlined } from '@ant-design/icons';
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 moment from 'moment';
const { Header, Footer, Sider, Content } = Layout;
const TabPane = Tabs.TabPane;
const { TextArea } = Input;
const { Step } = Steps;
import {
    extend,
    extendRule,
    initFilter,
    initQueryFilter,
    getOnlyPropertyData,
    extendInclude,
    empty,
    getDataFieldValue, guid, initFilterGroup, extendGroupRule
} from "../../../utils/common";
import FormPage from '../../../components/FormPage'
class PFTodayReminder extends React.Component {
    constructor(props) {
        super(props)
        this.state = {
            title: '今日提醒',
            data: {},
        }
    };
    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);
        }
    }

    BtnClose = () => {
        if (typeof this.props.data.onCancel != "undefined" && typeof this.props.data.onCancel == 'function')
            this.props.data.onCancel();
    }

    onClick = () => {
        const json = initFilter(null,this.props.data.TaskID);
            this.props.dispatch({
                type: 'app/getDataByPost',
                url: 'FM/FMNotificationTask/ChangeStatus',
                payload: json,
                onComplete: (re) => {
                    if (re) {
                            message.success("成功");
                            this.BtnClose();
                    } else {
                        message.error("失败");
                    }
                }
            })
    }
    loadData(dataid) {
        const json = initFilter(null,this.props.data.TaskID);
            this.props.dispatch({
                type: 'app/getDataByPost',
                url: 'FM/FMNotificationTask/ChangeReadStatus',
                payload: json,
                onComplete: (re) => {
                    if (re) {
                            // message.success("成功");
                            // this.BtnClose();
                    } else {
                        // message.error("失败");
                    }
                }
            })
    }

    render() {
        let id=this.props.data?.id;
        return (
          <Layout style={{backgroundColor:"#fff"}}>
                    {
                     this.props.data ?
                     <div style={{margin:'100px 85px 15px 85px'}}>
                        <h3 style={{textAlign:"center"}}>{this.props.data?.noticeTitle}</h3>
                        <h3  style={{textAlign:"right",marginTop:"50px"}}>{this.props.data?moment(this.props.data.taskStartdt).format('YYYY-MM-DD'):null}</h3>
                        
                     </div>:null
                     
                    }
                    {
                     this.props.data ?
                     <div style={{textAlign:"center",marginTop:"50px",display:this.props.data.taskStatus===0?"block":"none"}}>
                        <Button type="primary" onClick={this.onClick} >已办</Button>
                     </div>:null
                    }
                    
          </Layout >
        )
    }
}
export default connect(({ login, app }) => ({ login, app }))(Form.create()(PFTodayReminder))