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 getChildrenDataListApi = (params: {
  projectNodeId?: string;
  phaseNodeId?: string;
  machineNodeId?: string;
  workspaceNodeId?: string;
  taskNodeId?: string;
  nodeType: string;
}) => {
  return post(`${PREFIX}node/getChildrenDataList`, 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 getAllUserTaskCompleteStatisticsApi = (params: any) => {
  return post(`${PREFIX}node/getAllUserTaskCompleteStatistics`, 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);
};
/**
 * 查询（任务）完成统计  基于学科（学科不是节点，是task的一个属性）
 */
export const getTaskCompleteStatisticsByDisciplineApi = (params: any) => {
  return post(`${PREFIX}node/getTaskCompleteStatisticsByDiscipline`, params);
};
/**
 * 查询（指标）完成统计  基于学科（学科不是节点，是task的一个属性）
 */
export const getPerformanceCompleteStatisticsByDisciplineApi = (params: any) => {
  return post(`${PREFIX}node/getPerformanceCompleteStatisticsByDiscipline`, 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 editNodeForDataApi = (params: any) => {
  return post(`${PREFIX}node/editNodeForData`, 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);
};

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

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

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

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

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

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

export const queryProjectPdtApi = (params: any) => {
  return get(`${PREFIX}node/queryProjectPdt`, params);
};
/**
 * queryType: 区分人员状态的标识，为空：代表查询所有状态的人员，0：存在, 1：删除 , 2：冻结
 * @param params
 * @returns
 */
export const queryProjectMemberApi = (params: any) => {
  return get(`${PREFIX}node/queryProjectMember`, params);
};

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

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

/**
 * lyric 同步阶段接口
 * @param params
 * @returns
 */
export const syncPhaseApi = (params: any) => {
  return post(`${PREFIX}node/syncPhase`, params);
};

export const getRunListByRunIdListApi = (params: { runIdList: string[] }) => {
  return post(`${PREFIX}node/getRunListByRunIdList`, params);
};
export const getDedicatedTimeApi = (params: any) => {
  return post(`${PREFIX}node/getDedicatedTime`, params);
};
export const batchUpdateWorkspaceExtraApi = (params: any) => {
  return post(`${PREFIX}node/batchUpdateWorkspaceExtra`, params);
};

/**
 * 仿真策划提交审批接口
 * @param params
 * @returns
 */
export const modifyWithApproveAPi = (params: any) => {
  return post(`${PREFIX}project/modifyWithApprove`, params);
};
