import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { TaskVO, TaskForm, TaskQuery, TaskDetailAuditForm, TaskLogQuery, TaskLogVO } from '@/api/qc/task/types';

/**
 * 查询文档质控任务列表
 * @param query
 * @returns {*}
 */

export const listTask = (query?: TaskQuery): AxiosPromise<TaskVO[]> => {
  return request({
    url: '/qc/task/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询文档质控任务详细
 * @param id
 */
export const getTask = (id: string | number): AxiosPromise<TaskVO> => {
  return request({
    url: '/qc/task/' + id,
    method: 'get'
  });
};

/**
 * 新增文档质控任务
 * @param data
 */
export const addTask = (data: TaskForm) => {
  return request({
    url: '/qc/task',
    method: 'post',
    data: data
  });
};

/**
 * 修改文档质控任务
 * @param data
 */
export const updateTask = (data: TaskForm) => {
  return request({
    url: '/qc/task',
    method: 'put',
    data: data
  });
};

/**
 * 删除文档质控任务
 * @param id
 */
export const delTask = (id: string | number | Array<string | number>) => {
  return request({
    url: '/qc/task/' + id,
    method: 'delete'
  });
};

/**
 * 开始文档质控任务
 * @param id
 */
export const startTask = (id: string | number): AxiosPromise<any> => {
  return request({
    url: '/qc/task/' + id,
    method: 'put'
  });
};

/**
 * 生成质控任务详情
 * @param projectId
 */
export const generateTaskDetail = (projectId: string | number): AxiosPromise<any> => {
  return request({
    url: '/qcTask/detail/generate',
    method: 'get',
    params: { projectId }
  });
};

/**
 * 查询质控任务详情列表
 * @param query
 */
export const listTaskDetail = (query?: any): AxiosPromise<any> => {
  return request({
    url: '/qcTask/detail/listPage',
    method: 'get',
    params: query
  });
};

/**
 * 审核质控任务详情
 * @param data
 */
export const auditTaskDetail = (data: TaskDetailAuditForm): AxiosPromise<any> => {
  return request({
    url: '/qcTask/detail/audit',
    method: 'put',
    data: data
  });
};

/**
 * 查询质控任务审核记录
 * @param query
 */
export const listTaskLogOnDetail = (query?: any): AxiosPromise<any> => {
  return request({
    url: '/qcTask/log/listOnDetail',
    method: 'get',
    params: query
  });
};
