import request from '@/utils/request'
const api = {
  page: '/process/project/page',
  add: '/process/project',
  info: '/process/project/preview',
  abandon: '/process/project/abandon',

  projectUser: '/process/project/project/user/list',
  projectCreateBy: '/process/project/user/list',
  taskUser: '/process/project/task/user/list',
  user: '/system/plat/user/process/user/list', // 查看平台端用户
  kindergartenUser: '/system/user/process/user/list/tenant', // 查看幼儿园端用户
  allExpert: '/system/plat/user/process/expert/list', // 查看幼儿园端用户
  checkIsSetProjectUser: '/process/project/check/project/participant',
  checkIsSetTakUser: '/process/project/check/task/participant',

  updateProjectStatus: '/process/project/update/status',

  projectProgress: '/process/project/progress',
  projectWithDirInfo: '/process/directory/project',
  discussWithDirInfo: '/process/directory/relate'
}
export function fetchProjectPage(params) {
  return request({
    url: api.page,
    method: 'get',
    params
  })
}

export function addProject(data) {
  return request({
    url: api.add,
    method: data.id ? 'put' : 'post',
    data
  })
}
export function abandonProject(ids) {
  return request({
    url: `${api.abandon}/${ids}`,
    method: 'put'
  })
}
export function fetchProjectInfo(id) {
  return request({
    url: `${api.info}/${id}`,
    method: 'get'
  })
}

// 编辑项目 通过项目参与人员类型来获取项目参与人员列表
export function fetchProjectAllUser(params) {
  return request({
    url: api.projectUser,
    method: 'get',
    params
  })
}

// 编辑任务 通过项目参与人员类型来获取任务参与人员列表
export function fetchTaskAllUser(params) {
  return request({
    url: api.taskUser,
    method: 'get',
    params
  })
}

// 查询项目参与人员列表
export function fetchAllUser(params) {
  return request({
    url: api.user,
    method: 'get',
    params
  })
}

// 查询项目参与人员 全部专家列表
export function fetchAllExpert(params) {
  return request({
    url: api.allExpert,
    method: 'get',
    params
  })
}
// 查询项目幼儿园参与人员列表
export function fetchKinderAllUser(params) {
  return request({
    url: api.kindergartenUser,
    method: 'get',
    params
  })
}

// 检查是否可以如此设置当前项目的参与人员
export function checkIsSetProjectUser(data) {
  return request({
    url: api.checkIsSetProjectUser,
    method: 'post',
    data
  })
}

// 检查是否可以如此设置当前任务 参与人员
export function checkIsSetTaskUser(data) {
  return request({
    url: api.checkIsSetTakUser,
    method: 'post',
    data
  })
}

export function editProjectStatus({ id, status }) {
  return request({
    url: `${api.updateProjectStatus}?id=${id}&status=${status}`,
    method: 'put'
  })
}

export function fetchProjectProgress(params) {
  return request({
    url: api.projectProgress,
    method: 'get',
    params
  })
}

export function fetchProjectWithDirInfo(id) {
  return request({
    url: `${api.projectWithDirInfo}/${id}`,
    method: 'get'
  })
}

// 获取创建项目的用户列表
export function fetchProjectCreateBy(params) {
  return request({
    url: api.projectCreateBy,
    method: 'get',
    params
  })
}

/**
 *
 * @param id 实例Id
 * @returns {*}
 */
export function fetchDiscussWidthDirInfo(id) {
  return request({
    url: `${api.discussWithDirInfo}/${id}`,
    method: 'get'
  })
}
