import HttpAxios from '@/utils/axios'

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

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

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

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

/**
 * 获取Booking详情页发送邮件
 */
export const bookingSendEmail = (params: any, config: any) => {
  return HttpAxios.post(
    `${baseUrl}`,
    {
      action: 'ocean_booking',
      operate: 'save_communication',
      ...params
    },
    config
  )
}
/**
 * 获取自动完成列表
 */
export const getMoreFiltersData = (params: any, config: any) => {
  return HttpAxios.post(
    `${baseUrl}`,
    {
      action: 'ajax',
      operate: 'autody',
      ...params
    },
    config
  )
}
/**
 * 获取table自动完成列表
 */
export const getMoreFiltersTableData = (params: any, config: any) => {
  return HttpAxios.post(
    `${baseUrl}`,
    {
      action: 'ajax',
      operate: 'autoport',
      ...params
    },
    config
  )
}

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