import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { InspectionItemsVO, InspectionItemsForm, InspectionItemsQuery } from '@/api/qms/inspectionItems/types';

/**
 * 查询检验项目基础列表
 * @param query
 * @returns {*}
 */

export const listInspectionItems = (query?: InspectionItemsQuery): AxiosPromise<InspectionItemsVO[]> => {
  return request({
    url: '/qms/inspectionItems/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询检验项目基础详细
 * @param inspectionItemId
 */
export const getInspectionItems = (inspectionItemId: string | number): AxiosPromise<InspectionItemsVO> => {
  return request({
    url: '/qms/inspectionItems/' + inspectionItemId,
    method: 'get'
  });
};

/**
 * 新增检验项目基础
 * @param data
 */
export const addInspectionItems = (data: InspectionItemsForm) => {
  return request({
    url: '/qms/inspectionItems',
    method: 'post',
    data: data
  });
};

/**
 * 修改检验项目基础
 * @param data
 */
export const updateInspectionItems = (data: InspectionItemsForm) => {
  return request({
    url: '/qms/inspectionItems',
    method: 'put',
    data: data
  });
};

/**
 * 删除检验项目基础
 * @param inspectionItemId
 */
export const delInspectionItems = (inspectionItemId: string | number | Array<string | number>) => {
  return request({
    url: '/qms/inspectionItems/' + inspectionItemId,
    method: 'delete'
  });
};


/**
 * 下拉框查询检验项目基础列表
 * @param query
 * @returns {*}
 */
export function getQcInspectionItemsList (query) {
    return request({
        url: '/qms/inspectionItems/getQcInspectionItemsList',
        method: 'get',
        params: query
    });
};
