import request from '@/config/axios'

export interface RepairItemVO {
  id?: number
  subjectCode: string
  subjectName: string
  deviceType: string | number
  deviceId?: string | number
  componentId?: string | number
  inspectionMethod?: string
  valueType?: string
  judgmentCriteria?: string
  isEnable: string
  deviceName?: string
  componentName?: string
  creatorName?: string
  createTime?: string | number | Date
  projectContent?: string
}

export const RepairItemsApi = {
  getRepairItemsPage: async (params: any) => {
    return await request.get({ url: `/mes/repair-tems/page`, params })
  },

  getComponentList: async (deviceId: number) => {
    return await request.get({ url: `/mes/repair-tems/getComponentList`, params: { deviceId } })
  },

  getDeviceOrComponentList: async (params: { deviceId: number; componentId?: number; deviceType: number }) => {
    return await request.get({ url: `/mes/repair-tems/getDeviceOrComponentList`, params })
  },

  createRepairItem: async (data: RepairItemVO) => {
    return await request.post({ url: `/mes/repair-tems/create`, data })
  },

  updateRepairItem: async (data: RepairItemVO) => {
    return await request.put({ url: `/mes/repair-tems/update`, data })
  },

  deleteRepairItems: async (ids: string) => {
    return await request.delete({ url: `/mes/repair-tems/delete?ids=` + ids })
  },

  exportRepairItems: async (params: any) => {
    return await request.download({ url: `/mes/repair-tems/export-excel`, params })
  }
}
