import request from "@/router/axios";
import {getToken} from "@/util/auth";

export const getList = (current, size, params) => {
  return request({
    url: "/api/jobslink-api/missions/mission/manage/list",
    method: "get",
    params: {
      ...params,
      current,
      size,
    },
  });
};

export const exportList = (current, size, params) => {
  return request({
    url: "/api/jobslink-api/missions/mission/manage/export",
    method: "get",
    params: {
      ...params,
      current,
      size,
    },
    responseType: 'blob',
  });
};

export const getZPView = (current, size, missionNo, params) => {
  return request({
    url: "/api/jobslink-api/missions/mission/apply/manage/list",
    method: "get",
    params: {
      ...params,
      current,
      size,
      missionNo,
      type: 1,
    },
  });
};

export const getWageView = (current, size, missionNo, params) => {
  return request({
    url: "/api/jobslink-api/payment/userOrder/mission/user/list",
    method: "get",
    params: {
      ...params,
      current,
      size,
      missionNo,
    },
  });
};

export const getDetail = (missionNo) => {
  return request({
    url: "/api/jobslink-api/missions/mission/detail",
    method: "get",
    params: {missionNo},
  });
};

export const delay = (missionNo, expiryTime, remarks) => {
  return request({
    url: "/api/jobslink-api/payment/mission/payroll/manage/delay",
    method: "post",
    params: {
      missionNo,
      expiryTime,
      remarks,
    },
  });
};

export const review = (ids, remarks) => {
  return request({
    url: "/api/jobslink-api/missions/mission/manage/review",
    method: "post",
    data: {
      ids,
      remarks,
    },
  });
};

export const complet = (ids) => {
  return request({
    url: "/api/jobslink-api/missions/mission/manage/complet",
    method: "post",
    params: {ids},
  });
};

//导出数据
export const download = (query) => {
  query = JSON.stringify(query).replace(/:/g, "=");
  query = query.replace(/{/g, "");
  query = query.replace(/}/g, "");
  query = query.replace(/,/g, "&");
  query = query.replace(/"/g, "");
  return `jobslink-api/missions/mission/export-mission?${query}&Jobslink-Auth=${getToken()}`;

  /*let {
    companyName,missionNo,missionTitle,type,stime,etime,status
  }=query;

  return  `jobslink-api/missions/mission/export-mission?companyName=${companyName}&missionNo=${missionNo}&missionTitle=${missionTitle}&type=${type}&stime=${stime}&etime=${etime}&status=${status}&Jobslink-Auth=${getToken()}`
*/
};


export const Auditing = (data) => {
  return request({
    url: "/api/jobslink-api/user/userrecruit/approval",
    method: "post",
    data,
  });
};

export const getAllCountWorkCount = (params) => {
  return request({
    url: "/api/jobslink-api/report/allCount/workCount",
    method: "get",
    params,
  });
};

