import request from '@/utils/request'

const maTypeUrl = '/material/base/type/getMaType' // 物品类型+配件
const addOrUpdateUrl = '/material/maWhole/addOrUpdate' // 添加
const selectListUrl = '/material/maWhole/selectList' // 查询首页
const selectListByIdUrl = '/material/maWhole/selectListById' // 查询详情
const deleteByIdUrl = '/material/maWhole/deleteById' // 删除
const treeTypeUrl = '/system/select/getDeviceTypeTree' // 设备树
const selectListTreeUrl = '/material/maWhole/selectListTree' // 编辑查询

// 物品类型 选择配件
export function getMaType(query) {
  return request({
    url: maTypeUrl,
    method: 'get',
    params: query,
  })
}

// 设备树
export function getDeviceTypeTree(params = {}) {
  return request({
    url: treeTypeUrl,
    method: 'post',
    data: params
  })
}

// 新增
export function addOrUpdateWhole(data) {
  return request({
    url: addOrUpdateUrl,
    method: 'post',
    data,
  })
}

// 查询首页
export function searchSelectList(data = {}) {
  return request({
    url: selectListUrl,
    method: 'post',
    data,
  })
}

// 查询详情
export function searchSelectListById(data) {
  return request({
    url: selectListByIdUrl,
    method: 'post',
    data,
  })
}

// 删除
export function deleteById(data) {
  return request({
    url: deleteByIdUrl,
    method: 'post',
    data,
  })
}

// 编辑
export function editRequest(data) {
  return request({
    url: selectListTreeUrl,
    method: 'post',
    data,
  })
}