
import React from 'react';
import { message } from "antd/lib/index";
import { Button } from 'antd'

export default {
    btnExport: ({ record, loadData, login, dispatch, btn, getSelectedRowKeys, clearSelectedRowKeys, getSelectedRecords, getLoadParam, btnCustomParams }) => {
        const selectRecords = getSelectedRecords();
        const selectedRowKeys = getSelectedRowKeys();

        const confirm = () => {
          if (selectRecords.length !== 1) return;

          const json = { Keyword: selectedRowKeys[0], Parameter1: selectRecords[0].Nav_QCOrder.Nav_Job.Nav_Line.NAME };
          dispatch({
            type: 'QCBatchModel/qcBatchExport',
            payload:json,
            onComplete: (ret) => {
              if(ret) {
                message.success('执行成功');
                loadData();
              }
            }
          })
        };
        return {
            content: <Button
                      type='default'
                      disabled={selectedRowKeys.length !== 1}
                      icon={btn.ICON}
                      title='导出'
                      onClick={confirm}
                    >
                      {btn.LABEL}
                    </Button>
        };
    }
}
