import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { LevelInfoVO, LevelInfoForm, LevelInfoQuery } from '@/api/qms/levelInfo/types';

/**
 * 查询层级信息列表
 * @param query
 * @returns {*}
 */

export const listLevelInfo = (query?: LevelInfoQuery): AxiosPromise<LevelInfoVO[]> => {
  return request({
    url: '/qms/levelInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询层级信息详细
 * @param levelId
 */
export const getLevelInfo = (levelId: string | number): AxiosPromise<LevelInfoVO> => {
  return request({
    url: '/qms/levelInfo/' + levelId,
    method: 'get'
  });
};

/**
 * 新增层级信息
 * @param data
 */
export const addLevelInfo = (data: LevelInfoForm) => {
  return request({
    url: '/qms/levelInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改层级信息
 * @param data
 */
export const updateLevelInfo = (data: LevelInfoForm) => {
  return request({
    url: '/qms/levelInfo',
    method: 'put',
    data: data
  });
};

/**
 * 删除层级信息
 * @param levelId
 */
export const delLevelInfo = (levelId: string | number | Array<string | number>) => {
  return request({
    url: '/qms/levelInfo/' + levelId,
    method: 'delete'
  });
};


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