import request from "@/router/axios";
import { getToken } from "@/util/auth";
// 任务汇总概况
export const gatherInfo = (params) => {
  return request({
    url: "/api/jobslink-api/works/station/gatherInfo",
    method: "get",
    params: params,
  });
};
// 任务明细概况
export const detailInfo = (params) => {
  return request({
    url: "/api/jobslink-api/works/station/detailInfo",
    method: "get",
    params: params,
  });
};
// 任务汇总列表分页
export const gatherList = (params) => {
  return request({
    url: "/api/jobslink-api/works/station/gatherList",
    method: "get",
    params: params,
  });
};
// 任务明细列表分页
export const detailList = (params) => {
  return request({
    url: "/api/jobslink-api/works/station/detailList",
    method: "get",
    params: params,
  });
};
// 任务明细列表导出

export const stationExport = (
  status,
  companyName,
  missionNo,
  missionTitle,
  reviewState,
  stime,
  etime,
  current,
  size
) => {
  return `jobslink-api/works/station/export?status=${status}&companyName=${companyName}&missionNo=${missionNo}&missionTitle=${missionTitle}&reviewState=${reviewState}&stime=${stime}&etime=${etime}&current=${current}&size=${size}&Jobslink-Auth=${getToken()}`;
};

export const getList = (current, size, params) => {
  return request({
    url: "/api/jobslink-api/jkWorks/jkWorks/list",
    method: "get",
    params: {
      ...params,
      current,
      size,
    },
  });
};
export const exportList = (current, size, params) => {
  return request({
    url: "/api/jobslink-api/jkWorks/jkWorks/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: 2,
    },
  });
};

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/jkWorks/jkWorks/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/jkWorks/jkWorks/manage/review",
    method: "post",
    data: {
      ids,
      remarks,
    },
  });
};

export const complet = (ids) => {
  return request({
    url: "/api/jobslink-api/jkWorks/jkWorks/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/jkWorks/jkWorks/export-mission?${query}&Jobslink-Auth=${getToken()}`;

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

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