import { request } from 'umi';
import { stringify } from 'qs';

/**
 * 请求月度psr或现金流列表
 * @param data
 * @param {*} project_id
 * @param {*} data_type  1 psr 2 现金流
 * @param {} currentPage
 * @param {} pageSize
 * @returns
 */
export const queryPsrMonthList = async (data) => {
  return await request('/api/v1/purchase/psr/month/list', {
    params: data,
  });
};

/**
 * 另存为 月度psr或现金流
 * @param data
 * @param {*} project_id
 * @param {*} data_type  1 psr 2 现金流
 * @param {} day   日期
 * @param {} json_data
 * @returns
 */
export const querySavePsrMonth = async (data) => {
  return await request('/api/v1/purchase/psr/month', {
    method: 'POST',
    data,
  });
};

/**
 * 另存为 月度psr或现金流
 * @param data
 * @param {*} id
 * @returns
 */
export const queryPsrMonthDetail = async (data) => {
  return await request('/api/v1/purchase/psr/month/detail', {
    params: data,
  });
};
/**
 * 获取人日有效工时
 * @param data
 * @param {*} project_id
 * @param {*} s_time
 * @param {*} e_time
 */
export const queryPsrWorkLoad = async (data) => {
  return await request('/api/v2/workload/psr', {
    params: data,
  });
};

/**
 * 获取PSR管理列表
 * @param data
 * @param {*} name
 * @param {*} code
 */
export const queryPsrList = async (data) => {
  return await request('/api/v1/psr/project/list', {
    params: data,
  });
};

/**
 * 获取psr excel
 * @param {*} gridKey
 * NodeID = 投标版
 * FlowID = 签字版
 */
export const queryPsrExcel = async (data) => {
  return await request(`/api/v1/purchase/record/sheet?${stringify(data)}`, {
    method: 'POST',
    data,
  });
};

/**
 * 获取最新psr和现金流接口
 * @param {*} project_id
 */
export const queryPsrMonthLast = async (data) => {
  return await request(`/api/v1/purchase/psr/month/last`, {
    params: data,
  });
};
