import React from 'react';
import { connect } from 'dva';
import {Tabs} from "antd/lib/index";
import { Timeline,Button, Row, Col, Affix, Select,Checkbox,Modal,Transfer,Spin,Card,Table,Radio,InputNumber,DatePicker,Steps,Icon,Divider  } from 'antd';
import {extendRule, initFilter, initQueryFilter} from "../../../utils/common";
const TabPane = Tabs.TabPane;
//计划排产
class BatchSchedul extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      tableList:[],
      param:{},
      loadFunc:{},
      clearRowFunc:{},
      searchRules:{},
      dafaultDateRange:[],
      selectRowKeys:{}
    };
  };

  componentDidMount() {
    this.loadData();
  }

  loadData = () => {
    const orgId = this.props.login.OrgId;
    const OJson = initFilter(orgId);
    this.props.dispatch({
      type: 'app/getDataByPost',
      url:'PM/SchedulIn/Last',
      payload: OJson,
      onComplete: (ret) => {
        if (ret) {
          this.setState({
            formData: ret
          },()=>{

          });
        }
      }
    });

  };
  render() {
    const tabListNoTitle = [ {
      key: 'schedul',
      tab: this.state.selectRowKeys['workstage']?<span><Icon type="check" />2.排程过程</span>:<span><Icon type="exclamation-circle" />2.选择中心</span>,
    }];
    const colors=['green','#2452F0','red','green','#2452F0','#2452F0','green','#2452F0','green','#2452F0','#2452F0'];
    const icons=['read','check-square','issues-close','read','check-square',
      'login','down-square','check-square','check-circle','check-square','check-square'];
    const text=['模具状态获取','排程粗算模拟','模具优先排序','排程细算模拟'];
    const contentListNoTitle = {
      task:  this.getTabPanel('task'),
      schedul: <div>
        <Timeline mode="alternate">
          {
            this.state.formData ?
              this.state.formData.map((item) => {
                return <Timeline.Item
                  key={item.ID}
                  dot={<Icon type={icons[item.STAGE]} style={{fontSize: '16px', color: colors[item.STAGE]}} />}>
                  [{item.CREATE_TIME}]{text[item.STAGE]}
                </Timeline.Item>
              }) : ''
          }
        </Timeline>,
      </div>,
    };


    return (
      <div style={{ marginTop: 16 }}>
        <Card>
          <Tabs defaultActiveKey={tabListNoTitle[0].key} >
            {tabListNoTitle.map(item => <TabPane tab={item.tab} key={item.key}>{contentListNoTitle[item.key]}</TabPane>)}
          </Tabs>
        </Card>
      </div>
    );
  }

}


BatchSchedul.propTypes = {
};

export default connect(({ login, loading, app }) => ({ login, loading, app }))(BatchSchedul);
