import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { WardVO, WardForm, WardQuery } from '@/api/system/ward/types';

/**
 * 查询病区管理列表
 * @param query
 * @returns {*}
 */

export const listWard = (query?: WardQuery): AxiosPromise<WardVO[]> => {
  return request({
    url: '/system/ward/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询病区管理详细
 * @param wardId
 */
export const getWard = (wardId: string | number): AxiosPromise<WardVO> => {
  return request({
    url: '/system/ward/' + wardId,
    method: 'get'
  });
};

export const listUsed = (): AxiosPromise<WardVO> => {
  return request({
    url: '/system//ward/listUsed',
    method: 'get'
  });
};

/**
 * 新增病区管理
 * @param data
 */
export const addWard = (data: WardForm) => {
  return request({
    url: '/system/ward',
    method: 'post',
    data: data
  });
};

/**
 * 修改病区管理
 * @param data
 */
export const updateWard = (data: WardForm) => {
  return request({
    url: '/system/ward',
    method: 'put',
    data: data
  });
};

/**
 * 删除病区管理
 * @param wardId
 */
export const delWard = (wardId: string | number | Array<string | number>) => {
  return request({
    url: '/system/ward/' + wardId,
    method: 'delete'
  });
};
