import { tmallabHttp } from '/@/utils/http/axios';
import { SearchFormType, ListTpyes, UploadTaskType } from '/@/views/regionalSpotManage/types';
enum Api {
  GetStatus = '/system/opsProduct/IsOpsSupplier',
  List = '/system/opsProduct/getList',
  GroupList = '/system/opsProduct/getTypeList',
  BrandList = '/system/supplierBrandQualification/getApproveList',
  ProductList = '/system/productNegotiated/getProductList',
  GetAreaList = '/system/opsProduct/getAreaList',
  OpsAddProduct = '/system/opsProduct/opsAddProduct',
  GetGhsAreaList = '/system/opsProduct/getGhsAreaList',
  OpsDeleteProduct = '/system/opsProduct/opsDeleteProduct',
  OpsEditProduct = '/system/opsProduct/opsEditProduct',
  UploadOpsProduct = '/excel/excelNew/uploadOpsProduct',
  QueryList = '/system/logProductManager/queryList',
  RevokeExcelUpload = '/system/logProductManager/revokeExcelUpload',
  PlatformProBatchList = '/system/logNegotiationProductOperate/getList',
  PlatformProBatchGetDetail = '/system/logNegotiationProductOperate/getDetail',
}

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

/**
 * @description: 区域现货管理列表
 */
export const regionalSpotManageGetStatusApi = () => tmallabHttp.post({ url: Api.GetStatus });

/**
 * @description: 区域现货管理列表
 */
export const regionalSpotManageListApi = (data: SearchFormType) =>
  tmallabHttp.post<ResponseData<ListTpyes[]>>(
    { url: Api.List, data },
    { errorMessageMode: 'message' },
  );

/**
 * @description: 获取品牌列表
 */
export const regionalSpotManageBrandListApi = (data) =>
  tmallabHttp.post({ url: Api.BrandList, data });

/**
 * @description: 获取分组列表
 */
export const regionalSpotManageGroupListApi = (data) =>
  tmallabHttp.post({ url: Api.GroupList, data });

/**
 * @description: 获取左边穿梭框商品列表
 */
export const regionalSpotManageProductListApi = (data) =>
  tmallabHttp.post({ url: Api.ProductList, data });

/**
 * @description: 获取现货区域列表
 */
export const regionalSpotManageGetAreaListApi = (data) =>
  tmallabHttp.post({ url: Api.GetAreaList, data });

/**
 * @description: 新增商品接口
 */
export const regionalSpotManageOpsAddProductApi = (data) =>
  tmallabHttp.post({ url: Api.OpsAddProduct, data }, { errorMessageMode: 'message' });

/**
 * @description: 获取已开通区域
 */
export const regionalSpotManageGetGhsAreaListApi = (data) =>
  tmallabHttp.post({ url: Api.GetGhsAreaList, data });

/**
 * @description: 单条/批量删除
 */
export const regionalSpotManageOpsDeleteProductApi = (data) =>
  tmallabHttp.post({ url: Api.OpsDeleteProduct, data }, { errorMessageMode: 'message' });

/**
 * @description: 增加区域
 */
export const regionalSpotManageOpsEditProductApi = (data) =>
  tmallabHttp.post({ url: Api.OpsEditProduct, data }, { errorMessageMode: 'message' });

/**
 * @description: 批量上传
 */
export const regionalSpotManageUploadOpsProductApi = (data, file) =>
  tmallabHttp.uploadFile(
    {
      url: Api.UploadOpsProduct,
      method: 'POST',
      data,
      baseURL: import.meta.env.VITE_GLOB_TMALLAB_URL,
    },
    { file, data },
  );

/**
 * @description: 任务中心获取列表
 */
export const taskCenterQueryListApi = (data: { type: number }) =>
  tmallabHttp.post<ResponseData<UploadTaskType[]>>({ url: Api.QueryList, data });

/**
 * @description: 撤销
 */
export const taskCenterRevokeExcelUploadApi = (data) =>
  tmallabHttp.post({ url: Api.RevokeExcelUpload, data }, { errorMessageMode: 'message' });

/**
 * @description: 任务中心获取列表--平台商品批量页签
 */
export const platformProBatchGetListApi = (data) =>
  tmallabHttp.post({ url: Api.PlatformProBatchList, data }, { errorMessageMode: 'message' });

/**
 * @description: 任务中心获取列表--平台商品批量页签--操作记录详情
 */
export const platformProBatchGetDetailApi = (data) =>
  tmallabHttp.post({ url: Api.PlatformProBatchGetDetail, data }, { errorMessageMode: 'message' });
