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 PF136FormRunAnalysis extends React.Component {
    constructor(props) {
        super(props)
        this.state = {
            title: '未完成',
            data: {},
            columns:[
                {
                    width: "100px",
                    title: '名称',
                    dataIndex: 'NAME',
                    key: 'NAME',
                    // render:(value,record,index)=>{
                     
                    // },
                  },
                  {
                    width: "200px",
                    title: '发起人',
                    dataIndex: 'CREATE_NAME',
                    key: 'CREATE_NAME'
                  },
                  {
                    width: "80px",
                    title: '发起部门',
                    dataIndex: 'DEPARTMENT_NAME',
                    key: 'DEPARTMENT_NAME'
                  },
                  {
                    width: "80px",
                    title: '发起时间',
                    dataIndex: 'CREATE_TIME',
                    key: 'CREATE_TIME'
                  },
                  {
                    width: "80px",
                    title: '状态',
                    dataIndex: 'STATUS_NAME',
                    key: 'STATUS_NAME'
                  },
            ]
        }
    };
    componentDidMount() {
        if (this.props.data?.MOUDLE_NAME && this.props.data?.FORM_NAME)
            this.loadData(this.props.data?.MOUDLE_NAME,this.props.data?.FORM_NAME,this.props.data?.DEPARTMENT_ID,this.props.data?.startTime,this.props.data?.endTime);
    }

    componentWillReceiveProps(NextProps) {
        if (NextProps.data?.MOUDLE_NAME && this.props.data?.MOUDLE_NAME != NextProps.data?.MOUDLE_NAME&& this.props.data?.FORM_NAME != NextProps.data?.FORM_NAME) {
            this.loadData(NextProps.data?.MOUDLE_NAME,this.props.data?.FORM_NAME,this.props.data?.DEPARTMENT_ID,this.props.data?.startTime,this.props.data?.endTime);
        }
    }

    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(MOUDLE_NAME,FORM_NAME,DEPARTMENT_ID,startTime,endTime) {
        const json = initFilter(null,DEPARTMENT_ID,'','','',startTime,endTime,MOUDLE_NAME,FORM_NAME);
            this.props.dispatch({
                type: 'app/getDataByPost',
                url: 'BI/BIStatiscialAnalysisController/GetFormRunAnalyze',
                payload: json,
                onComplete: (re) => {
                    if (re) {
                        this.setState({retData :re})
                    } 
                }
            })
    }

    render() {
        
        return (
          <div>
            <Table style={{ width:"1550px",margin:"auto",alignContent:"center",backgroundColor:"white",marginTop:"20px"}}
                dataSource={this.state.retData}
                columns={this.state.columns}
                // pagination={false}
                bordered
                loading={this.state.showLoading}
                size="small"
                rowKey="2"
              />
          </div>
        )
    }
}
export default connect(({ login, app }) => ({ login, app }))(Form.create()(PF136FormRunAnalysis))