import { WeaTools } from "ecCom";
import { formHeaderPost, postFetch } from "../util/request";
import { convertToUrlString } from "../util/url";

// 工资单列表
export const mySalaryBillList = params => {
  return postFetch("/api/bs/hrmsalary/salaryBill/mySalaryBillList", params);
};
// 人事卡片-工资单列表
export const mySalaryBillList4Card = params => {
  return postFetch("/api/bs/hrmsalary/salaryBill/mySalaryBillList4Card", params);
};
// 人事卡片-调薪记录列表
export const mySalaryRecordList4Card = params => {
  return WeaTools.callApi("/api/bs/hrmsalary/report/record/list4Card", "GET", params);
};

// 调薪记录列表
export const recordList = params => {
  return WeaTools.callApi("/api/bs/hrmsalary/report/record/list", "GET", params);
};

// 工资查看详情
export const mySalaryBill = params => {
  const { header, ...payload } = params;
  return fetch(`/api/bs/hrmsalary/salaryBill/mySalaryBill?${convertToUrlString(payload)}`, {
    method: "GET",
    mode: "cors",
    headers: { "Content-Type": "application/json", ...header }
  }).then(res => res.json());
};

export const isNeedSecondPwdVerify = (params, headers) => {
  return formHeaderPost("/api/encrypt/secondauthsetting/isNeedSecondAuth", "POST", params, headers);
  // return WeaTools.callApi("/api/encrypt/secondauthsetting/isNeedSecondAuth", "POST", params);
};
export const getSecondAuthForm = (params, headers) => {
  return formHeaderPost("/api/encrypt/secondauthsetting/getSecondAuthForm", "POST", params, headers);
  // return WeaTools.callApi("/api/encrypt/secondauthsetting/getSecondAuthForm", "POST", params);
};
export const doSecondAuth = (params, headers) => {
  return formHeaderPost("/api/encrypt/secondauthsetting/doSecondAuth", "POST", params, headers);
  // return WeaTools.callApi("/api/encrypt/secondauthsetting/doSecondAuth", "POST", params);
};
export const getPasswordForm = params => {
  return WeaTools.callApi("/api/hrm/secondarypwd/getPasswordForm", "GET", params);
};
export const checkPassword = (params, headers) => {
  return formHeaderPost("/api/hrm/secondarypwd/checkPassword", "POST", params, headers);
  // return WeaTools.callApi("/api/hrm/secondarypwd/checkPassword", "POST", params);
};
export const saveSecondaryPwd = (params, headers) => {
  return formHeaderPost("/api/hrm/secondarypwd/saveSecondaryPwd", "POST", params, headers);
  // return WeaTools.callApi("/api/hrm/secondarypwd/saveSecondaryPwd", "POST", params);
};
export const salaryBillGetToken = params => {
  return postFetch("/api/bs/hrmsalary/salaryBill/getToken", params);
};
