import request from '/@/utils/request';

/**
 * 分页查询心理健康列表
 * @param query
 */
export const fetchList = (query?: any) => {
  return request({
    url: '/stuwork/stucare/page',
    method: 'get',
    params: query
  });
};

/**
 * 新增心理健康
 * @param data
 */
export const addObj = (data: any) => {
  return request({
    url: '/stuwork/stucare',
    method: 'post',
    data
  });
};

/**
 * 获取详情
 * @param id
 */
export const getDetail = (id: string) => {
  return request({
    url: '/stuwork/stucare/detail',
    method: 'get',
    params: { id }
  });
};

/**
 * 编辑心理健康
 * @param data
 */
export const editObj = (data: any) => {
  return request({
    url: '/stuwork/stucare/edit',
    method: 'post',
    data
  });
};

/**
 * 删除心理健康
 * @param ids
 */
export const delObj = (ids: string[]) => {
  return request({
    url: '/stuwork/stucare/delete',
    method: 'post',
    data: ids
  });
};

/**
 * 更新干预结果
 * @param data
 */
export const updateResult = (data: any) => {
  return request({
    url: '/stuwork/stucare/edit',
    method: 'post',
    data
  });
};

/**
 * 导入心理健康数据
 * @param file
 */
export const importExcel = (file: File) => {
  const formData = new FormData();
  formData.append('file', file);
  return request({
    url: '/stuwork/stucare/import',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
};

/**
 * 下载导入模板
 */
export const downloadTemplate = () => {
  return request({
    url: '/stuwork/stucare/importTemplate',
    method: 'get',
    responseType: 'blob'
  });
};

