import { download, get, post } from '@/api/request';

const env = import.meta.env;
const PREFIX = env.VITE_API_PREFIX_PROJECT;

export const addNodeApi = (params: any) => {
  return post(`${PREFIX}node/addNode`, params);
};

export const queryNodeListApi = (params: any) => {
  return post(`${PREFIX}node/list`, params);
};

export const getChildrenNodeListApi = (params: any) => {
  return get(`${PREFIX}node/getChildrenNodeList`, params);
};

export const editNodeApi = (params: any) => {
  return post(`${PREFIX}node/editNode`, params);
};

export const deleteNodeApi = (params: any) => {
  return post(`${PREFIX}node/deleteNode`, params);
};

export const getNodeDetailApi = (params: any) => {
  return get(`${PREFIX}node/getNodeDetail`, params);
};

export const deleteNodeTaskPerformanceApi = (params: any) => {
  return post(`${PREFIX}project/delete`, params);
};

export const editNodeTaskPerformanceApi = (params: any) => {
  return post(`${PREFIX}project/edit`, params);
};

export const addNodeTaskPerformanceApi = (params: any) => {
  return post(`${PREFIX}project/add`, params);
};

export const getTaskListApi = (params: any) => {
  return get(`${PREFIX}project/list`, params);
};

export const getTaskTreeApi = (params: any) => {
  return post(`${PREFIX}project/getTaskTree`, params);
};

export const modifyNodeTaskPerformanceApi = (params: any) => {
  return post(`${PREFIX}project/modify`, params);
};

export const getProjectMemberListApi = (params: any) => {
  return get(`${PREFIX}node/getProjectMemberList`, params);
};

export const getUserGroupProjectStatisticsApi = (params: any) => {
  return get(`${PREFIX}node/getUserGroupProjectStatistics`, params);
};

export const getUserGroupTaskCompleteStatisticsApi = (params: any) => {
  return post(`${PREFIX}node/getUserGroupTaskCompleteStatistics`, params);
};

/**
 * 工位评审通过统计查询
 * @param params
 * @returns
 */
export const getWorkstationReviewStatisticsApi = (params: any) => {
  return post(`${PREFIX}node/getWorkstationReviewStatistics`, params);
};

/**
 * 用户组难度系数统计
 * @param params
 * @returns
 */
export const getUserGroupDifficultyStatisticsApi = (params: any) => {
  return post(`${PREFIX}node/getUserGroupDifficultyStatistics`, params);
};

// /node/getCommonCompleteStatistics

/**
 * 任务/指标 完成情况统计请求参数(工位、学科)
 * @param params queryType 查询统计类型 task/performance
 * @returns
 */
export const getCommonCompleteStatisticsApi = (params: any) => {
  return post(`${PREFIX}node/getCommonCompleteStatistics`, params);
};
// 新增任务（数据总览专用）
export const addTaskForDataApi = (params: any) => {
  return post(`${PREFIX}node/addTaskForData`, params);
};
// 新增节点（数据总览专用）
export const addNodeForDataApi = (params: any) => {
  return post(`${PREFIX}node/addNodeForData`, params);
};

export const exportProjectApi = (params: any, filename:string) => {
  return download(`${PREFIX}node/exportProject`, params, filename);
};

// 获取节点详情（数据总览专用）
export const getNodeDetailForDataApi = (params: any) => {
  return post(`${PREFIX}node/getNodeDetailForData`, params);
};
