import { defHttp } from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";

const { createConfirm } = useMessage();

enum Api {
  list = '/linkpersonalbankcarddetection/linkPersonalBankCardDetection/listVo',
  save='/linkpersonalbankcarddetection/linkPersonalBankCardDetection/add',
  edit='/linkpersonalbankcarddetection/linkPersonalBankCardDetection/edit',
  deleteOne = '/linkpersonalbankcarddetection/linkPersonalBankCardDetection/delete',
  deleteBatch = '/linkpersonalbankcarddetection/linkPersonalBankCardDetection/deleteBatch',
  importExcel = '/linkpersonalbankcarddetection/linkPersonalBankCardDetection/importExcel',
  exportXls = '/linkpersonalbankcarddetection/linkPersonalBankCardDetection/exportXls',

  batchHIgnoreHandle = '/linkpersonalbankcarddetection/linkPersonalBankCardDetection/batchHIgnoreHandle',
  batchHIgnoreHandleDelete = '/linkpersonalbankcarddetection/linkPersonalBankCardDetection/batchHIgnoreHandleDelete',
  batchHModifyTrue = '/linkpersonalbankcarddetection/linkPersonalBankCardDetection/batchHModifyTrue',
  batchHModifyFalse = '/linkpersonalbankcarddetection/linkPersonalBankCardDetection/batchHModifyFalse',
  batchHAddWhiteLink = '/linkpersonalbankcarddetection/linkPersonalBankCardDetection/batchHAddWhiteLink',
  batchHRemoveWhiteLink = '/linkpersonalbankcarddetection/linkPersonalBankCardDetection/batchHRemoveWhiteLink',
}

/**
 * 导出api
 * @param params
 */
export const getExportUrl = Api.exportXls;

/**
 * 导入api
 */
export const getImportUrl = Api.importExcel;

/**
 * 列表接口
 * @param params
 */
export const list = (params) => defHttp.get({ url: Api.list, params });

/**
 * 删除单个
 * @param params
 * @param handleSuccess
 */
export const deleteOne = (params,handleSuccess) => {
  return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}

/**
 * 批量删除
 * @param params
 * @param handleSuccess
 */
export const batchDelete = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}

/**
 * 保存或者更新
 * @param params
 * @param isUpdate
 */
export const saveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.edit : Api.save;
  return defHttp.post({ url: url, params }, { isTransformResponse: false });
}




export const batchHIgnoreHandle = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认忽略',
    content: '是否忽略选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.batchHIgnoreHandle, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}


export const batchHIgnoreHandleDelete = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '取消忽略',
    content: '是否取消忽略选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.batchHIgnoreHandleDelete, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}


export const batchHModifyTrue = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认修改',
    content: '是否修改选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.batchHModifyTrue, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}

export const batchHModifyFalse = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认取消修改',
    content: '是否取消修改选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.batchHModifyFalse, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}

export const batchHAddWhiteLink = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认添加白名单电话号',
    content: '是否添加选中白名单电话号数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.batchHAddWhiteLink, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}


export const batchHRemoveWhiteLink = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认取消白名单电话号',
    content: '是否取消白名单电话号选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.batchHRemoveWhiteLink, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}
