import { request } from '@/api/request'

/** 获取供应商列表（分页） */
export const fetchSupplierList = (data?: { page?: number; page_size?: number; keyword?: string; status?: string; enabled?: boolean }) => {
  return request.post('/Assets/v1/supplier/list', data || {})
}

/** 获取供应商详情 */
export const fetchSupplierDetail = (id: number) => {
  return request.get(`/Assets/v1/supplier/detail/${id}`)
}

/** 创建供应商 */
export const createSupplier = (data: any) => {
  return request.post('/Assets/v1/supplier/create', data)
}

/** 更新供应商 */
export const updateSupplier = (data: any) => {
  return request.put('/Assets/v1/supplier/update', data)
}

/** 删除供应商 */
export const deleteSupplier = (id: number) => {
  return request.delete(`/Assets/v1/supplier/delete/${id}`)
}

/** 获取所有供应商（用于下拉选择） */
export const fetchAllSuppliers = (keyword?: string, status?: string, pageSize?: number) => {
  const params: any = {}
  if (keyword) params.keyword = keyword
  if (status) params.status = status
  if (pageSize) params.page_size = pageSize
  return request.get('/Assets/v1/supplier/all', { params })
}
