import request from "@/router/axios";
import { getToken } from "@/util/auth";
//申请开通电子签章
export const apply = (data) => {
  return request({
    url: `jobslink-api/doc/docCompanySeal/signseal/apply`,
    method: "post",
    data: data,
  });
};
//电子合同状态
export const applyStatus = () => {
  return request({
    url: "/api/jobslink-api/doc/company/cert/company/status",
    method: "get",
    params: {},
  });
};
//电子合同管理列表
export const tenantList = (current, size, params) =>
  request({
    url: "/api/jobslink-api/doc/contract/tenant/list",
    method: "get",
    params: {
      ...params,
      current,
      size,
    },
    headers: {
      "content-type": "application/pdf",
    },
  });

//企业-录用人员-已录用中查看合同
export const viewContractImg = (userId, missionsNo) => {
  return request({
    url: "/api/jobslink-api/doc/contract/mission/viewContract",
    method: "get",
    params: {
      userId: userId,
      missionsNo: missionsNo,
    },
  });
};
//企业-录用人员-已录用中是否显示查看合同
export const isGenerateContract = (userId, missionsNo) => {
  return request({
    url: "/api/jobslink-api/doc/contract/isGenerateContract",
    method: "get",
    params: {
      userId: userId,
      missionsNo: missionsNo,
    },
  });
};
//企业端校验印章密码是否正确
export const certCheckPass = (pass) => {
  return request({
    url: "/api/jobslink-api/doc/company/cert/checkPass",
    method: "get",
    params: {
      pass: pass,
    },
  });
};

//获取手机短信验证码
export const getCode = (mobile) => {
  return request({
    url: "/api/jobslink-api/doc/company/cert/resetPass/sendValidate",
    method: "get",
    params: { mobile },
  });
};

//重置密码
export const resetPwd = (mobile, password, code) => {
  return request({
    headers: { "SCaptcha-Key": mobile, "SCaptcha-Code": code },
    url: "/api/jobslink-api/doc/company/cert/resetPass",
    method: "post",
    params: { mobile, password, code },
  });
};

//查看签章图片
export const viewSignature = () => {
  return request({
    url: "/api/jobslink-api/doc/docCompanySeal/company/details",
    method: "get",
  });
};

//查看电子合同
export const viewLetter = (userId, missionsNo) => {
  return request({
    url: "/api/jobslink-api/doc/contract/mission/viewContract",
    method: "get",
    params: { userId, missionsNo },
  });
};

//下载电子合同
export const downLetter = (id) => {
  return `jobslink-api/doc/contract/download/${id}?Jobslink-Auth=${getToken()}`;
};

//判断企业是否设置签章密码
export const whetherSetSignPwd = () => {
  return request({
    url: "/api/jobslink-api/doc/company/cert/hasPass",
    method: "get",
  });
};

//查看pdf
export const viewPdf = (url) => {
  console.log(url);
  return request({
    url: url,
    method: "get",
  });
};

//批量下载合同
export const mutiDownPdf = (ids) => {
  return `jobslink-api/doc/contract/contract/bulkDownload?ids=${ids}&Jobslink-Auth=${getToken()}`;
};
