import request from '@/config/axios'

// 模具维保 VO
export interface MoldRecordVO {
  id: number // ID
  flowCode: string // 流程ID
  brandId: number // 模具型号ID
  moldId: number // 模具ID
  oldMoldId: number // 前模具ID
  machineId: number // 机台ID
  userId: number // 负责人ID
  recordType: string // 单据类型
  recordStatus: string // 状态
  remark: string // 备注
}

// 模具维保 API
export const MoldRecordApi = {
  // 查询模具维保分页
  getMoldRecordPage: async (params: any) => {
    return await request.get({ url: `/mes/mold-record/page`, params })
  },

  // 查询模具维保详情
  getMoldRecord: async (id: number) => {
    return await request.get({ url: `/mes/mold-record/get?id=` + id })
  },

  // 新增模具维保
  createMoldRecord: async (data: MoldRecordVO) => {
    return await request.post({ url: `/mes/mold-record/create`, data })
  },

  // 修改模具维保
  updateMoldRecord: async (data: MoldRecordVO) => {
    return await request.put({ url: `/mes/mold-record/update`, data })
  },

  // 删除模具维保
  deleteMoldRecord: async (id: number) => {
    return await request.delete({ url: `/mes/mold-record/delete?id=` + id })
  },

  // 导出模具维保 Excel
  exportMoldRecord: async (params) => {
    return await request.download({ url: `/mes/mold-record/export-excel`, params })
  },

// ==================== 子表（模具维保明细） ====================

  // 获得模具维保明细列表
  getMoldRecordSubjectDetailListByRecordId: async (recordId) => {
    return await request.get({ url: `/mes/mold-record/mold-record-subject-detail/list-by-record-id?recordId=` + recordId })
  }
}