import request from '@/config/axios'

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

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

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

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

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

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

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

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