import {defHttp} from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";

const { createConfirm } = useMessage();

enum Api {
  list = '/showlist/okkiShowlist/list',
  save='/showlist/okkiShowlist/add',
  edit='/showlist/okkiShowlist/edit',
  deleteOne = '/showlist/okkiShowlist/delete',
  deleteBatch = '/showlist/okkiShowlist/deleteBatch',
  importExcel = '/showlist/okkiShowlist/importExcel',
  exportXls = '/showlist/okkiShowlist/exportXls',
  okkiOverviewList = '/showlist/okkiShowlist/queryOkkiOverviewByMainId',
  okkiProductListList = '/showlist/okkiShowlist/queryOkkiProductListByMainId',
  okkiHighlightList = '/showlist/okkiShowlist/queryOkkiHighlightByMainId',
  okkiAdvantageList = '/showlist/okkiShowlist/queryOkkiAdvantageByMainId',
  okkiRecommendedProductsList = '/showlist/okkiShowlist/queryOkkiRecommendedProductsByMainId',
  okkiKeywordsList = '/showlist/okkiShowlist/queryOkkiKeywordsByMainId',
  okkiKeywordsSeriesList = '/showlist/okkiShowlist/queryOkkiKeywordsSeriesByMainId',
  okkiReviewList = '/showlist/okkiShowlist/queryOkkiReviewByMainId',
  okkiFaqList = '/showlist/okkiShowlist/queryOkkiFaqByMainId',
  okkiShowlistBlogList = '/showlist/okkiShowlist/queryOkkiShowlistBlogByMainId',
}
/**
 * 导出api
 * @param params
 */
export const getExportUrl = Api.exportXls;

/**
 * 导入api
 */
export const getImportUrl = Api.importExcel;
/**
 * 查询子表数据
 * @param params
 */
export const okkiOverviewList = Api.okkiOverviewList;
/**
 * 查询子表数据
 * @param params
 */
export const okkiProductListList = Api.okkiProductListList;
/**
 * 查询子表数据
 * @param params
 */
export const okkiHighlightList = Api.okkiHighlightList;
/**
 * 查询子表数据
 * @param params
 */
export const okkiAdvantageList = Api.okkiAdvantageList;
/**
 * 查询子表数据
 * @param params
 */
export const okkiRecommendedProductsList = Api.okkiRecommendedProductsList;
/**
 * 查询子表数据
 * @param params
 */
export const okkiKeywordsList = Api.okkiKeywordsList;
/**
 * 查询子表数据
 * @param params
 */
export const okkiKeywordsSeriesList = Api.okkiKeywordsSeriesList;
/**
 * 查询子表数据
 * @param params
 */
export const okkiReviewList = Api.okkiReviewList;
/**
 * 查询子表数据
 * @param params
 */
export const okkiFaqList = Api.okkiFaqList;
/**
 * 查询子表数据
 * @param params
 */
export const okkiShowlistBlogList = Api.okkiShowlistBlogList;
/**
 * 列表接口
 * @param params
 */
export const list = (params) =>
  defHttp.get({url: Api.list, params});

/**
 * 删除单个
 */
export const deleteOne = (params,handleSuccess) => {
  return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}
/**
 * 批量删除
 * @param params
 */
export const batchDelete = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}
/**
 * 保存或者更新
 * @param params
 */
export const saveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.edit : Api.save;
  return defHttp.post({url: url, params});
}
