import request from '@/config/axios'

export interface SupplierProductVo {
  id: number
  name: string
  productCode: string
  status: number
  type: number
  createTime: Date
}

export interface UpdateStatusReqVO {
  id: number
  status: number
}

// 查询产品列表
export const getSupplierProductPage = async (params: PageParam) => {
  return await request.get({ url: '/supplier/product/page', params })
}

// 查询产品（精简)列表
export const getSimpleSupplierProductList = async (): Promise<SupplierProductVo[]> => {
  return await request.get({ url: '/supplier/product/simple-list' })
}

// 查询产品详情
export const getSupplierProduct = async (id: number) => {
  return await request.get({ url: '/supplier/product/get?id=' + id })
}

// 新增产品
export const createSupplierProduct = async (data: SupplierProductVo) => {
  return await request.post({ url: '/supplier/product/create', data })
}

// 修改产品
export const updateSupplierProduct = async (data: SupplierProductVo) => {
  return await request.put({ url: '/supplier/product/update', data })
}

// 修改产品状态
export const updateSupplierProductStatus = async (data: UpdateStatusReqVO) => {
  return await request.put({ url: '/supplier/product/update-status', data })
}

// 删除产品
export const deleteSupplierProduct = async (id: number) => {
  return await request.delete({ url: '/supplier/product/delete?id=' + id })
}

// 导出产品
export const exportSupplierProduct = (params) => {
  return request.download({
    url: '/supplier/product/export-excel',
    params
  })
}
export const getAll= async () =>{
  return await request.get({ url: `/supplier/product/all` })
}
