import axios from '@/libs/api.request'

export const getTableData = () => {
  return axios.request({
    url: 'get_table_data',
    method: 'get'
  })
}

export const getDragList = () => {
  return axios.request({
    url: 'get_drag_list',
    method: 'get'
  })
}

export const errorReq = () => {
  return axios.request({
    url: 'error_url',
    method: 'post'
  })
}

export const saveErrorLogger = info => {
  return axios.request({
    url: 'save_error_logger',
    data: info,
    method: 'post'
  })
}

export const uploadImg = formData => {
  return axios.request({
    url: 'image/upload',
    data: formData
  })
}

export const getOrgData = () => {
  return axios.request({
    url: 'get_org_data',
    method: 'get'
  })
}

export const getTreeSelectData = () => {
  return axios.request({
    url: 'get_tree_select_data',
    method: 'get'
  })
}

// new 20221205

// 判断获取配送中心列表
export const getcenterlist = searchData => {
  return axios.request({
    url: '/admin/meal/getcenterlist',
    method: 'post',
    data: searchData
  })
}
// 根据id获取配送中心信息
export const getmealcenterinfobyid = ({ id }) => {
  return axios.request({
    url: '/admin/meal/getmealcenterinfobyid',
    method: 'post',
    data: { 'cmid': id }
  })
}
/**
 * 获取套餐列表
 * @param {*} param0
 * @returns
 */
export const getmeallist = searchData => {
  return axios.request({
    url: '/admin/meal/getmeallist',
    method: 'post',
    data: searchData
  })
}
/**
 * 改套餐可用
 * @param {*} param0
 * @returns
 */
export const updatemealisactive = ({ id, is_active }) => {
  return axios.request({
    url: '/admin/meal/updatemealisactive',
    method: 'post',
    data: { id, is_active }
  })
}

/**
 * 改套餐可用
 * @param {*} param0
 * @returns
 */
export const editmeal = formData => {
  return axios.request({
    url: '/admin/meal/editmeal',
    method: 'post',
    data: formData
  })
}
export const getmealinfo = ({ id }) => {
  return axios.request({
    url: '/admin/meal/getmealinfo',
    method: 'post',
    data: { id }
  })
}
// 获取菜品列表
export const getcooks = ({ center_id }) => {
  return axios.request({
    url: '/admin/meal/getcooks',
    method: 'post',
    data: { center_id }
  })
}
// 保存套餐菜谱
export const savemealcooks = ({ center_id, meal_id, week, items }) => {
  return axios.request({
    url: '/admin/meal/savemealcooks',
    method: 'post',
    data: { center_id, meal_id, week, items }
  })
}

// 获取套餐菜谱列表
export const getmealcooklist = searchData => {
  return axios.request({
    url: '/admin/meal/getmealcooklist',
    method: 'post',
    data: searchData
  })
}

// 获取菜品列表
export const getcookslist = searchData => {
  return axios.request({
    url: '/admin/meal/getcookslist',
    method: 'post',
    data: searchData
  })
}

// 菜品修改
export const editcookinfo = formData => {
  return axios.request({
    url: '/admin/meal/editcookinfo',
    method: 'post',
    data: formData
  })
}

// 菜品修改可用
export const updatecookisactive = formData => {
  return axios.request({
    url: '/admin/meal/updatecookisactive',
    method: 'post',
    data: formData
  })
}

// 获取订餐订单列表
export const getmealorderlist = searchData => {
  return axios.request({
    url: '/admin/meal/getorderlist',
    method: 'post',
    data: searchData
  })
}

// 获取到访类型
export const getvbtlist = () => {
  return axios.request({
    url: '/admin/visit/getbusinesstyoelist',
    method: 'post'
  })
}
/**
 * 新增到防
 */
export const newvisitinfo = formData => {
  return axios.request({
    url: '/admin/visit/newinfo',
    method: 'post',
    data: formData
  })
}
/**
 * 获取到访列表
 * @param {*} formData
 * @returns
 */
export const getvisitlist = searchData => {
  return axios.request({
    url: '/admin/visit/getlist',
    method: 'post',
    data: searchData
  })
}
