import HttpAxios from '@/utils/axios'

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

/**
 * 获取表格定制列功能数据
 */
export const getTableSettingColumns = (params: any, config: any) => {
  return HttpAxios.get(`${baseUrl}`, params, config)
}

/**
 * 保存表格定制列数据
 */
export const saveTableSettingColumns = (params: any, config: any) => {
  return HttpAxios.post(
    `${baseUrl}`,
    {
      action: 'ajax',
      operate: 'save_setting_display',
      model_name: 'Booking_Search',
      ...params
    },
    config
  )
}

/**
 * 修改密码
 */
export const changePwdByLogin = (params: any, config: any) => {
  return HttpAxios.post(
    `${baseUrl}`,
    {
      action: 'password',
      ...params
    },
    config
  )
}

/**
 * 获取菜单列表
 */
export const getMenuList = (params: any, config: any) => {
  return HttpAxios.get(
    `${baseUrl}`,
    {
      action: 'main',
      ...params
    },
    config
  )
}

/**
 * 获取日志列
 */
export const getOperationTableColumns = (params: any, config: any) => {
  return HttpAxios.get(
    `${baseUrl}`,
    {
      action: 'opreation_log'
    },
    config
  )
}
/**
 * 查询日志
 */
export const SearchOperationLog = (params: any, config: any) => {
  return HttpAxios.post(
    `${baseUrl}`,
    {
      action: 'opreation_log',
      operate: 'search',
      ...params
    },
    config
  )
}
/**
 * 日志表格下载
 */
export const OperationLogDownload = (params: any, config: any) => {
  return HttpAxios.post(
    `${baseUrl}`,
    {
      action: 'opreation_log',
      operate: 'excel',
      ...params
    },
    config
  )
}
/**
 * 获取首页数据
 */
export const GetDashboardData = (params: any, config: any) => {
  return HttpAxios.post(
    `${baseUrl}`,
    {
      action: 'main_welcome',
      ...params
    },
    config
  )
}
/**
 * 获取ETD to ETA (Days)
 */
export const GetETDEcharts = (params: any, config: any) => {
  return HttpAxios.get(
    `${baseUrl}`,
    {
      action: 'main_report_etd',
      r_type: 'r1',
      ...params
    },
    config
  )
}
/**
 * 获取KPI Echarts
 */
export const GetKPIEcharts = (params: any, config: any) => {
  return HttpAxios.get(
    `${baseUrl}`,
    {
      action: 'main_report_kpi',
      ...params
    },
    config
  )
}
/**
 * 获取Pending Echarts
 */
export const GetPendingEcharts = (params: any, config: any) => {
  return HttpAxios.get(
    `${baseUrl}`,
    {
      action: 'main_report',
      ...params
    },
    config
  )
}
/**
 * 获取ContainerCount Echarts
 */
export const GetContainerCountEcharts = (params: any, config: any) => {
  return HttpAxios.get(
    `${baseUrl}`,
    {
      action: 'main_report_container_bar',
      r_type: 'r2',
      ...params
    },
    config
  )
}
/**
 * 获取CO2 Emission
 */
export const GetCo2EmissionEcharts = (params: any, config: any) => {
  return HttpAxios.get(
    `${baseUrl}`,
    {
      action: 'main_report_co2e_bar',
      r_type: 'co2e_orgin',
      ...params
    },
    config
  )
}
/**
 * 获取CO2 Destination
 */
export const GetCo2DestinationEcharts = (params: any, config: any) => {
  return HttpAxios.get(
    `${baseUrl}`,
    {
      action: 'main_report_co2e_bar',
      r_type: 'co2e_destination',
      ...params
    },
    config
  )
}
/**
 * Top10 Origin/Destination
 */
export const GetTop10ODEcharts = (params: any, config: any) => {
  return HttpAxios.get(
    `${baseUrl}`,
    {
      action: 'main_report_top10_bar',
      r_type: 'top',
      ...params
    },
    config
  )
}
/**
 * Revenue Spent
 */
export const GetRevenueEcharts = (params: any, config: any) => {
  return HttpAxios.get(
    `${baseUrl}`,
    {
      action: 'main_report_revenue',
      ...params
    },
    config
  )
}
/**
 * Save Layout
 */
export const SaveLayout = (params: any, config: any) => {
  return HttpAxios.post(
    `${baseUrl}`,
    {
      action: 'save_layout',
      ...params
    },
    config
  )
}
/**
 * 评分提交
 */
export const scoringgrade = (params: any, config: any) => {
  return HttpAxios.post(
    `${baseUrl}`,
    {
      action: 'tools',
      operate: 'mark_save',
      ...params
    },
    config
  )
}
/**
 * 获取首页筛选条件
 */
export const getDashboardFilters = (config: any) => {
  return HttpAxios.get(
    `${baseUrl}`,
    {
      action: 'main_filter',
    },
    config
  )
}

/**
 * 获取首页筛选条件
 */
export const RevenueDownload = (params:any,config: any) => {
  return HttpAxios.get(
    `${baseUrl}`,
    {
      action: 'ocean_order',
      operate: 'revenue',
      ...params
    },
    config
  )
}
