import request from '@/utils/request'
import qs from 'qs'
import { upcloud_base_wh ,SERVICE_DATA_API_BASE, upcloud_base_common} from "@/config/serviceSettings";

const commonApi = SERVICE_DATA_API_BASE+'/search/page'

export function wmsdcPage(params) {
  // 仓配中心/分页查询
  return request({
    url: upcloud_base_wh + '/wmsdc/page',
    method: 'get',
    params: params,
    headers: {
      'Content-Type': 'x-www-form-urlencoded;'
    }
  })
}

// workstageDel
export function workstageDel(params) {
  //  集货区删除 POST
  return request({
    url: upcloud_base_wh + '/workstage/setting/del	',
    method: 'post',
    data: params
  })
}
// workstagebatchEdit
export function workstagebatchEdit(params) {
  //  集货区批量批量修改 POST
  return request({
    url: upcloud_base_wh + '/workstage/setting/batchEdit',
    method: 'post',
    data: params
  })
}
export function workstageadd(params) {
  // 新增集货区类型
  return request({
    url: upcloud_base_wh + '/workstage/setting/add',
    method: 'post',
    data: params
  })
}

export function wmsdcAdd(params) {
  // 仓配中心/新增
  return request({
    url: upcloud_base_wh + '/wmsdc/add',
    method: 'post',
    data: params
  })
}

export function wmsdcDelete(params) {
  // 仓配中心/批量删除
  return request({
    url: upcloud_base_wh + '/wmsdc/delete',
    method: 'post',
    data: qs.stringify(params)
  })
}

export function wmsdcUpdate(params) {
  // /仓配中心/修改
  return request({
    url: upcloud_base_wh + '/wmsdc/update',
    method: 'post',
    data: params
  })
}

/* 货位单条查询 */
export function freightOne(params) {
  return request({
    url: upcloud_base_wh + '/locator',
    method: 'get',
    params: params,
    headers: {
      'Content-Type': 'x-www-form-urlencoded;'
    }
  })
}

/* 货位分页查询 */
export function freightPage(params) {
  return request({
    url: upcloud_base_wh + '/locator/page',
    method: 'get',
    params: params,
    headers: {
      'Content-Type': 'x-www-form-urlencoded;'
    }
  })
}

/* 货位新增 */
export function freightAdd(params) {
  return request({
    url: upcloud_base_wh + '/locator/add',
    method: 'post',
    data: params
  })
}

/* 货位批量删除 */
export function freightDelete(params) {
  return request({
    url: upcloud_base_wh + '/locator/delete',
    method: 'post',
    data: qs.stringify(params)
  })
}

/* 货位修改 */
export function freightUpdate(params) {
  return request({
    url: upcloud_base_wh + '/locator/update',
    method: 'post',
    data: params
  })
}
/* 货位逻辑区修改 */
export function updateLogic(params) {
  return request({
    url: upcloud_base_wh + '/locator/batch/updateLogic',
    method: 'post',
    data: params
  })
}

/* 货位批量编辑 */
export function batchEdit(params) {
  return request({
    url: upcloud_base_wh + '/baseWmsWarehouseArea/batchEdit',
    method: 'post',
    params: params,
    headers: {
      'Content-Type': 'application/json;'
    }
  })
}

/* 货位批量修改 */
export function locatotBatchUpdate(params) {
  return request({
    url: upcloud_base_wh + '/locator/batchEdit',
    method: 'post',
    data: params
  })
}

/* 集货区分页查询 */
export function collectionPage(params) {
  return request({
    method: 'post',
    url: commonApi,
    data: params
  })
}

/* 集货区新增 */
export function collectionAdd(params) {
  return request({
    url: upcloud_base_wh + '/workstage/add',
    method: 'post',
    data: params
  })
}

/* 集货区批量删除 */
export function collectionDelete(params) {
  return request({
    url: upcloud_base_wh + '/workstage/delete',
    method: 'get',
    params: params,
    headers: {
      'Content-Type': 'x-www-form-urlencoded;'
    }
  })
}

