import request from '@/config/axios'

// 客户组相关类型定义
export interface CustomerGroupVO {
  id?: number // 主键ID
  customerGroup: string // 客户组
  customerSapCode: string // 客户SAP编码
  customerName: string // 客户名称
  createUser?: string // 创建人
  createTime?: string // 创建时间
  updateUser?: string // 修改人
  updateTime?: string // 修改时间
}

// 分页查询参数
export interface CustomerGroupPageParam {
  pageNo?: number
  pageSize?: number
  customerGroup?: string // 客户组
  customerSapCode?: string // 客户SAP编码
}

// 客户组分页查询
export const customerGroupPage = (data: CustomerGroupPageParam) => {
  return request.post({ url: '/print/customer-group-info/page', data })
}
export const customerGroupPageAll = () => {
  return request.get({ url: '/print/customer-group-info/getAll' })
}
// 创建客户组
export const createCustomerGroup = (data: CustomerGroupVO) => {
  return request.post({ url: '/print/customer-group-info/create', data })
}

// 修改客户组
export const updateCustomerGroup = (data: CustomerGroupVO) => {
  return request.put({ url: '/print/customer-group-info/update', data })
}

// 删除客户组
export const deleteCustomerGroup = (id: number) => {
  return request.delete({ url: '/print/customer-group-info/delete?id=' + id })
}

// 批量删除客户组
export const deleteCustomerGroupList = (ids: number[]) => {
  return request.delete({
    url: '/print/customer-group-info/delete-list',
    params: { ids: ids.join(',') }
  })
}

// 导出客户组
export const exportCustomerGroup = (data: any) => {
  return request.downloadPost({ url: '/print/customer-group-info/export-excel', data })
}

// 下载客户组导入模板
export const importCustomerGroupTemplate = () => {
  return request.download({ url: '/print/customer-group-info/get-import-template' })
}

// 导入客户组
export const importCustomerGroup = (data: FormData) => {
  return request.post({
    url: '/print/customer-group-info/import',
    data,
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

// 客户组操作日志分页查询
export const customerGroupOperationLogPage = (data: any) => {
  return request.post({ url: '/print/customer-group-operation-log/page', data })
}
export const getCustomerCodeList = (params: any) => {
  return request.get({ url: '/print/purchase/order-detail/getCustomerCodeList', params })
}
