import request from '@/utils/request'

// 创建仓库
export function createWarehouse(data) {
  return request({
    url: '/ecw/warehouse/create',
    method: 'post',
    data: data
  })
}

//创建提单模板
export function createTemplate(data) {
  console.log(data);
  return request({
    url: '/ecw/lading-template/create',
    method: 'post',
    data: data
  })
}

// 更新仓库
export function updateWarehouse(data) {
  return request({
    url: '/ecw/warehouse/update',
    method: 'put',
    data: data
  })
}

// 删除仓库
export function deleteWarehouse(id) {
  return request({
    url: '/ecw/warehouse/delete?id=' + id,
    method: 'delete'
  })
}

// 获得仓库
export function getWarehouse(id) {
  return request({
    url: '/ecw/warehouse/get?id=' + id,
    method: 'get'
  })
}

// 获得仓库分页
export function getWarehousePage(query) {
  return request({
    url: '/ecw/warehouse/page',
    method: 'get',
    params: query
  })
}

// 获得仓库列表
export function getWarehouseList(query) {
  return request({
    url: '/ecw/warehouse/list',
    method: 'get',
    params: query
  })
}

// 导出仓库 Excel
export function exportWarehouseExcel(query) {
  return request({
    url: '/ecw/warehouse/export-excel',
    method: 'get',
    params: query,
    responseType: 'blob'
  })
}

/**所有线路列表 */
export function routerList(data) {
  return request({
    url: '/ecw/warehouse/routerList',
    method: 'post',
    data: data
  })
}

/**修改线路开通状态 */
export function changeRouteStatus(data) {
  return request({
    url: '/ecw/warehouse/changeRouteStatus',
    method: 'post',
    data: data
  })
}

export function getLadingTemplate(data) {
  console.log(data);
  return request({
    url: '/ecw/lading-template/getByLineId?lineId='+data,
    method: 'get'
  })
}

/**查看已开通线路列表 */
export function openedRouterList(data = {}) {
  return request({
    url: '/ecw/warehouse/openedRouterList',
    method: 'post',
    data: data
  })
}

/**仓库绑定部门 */
export function deptBind(data) {
  return request({
    url: '/ecw/warehouse/deptBind',
    method: 'post',
    data: data
  })
}

/**获取已绑定的部门列表 */
export function deptList(data) {
  return request({
    url: '/ecw/warehouse/deptList',
    method: 'post',
    data: data
  })
}

/** 修改其他服务 */
export function serviceConfig(data) {
  return request({
    url: '/ecw/warehouse/serviceConfig',
    method: 'post',
    data: data
  })
}

// 数量是否必填
export function quantityRequired(lineId) {
  return request({
    url: '/ecw/warehouse/quantity/required/' + lineId,
    method: 'get'
  })
}

// 获取仓库区域并行国家、城市、仓库列表
export function getGuojiaAndShiAndWarehouseList(params = {}) {
  return request({
    url: '/ecw/warehouse/getGuojiaAndShiAndWarehouseList',
    method: 'get',
    params
  })
}

// 出货阶段-追加申请
export function appendApplyWhenShipment(data) {
  return request({
    url: '/order/order-warehouse-in/append-apply-when-shipment',
    method: 'post',
    data
  })
}

// 出货阶段-入仓修改申请
export function updateApplyWhenShipment(data) {
  return request({
    url: '/order/order-warehouse-in/update-apply-when-shipment',
    method: 'post',
    data
  })
}
