import request from '@/config/axios'

export interface MoldRepairVO {
  id: number
  repairCode: string
  repairName: string
  moldId?: number
  moldCode?: string
  moldName?: string
  machineryId?: number
  machineryCode?: string
  machineryName?: string
  machineryBrand: string
  machinerySpec: string
  machineryTypeId: number
  requireDate: Date
  finishDate: Date
  confirmDate: Date
  repairResult: string
  acceptedBy: string
  confirmBy: string
  status: string
  remark: string
}

export type MoldRepairSaveVO = Omit<MoldRepairVO, 'machineryId' | 'machineryCode' | 'machineryName'>

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

  getMoldRepair: async (id: number) => {
    return await request.get({ url: `/mes/mold-repair/get?id=` + id })
  },

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

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

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

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

  updateMoldRepairStatus: async (data: any) => {
    return await request.put({ url: `/mes/mold-repair/updateMoldRepairStatus`, data })
  },

  getMoldRepairLineListByRepairId: async (repairId) => {
    return await request.get({ url: `/mes/mold-repair/mold-repair-line/list-by-repair-id?repairId=` + repairId })
  },

  getRepairListByMoldId: async (params: { moldId: number; startTime?: string; endTime?: string }) => {
    return await request.get({ url: `/mes/mold-repair/getRepairListByMoldId`, params })
  },

  exportRepairExcel: async (params: { moldId: number; startTime?: string; endTime?: string }) => {
    return await request.download({ url: `/mes/mold-repair/export-repair-excel`, params })
  }
}
