import React, { Component } from "react";
import { Menu, message } from "antd";
import * as API from "../../../apis/payrollFiles";
import "../index.less";

class BatchSuspendpay extends Component {
  handleClick = ({ key }) => {
    const { selectedRowKeys, refreshList } = this.props;
    if (selectedRowKeys.length === 0) {
      message.warning("未选择条目");
      return;
    }
    API.cancelStop(selectedRowKeys).then(({ status, errormsg }) => {
      if (status) {
        message.success("操作成功!");
        refreshList();
      } else {
        message.error(errormsg || "操作失败!");
      }
    });
  };

  render() {
    return (
      <Menu className="dropdownMenuWrapper" onClick={this.handleClick}>
        <Menu.Item key="batchSuspendpay">批量取消停薪</Menu.Item>
      </Menu>
    );
  }
}

export default BatchSuspendpay;
