import fetch from '@/utils/fetch'

/**
 * 供应商
 * @param {*} param0 
 */
// 新增供应商
export const createSupplier = ({
  supplier_name, 
  supplier_man,
  supplier_phone,
  supplier_address,
  accept_man,
  init_due,
  init_pay,
  supplier_num
}) => fetch('/admin/base/create_supplier', {
  supplier_name, 
  supplier_man,
  supplier_phone,
  supplier_address,
  accept_man,
  init_due,
  init_pay,
  supplier_num
}, 'POST')

// 供应商列表
export const listSupplier = ({ 
  page, 
  page_len,
  supplier_name,
  supplier_man,
  supplier_phone
}) => fetch('/admin/base/list_supplier', {
  page, 
  page_len,
  supplier_name,
  supplier_man,
  supplier_phone
}, 'POST')

// 供应商详情
export const detailSupplier = (supplier_id) => fetch('/admin/base/detail_supplier', { supplier_id }, 'POST')

// 编辑供应商
export const updateSupplier = ({ 
  supplier_id,
  supplier_num,
  supplier_name,
  supplier_man,
  supplier_phone,
  supplier_address,
  accept_man,
  init_due,
  init_pay
}) => fetch('/admin/base/update_supplier', {
  supplier_id,
  supplier_num,
  supplier_name,
  supplier_man,
  supplier_phone,
  supplier_address,
  accept_man,
  init_due,
  init_pay
}, 'POST')

// 删除供应商
export const deleteSupplier = (supplier_id) => fetch('/admin/base/delete_supplier', { supplier_id }, 'POST')

/**
 * 客户
 * @param {} param0 
 */
// 新增客户
export const createClient = ({ 
  client_name_id,
  client_num, 
  client_company,
  client_man,
  client_phone,
  client_address,
  accept_man,
  accept_finance,
  init_due,
  init_pay
}) => fetch('/admin/base/create_client', {
  client_name_id,
  client_num, 
  client_company,
  client_man,
  client_phone,
  client_address,
  accept_man,
  accept_finance,
  init_due,
  init_pay
}, 'POST')

// 客户列表
export const listClient = ({
  page, 
  page_len,
  client_company,
  client_man,
  client_phone
}) => fetch('/admin/base/list_client', {
  page, 
  page_len,
  client_company,
  client_man,
  client_phone
}, 'POST')

// 客户详情
export const detailClient = (client_id) => fetch('/admin/base/detail_client', { client_id }, 'POST')

// 编辑客户
export const updateClient = ({ 
  client_num,
  client_name_id,
  client_company,
  client_man,
  client_phone,
  client_address,
  accept_man,
  accept_finance,
  init_due,
  init_pay,
  client_id
}) => fetch('/admin/base/update_client', {
  client_num,
  client_name_id,
  client_company,
  client_man,
  client_phone,
  client_address,
  accept_man,
  accept_finance,
  init_due,
  init_pay,
  client_id
}, 'POST')

// 删除客户
export const deleteClient = (client_id) => fetch('/admin/base/delete_client', { client_id }, 'POST')

/**
 * 工地
 * @param {} param0 
 */
// 新增工地
export const createSite = ({ 
  site_name, 
  site_man,
  man_phone,
  site_address,
  client_id
}) => fetch('/admin/base/create_site', {
  site_name, 
  site_man,
  man_phone,
  site_address,
  client_id
}, 'POST')

// 获取客户单位
export const getClient = () => fetch('/admin/base/get_client', { }, 'POST')

// 客户列表
export const listSite = ({ 
  page, 
  page_len,
  site_name,
  client_company
}) => fetch('/admin/base/list_site', {
  page, 
  page_len,
  site_name,
  client_company
}, 'POST')

// 工地详情
export const detailSite = (site_id) => fetch('/admin/base/detail_site', { site_id }, 'POST')

// 编辑工地
export const updateSite = ({ 
  site_id,
  site_name,
  site_man,
  man_phone,
  site_address,
  client_id
}) => fetch('/admin/base/update_site', {
  site_id,
  site_name,
  site_man,
  man_phone,
  site_address,
  client_id
}, 'POST')

