import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ScreeningAssessmentConfigVO, ScreeningAssessmentConfigForm, ScreeningAssessmentConfigQuery } from '@/api/system/screeningAssessmentConfig/types';

/**
 * 查询筛查/评估配置列表
 * @param query
 * @returns {*}
 */

export const listScreeningAssessmentConfig = (query?: ScreeningAssessmentConfigQuery): AxiosPromise<ScreeningAssessmentConfigVO[]> => {
  return request({
    url: '/system/screeningAssessmentConfig/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询筛查/评估配置详细
 * @param configId
 */
export const getScreeningAssessmentConfig = (configId: string | number): AxiosPromise<ScreeningAssessmentConfigVO> => {
  return request({
    url: '/system/screeningAssessmentConfig/' + configId,
    method: 'get'
  });
};

/**
 * 新增筛查/评估配置
 * @param data
 */
export const addScreeningAssessmentConfig = (data: ScreeningAssessmentConfigForm) => {
  return request({
    url: '/system/screeningAssessmentConfig',
    method: 'post',
    data: data
  });
};

/**
 * 修改筛查/评估配置
 * @param data
 */
export const updateScreeningAssessmentConfig = (data: ScreeningAssessmentConfigForm) => {
  return request({
    url: '/system/screeningAssessmentConfig',
    method: 'put',
    data: data
  });
};

export const updateConclusion = (data: ScreeningAssessmentConfigForm) => {
  return request({
    url: '/system/screeningAssessmentConfig/editConclusion',
    method: 'post',
    data: data
  });
};

export const changeConfigStatus = (configId: string | number, status: string) => {
  const data = {
    configId,
    status
  };
  return request({
    url: '/system/screeningAssessmentConfig/changeStatus',
    method: 'put',
    data: data
  });
};

/**
 * 删除筛查/评估配置
 * @param configId
 */
export const delScreeningAssessmentConfig = (configId: string | number | Array<string | number>) => {
  return request({
    url: '/system/screeningAssessmentConfig/' + configId,
    method: 'delete'
  });
};
