import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { QcUnqualifiedReviewVO, QcUnqualifiedReviewForm, QcUnqualifiedReviewQuery, CompleteTaskRequest } from '@/api/qms/qcUnqualifiedReview/types';

/**
 * 查询不合格品待评审列表
 * @param query
 * @returns {*}
 */

export const listQcUnqualifiedReview = (query?: QcUnqualifiedReviewQuery): AxiosPromise<QcUnqualifiedReviewVO[]> => {
  return request({
    url: '/qms/qcUnqualifiedReview/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询不合格品待评审详细
 * @param reviewId
 */
export const getQcUnqualifiedReview = (reviewId: string | number): AxiosPromise<QcUnqualifiedReviewVO> => {
  return request({
    url: '/qms/qcUnqualifiedReview/' + reviewId,
    method: 'get'
  });
};

/**
 * 新增不合格品待评审
 * @param data
 */
export const addQcUnqualifiedReview = (data: QcUnqualifiedReviewForm) => {
  return request({
    url: '/qms/qcUnqualifiedReview',
    method: 'post',
    data: data
  });
};

/**
 * 修改不合格品待评审
 * @param data
 */
export const updateQcUnqualifiedReview = (data: QcUnqualifiedReviewForm) => {
  return request({
    url: '/qms/qcUnqualifiedReview',
    method: 'put',
    data: data
  });
};

/**
 * 删除不合格品待评审
 * @param reviewId
 */
export const delQcUnqualifiedReview = (reviewId: string | number | Array<string | number>) => {
  return request({
    url: '/qms/qcUnqualifiedReview/' + reviewId,
    method: 'delete'
  });
};


/**
 * 下拉框查询不合格品待评审列表
 * @param query
 * @returns {*}
 */
export function getQcUnqualifiedReviewList (query) {
    return request({
        url: '/qms/qcUnqualifiedReview/getQcUnqualifiedReviewList',
        method: 'get',
        params: query
    });
};

/**
 * 删除不合格品待评审
 * @param dispositionType
 * @param reviewId
 */
export const handleUnqualified = (dispositionType: string | number, reviewId: string | number | Array<string | number>) => {
  return request({
    url: '/qms/qcMobile/handleUnqualified/' + dispositionType + '/' + reviewId,
    method: 'get'
  });
};

/**
 * 主管审批
 * @param data
 */
export const completeTask = (data: QcUnqualifiedReviewForm) => {
  return request({
    url: '/qms/qcUnqualifiedReview/completeTask',
    method: 'post',
    data: data
  });
};