/* 集货区修改 */
export function collectionUpdate(params) {
  return request({
    url: upcloud_base_wh + '/workstage/edit',
    method: 'post',
    data: params

    // method: 'post',
    // url: api.uploadItem,
    // data: {
    //   id: '579666970018975744',
    //   pageNum: 1,
    //   pageSize: 10,
    //   params: {} //外部传入的参数
    // }
  })
}
/* 集货区配送查询 */
export function collectionShipline(params) {
  return request({
    // url: upcloud_base_common+'/dict/listbytype/?dicttypeCodes=common_shiplineid',
    // method: 'post'
    url: SERVICE_DATA_API_BASE+'/search',
    method: 'post',
    data: {
      num: 'trans_line',
      params: params
    }
  })
}
/* 集货区锁定 */
export function collectionLock(params) {
  return request({
    url: upcloud_base_wh+'/workstage/lock',
    method: 'post',
    data: params
  })
}
/* 集货区解锁 */
export function collectionUnlock(params) {
  return request({
    url: upcloud_base_wh+'/workstage/unlock',
    // url: '/api/workstage/unlock',
    method: 'post',
    data: params
  })
}
/* 集货区类型查询 */
export function collectionTypeList(params) {
  return request({
    url: upcloud_base_wh+'/workstage/all-setting',
    method: 'get',
    params: params
  })
}
/* 集货区类型查询详情 */
export function collectionTypeDetail(params) {
  return request({
    url: commonApi,
    method: 'post',
    data: {
      num: 'workstageQuery',
      pageNum: 1,
      pageSize: 5,
      params: params
    }
  })
}

/* 集货区批量修改 */
export function batchUpdate(params) {
  return request({
    url: upcloud_base_wh + '/workstage/batchEdit',
    method: 'post',
    data: params
  })
}

/* 工作站分页查询 */
export function workstationPage(params) {
  return request({
    method: 'post',
    url: commonApi,
    data: params
  })
}

/* 工作站新增 */
export function workstationAdd(params) {
  return request({
    url: upcloud_base_wh + '/workstation/add',
    method: 'post',
    data: params
  })
}

/* 工作站批量删除 */
export function workstationDelete(params) {
  return request({
    url: upcloud_base_wh + '/workstation/delete',
    method: 'post',
    data: qs.stringify(params)
  })
}

/* 工作站修改 */
export function workstationUpdate(params) {
  return request({
    url: upcloud_base_wh + '/workstation/edit',
    method: 'post',
    data: params
  })
}

/* 工作站--库区查询 */
export function workstationWhArea(params) {
  return request({
    url: upcloud_base_wh + '/wmsWhAreaStation/v1/findAll',
    method: 'get',
    params: params
  })
}
/* 工作站--库区新增 */
export function workstationWhAreaAdd(params) {
  return request({
    url: upcloud_base_wh + '/wmsWhAreaStation/v1/batchAdd',
    method: 'post',
    data: params
  })
}
/* 工作站--库区删除 */
export function workstationWhAreaDel(params) {
  return request({
    url: upcloud_base_wh + '/wmsWhAreaStation/v1/delIds',
    method: 'post',
    data: params
  })
}

/* 工作站--滑道查询 */
export function workstationSlide(params) {
  return request({
    url: upcloud_base_wh + '/wmsWhSlideway/v1/findAll',
    method: 'post',
    params: params
  })
}
/* 工作站--滑道新增 */
export function workstationSlideAdd(params) {
  return request({
    url: upcloud_base_wh + '/wmsWhSlideway/v1/batchAdd',
    method: 'post',
    data: params
  })
}
/* 工作站--滑道更新 */
export function workstationSlideUpload(params) {
  return request({
    url: upcloud_base_wh + '/wmsWhSlideway/v1/batchEdit',
    method: 'post',
    data: params
  })
}
/* 工作站--滑道删除 */
export function workstationSlideDel(params) {
  return request({
    url: upcloud_base_wh + '/wmsWhSlideway/v1/delIds',
    method: 'post',
    data: params
  })
}

