// src/api/mes/hw/hardwareinfo.ts
import request from '@/config/axios'

export interface HardwareVO {
  id?: number
  hardwareCode: string
  hardwareName: string
  hardwareTypeId?: number
  workshopId?: number
  enableFlag?: string
  remark?: string
  createBy?: string
  createTime?: Date
  updateBy?: string
  updateTime?: Date
}

export interface WorkshopVO {
  id: number
  workshopCode: string
  workshopName: string
  enableFlag?: string
}

export interface PageParam {
  pageNo: number
  pageSize: number
  hardwareCode?: string
  hardwareName?: string
  hardwareTypeId?: number
  workshopId?: number
  enableFlag?: string
}

// 查询硬件-列表
export const listHardware = async (params: PageParam) => {
  return await request.get({ url: '/iscs/hardware/getHardwarePage', params })
}

// 获取所有车间
export const listAllWorkshop = async () => {
  return await request.get<WorkshopVO[]>({ url: '/mes/md/workshop/listAll' })
}

// 获取硬件详细信息
export const getHardwareInfo = async (id: number) => {
  return await request.get<HardwareVO>({
    url: '/iscs/hardware/selectHardwareById',
    params: { id }
  })
}

// 新增硬件信息
export const addHardware = async (data: HardwareVO) => {
  return await request.post({ url: '/iscs/hardware/insertHardware', data })
}

// 修改硬件
export const updateHardware = async (data: HardwareVO) => {
  return await request.put({ url: '/iscs/hardware/updateHardware', data })
}

// 删除硬件
export const delHardware = async (id: number) => {
  return await request.delete({
    url: '/iscs/hardware/deleteHardwareList',
    params: { ids: id }
  })
}
