import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DefectDetailVO, DefectDetailForm, DefectDetailQuery } from '@/api/qms/defectDetail/types';

/**
 * 查询病疵详细列表
 * @param query
 * @returns {*}
 */

export const listDefectDetail = (query?: DefectDetailQuery): AxiosPromise<DefectDetailVO[]> => {
  return request({
    url: '/qms/defectDetail/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询病疵详细详细
 * @param defectDetailId
 */
export const getDefectDetail = (defectDetailId: string | number): AxiosPromise<DefectDetailVO> => {
  return request({
    url: '/qms/defectDetail/' + defectDetailId,
    method: 'get'
  });
};

/**
 * 新增病疵详细
 * @param data
 */
export const addDefectDetail = (data: DefectDetailForm) => {
  return request({
    url: '/qms/defectDetail',
    method: 'post',
    data: data
  });
};

/**
 * 修改病疵详细
 * @param data
 */
export const updateDefectDetail = (data: DefectDetailForm) => {
  return request({
    url: '/qms/defectDetail',
    method: 'put',
    data: data
  });
};

/**
 * 删除病疵详细
 * @param defectDetailId
 */
export const delDefectDetail = (defectDetailId: string | number | Array<string | number>) => {
  return request({
    url: '/qms/defectDetail/' + defectDetailId,
    method: 'delete'
  });
};


/**
 * 下拉框查询病疵详细列表
 * @param query
 * @returns {*}
 */
export function getQcDefectDetailList (query) {
    return request({
        url: '/qms/defectDetail/getQcDefectDetailList',
        method: 'get',
        params: query
    });
};
