"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _message = _interopRequireDefault(require("antd/lib/message"));
var _PublicService = _interopRequireDefault(require("../../_mapUtil/PublicService"));
var _Download = _interopRequireDefault(require("../../../utils/Download"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
 * @Author: lixiaohui lixiaohui@vortexinfo.cn
 * @Date: 2022-07-28 11:28:24
 * @LastEditors: limingxian limingxian@vortexinfo.cn
 * @LastEditTime: 2023-02-25 21:16:25
 * @FilePath: \jinyuan-web\src\components\Common\MyTable\exportMethod.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
/**
 * 导出公共方法
 * @param url 接口地址
 * @param selectedRows 选中行数据
 * @param tableData 表格数据
 * @param rowId 所需id字段
 * @param type 导出类型
 * @param method 导出接口方式
 */
function exportMethod(_ref) {
  var url = _ref.url,
    _ref$selectedRows = _ref.selectedRows,
    selectedRows = _ref$selectedRows === void 0 ? [] : _ref$selectedRows,
    _ref$tableData = _ref.tableData,
    tableData = _ref$tableData === void 0 ? [] : _ref$tableData,
    _ref$rowId = _ref.rowId,
    rowId = _ref$rowId === void 0 ? 'id' : _ref$rowId,
    type = _ref.type,
    _ref$method = _ref.method,
    method = _ref$method === void 0 ? 'GET' : _ref$method,
    _ref$params = _ref.params,
    params = _ref$params === void 0 ? {} : _ref$params;
  var P = {
    select: {
      // exportType: 'SELECTED',
      idList: selectedRows
    },
    page: {
      // exportType: 'SELECTED',
      idList: _PublicService["default"].getDataByKey(tableData, rowId)
    },
    all: {
      // exportType: 'ALL',
    }
  };
  var param = _objectSpread(_objectSpread({}, params), P[type]);
  if (['select'].includes(type)) {
    if (!param.idList.length) {
      return _message["default"].warning('请选择要导出的数据！');
    }
  }
  (0, _Download["default"])({
    url: url,
    params: param,
    method: method
  });
}
var _default = exports["default"] = exportMethod;
//# sourceMappingURL=exportMethod.js.map
