import HttpAxios from '@/utils/axios'

const base = import.meta.env.VITE_API_HOST
const baseUrl = `${base}/main_new_version.php`

/**
 * Tracking首页表格列数据
 */
export const getTrackingTableColumns = (params: any, config: any) => {
  return HttpAxios.get(
    `${baseUrl}`,
    {
      action: 'ocean_order',
      ...params
    },
    config
  )
}

/**
 * 获取Tracking首页表格数据
 */
export const getTrackingTableData = (params: any, config: any) => {
  return HttpAxios.post(
    `${baseUrl}`,
    {
      action: 'ocean_order',
      operate: 'search',
      _ntype: 'ocean_order',
      ...params
    },
    config
  )
}

/**
 * 获取Tracking详情页数据
 */
export const getTrackingDetail = (params: any, config: any) => {
  return HttpAxios.get(
    `${baseUrl}`,
    {
      action: 'ocean_order',
      operate: 'detail',
      _schemas: 'public',
      ...params
    },
    config
  )
}

/**
 * 获取Tracking详情页中地图数据
 */
export const getTrackingDetailMapData = (params: any, config: any) => {
  return HttpAxios.get(
    `${baseUrl}`,
    {
      action: 'main_map_new',
      ...params
    },
    config
  )
}

/**
 * 获取Tracking详情页中AMS/ISF表格数据
 */
export const getTrackingAmsIsf = (params: any, config: any) => {
  return HttpAxios.get(
    `${baseUrl}`,
    {
      action: 'ocean_order',
      operate: 'ams_isf_log',
      ...params
    },
    config
  )
}

/**
 * 获取add vgm页面数据
 */
export const getVGMData = (params: any, config: any) => {
  return HttpAxios.get(
    `${baseUrl}`,
    {
      action: 'ocean_order',
      operate: 'ocean_vgm',
      ...params
    },
    config
  )
}

/**
 * 保存 vgm页面数据
 */
export const saveVGMData = (params: any, config: any) => {
  return HttpAxios.post(
    `${baseUrl}`,
    {
      action: 'ocean_order',
      operate: 'save_ocean_vgm',
      ...params
    },
    config
  )
}

/**
 * 用户下载表格时获取所有数据
 */
export const getAllTrackingTableData = (params: any, config: any) => {
  return HttpAxios.post(
    `${baseUrl}`,
    {
      action: 'ocean_order',
      operate: 'excel',
      ...params
    },
    config
  )
}
