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

const prefix = 'western-medicine/';

/**
 * 分页查询用户列表
 * @param data
 */
export async function getWesternMedicineList(data: any) {
  return requestClient.get<any>(`${prefix}list`, { params: data });
}

/**
 * 分页查询用户列表
 * @param data
 */
export async function getWesternMedicineOption(data: any) {
  return requestClient.get<any>(`${prefix}option`, { params: data });
}

/**
 * 获取西（中成）药详情
 * @param id
 */
export async function getWesternMedicineInfo(id: number) {
  return requestClient.get<any>(`${prefix}detail`, { params: { id } });
}

/**
 * 导出西药药品
 */
export async function exportWesternMedicineApi() {
  return requestClient.download(`${prefix}export`);
}

/**
 * 新增西（中成）药
 * @param data
 */
export async function createWesternMedicine(data: Record<string, any>) {
  return requestClient.post<any>(`${prefix}create`, data);
}

/**
 * 编辑西（中成）药
 * @param data
 */
export async function updateWesternMedicine(data: Record<string, any>) {
  return requestClient.post<any>(`${prefix}update`, data);
}

/**
 * 删除西（中成）药
 * @param data
 */
export async function deleteWesternMedicine(data: Record<string, any>) {
  return requestClient.post<any>(`${prefix}delete`, data);
}

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

/**
 * 更新药品分区分类
 * @param data
 */
export async function updateZoneCategory(data: Record<string, any>) {
  return requestClient.post<any>(`${prefix}update-zone-category`, data);
}

/**
 * 更新最低调整金额
 * @param data
 */
export async function updateMinAdjustPrice(data: {
  id: number;
  min_adjust_price: number | null;
  max_adjust_price?: number | null;
}) {
  return requestClient.post<any>(`${prefix}update-min-adjust-price`, data);
}

/**
 * 更新 ERP 抓取数量倍数
 * @param data
 */
export async function updateErpQtyFactor(data: { id: number; erp_qty_factor: number }) {
  return requestClient.post<any>(`${prefix}update-erp-qty-factor`, data);
}

/**
 * 同步空拼音（首拼/全拼/数字串）
 */
export async function syncWesternMedicinePinyin() {
  return requestClient.post<any>(`${prefix}sync-pinyin`, {});
}
