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

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

/**
 *
 * @param type: 0 我执行的 1我关注的 2所有任务 3我负责的
 * @param sortOrder 0-按创建时间正序，1-倒序
 * @returns
 */
export const queryTaskListApi = (params: any) => {
  return post(`${PREFIX}task/list`, params);
};

export const updateTaskStatusApi = (params: any) => {
  return post(`${PREFIX}task/operation`, params);
};

export const attentionTaskApi = (params: any) => {
  return post(`${PREFIX}task/attention`, params);
};

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

export const getTaskCountApi = (params: any) => {
  return post(`${PREFIX}task/count`, params);
};

/**
 * 获取用户工作负载信息
 * @param params
 * @returns
 */
export const getListUserWorkloadsApi = (params: any) => {
  return post(`${PREFIX}task/listUserWorkloads`, params);
};

export const exportTaskApi = (params: any, filename: string) => {
  return download(`${PREFIX}task/exportTask`, params, filename);
};

export const exportTaskByDemandIdApi = (params: any, filename: string) => {
  return download(`${PREFIX}task/exportTaskByDemandId`, params, filename);
};
// 获取任务详情（数据总览专用）
export const getTaskDetailApi = (params: any) => {
  return post(`${PREFIX}task/getTaskDetail`, params);
};

// 按工位、学科的仿真任务达成统计
export const getTaskCompleteStatisticsApi = (params: any) => {
  return post(`${PREFIX}task/getTaskCompleteStatistics`, params);
};

// 按工位、学科的仿真任务达成统计
export const getTaskAchieveStatisticsApi = (params: any) => {
  return post(`${PREFIX}task/getTaskAchieveStatistics`, params);
};

// 按工位、学科的仿真指标达成统计
export const getPerformanceCompleteStatisticsApi = (params: any) => {
  return post(`${PREFIX}task/getPerformanceCompleteStatistics`, params);
};

// 项目成员难度系数统计
export const getUserDifficultyStatisticsApi = (params: any) => {
  return post(`${PREFIX}task/getUserDifficultyStatistics`, params);
};

// 项目成员任务进度统计
export const getUserTaskCompleteStatisticsApi = (params: any) => {
  return post(`${PREFIX}task/getUserTaskCompleteStatistics`, params);
};

/**
 * 工作负载-任务工时统计图表
 * @param params taskIds 任务的uuid
 * @returns
 */
export const listTaskWorkDaysApi = (params: any) => {
  return post(`${PREFIX}task/listTaskWorkDays`, params);
};

export const getTaskListByDemandIdApi = (params: any) => {
  return post(`${PREFIX}task/getTaskListByDemandId`, params);
};

export const deleteTaskApi = (params: any) => {
  return post(`${PREFIX}task/deleteTask`, params);
};

// 编辑任务（数据总览专用）
export const editTaskForDataApi = (params: any) => {
  return post(`${PREFIX}task/editTaskForData`, params);
};
// 人员安排预测
export const queryProjectUserLoadsApi = (params: any) => {
  return post(`${PREFIX}task/queryProjectUserLoads`, params);
};
