// 获取商户应收账款列表
import request from '@/utils/request';
import { wrapTreeNode } from '@/utils/testFormat';

export async function handleGetNestingCOMMODITYTYPEList(params?: any) {

  const data = await request(`/BaseInfo/GetNestingCOMMODITYTYPEList`, {
    method: 'GET',
    params
  });

  if (data.Result_Code !== 100) {
    return {
      data: [],
      current: 1,
      pageSize: 10,
      total: 0,
      success: false
    }
  }
  return  wrapTreeNode(data.Result_Data.List)
}

export async function handleGetNestingCOMMODITYTYPETree(params?: any) {

  const data = await request(`/BaseInfo/GetNestingCOMMODITYTYPETree`, {
    method: 'GET',
    params
  });

  if (data.Result_Code !== 100) {
    return {
      data: [],
      current: 1,
      pageSize: 10,
      total: 0,
      success: false
    }
  }
  return  wrapTreeNode(data.Result_Data.List)
}

export async function handleCreateUpdateCOMMODITYTYPE(params?: any) {

  const data = await request(`/BaseInfo/SynchroCOMMODITYTYPE`, {
    method: 'POST',
    data: params
  });

  if (data.Result_Code !== 100) {
    return {
      data: [],
      current: 1,
      pageSize: 10,
      total: 0,
      success: false
    }
  }
  return  data
}


// 删除商品类别
export async function handleDeleteCOMMODITYTYPE(params?: any) {

  const data = await request(`/BaseInfo/DeleteCOMMODITYTYPE`, {
    method: 'GET',
    params
  });

  if (data.Result_Code !== 100) {
    return {
      data: [],
      current: 1,
      pageSize: 10,
      total: 0,
      success: false
    }
  }
  return  data
}

