import request from '@/utils/request'

// 查询库存管理列表
export function listStock(query) {
  return request({
    url: '/assets/stock/list',
    method: 'get',
    params: query
  })
}


// 查询库存管理列表
export function selectlistStock(dbMaterielId, status) {
  if (status == undefined) {
    return request({
      url: '/assets/stock/select/list?dbMaterielId=' + dbMaterielId,
      method: 'get'
    })
  } else {
    return request({
      url: '/assets/stock/select/list?dbMaterielId=' + dbMaterielId + '&status=' + status,
      method: 'get'
    })
  }
}

// 出库物质管理列表
export function outlistStock(depId, leadUserId,status) {
  if(undefined!=status){
    return request({
      url: '/assets/stock/out/list?depId=' + depId + '&leadUserId=' + leadUserId+'&status='+status,
      method: 'get'
    })
  }else{
    return request({
      url: '/assets/stock/out/list?depId=' + depId + '&leadUserId=' + leadUserId,
      method: 'get'
    })
  }
}

// 监听选择
export function selectStockDictLabel(datas, value) {
  var obj
  Object.keys(datas).map((key) => {
    if (datas[key].aId == ('' + value)) {
      obj = datas[key]
      return false
    }
  })
  return obj
}

// 查询库存管理详细
export function getStock(aId) {
  return request({
    url: '/assets/stock/' + aId,
    method: 'get'
  })
}

// 新增库存管理
export function addStock(data) {
  return request({
    url: '/assets/stock',
    method: 'post',
    data: data
  })
}

// 修改库存管理
export function updateStock(data) {
  return request({
    url: '/assets/stock',
    method: 'put',
    data: data
  })
}

// 删除库存管理
export function delStock(aId) {
  return request({
    url: '/assets/stock/' + aId,
    method: 'delete'
  })
}

// 导出库存管理
export function exportStock(query) {
  return request({
    url: '/assets/stock/export',
    method: 'get',
    params: query
  })
}



