import { WeaTools } from "ecCom";
import { postFetch } from "../util/request";

//数据采集-其他免税扣除列表
export const getOtherDeductList = (params) => {
  return postFetch("/api/bs/hrmsalary/otherDeduction/list", params);
};

//数据采集-其他免税扣除列表的高级搜索
export const getOtherDeductSaCondition = (params) => {
  return WeaTools.callApi("/api/bs/hrmsalary/otherDeduction/getSearchCondition", "get", params);
};

//数据采集-其他免税扣除-导出
export const exportOtherDeductList = (ids = "") => {
  fetch("/api/bs/hrmsalary/otherDeduction/export?ids=" + ids).then((res) =>
    res.blob().then((blob) => {
      var filename = `其他免税扣除.xlsx`;
      var a = document.createElement("a");
      var url = window.URL.createObjectURL(blob);
      a.href = url;
      a.download = filename;
      a.click();
      window.URL.revokeObjectURL(url);
    })
  );
};

//数据采集-获取其他免税扣除记录
export const getOtherDeductDetailList = (params) => {
  return postFetch("/api/bs/hrmsalary/otherDeduction/getDetailList", params);
};

//数据采集-其他免税扣除-导出明细
export const exportOtherDeductDetailList = (id, ids) => {
  fetch(
    "/api/bs/hrmsalary/otherDeduction/exportDetail?otherTaxExemptDeductionId=" +
    id +
    "&ids=" +
    ids + "&taxAgentId=" + taxAgentId
  ).then((res) =>
    res.blob().then((blob) => {
      var filename = `其他免税扣除.xlsx`;
      var a = document.createElement("a");
      var url = window.URL.createObjectURL(blob);
      a.href = url;
      a.download = filename;
      a.click();
      window.URL.revokeObjectURL(url);
    })
  );
};

// 数据采集-其他免税扣除-导入
export const importOtherDeductionParam = (params) => {
  return postFetch("/api/bs/hrmsalary/otherDeduction/importData", params);
};

// 数据采集-其他免税扣除-导入预览
export const importOtherDeductionPreview = (params) => {
  return postFetch("/api/bs/hrmsalary/otherDeduction/preview", params);
};

//新增其他免税扣除
export const createData = (params) => {
  return postFetch("/api/bs/hrmsalary/otherDeduction/createData", params);
};
//查看信息
export const getData = (params) => {
  return postFetch("/api/bs/hrmsalary/otherDeduction/getData", params);
};
//编辑其他免税扣除
export const editData = (params) => {
  return postFetch("/api/bs/hrmsalary/otherDeduction/editData", params);
};
//批量删除其他免税扣除
export const deleteSelectData = (params) => {
  return postFetch("/api/bs/hrmsalary/otherDeduction/deleteSelectData", params);
};
//一键清空其他免税扣除
export const deleteAllData = (params) => {
  return postFetch("/api/bs/hrmsalary/otherDeduction/deleteAllData", params);
};
//沿用上月
export const extendToLastMonth = (params) => {
  return postFetch("/api/bs/hrmsalary/otherDeduction/extendToLastMonth", params);
};
