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

const prefix = 'warehouse-drug-management-store/';

/**
 * 分页查询诊所仓库商品列表
 * @param data
 */
export async function getWarehouseDrugManagementStoreList(data: any) {
  return requestClient.get<any>(`${prefix}list`, { params: data });
}

/**
 * 分页查询诊所仓库商品列表
 * @param data
 */
export async function getWarehouseDrugManagementStoreOption(data: any) {
  return requestClient.get<any>(`${prefix}option`, { params: data });
}

/** 仓库筛选：商品类型（与后端 ProductTypeEnum 一致） */
export async function getWarehouseProductTypeOptions() {
  return requestClient.get<{ label: string; value: number }[]>(
    `${prefix}product-type-options`,
  );
}

/**
 * 获取诊所仓库商品药详情
 * @param id
 */
export async function getWarehouseDrugManagementStoreInfo(id: number) {
  return requestClient.get<any>(`${prefix}detail`, { params: { id } });
}

/**
 * 上架/下架
 * @param id
 */
export async function updateWarehouseDrugManagementStoreStatusApi(id: number) {
  return requestClient.get<any>(`${prefix}update-status`, { params: { id } });
}

/**
 * 上架/下架
 * @param id
 */
export async function updateWarehouseDrugManagementShopUpdateStatusApi(id: number) {
  return requestClient.get<any>(`${prefix}shop-update-status`, { params: { id } });
}

/**
 * 导出仓库药品药品
 */
export async function exportWarehouseDrugManagementStoreApi(params?: { type?: number }) {
  return requestClient.download(`${prefix}export`, { params });
}
/**
 * 导出仓库药品药品 - 模板
 */
export async function exportWarehouseDrugManagementStoreTemplateApi() {
  return requestClient.download(`${prefix}export-template`);
}

/**
 * 新增诊所仓库商品药
 * @param data
 */
export async function createWarehouseDrugManagementStore(data: Record<string, any>) {
  return requestClient.post<any>(`${prefix}create`, data);
}

/**
 * 编辑诊所仓库商品药
 * @param data
 */
export async function updateWarehouseDrugManagementStore(data: Record<string, any>) {
  return requestClient.post<any>(`${prefix}update`, data);
}

/**
 * 删除诊所仓库商品药
 * @param data
 */
export async function deleteWarehouseDrugManagementStore(data: Record<string, any>) {
  return requestClient.post<any>(`${prefix}delete`, data);
}

/**
 * 导入仓库药品
 * @param data
 */
export async function importWarehouseDrugManagementStoreApi(data: Record<string, any>) {
  return requestClient.upload(`${prefix}import`, data);
}

/**
 * 导入仓库药品修改价格
 * @param data
 */
export async function importUpdatePriceApi(data: Record<string, any>) {
  return requestClient.upload(`${prefix}import-update-price`, data);
}

/**
 * 同步总仓库api
 * @param data
 */
export async function syncDrugApi(params?: Record<string, any>) {
  return requestClient.get(`${prefix}sync-drug`, { params });
}

/**
 * 同步总仓库价格api
 * @param params
 */
export async function syncDrugPriceApi(params?: Record<string, any>) {
  return requestClient.get(`${prefix}sync-drug-price`, { params });
}

/**
 * 检查订阅总仓库价格api
 */
export async function checkSubscribeApi() {
  return requestClient.get(`${prefix}check-subscribe`);
}

/**
 * 订阅总仓库价格api
 */
export async function subscribeApi() {
  return requestClient.get(`${prefix}subscribe`);
}
