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

const prefix = 'special-prescription/';

export async function getSpecialPrescriptionList(data: any) {
  return requestClient.get<any>(`${prefix}list`, { params: data });
}

export async function getSpecialPrescriptionInfo(id: number) {
  return requestClient.get<any>(`${prefix}detail`, { params: { id } });
}

export async function createSpecialPrescription(data: Record<string, any>) {
  return requestClient.post<any>(`${prefix}create`, data);
}

export async function updateSpecialPrescription(data: Record<string, any>) {
  return requestClient.post<any>(`${prefix}update`, data);
}

/** 上下架状态切换（列表 Tag 点击） */
export async function updateSpecialPrescriptionStatus(data: {
  id: number;
  status: number;
}) {
  return requestClient.post<any>(`${prefix}update-status`, data);
}

export async function deleteSpecialPrescription(data: Record<string, any>) {
  return requestClient.post<any>(`${prefix}delete`, data);
}

export async function applySpecialPrescriptionApi(data: { register_id: number }) {
  return requestClient.post<any>(`${prefix}apply`, data);
}

/** 自动均分药品单价 */
export async function distributeDrugPricesApi(data: Record<string, any>) {
  return requestClient.post<any>(`${prefix}distribute-drug-prices`, data);
}

/** 价格配置详情（路由与 cc_auto_route_register 生成的 price-config-detail 对齐） */
export async function getSpecialPrescriptionPriceConfig(id: number) {
  return requestClient.get<any>(`${prefix}price-config-detail`, { params: { id } });
}

/** 保存价格配置 */
export async function saveSpecialPrescriptionPriceConfig(data: Record<string, any>) {
  return requestClient.post<any>(`${prefix}save-price-config`, data);
}