// 删除工地
export const deleteSite = (site_id) => fetch('/admin/base/delete_site', { site_id }, 'POST')

// 中转站列表
export const listTransfer = ({ 
  page, 
  page_len,
  transit_name,
  driver_account
}) => fetch('/admin/base/list_transit', {
  page, 
  page_len,
  transit_name,
  driver_account
}, 'POST')

// 中转站详情
export const detailTransfer = (transit_id) => fetch('/admin/base/detail_transit', { transit_id }, 'POST')

// 新增中转站
export const createTransfer = ({ 
  transit_name, 
  driver_id,
  transit_man,
  transit_phone,
  transit_addr
}) => fetch('/admin/base/create_transit', {
  transit_name, 
  driver_id,
  transit_man,
  transit_phone,
  transit_addr
}, 'POST')

// 编辑中转站
export const updateTransfer = ({ 
  transit_id,
  transit_name, 
  driver_id,
  transit_man,
  transit_phone,
  transit_addr
}) => fetch('/admin/base/update_transit', {
  transit_id,
  transit_name, 
  driver_id,
  transit_man,
  transit_phone,
  transit_addr
}, 'POST')

// 删除中转站
export const deleteTransfer = (transit_id) => fetch('/admin/base/delete_transit', { transit_id }, 'POST')

// 获取司机车牌列表
export const listDriver = ({ 
  driver_account
}) => fetch('/admin/base/get_driver', {
  driver_account
}, 'POST')
/**
 * 品种
 * @param {} param0 
 */
// 新增品种
export const createVariety = ({ 
  variety_num, 
  variety_note
}) => fetch('/admin/base/create_variety', {
  variety_num, 
  variety_note
}, 'POST')

// 品种列表
export const listVariety = ({ 
  page, 
  page_len,
  variety_num
}) => fetch('/admin/base/list_variety', {
  page, 
  page_len,
  variety_num
}, 'POST')

// 品种详情
export const detailVariety = (variety_id) => fetch('/admin/base/detail_variety', { variety_id }, 'POST')

// 编辑品种
export const updateVariety = ({ 
  variety_id,
  variety_num,
  variety_note
}) => fetch('/admin/base/update_variety', {
  variety_id,
  variety_num,
  variety_note
}, 'POST')

// 删除品种
export const deleteVariety = (variety_id) => fetch('/admin/base/delete_variety', { variety_id }, 'POST')


/**
 * 客户名称
 * @param {} param0 
 */
// 新增客户名称
export const createClientData = ({ 
  client_name, 
  client_note
}) => fetch('/admin/base/create_client_data', {
  client_name, 
  client_note
}, 'POST')

// 客户名称列表
export const listClientData = ({ 
  page, 
  page_len,
  client_name
}) => fetch('/admin/base/list_client_data', {
  page, 
  page_len,
  client_name
}, 'POST')

// 客户名称详情
export const detailClientData = (data_id) => fetch('/admin/base/detail_client_data', { data_id }, 'POST')

// 编辑客户名称
export const updateClientData = ({ 
  data_id,
  client_name,
  client_note
}) => fetch('/admin/base/update_client_data', {
  data_id,
  client_name,
  client_note
}, 'POST')

// 删除品种
export const deleteClientData = (data_id) => fetch('/admin/base/delete_client_data', { data_id }, 'POST')

// 获取客户名称列表
export const getClientData = () => fetch('/admin/base/get_client_data', {  }, 'POST')

// 车辆负责人列表
export const listHead = ({ 
  page, 
  page_len,
  head_name
}) => fetch('/admin/base/list_head', {
  page, 
  page_len,
  head_name
}, 'POST')

// 车辆负责人详情
export const detailHead = (head_id) => fetch('/admin/base/detail_head', { head_id }, 'POST')

// 新增车辆负责人
export const createHead = ({ 
  head_name
}) => fetch('/admin/base/create_head', {
  head_name
}, 'POST')

// 编辑车辆负责人
export const updateHead = ({ 
  head_id,
  head_name
}) => fetch('/admin/base/update_head', {
  head_id,
  head_name
}, 'POST')

// 删除车辆负责人
export const deleteHead = (head_id) => fetch('/admin/base/delete_head', { head_id }, 'POST')

