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

//薪资档案-薪资档案列表
export const getArchiveList = params => {
  return postFetch("/api/bs/hrmsalary/salaryArchive/list", params);
};
//薪资档案的高级搜索
export const getSaCondition = params => {
  return WeaTools.callApi("/api/bs/hrmsalary/archives/getSearchCondition", "get", params);
};
//薪资档案-获取薪资档案详情表单
export const getArchiveForm = params => {
  return WeaTools.callApi("/api/bs/hrmsalary/salaryArchive/getForm", "get", params);
};
//薪资档案-获取薪资项目调整表单
export const getSalaryItemForm = params => {
  return WeaTools.callApi("/api/bs/hrmsalary/salaryArchive/getSalaryItemForm", "GET", params);
};
//薪资档案-保存薪资项目调整
export const saveSalaryItem = params => {
  return postFetch("/api/bs/hrmsalary/salaryArchive/saveSalaryItem", params);
};
//薪资档案-获取个税扣缴义务人调整表单
export const getTaxAgentForm = params => {
  return WeaTools.callApi("/api/bs/hrmsalary/salaryArchive/getTaxAgentForm", "GET", params);
};
//薪资档案-保存个税扣缴义务人调整
export const saveTaxAgent = params => {
  return postFetch("/api/bs/hrmsalary/salaryArchive/saveTaxAgent", params);
};
// 获取导入类型
export const getImportTypes = () => {
  return WeaTools.callApi("/api/bs/hrmsalary/salaryArchive/getImportTypes", "GET", {});
};
// 获取档案和人员状态类型
export const commonEnumList = (params) => {
  return WeaTools.callApi("/api/bs/hrmsalary/common/enum/list", "GET", params);
};
// 发起调薪地址
export const salaryAdjustmentInfo = (params) => {
  return WeaTools.callApi("/api/bs/hrmsalary/process/salaryAdjustmentInfo", "GET", params);
};
// 导入预览
export const importPreview = (params) => {
  return postFetch("/api/bs/hrmsalary/salaryArchive/preview", params);
};
// 导入档案
export const importSalaryArchive = (params) => {
  return postFetch("/api/bs/hrmsalary/salaryArchive/importSalaryArchive", params);
};
// 导出档案
export const exportSalaryArchive = (ids = "") => {
  fetch("/api/bs/hrmsalary/salaryArchive/exportList?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 adjustRecordTaxAgentList = (params) => {
  return postFetch("/api/bs/hrmsalary/salaryArchive/adjustRecord/taxAgentList", params);
};
// 调整记录-薪资项目-列表
export const adjustRecordSalaryItemList = (params) => {
  return postFetch("/api/bs/hrmsalary/salaryArchive/adjustRecord/salaryItemList", params);
};
// 调整记录-薪资项目-单个
export const singleSalaryItemList = (params) => {
  return postFetch("/api/bs/hrmsalary/salaryArchive/adjustRecord/singleSalaryItemList", params);
};
// 调整记录-个税扣缴义务人-单个
export const singleTaxAgentList = (params) => {
  return postFetch("/api/bs/hrmsalary/salaryArchive/adjustRecord/singleTaxAgentList", params);
};
// 调整-义务扣缴人-通过薪资档案的个税扣缴义务人id获取个税扣缴义务人调整表单
export const getTaxAgentFormBySalaryArchiveTaxAgentId = (params) => {
  return WeaTools.callApi("/api/bs/hrmsalary/salaryArchive/getTaxAgentFormBySalaryArchiveTaxAgentId", "GET", params);
};
// 调整-薪资项目-获取调整前的值
export const getSalaryItemAdjustBeforeValue = (params) => {
  return postFetch("/api/bs/hrmsalary/salaryArchive/getSalaryItemAdjustBeforeValue", params);
};
// 停薪
export const stopSalary = (params) => {
  return postFetch("/api/bs/hrmsalary/salaryArchive/stopSalary", params);
};
// 调整-薪资项目-通过薪资档案的薪资项目id获取薪资项目调整表单
export const getSalaryItemFormByItemId = (params) => {
  return WeaTools.callApi("/api/bs/hrmsalary/salaryArchive/getSalaryItemFormBySalaryArchiveItemId", "GET", params);
};
// 删除薪资项目调薪
export const deleteSalaryItem = (params) => {
  return WeaTools.callApi(`/api/bs/hrmsalary/salaryArchive/deleteSalaryItem?salaryArchiveItemId=${params.salaryArchiveItemId}`, "GET", params);
};
export const getSingleSalaryItemInfo = (params) => {
  return postFetch("/api/bs/hrmsalary/salaryArchive/adjustRecord/getSingleSalaryItemInfo", params);
};
export const editSingleSalaryItem = (params) => {
  return postFetch("/api/bs/hrmsalary/salaryArchive/adjustRecord/editSingleSalaryItem", params);
};
