
import { Button, Popconfirm } from 'antd'
import FormPage from '../../components/FormPage'
import {extendRule, initFilter} from "../../utils/common";
import {message} from "antd/lib/index";

//工程方案列表
export default {
  btnEdit:({record,close,loadData,custom,btn,dispatch})=> {
    const closeF=()=>{
      close();
      loadData();
    };
    const regClick= async function (){
      await dispatch({
        type: 'custom/save',
        payload: {
          ['emProposalEditClick'+(record? record.ID:'')]:true
        },
      });
    };
    const data={
      id:(record? record.ID:''),
      close:closeF,
      emProposalEditClick:custom.emProposalEditClick,
      isShow:false,
    };
    return {
      content: <FormPage formCode={'EM006'} data={data}/>,
      click: regClick,
    }
  },
  
  btnFlowCard: ({record,close,loadData,custom,btn,dispatch,formId}) => {
    const closeF=()=>{
      loadData();
    };
    const regClick=async function () {
      await dispatch({
        type: 'custom/save',
        payload: {
          ['emProposalFlowCardClick'+(record ? record.ID : '')]:true
        },
      });
    };
    const data = {
      id:(record ? record.ID : ''),
      close:closeF,
      getIds:()=>{return record.ID;},
      emProposalFlowCardClick:custom.emProposalFlowCardClick
    };
    return {
      content: <FormPage formCode={'EM014'} data={data}/>,
      click: regClick,
      close:closeF,
    }
  },
  btnFlowCardByBatch: ({record,close,loadData,custom,btn,dispatch,getSelectedRecords}) => {
    const closeF=()=>{
      loadData();
    };
    const getIds=()=>{
      var selectRecords=getSelectedRecords();
      let ids=[];
      if(selectRecords){
        selectRecords.forEach(item => {
          ids.push(item.ID);
        });
      }
      return ids.join(',');
    }
    const regClick=async function () {
      const ids = getIds();
      let isError = false;
      if (!ids) {
        message.error('请选择记录');
        isError = true;
      }
      else if (ids) {
        await dispatch({
          type: 'custom/save',
          payload: {
            ['emProposalFlowCardClick' + (record ? record.ID : '')]: true,
          },
        });
      }
      return {
        isReturn: isError
      }
    };
    const data = {
      id:(record ? record.ID : ''),
      close:closeF,
      emProposalFlowCardClick:custom.emProposalFlowCardClick,
      getIds:getIds,
    };
    return {
      content: <FormPage formCode={'EM014'} data={data}/>,
      click: regClick,
      close:closeF,
    }
  },

}
