import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CategoryVO, CategoryForm, CategoryQuery } from '@/api/warehouse/suppliesCategory/types';

/**
 * 查询耗材分类列表
 * @param query
 * @returns {*}
 */

export const listSuppliesCategory = (query?: CategoryQuery): AxiosPromise<CategoryVO[]> => {
  return request({
    url: '/warehouse/supplies/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询耗材分类详细
 * @param categoryId
 */
export const getSuppliesCategory = (categoryId: string | number): AxiosPromise<CategoryVO> => {
  return request({
    url: '/warehouse/supplies/' + categoryId,
    method: 'get'
  });
};

/**
 * 新增耗材分类
 * @param data
 */
export const addSuppliesCategory = (data: CategoryForm) => {
  return request({
    url: '/warehouse/supplies',
    method: 'post',
    data: data
  });
};

/**
 * 修改耗材分类
 * @param data
 */
export const updateSuppliesCategory = (data: CategoryForm) => {
  return request({
    url: '/warehouse/supplies',
    method: 'put',
    data: data
  });
};

/**
 * 删除耗材分类
 * @param categoryId
 */
export const delSuppliesCategory = (categoryId: string | number | Array<string | number>) => {
  return request({
    url: '/warehouse/supplies/' + categoryId,
    method: 'delete'
  });
};
