import { axios } from '@/utils/request'

/* 商品分类 */

// 列表
export const getGoodsClassList = (params) => {
  const url = `goodsType/query/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}

// 启用禁用
export const changeGoodsStatus = (params) => {
  const url = `goodsType/enable/${params.id}/${params.flag}`
  return axios({
    url: url,
    data: params,
    method: 'get'
  })
}

// 详情
export const goodsClassDetails = (params) => {
  const url = `goodsType/findById/${params.id}`
  return axios({
    url: url,
    data: params,
    method: 'get'
  })
}

// 编辑/保存
export const saveGoodsClass = (params) => {
  const url = `goodsType/save`
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}

// 排序 上移下移
export const goodsChangeSort = (params) => {
  const url = `goodsType/swapGoodTypeSort/${params.currentId}/${params.id}`
  return axios.request({
    url: url,
    data: {},
    method: 'post'
  })
}

/* 供货商管理 */

// 列表
export const getSupplierList = (params) => {
  const url = `supplier/query/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}

// 启用禁用
export const changeSupplierStatus = (params) => {
  const url = `supplier/enable/${params.id}/${params.flag}`
  return axios({
    url: url,
    data: {},
    method: 'get'
  })
}

// 详情
export const supplierDetails = (params) => {
  const url = `supplier/findById/${params.id}`
  return axios({
    url: url,
    data: {},
    method: 'get'
  })
}

// 编辑/保存
export const saveSupplier = (params) => {
  const url = `supplier/save`
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}
