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

const prefix = 'department-finance-report/';

/**
 * 报表批次列表
 */
export async function getDepartmentFinanceReportListApi(params: Record<string, unknown>) {
  return requestClient.get<any>(`${prefix}list`, { params });
}

/**
 * 报表详情
 */
export async function getDepartmentFinanceReportDetailApi(id: number) {
  return requestClient.get<any>(`${prefix}detail`, { params: { id } });
}

/**
 * 诊所药品供货明细
 */
export async function getDepartmentFinanceStoreDrugDetailApi(params: {
  store_id: number;
  report_id?: number;
  search_time?: [string, string];
}) {
  return requestClient.get<any>(`${prefix}store-drug-detail`, { params });
}

/**
 * 手动生成报表（须传统计区间）
 */
export async function generateDepartmentFinanceReportApi(data: {
  search_time: [string, string];
}) {
  return requestClient.post<any>(`${prefix}generate`, data);
}

/**
 * 读取生成配置
 */
export async function getDepartmentFinanceConfigApi() {
  return requestClient.get<any>(`${prefix}config`);
}

/**
 * 保存生成配置
 */
export async function saveDepartmentFinanceConfigApi(data: {
  generate_day: number;
  generate_hour: number;
}) {
  return requestClient.post<any>(`${prefix}save-config`, data);
}
