import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { InspectionRulesVO, InspectionRulesForm, InspectionRulesQuery } from '@/api/qms/inspectionRules/types';

/**
 * 查询检验规则列表
 * @param query
 * @returns {*}
 */

export const listInspectionRules = (query?: InspectionRulesQuery): AxiosPromise<InspectionRulesVO[]> => {
  return request({
    url: '/qms/inspectionRules/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询检验规则详细
 * @param ruleId
 */
export const getInspectionRules = (ruleId: string | number): AxiosPromise<InspectionRulesVO> => {
  return request({
    url: '/qms/inspectionRules/' + ruleId,
    method: 'get'
  });
};

/**
 * 新增检验规则
 * @param data
 */
export const addInspectionRules = (data: InspectionRulesForm) => {
  return request({
    url: '/qms/inspectionRules',
    method: 'post',
    data: data
  });
};

/**
 * 修改检验规则
 * @param data
 */
export const updateInspectionRules = (data: InspectionRulesForm) => {
  return request({
    url: '/qms/inspectionRules',
    method: 'put',
    data: data
  });
};

/**
 * 删除检验规则
 * @param ruleId
 */
export const delInspectionRules = (ruleId: string | number | Array<string | number>) => {
  return request({
    url: '/qms/inspectionRules/' + ruleId,
    method: 'delete'
  });
};


/**
 * 下拉框查询检验规则列表
 * @param query
 * @returns {*}
 */
export function getQcInspectionRulesList (query) {
    return request({
        url: '/qms/inspectionRules/getQcInspectionRulesList',
        method: 'get',
        params: query
    });
};
