import { requestClient } from '#/api/request';

const prefix = 'delivery-warehouse-drug/';

/**
 * 分页查询仓药绑定列表
 */
export async function getDeliveryWarehouseDrugList(data: any) {
  return requestClient.get<any>(`${prefix}list`, { params: data });
}

/**
 * 获取仓药绑定详情
 */
export async function getDeliveryWarehouseDrugInfo(id: number) {
  return requestClient.get<any>(`${prefix}detail`, { params: { id } });
}

/**
 * 新增仓药绑定
 */
export async function createDeliveryWarehouseDrug(data: Record<string, any>) {
  return requestClient.post<any>(`${prefix}create`, data);
}

/**
 * 编辑仓药绑定
 */
export async function updateDeliveryWarehouseDrug(data: Record<string, any>) {
  return requestClient.post<any>(`${prefix}update`, data);
}

/**
 * 删除仓药绑定
 */
export async function deleteDeliveryWarehouseDrug(data: Record<string, any>) {
  return requestClient.post<any>(`${prefix}delete`, data);
}

/**
 * @deprecated 已禁止直改库存
 */
export async function updateDeliveryWarehouseDrugStock(data: {
  id: number;
  stock: number;
}) {
  return requestClient.post<any>(`${prefix}update-stock`, data);
}

/** 手动入库 */
export async function stockInDeliveryWarehouseDrug(data: {
  id: number;
  qty: number;
  remark?: string;
}) {
  return requestClient.post<any>(`${prefix}stock-in`, data);
}

/** 手动出库 */
export async function stockOutDeliveryWarehouseDrug(data: {
  id: number;
  qty: number;
  remark?: string;
}) {
  return requestClient.post<any>(`${prefix}stock-out`, data);
}

/** 出入库流水 */
export async function getDeliveryWarehouseStockLogList(data: Record<string, any>) {
  return requestClient.get<any>(`${prefix}stock-log-list`, { params: data });
}
