import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SuppliesManageVO, SuppliesManageForm, SuppliesManageQuery } from '@/api/warehouse/suppliesManage/types';

/**
 * 查询耗材管理列表
 * @param query
 * @returns {*}
 */

export const listSuppliesManage = (query?: SuppliesManageQuery): AxiosPromise<SuppliesManageVO[]> => {
  return request({
    url: '/warehouse/suppliesManage/list',
    method: 'get',
    params: query
  });
};

export const listAll = ( ): AxiosPromise<SuppliesManageVO[]> => {
  return request({
    url: '/warehouse/suppliesManage/listAll',
    method: 'get'     
  });
};

/**
 * 查询耗材管理详细
 * @param id
 */
export const getSuppliesManage = (id: string | number): AxiosPromise<SuppliesManageVO> => {
  return request({
    url: '/warehouse/suppliesManage/' + id,
    method: 'get'
  });
};

/**
 * 新增耗材管理
 * @param data
 */
export const addSuppliesManage = (data: SuppliesManageForm) => {
  return request({
    url: '/warehouse/suppliesManage',
    method: 'post',
    data: data
  });
};

/**
 * 修改耗材管理
 * @param data
 */
export const updateSuppliesManage = (data: SuppliesManageForm) => {
  return request({
    url: '/warehouse/suppliesManage',
    method: 'put',
    data: data
  });
};

export function batchUpdateSuppliesManage(data) {
  return request({
    url: '/warehouse/suppliesManage/batchUpdate',
    method: 'post',
    data
  });
}

/**
 * 删除耗材管理
 * @param id
 */
export const delSuppliesManage = (id: string | number | Array<string | number>) => {
  return request({
    url: '/warehouse/suppliesManage/' + id,
    method: 'delete'
  });
};

/**
 * 更新上架状态
 * @param id
 * @param flag
 */
export const updatePutFlag = (id: string | number, flag: string) => {
  return request({
    url: `/warehouse/suppliesManage/${id}/putFlag/${flag}`,
    method: 'put'
  });
};
