import { tmallabHttp } from '/@/utils/http/axios';
import { List, Supplier, ParamsList, ParamsAdd, BrandList } from '/@/types/manufacturer';

type ResponseData<T> = {
  code: number;
  data: T;
  message: string;
  success: boolean;
  time: string;
  traceId: string;
};

export const getManufacturerListApi = (data: ParamsList) =>
  tmallabHttp.post<ResponseData<List[]>>({
    url: '/system/mfrCooperate/getList',
    data,
  });

// 获取供货商名称列表
export const getSupplierApi = () =>
  tmallabHttp.post<ResponseData<Supplier[]>>({
    url: '/system/supplier/getSupplierComboBox',
  });

// 新增厂商
export const handleManufacturerAdd = (data: ParamsAdd) =>
  tmallabHttp.post<ResponseData<null>>({
    url: '/system/mfrCooperate/add',
    data,
  });

// 合作品牌
export const getBrandListApi = (data: { brand: string }) =>
  tmallabHttp.post<ResponseData<BrandList[]>>({
    url: '/system/supplierBrandQualification/getApproveList',
    data,
  });

// 获取详情
export const getManuFactureDetail = (data: { supplierCode: string }) =>
  tmallabHttp.post<ResponseData<List>>({
    url: '/system/mfrCooperate/getOne',
    data,
  });

// 编辑
export const handleEditApi = (data: ParamsAdd) =>
  tmallabHttp.post<ResponseData<null>>({
    url: '/system/mfrCooperate/edit',
    data,
  });
