
import { defHttp } from '/@/utils/http/axios';
import { Modal } from 'ant-design-vue';

enum Api {
  list = '/zjk/list',
  save = '/zjk/add',
  edit = '/zjk/edit',
  deleteOne = '/zjk/delete',
  view = '/zjk/queryById',
  sczh = '/zjk/sczh', //生成账户
  updateStatus = '/zjk/updateStatus',
  importExcel = '/zjk/importExcel',
  exportXls = '/zjk/exportXls',
  downloadZjk = '/zjk/downloadZjk',

  // 抽取相关接口
  cqlist = '/zjcq/getCqlist',
  searDkbm = '/qdml/zjcqlikeWrdkbm',
  saveCq = '/zjcq/add',
  getFaList = '/zjcq/getFaList',
  importExcelCc = '/zjcq/exportXls',
  getCqZjList = '/zjcq/getCqZjList',
  getCqXqZjList = '/zjcq/getCqXqZjList',
  sjcq = '/zjcq/sjcq',
  deleteCq = '/zjcq/delete',
  getZjlist = '/zjcq/getZjlist',
  addOrEdit = '/zjcq/addOrEdit', //保存
  deleteZjYj = '/zjcq/deleteZjYj', //保存
  submit = '/zjcq/submit' //提交



}
/**
 * 导出api
 * @param params
 */
export const getExportUrl = Api.exportXls;
export const importExcelCc = Api.importExcelCc;
export const getDownloadZjk = Api.downloadZjk;
/**
 * 导入api
 */
export const getImportUrl = Api.importExcel;
/**
 * 列表接口
 * @param params
 */
export const list = (params) =>
  defHttp.get({ url: Api.list, params });

export const cqlist = (params) =>
  defHttp.get({ url: Api.cqlist, params });

export const getZjlist = (params) =>
  defHttp.get({ url: Api.getZjlist, params });

// 查询数据的接口
export const view = (params) => {
  return defHttp.get({ url: Api.view, params });
}
// 地块编码查询接口
export const searDkbm = (params) => defHttp.get({ url: Api.searDkbm, params });
// 启用停用
export const updateStatus = (params) => {
  return defHttp.get({ url: Api.updateStatus, params });
}
// 后期方案列表
export const getFaList = (params) => {
  return defHttp.get({ url: Api.getFaList, params });
}
// 点击抽取获取的抽取列表
export const getCqXqZjList = (params) => {
  return defHttp.get({ url: Api.getCqXqZjList, params });
}
// 点击抽取获取的抽取列表
export const getCqZjList = (params) => {
  return defHttp.get({ url: Api.getCqZjList, params });
}

// 生成账户
export const sczh = (params) => {
  return defHttp.get({ url: Api.sczh, params });
}
/**
 * 删除单个
 * @param params
 * @param handleSuccess
 */
export const deleteOne = (params, handleSuccess) => {
  defHttp.post({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
    handleSuccess();
  });
  // Modal.confirm({
  //   title: '确认删除',
  //   content: '是否删除选中数据',
  //   okText: '确认',
  //   cancelText: '取消',
  //   onOk: () => {
  //     return 
  //   }
  // });

}

// 抽取删除
export const deleteCq = (params, handleSuccess) => {
  Modal.confirm({
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.get({ url: Api.deleteCq, params }, { joinParamsToUrl: true }).then(() => {
        handleSuccess();
      });
    }
  });

}

/**
 * 保存或者更新
 * @param params
 * @param isUpdate 是否是更新数据
 */
export const saveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.edit : Api.save;
  return defHttp.post({ url: url, params });
}
export const saveCq = (params) => {
  return defHttp.post({ url: Api.saveCq, params });
}
// 点击随机抽取
export const sjcq = (params) => {
  return defHttp.get({ url: Api.sjcq, params });
}
// 点击保存或者提交
export const saveOrUpdateCc = (params, isUpdate) => {
  let url = isUpdate ? Api.addOrEdit : Api.submit;
  return defHttp.post({ url: url, params });
}
//删除抽取专家
export const deleteZjYj = (params) => {
  return defHttp.post({ url: Api.deleteZjYj, params });
}