
import React from 'react';
import { Button, Popconfirm } from 'antd'
import FormPage from '../../components/FormPage'
import { ConfirmButton } from '@woowalker/feui'
import {extendRule, initFilter} from "../../utils/common";
import {message} from "antd/lib/index";

//工程方案
export default {
  btnEdit:({record,close,loadData,login,btn,dispatch})=> {
    let isShow=record.EM_CONFIRM_STATUS==1;
    const closeF=()=>{
      close();
      loadData();
    };
    const regClick= async function () {
      await dispatch({
        type: 'custom/save',
        payload: {
          ['engineeringPlanEditClick'+(record? record.ID:'')]:true
        },
      });
    };
    const data={
      id:(record? record.ID:''),
      close:closeF,
      engineeringPlanEditClick:login.engineeringPlanEditClick,
      isShow:isShow,
    };
    if(isShow){
      btn.LABEL="查看方案";
    }
    else{
      btn.LABEL="建立方案";
    }

    return {
      content: <FormPage formCode={'EM004'} data={data}/>,
      click: regClick,
    }
  },
  btnConfirmEM:({record,close,loadData,login,btn,dispatch})=> {
    let isReturn=record.EM_CONFIRM_STATUS==1;
    const confirm=()=>{
      //dispatch()
      const json={Keyword:record.ID};
      dispatch({
        type: 'EMengineeringPlanEdit/updateEMConfirmStatus',
        payload:json,
        onComplete: (ret) => {
          if(ret) {
            message.success('执行成功');
            loadData();
          };
        }
      })
    };
    return {
      content:<ConfirmButton isConfirm={true} confirmTitle="是否确定确认?" onClick={confirm} key={record ? (record.ID + btn.ID) : btn.ID}
                             type={btn.CSS} icon={btn.ICON}   disabled={isReturn} title={btn.LABEL}/>,
    };
  },



}
