
import { Button } from 'antd'
import FormPage from '../../components/FormPage'
import ShowModal from '../../components/common/ShowModal'
import {message} from "antd/lib/index";
//工程方案
export default {
  btnResetdata:({record,close,loadData,login,btn,dispatch})=> {
    const confirm=()=>{
      const json={OrgId:login.OrgId};
      dispatch({
        type: 'app/getDataByPost',
        payload:json,
        url:"DT/ExtPdtOrderSync/SyncOtherCode",
        onComplete: (ret) => {
          if(ret) {
            message.success('执行成功');
            loadData();
          };
        }
      })
    };
    return {
      content: <Button onClick={confirm}>{btn.LABEL}</Button>
    }
  },
  btnReceive :({record,loadData,getLoadParam,login,btn,dispatch,setState,getState})=>{
    const clickKey = "productProcessEditClick";
    const close = (type) => {
        if (type === undefined || type === 0) {
          const tmpFunc = getState('closeModelFunc'+record.ID);
          if (tmpFunc) {
            tmpFunc();
          }
        }
      };
    const closeFunc = (fun) => {
      const data = {};
      data['closeModelFunc'+record.ID] = fun;
      setState(data);
    };
    const data={
      id:(record? record.ID:''),
      clickKey,
      regClose: closeFunc,
      onSave: () => {
        close();
        loadData();
      },
      onCancel:()=>{
        close();
      },
      productProcessEditClick:login.productProcessEditClick,
      content: <FormPage formCode={'WO030'} data={{id:(record? record.ID:''),
      onSave: () => {
        close();
        loadData();
      },
      onCancel:()=>{
        close();
      },
      }}/>,
      onRegDestroyCacheDataFunc: (ret) => {
        // if (!this.regDestroyCacheDataFunc) {
        //   this.regDestroyCacheDataFunc = {};
        // }
        // this.regDestroyCacheDataFunc[clickKey + ('')] = ret;
      },
    };
    data.close = () => {
      // if (this.regDestroyCacheDataFunc && this.regDestroyCacheDataFunc[clickKey + ('')]) {
      //   this.regDestroyCacheDataFunc[clickKey + ('')]();
      // }
    }
    return {
        // content:!record.IS_RECEIVE? <ShowModal data={data} login={login} title="接收">
        //   <Button  disabled={record.IS_RECEIVE} type={btn.CSS} icon={btn.ICON}></Button>
        // </ShowModal>: <Button  disabled={record.IS_RECEIVE} type={btn.CSS} icon={btn.ICON}></Button>
         content: <ShowModal data={data} login={login} title="接收">
         <Button  type={btn.CSS} icon={btn.ICON}></Button>
         </ShowModal>
    }
  },
}
