import request from '@/config/axios'

// PMS 库区 VO
export interface IotStorageAreaVO {
  id: number // 主键
  deptId: number // 部门id
  factoryId: number // 工厂id(SAP) 专业公司id system_sap_org表id
  factoryCode: string // 工厂code
  factoryName: string // 工厂name
  costCenterId: number // 成本中心id (system_sap_org表id)
  costCenterCode: string // 成本中心 code
  storageLocationId: number // 库存地点id (system_sap_org表id)
  storageLocationCode: string // 库存地点编码
  storageLocationName: string // 库存地点名称
  code: string // 库区编码
  name: string // 库区名称
  type: number // 库区类型
  sort: number // 显示顺序
  status: number // 状态 0启用  1停用
  remark: string // 备注
}

// PMS 库区 API
export const IotStorageAreaApi = {
  // 查询PMS 库区分页
  getIotStorageAreaPage: async (params: any) => {
    return await request.get({ url: `/pms/iot-storage-area/page`, params })
  },

  getSimpleStorageAreaList: async (): Promise<IotStorageAreaVO[]> => {
    return await request.get({ url: '/pms/iot-storage-area/simple-list' })
  },

  // 查询PMS 库区详情
  getIotStorageArea: async (id: number) => {
    return await request.get({ url: `/pms/iot-storage-area/get?id=` + id })
  },

  // 新增PMS 库区
  createIotStorageArea: async (data: IotStorageAreaVO) => {
    return await request.post({ url: `/pms/iot-storage-area/create`, data })
  },

  // 修改PMS 库区
  updateIotStorageArea: async (data: IotStorageAreaVO) => {
    return await request.put({ url: `/pms/iot-storage-area/update`, data })
  },

  // 删除PMS 库区
  deleteIotStorageArea: async (id: number) => {
    return await request.delete({ url: `/pms/iot-storage-area/delete?id=` + id })
  },

  // 导出PMS 库区 Excel
  exportIotStorageArea: async (params) => {
    return await request.download({ url: `/pms/iot-storage-area/export-excel`, params })
  },
}
