import request from '@/utils/request'
import qs from 'qs'
import { upcloud_base_wh_control,upcloud_base_item ,SERVICE_CTRL_TOWER } from "@/config/serviceSettings";


export const api = {
  queryItem: upcloud_base_wh_control + '/item-locator/v1/head/infoByPkIdCasecade',
  addItem: upcloud_base_wh_control + '/item-locator/v1/head/addCascade',
  uploadItem: upcloud_base_wh_control + '/item-locator/v1/head/updateCascade',
  deleteList: upcloud_base_wh_control + '/item-locator/v1/head/delIds',
  queryLogicArea: upcloud_base_wh_control + '/item-locator/v1/locator/page',
  queryAlgorithm: upcloud_base_wh_control + '/item-locator/v1/algo/page'
}

const itemsApi = upcloud_base_item+'/item/pagebyRelated'

export function queryItem(parameter) {
  return request({
    method: 'get',
    url: api.queryItem,
    params: parameter
  })
}
//获取货主信息
export function getAuthByUser(params) {
  return request({
    url: SERVICE_CTRL_TOWER+'/userDataAuth/allDataAuthByUser/?companyType=H&pageNum=1&pageSize=10',
    method: 'get',
    // headers: { 'Content-Type': 'application/json' },
    params: params
  })
}

export function addItem(parameter) {
  return request({
    method: 'post',
    url: api.addItem,
    data: parameter
  })
}

export function uploadItem(parameter) {
  return request({
    method: 'post',
    url: api.uploadItem,
    data: parameter
  })
}

export function delItems(parameter) {
  return request({
    method: 'post',
    url: api.deleteList,
    data: parameter
  })
}

export function queryItemInfos(parameter) {
  return request({
    method: 'post',
    url: itemsApi,
    data: parameter
  })
}

// let warehouse = this.$store.state.user.warehouse
//       if (Object.keys(warehouse).length > 0) {
//         if (this.$refs.phtml) {
//           this.$refs.phtml.$refs.gridform.form.setFieldsValue(
//             pick(warehouse, 'warehouseId', 'warehouseCode', 'warehouseName')
//           )
//         } else if (this.$refs.search) {
//           this.$refs.search.form.setFieldsValue(pick(warehouse, 'warehouseId', 'warehouseCode', 'warehouseName'))
//         }
//       }
//     }
