import request from '@/utils/request.js'
import axios from "axios";
import {getToken} from "@/utils/auth";

export const addAllocation = (data) => {
  return request({
    url:'/workflow/mosr/cost/allocation',
    method: "post",
    data
  });
};
export const addShare = (data) => {
  return request({
    url:'/workflow/mosr/cost/share',
    method: "post",
    data
  });
};
export const getAllocationDetail = (allocationId) => {
  return request({
    url: `/workflow/mosr/cost/allocation/info/${allocationId}`,
    method: "get"
  });
};
export const getAllocationDetails = (allocationId) => {
  return request({
    url: `/workflow/mosr/cost/allocation/usr/detail/${allocationId}`,
    method: "get"
  });
};
export const getAllocationSummaryDetails = (params) => {
  return request({
    url: '/workflow/mosr/cost/allocation/collect',
    method: "get",
    params:params
  });
};
export const getAllocationProcess = () => {
  return request({
    url: '/workflow/mosr/cost/allocation/process',
    method: "get"
  });
};
export const getAllocationDetailList = (params) => {
  return request({
    url: '/workflow/mosr/cost/allocation/usr',
    method: "get",
    params:params
  });
};
export const getResearchUser = () => {
  return request({
    url: '/admin/mosr/user/research',
    method: "get"
  });
};
export const getProjectOption = () => {
  return request({
    url: '/workflow/mosr/project/implementation/in/implementation/option',
    method: "get"
  });
};

export const editAllocation = (data) => {
  return request({
    url: '/workflow/mosr/cost/allocation/edit',
    method: "post",
    data
  });
};
export const deleteAllocation = (id) => {
  return request({
    url:  `/workflow/mosr/cost/allocation/${id}`,
    method: "delete"
  });
};

export const shareExportExcel = (allocationId) => {
  return axios.get(
    `${import.meta.env.VITE_BASE_URL}/workflow/mosr/cost/allocation/collect/${allocationId}`,
     {
      responseType: 'blob',
      headers: {
        Authorization: getToken()
      }
    }
  );
};

export const shareDetailExport= (data) => {
  return axios.post(
      `${import.meta.env.VITE_BASE_URL}/workflow/mosr/cost/share/export`,
      data, {
        responseType: 'blob',
        headers: {
          Authorization: getToken()
        }
      }
  );
};
