import request from '@/utils/request'

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

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

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

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

// 删除库存
export function delStock(stockId) {
  return request({
    url: '/system/stock/' + stockId,
    method: 'delete'
  })
}


export function frozen(stockIds, value) {
  // 构建查询字符串
  let queryParams = new URLSearchParams();
  queryParams.append('stockIds', stockIds.join(',')); // 假设stockIds是一个数组
  queryParams.append('value', value);

  // 构建完整的URL（这里假设baseUrl是你的API的基础URL）
  let url = `/system/stock/frozen?${queryParams.toString()}`;

  // 发送GET请求
  return request({
    url: url,
    method: 'get'
  });
}

export function thaw(stockId) {
  return request({
    url: '/system/stock/thaw/' + stockId,
    method: 'get'
  })
}

// 查询库位列表数据
export function listWarehouse(query) {
  return request({
    url: '/system/storage/getStorageList',
    method: 'get',
  })
}

