import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DefectInfoVO, DefectInfoForm, DefectInfoQuery } from '@/api/qms/defectInfo/types';

/**
 * 查询病疵信息列表
 * @param query
 * @returns {*}
 */

export const listDefectInfo = (query?: DefectInfoQuery): AxiosPromise<DefectInfoVO[]> => {
  return request({
    url: '/qms/defectInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询病疵信息详细
 * @param defectId
 */
export const getDefectInfo = (defectId: string | number): AxiosPromise<DefectInfoVO> => {
  return request({
    url: '/qms/defectInfo/' + defectId,
    method: 'get'
  });
};

/**
 * 新增病疵信息
 * @param data
 */
export const addDefectInfo = (data: DefectInfoForm) => {
  return request({
    url: '/qms/defectInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改病疵信息
 * @param data
 */
export const updateDefectInfo = (data: DefectInfoForm) => {
  return request({
    url: '/qms/defectInfo',
    method: 'put',
    data: data
  });
};

/**
 * 删除病疵信息
 * @param defectId
 */
export const delDefectInfo = (defectId: string | number | Array<string | number>) => {
  return request({
    url: '/qms/defectInfo/' + defectId,
    method: 'delete'
  });
};


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