import request from '@/config/axios'

// 模具上下模 VO
export interface MoldOperateVO {
  id: number // ID
  operateType: string // 操作类型
  moldId: number | string // 关联模具id（上模/下模剩余模具，支持逗号分隔）
  deviceId: number // 关联设备id
  remark: string // 备注
  lowerMoldId?: number | string // 下模的模具id
}

// 模具上下模 API
export const MoldOperateApi = {
  // 查询模具上下模分页
  getMoldOperatePage: async (params: any) => {
    return await request.get({ url: `/mes/mold-operate/page`, params })
  },

  // 查询模具上下模详情
  getMoldOperate: async (id: number) => {
    return await request.get({ url: `/mes/mold-operate/get?id=` + id })
  },

  // 新增模具上下模
  createMoldOperate: async (data: MoldOperateVO) => {
    return await request.post({ url: `/mes/mold-operate/create`, data })
  },

  // 修改模具上下模
  updateMoldOperate: async (data: MoldOperateVO) => {
    return await request.put({ url: `/mes/mold-operate/update`, data })
  },

  // 删除模具上下模
  deleteMoldOperate: async (id: number) => {
    return await request.delete({ url: `/mes/mold-operate/delete?id=` + id })
  },

  // 导出模具上下模 Excel
  exportMoldOperate: async (params) => {
    return await request.download({ url: `/mes/mold-operate/export-excel`, params })
  },

  // 查询设备可下模具列表
  getLowerMoldList: async (id: number) => {
    return await request.get({ url: `/mes/mold-operate/getLowerMoldList`, params: { id } })
  },
}
