"use strict";

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); }
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _react = _interopRequireWildcard(require("react"));
var _index = require("../../index");
var _antd = require("antd");
var _vmCard = _interopRequireDefault(require("../../../vm-card"));
var _config = require("../../config");
var _vmInfoCollection = _interopRequireDefault(require("../../../vm-info-collection"));
var _api = require("../../api");
var _groupBy = _interopRequireDefault(require("lodash/groupBy"));
var _util = require("../../../util");
var _PointMap = _interopRequireDefault(require("../Basic/PointMap"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
var QdDetailInfo = function QdDetailInfo() {
  var _useContext = (0, _react.useContext)(_index.RestaurantContext),
    info = _useContext.info;
  var configData = _api.BasicService.getConfigData();
  var baseConfigList = (configData || []).filter(function (item) {
    return item.isVisible;
  });
  var groupByGroupName = (0, _groupBy["default"])(baseConfigList, 'groupName');
  var getDataSource = function getDataSource(config) {
    return config.filter(function (item) {
      return item.dataKey !== 'location';
    }).map(function (item) {
      var formItem = (0, _config.getFormItem)(item, info);
      if (item.dataKey === _config.RestaurantConfigureEnum.DIVISION_NAME) {
        formItem.isAddress = false;
      }
      return Object.assign(Object.assign({
        key: item.dataKey
      }, formItem), formItem.type === 'img' ? {
        render: function render() {
          var photos = JSON.parse(formItem.value || '[]');
          return /*#__PURE__*/_react["default"].createElement("div", {
            style: {
              whiteSpace: 'break-spaces'
            }
          }, photos.map(function (item) {
            return /*#__PURE__*/_react["default"].createElement(_antd.Image, {
              width: 80,
              height: 80,
              key: item.id,
              src: "/vortex/rest/cloud/np/file/downloadFileThumbnail?outputQuality=0.5&scale=0.2&id=".concat(item.id, "&token=").concat((0, _util.getUrlPara)('token')),
              preview: {
                src: "/cloudFile/common/downloadFile?id=".concat(item.id, "&token=").concat((0, _util.getUrlPara)('token'))
              }
            });
          }));
        }
      } : {});
    });
  };
  return /*#__PURE__*/_react["default"].createElement(_antd.Row, {
    gutter: [10, 10],
    style: {
      padding: '0 10px 10px'
    }
  }, Object.keys(groupByGroupName).map(function (name) {
    return /*#__PURE__*/_react["default"].createElement(_antd.Col, {
      span: 24,
      key: name
    }, /*#__PURE__*/_react["default"].createElement(_vmCard["default"], {
      title: name
    }, /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_vmInfoCollection["default"], {
      data: getDataSource(groupByGroupName[name]),
      horizontal: true,
      width: "33%",
      ellipsis: true
    }), groupByGroupName[name].find(function (item) {
      return item.dataKey === 'location';
    }) && /*#__PURE__*/_react["default"].createElement(_PointMap["default"], null))));
  }));
};
var _default = exports["default"] = QdDetailInfo;
//# sourceMappingURL=index.js.map