/* 容器分页查询 */
export function containerPage(params) {
  return request({
    url: upcloud_base_wh + '/container/page',
    method: 'get',
    params: params,
    headers: {
      'Content-Type': 'x-www-form-urlencoded;'
    }
  })
}

/* 容器新增 */
export function containerAdd(params) {
  return request({
    url: upcloud_base_wh + '/container/add',
    method: 'post',
    data: params
  })
}

/* 容器批量删除 */
export function containerDelete(params) {
  return request({
    url: upcloud_base_wh + '/container/delete',
    method: 'post',
    data: qs.stringify(params)
  })
}

/* 容器修改 */
export function containerUpdate(params) {
  return request({
    url: upcloud_base_wh + '/container/update',
    method: 'post',
    data: params
  })
}

/* 容器类型查询 */
export function findDictType(type) {
  return request({
    url: upcloud_base_common+`/dict/listbytype/?dicttypeCodes=${type}`,
    method: 'post',
    headers: {
      'Content-Type': 'x-www-form-urlencoded;'
    }
  })
}

export function warehousePage(params) {
  // 仓库/分页查询
  return request({
    url: upcloud_base_wh + '/warehouse/page',
    method: 'get',
    params: params
  })
}

export function warehouseAdd(params) {
  // 仓库/新增
  return request({
    url: upcloud_base_wh + '/warehouse/add',
    method: 'post',
    data: params
  })
}

export function delWarehouse(params) {
  // 仓库/批量删除
  return request({
    url: upcloud_base_wh + '/warehouse/delete',
    method: 'post',
    data: qs.stringify(params)
  })
}

export function warehouseUpdate(params) {
  // 仓库/修改
  return request({
    url: upcloud_base_wh + '/warehouse/update',
    method: 'post',
    data: params,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8;'
    }
  })
}

export function warehouseId(params) {
  // 仓库/修改
  return request({
    url: upcloud_base_wh + '/warehouse',
    method: 'get',
    params: params
  })
}

export function platformPage(params) {
  // 月台/分页查询
  return request({
    url: upcloud_base_wh + '/platform/page',
    method: 'get',
    params: params
  })
}

export function delPlatform(params) {
  //月台/批量删除
  return request({
    url: upcloud_base_wh + '/platform/delete',
    method: 'post',
    data: qs.stringify(params)
  })
}

export function platformAdd(params) {
  //月台/新增
  return request({
    url: upcloud_base_wh + '/platform/add',
    method: 'post',
    data: params
  })
}

export function platformUpdate(params) {
  //月台/修改
  return request({
    url: upcloud_base_wh + '/platform/update',
    method: 'post',
    data: params,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8;'
    }
  })
}

export function remoteData(params) {
  //月台/修改
  return request({
    url: upcloud_base_common+`/dict/listbytype/?dicttypeCodes=${params.type}`,
    method: 'post'
  })
}

// 建筑物--添加
export function buildingAdd(params) {
  return request({
    url: upcloud_base_wh + '/wmsWhBldg/v1/add',
    method: 'post',
    data: params
  })
}

// 建筑物--修改
export function buildingEdit(params) {
  return request({
    url: upcloud_base_wh + '/wmsWhBldg/v1/edit',
    method: 'post',
    data: params
  })
}

// 建筑物--删除
export function buildingDelIds(params) {
  return request({
    url: upcloud_base_wh + '/wmsWhBldg/v1/delIds',
    method: 'post',
    data: params
  })
}


// 查询配送方向与滑道对应关系
export function querySorterAndChuteList(params) {
  return request({
    url: upcloud_base_wh + '/sorterAndChute/querySorterAndChuteList',
    method: 'post',
    data: params
  })
}


// 保存配送方向与滑道对应关系 
export function saveSorterAndChute(params) {
  return request({
    url: upcloud_base_wh + '/sorterAndChute/saveSorterAndChute',
    method: 'post',
    data: params
  })
}

// 建筑物--分页
// export function buildingAdd(params) {
//   return request({
//     url: upcloud_base_wh + '/wmsWhBldg/v1/page',
//     method: 'get',
//     data: params
//   });
// }
