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

//产品列表
export default {
  btnImportOtherCode: ({record, close, loadData, login, dispatch}) => {
    const closeF = () => {
      close();
      loadData();
    };
    const regClick = async function () {
      await dispatch({
        type: 'custom/save',
        payload: {
          ['productImportClick' + (record ? record.ID : '')]: true
        },
      });
    };
    const data = {
      id: (record ? record.ID : ''),
      close: closeF,
      productImportClick: login.productImportClick
    };
    return {
      content: <FormPage formCode={'FM048'} data={data}/>,
      click: regClick
    }
  },
  btnProductImport: ({record, close, loadData, login, dispatch}) => {
    const closeF = () => {
      close();
      loadData();
    };
    const regClick = async function () {
      await dispatch({
        type: 'custom/save',
        payload: {
          ['productImportClick' + (record ? record.ID : '')]: true
        },
      });
    };
    const data = {
      id: (record ? record.ID : ''),
      close: closeF,
      productImportClick: login.productImportClick
    };
    return {
      content: <FormPage formCode={'FM053'} data={data}/>,
      click: regClick
    }
  },
  btnMJImport: ({record, close, loadData, login, dispatch}) => { //磨具测试架导入
    const closeF = () => {
      close();
      loadData();
    };
    const regClick = async function () {
      await dispatch({
        type: 'custom/save',
        payload: {
          ['productImportClick' + (record ? record.ID : '')]: true,
        },
      });
    };
    const data = {
      id: (record ? record.ID : ''),
      close: closeF,
      productImportClick: login.productImportClick,
      productType:4
    };
    return {
      content: <FormPage formCode={'FM054'} data={data}/>,
      click: regClick
    }
  },
  btnCSJImport: ({record, close, loadData, login, dispatch}) => { //磨具测试架导入
    const closeF = () => {
      close();
      loadData();
    };
    const regClick = async function () {
      await dispatch({
        type: 'custom/save',
        payload: {
          ['productImportClick' + (record ? record.ID : '')]: true,
        },
      });
    };
    const data = {
      id: (record ? record.ID : ''),
      close: closeF,
      productImportClick: login.productImportClick,
      productType:5
    };
    return {
      content: <FormPage formCode={'FM054'} data={data}/>,
      click: regClick
    }
  },
  SyncBtn:({record,loadData,login,dispatch,btn,getSelectedRowKeys,clearSelectedRowKeys, getSelectedRecords})=> {
    let enable = true;
    const confirm = () => {
      const json = {Keyword: "", OrgId: login.OrgId};
      dispatch({
        type: 'app/getDataByPost',
        payload: json,
        url: "DT/ProductSync/Sync",
        onComplete: (ret) => {
          if (ret) {
            message.success('执行成功');
            loadData();
          }
        }
      })
    };
    return {
      content:<Button type={btn.CSS}  size="default" title={'立即同步'}  onClick={() => confirm()} >同步</Button>
    };
  }
}
