
import { Select, Modal, Button,Table, DatePicker,Popconfirm } from 'antd'
import ListPage from '../../components/Table/ListPage';
import FormPage from '../../components/FormPage'
import {extendRule, initFilter} from "../../utils/common";
import {message} from "antd/lib/index";
import moment from 'moment';
//采购单列表
export default {


  DateTimeInput:({record,close,loadData,login,dispatch, width})=> {
    //var placedate='';
    const dateFormat = 'YYYY-MM-DD';
    const onchange=(monent,string, record) =>
    {
      if(monent!=null){
        record.IS_RPLY=true;
        record.DELIVERY_TMIE=monent.format("YYYY-MM-DD");
      }else {
        record.IS_RPLY=false;
        record.DELIVERY_TMIE=null;
      }
      dispatch({
        type: 'POApplyOrder/sendDeliveryDate',
        payload:record,
        onComplete: (ret) => {
          if(ret) {
            message.success('执行成功');
            loadData();
          }
        }
      })

    };
    const onfocus=(date) =>
    {

    };
    return <DatePicker
      style={{ width: width > 0 && width }}
      format="YYYY-MM-DD "
      focus ={onfocus(record.PLAN_DELIVERY_TMIE)}
      onChange={(mom, str) => onchange(mom, str, record)}
    />
  },
  btnShow:({getSelectedRecords,close,loadData,login,dispatch})=> {
    const closeF=()=>{
      close();
      loadData();
    };
    const regClick= async function (){
      await dispatch({
        type: 'custom/save',
        payload: {
          poApplyOrderToPOOrderEditClick:true,
          poApplyOrderToPOOrderEditRecords: getSelectedRecords
        },
      });
    };
    const data={
      close:closeF,
      poApplyOrderToPOOrderEditClick:login.poApplyOrderToPOOrderEditClick,
    };


    return {content: <FormPage formCode={'PO008'} data={data} />,
      click: regClick}
  },

}
