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

export const tips = params => {
  return WeaTools.callApi("/api/bs/hrmsalary/archives/tips", "get", params);
};

export const getCondition = params => {
  return WeaTools.callApi("/api/bs/hrmsalary/archives/getSearchCondition", "get", params);
};

//社保福利档案列表
export const queryList = (params) => {
  return postFetch("/api/bs/hrmsalary/archives/getTable", params);
};
//社保福利档案_非系统人员列表
export const getExtTable = (params) => {
  return postFetch("/api/bs/hrmsalary/archives/getExtTable", params);
};
//社保福利档案列表
export const queryInsuranceTabTotal = (params) => {
  return WeaTools.callApi("/api/bs/hrmsalary/archives/queryInsuranceTabTotal", params);
};
//删除待办-待增员
export const updateRunStatus = (params) => {
  return postFetch("/api/bs/hrmsalary/archives/updateRunStatus", params);
};
//删除待办-待减员
export const cancelStayDel = (params) => {
  return postFetch("/api/bs/hrmsalary/archives/cancelStayDel", params);
};
//全量增员
export const allStayAddToPay = (params) => {
  return WeaTools.callApi("/api/bs/hrmsalary/archives/allStayAddToPay", "GET", params);
};
//全量减员
export const allStayDelToStop = (params) => {
  return WeaTools.callApi("/api/bs/hrmsalary/archives/allStayDelToStop", "GET", params);
};
//增员
export const stayAddToPay = (params) => {
  return postFetch("/api/bs/hrmsalary/archives/stayAddToPay", params);
};
//减员
export const stayDelToStop = (params) => {
  return postFetch("/api/bs/hrmsalary/archives/stayDelToStop", params);
};
//删除社保档案
export const deleteArchive = (params) => {
  return postFetch("/api/bs/hrmsalary/archives/deleteArchive", params);
};
//取消停缴
export const cancelStopPayment = (params) => {
  return postFetch("/api/bs/hrmsalary/archives/cancelStopPayment", params);
};
export const getTable = params => {
  return postFetch("/api/bs/hrmsalary/archives/getTable", params);
};

export const getBaseForm = params => {
  return WeaTools.callApi("/api/bs/hrmsalary/archives/getBaseForm", "get", params);
};

export const getPaymentForm = params => {
  return WeaTools.callApi("/api/bs/hrmsalary/archives/getPaymentForm", "get", params);
};

// 保存
export const save = params => {
  return postFetch("/api/bs/hrmsalary/archives/save", params);
};

// 导入档案- 导出现有数据
export const exportCurData = params => {
  postFetch("/api/bs/hrmsalary/scheme/template/export", params).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 previewCurData = (params) => {
  return postFetch("/api/bs/hrmsalary/scheme/preview", params);
};

// 档案导入
export const importBatch = (params) => {
  return postFetch("/api/bs/hrmsalary/scheme/importBatch", params);
};

// 导出档案
export const exportArchives = (ids) => {
  fetch("/api/bs/hrmsalary/scheme/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 getAdjustHistoryList = (params) => {
  return postFetch("/api/bs/hrmsalary/archives/getAdjustHistoryList", params);
};

