import fetch from '@/utils/fetch'

// 新增企业
export const createEnterprise = ({ 
  username, 
  password,
  enterprise_name,
  enterprise_man,
  enterprise_phone
}) => fetch('/admin/user/create_enterprise', {
  username,
  password,
  enterprise_name,
  enterprise_man,
  enterprise_phone
}, 'POST')

// 企业列表
export const listEnterprise = ({ 
  page, 
  page_len,
  username,
  enterprise_name
}) => fetch('/admin/user/list_enterprise', {
  page, 
  page_len,
  username,
  enterprise_name
}, 'POST')

// 企业信息详情
export const detailEnterprise = (enterprise_id) => fetch('/admin/user/detail_enterprise', {
  enterprise_id
}, 'POST')

// 编辑企业信息
export const updateEnterprise = ({ 
  enterprise_id,
  username, 
  password,
  enterprise_name,
  enterprise_man,
  enterprise_phone
}) => fetch('/admin/user/update_enterprise', {
  enterprise_id,
  username,
  password,
  enterprise_name,
  enterprise_man,
  enterprise_phone
}, 'POST')

// 删除企业信息
export const deleteEnterprise = (enterprise_id) => fetch('/admin/user/delete_enterprise', {
  enterprise_id
}, 'POST')

// 新增后台管理员账号
export const createAdmin = ({ 
  username, 
  password,
  fullname,
  perm_list,
  perm_operate
}) => fetch('/admin/user/create_admin', {
  username, 
  password,
  fullname,
  perm_list,
  perm_operate
}, 'POST')

// 后台管理员账号列表
export const listAdmin = ({ 
  page,
  page_len,
  username
}) => fetch('/admin/user/list_admin', {
  page,
  page_len,
  username
}, 'POST')

// 后台管理员账号详情
export const detailAdmin = (user_id) => fetch('/admin/user/detail_admin', {
  user_id
}, 'POST')

// 编辑后台管理员账号
export const updateAdmin = ({ 
  user_id,
  username, 
  password,
  perm_list,
  perm_operate,
  fullname
}) => fetch('/admin/user/update_admin', {
  user_id,
  username, 
  password,
  perm_list,
  perm_operate,
  fullname
}, 'POST')

// 删除后台管理员账号
export const deleteAdmin = (user_id) => fetch('/admin/user/delete_admin', {
  user_id
}, 'POST')

// 创建调度员
export const createYardman = ({ 
  account, 
  password,
  yardman_name,
  yardman_gender,
  yardman_phone,
  freeze_flag
}) => fetch('/admin/user/create_yardman', {
  account, 
  password,
  yardman_name,
  yardman_gender,
  yardman_phone,
  freeze_flag
}, 'POST')

// 调度员列表
export const listYardman = ({ 
  page,
  page_len,
  yardman_name,
  account,
  yardman_phone,
  freeze_flag
}) => fetch('/admin/user/list_yardman', {
  page,
  page_len,
  yardman_name,
  account,
  yardman_phone,
  freeze_flag
}, 'POST')

// 调度员详情
export const detailYardman = (yardman_id) => fetch('/admin/user/detail_yardman', {
  yardman_id
}, 'POST')

// 编辑调度员
export const updateYardman = ({ 
  yardman_id, 
  account,
  password,
  yardman_name,
  yardman_gender,
  yardman_phone,
  freeze_flag
}) => fetch('/admin/user/update_yardman', {
  yardman_id, 
  account,
  password,
  yardman_name,
  yardman_gender,
  yardman_phone,
  freeze_flag
}, 'POST')

// 删除调度员
export const deleteYardman = (yardman_id) => fetch('/admin/user/delete_yardman', {
  yardman_id
}, 'POST')

// 冻结/解冻调度员
export const freezeYardman = ({ 
  yardman_id,
  freeze_flag
}) => fetch('/admin/user/freeze_yardman', {
  yardman_id,
  freeze_flag
}, 'POST')

// 新增司机
export const createDriver = ({ 
  account, 
  password,
  driver_name,
  driver_gender,
  driver_phone,
  yardman_id,
  freeze_flag,
  head_id
}) => fetch('/admin/user/create_driver', {
  account, 
  password,
  driver_name,
  driver_gender,
  driver_phone,
  yardman_id,
  freeze_flag,
  head_id
}, 'POST')

// 获取调度员列表
export const getYardman = () => fetch('/admin/user/get_yardman', {}, 'POST')

// 司机列表
export const listDriver = ({ 
  page, 
  page_len,
  driver_name,
  account,
  yardman_name,
  freeze_flag,
  head_name
}) => fetch('/admin/user/list_driver', {
  page, 
  page_len,
  driver_name,
  account,
  yardman_name,
  freeze_flag,
  head_name
}, 'POST')

// 司机详情
export const detailDriver = (driver_id) => fetch('/admin/user/detail_driver', {
  driver_id
}, 'POST')

// 编辑司机
export const updateDriver = ({ 
  driver_id,
  driver_name,
  driver_gender,
  account,
  driver_phone,
  yardman_id,
  password,
  freeze_flag,
  head_id
}) => fetch('/admin/user/update_driver', {
  driver_id,
  driver_name,
  driver_gender,
  account,
  driver_phone,
  yardman_id,
  password,
  freeze_flag,
  head_id
}, 'POST')

// 删除司机
export const deleteDriver = (driver_id) => fetch('/admin/user/delete_driver', {
  driver_id
}, 'POST')

// 冻结/解冻司机
export const freezeDriver = ({ 
  driver_id,
  freeze_flag
}) => fetch('/admin/user/freeze_driver', {
  driver_id,
  freeze_flag
}, 'POST')

// 获取车辆负责人列表
export const getHeadList = () => fetch('/admin/base/get_head', {}, 'POST')

