import http from '@/api'
import { SparePartsVO, SparePartsForm, SparePartsQuery } from '@/api/interface/als/spareParts'
/**
 * @name 查询部件列表
 * @param query 参数
 * @returns 返回列表
 */
export const listSparePartsApi = (query: SparePartsQuery) => {
  return http.get<SparePartsVO[]>('/als/spareParts/list', query, { loading: true })
}

/**
 * @name 查询部件详细
 * @param id id
 * @returns returns
 */
export const getSparePartsApi = (id: string | number) => {
  return http.get<SparePartsVO>(`/als/spareParts/${id}`)
}

/**
 * @name 新增部件
 * @param data data
 * @returns returns
 */
export const addSparePartsApi = (data: SparePartsForm) => {
  return http.post<any>('/als/spareParts', data, { loading: false })
}

/**
 * @name 修改部件
 * @param data data
 * @returns returns
 */
export const updateSparePartsApi = (data: SparePartsForm) => {
  return http.put<any>('/als/spareParts', data, { loading: false })
}

/**
 * @name 删除部件
 * @param id id
 * @returns returns
 */
export const delSparePartsApi = (id: string | number | Array<string | number>) => {
  return http.delete<any>(`/als/spareParts/${id}`)
}

/**
 * @name 下载模板
 * @returns returns
 */
export const importTemplateApi = () => {
  return http.downloadPost('/als/spareParts/importTemplate', {})
}

/**
 * @name 导入数据
 * @returns returns
 */
export const importSparePartsDataApi = (data: any) => {
  return http.post('/als/spareParts/importData', data)
}

/**
 * @name 导出数据
 * @returns returns
 */
export const exportSparePartsApi = (data: any) => {
  return http.post('/als/spareParts/export', data)
}
