var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/table/Actions/component/ExportImport/components/ExportTable/function.ts
var function_exports = {};
__export(function_exports, {
  batchExport: () => batchExport
});
module.exports = __toCommonJS(function_exports);
var import_antd = require("antd");
var import_locales = require("../../../../../../../locales/index");
var import_serve = require("../../../../../serve");
var import_status = require("../../../../../status");
var import_file = require("../../utils/file");
var _batchExport = async (params) => {
  let { status } = await (0, import_serve.exportData)(params);
  if (status) {
    import_antd.message.success({
      content: (0, import_locales.getText)("table-action-export-import-export-success"),
      key: import_status.defaultOptions.exportValue
    });
    return true;
  } else {
    import_antd.message.destroy();
  }
};
var batchExport = (exportParams, exportImport) => {
  const { selectLists, apiUrl, otherParams } = exportImport;
  let _name = (0, import_file.getFileDateName)();
  let params = { ...otherParams };
  params.url = apiUrl == null ? void 0 : apiUrl.export;
  console.log("exportParams", exportParams);
  const type = (exportParams == null ? void 0 : exportParams.type) || import_status.defaultOptions.exportType;
  if (type === import_status.defaultOptions.exportType) {
    _name = `${(0, import_locales.getText)("table-action-export-import-current-page")}${_name}`;
    const lists = (exportParams == null ? void 0 : exportParams.currentDataSource) || [];
    params.ids = lists.map((item) => (item == null ? void 0 : item.id) || (item == null ? void 0 : item.form_record_id));
    params.file_name = _name;
  }
  if (type === "all-records") {
    _name = `${(0, import_locales.getText)("table-action-export-import-all-records")}${_name}`;
    if ((otherParams == null ? void 0 : otherParams.form_id) || (otherParams == null ? void 0 : otherParams.code)) {
      const lists = (exportParams == null ? void 0 : exportParams.originDataSource) || [];
      params.ids = lists.map((item) => (item == null ? void 0 : item.id) || (item == null ? void 0 : item.form_record_id));
    }
    params.file_name = _name;
  }
  if (type === "selected-records") {
    _name = `${(0, import_locales.getText)(
      "table-action-export-import-selected-records"
    )}(${(0, import_locales.getText)("table-action-export-import-selected")} ${(0, import_locales.getText)("table-action-export-import-item")(selectLists == null ? void 0 : selectLists.length)}) ${_name}`;
    params.ids = selectLists || [];
    params.file_name = _name;
  }
  if (type !== "all-records") {
    params == null ? true : delete params.shipping_status;
    params == null ? true : delete params.payment_status;
    params == null ? true : delete params.status;
  } else {
    params == null ? true : delete params.ids;
  }
  return _batchExport(params);
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  batchExport
});
