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

//数据采集-累计情况列表
export const getCumSituationList = (params) => {
  return postFetch("/api/bs/hrmsalary/addUpSituation/list", params);
};

//数据采集-累计情况列表的高级搜索
export const getCumSituationSaCondition = (params) => {
  return WeaTools.callApi("/api/bs/hrmsalary/addUpSituation/getSearchCondition", "get", params);
};

//数据采集-累计情况-导出
export const exportCumSituationList = (ids) => {
  fetch("/api/bs/hrmsalary/addUpSituation/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 getCumSituationDetailList = (params) => {
  return postFetch("/api/bs/hrmsalary/addUpSituation/getDetailList", params);
};

//数据采集-累计情况-导出明细
export const exportCumSituationDetailList = (id, ids = "", taxAgentId = "") => {
  fetch(
    "/api/bs/hrmsalary/addUpSituation/exportDetail?accumulatedSituationId=" +
    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 importCumSituationParam = (params) => {
  return postFetch("/api/bs/hrmsalary/addUpSituation/importAddUpSituation", params);
};

// 数据采集-累计情况-导入预览
export const importCumSituationPreview = (params) => {
  return postFetch("/api/bs/hrmsalary/addUpSituation/preview", params);
};
//新建往期累计情况
export const createAddUpSituation = (params) => {
  return postFetch("/api/bs/hrmsalary/addUpSituation/createAddUpSituation", params);
};
//编辑往期累计情况
export const editAddUpSituation = (params) => {
  return postFetch("/api/bs/hrmsalary/addUpSituation/editAddUpSituation", params);
};
//删除所选往期累计情况
export const deleteSelectAddUpSituation = (params) => {
  return postFetch("/api/bs/hrmsalary/addUpSituation/deleteSelectAddUpSituation", params);
};
//一键清空往期累计情况
export const deleteAllAddUpSituation = (params) => {
  return postFetch("/api/bs/hrmsalary/addUpSituation/deleteAllAddUpSituation", params);
};
//查看信息
export const getAddUpSituation = (params) => {
  return postFetch("/api/bs/hrmsalary/addUpSituation/getAddUpSituation", params);
};
