import request from '@/config/axios'

export interface SegregationPointVO {
  pointId?: number
  pointCode: string
  pointName: string
  pointIcon?: string
  pointPicture?: string
  pointNfc: string
  workstationId: number
  lotoId: number
  powerType?: string
  pointSerialNumber?: string
  remark?: string
  createTime?: Date
}

export interface PageParam {
  current: number
  size: number
  pointCode?: string
  pointName?: string
  workstationId?: number
  lotoId?: number
}

// 查询隔离点列表
export const getIsIsolationPointPage = async (params: PageParam) => {
  return await request.get({ url: '/iscs/isolation-point/getIsolationPointPage', params })
}

// 查询隔离点详情
export const selectIsIsolationPointById = async (id: number) => {
  return await request.get({ url: '/iscs/isolation-point/selectIsolationPointById', params: { id: id } })
}

// 新增隔离点
export const addinsertIsIsolationPoint = async (data: SegregationPointVO) => {
  return await request.post({ url: '/iscs/isolation-point/insertIsolationPoint', data })
}

// 修改隔离点
export const updateIsIsolationPoint = async (data: SegregationPointVO) => {
  return await request.put({ url: '/iscs/isolation-point/updateIsolationPoint', data })
}

// 删除隔离点
export const deleteIsIsolationPointByPointIds = async (ids: number) => {
  return await request.delete({
    url: '/iscs/isolation-point/deleteIsolationPointList',
    params: { ids: ids }
  })
}

// 查询车间列表
export const getWorkshopList = async () => {
  return await request.get({ url: '/mes/md/workshop/listAll' })
}

// 查询工作区域列表
export const getWorkareaList = async (workshopId: number) => {
  return await request.get({
    url: '/iscs/workarea/getIsWorkareaList',
    params: { workshopId }
  })
}
