"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = _default;

var _react = _interopRequireDefault(require("react"));

var _classnames = _interopRequireDefault(require("classnames"));

var _userSelector = _interopRequireDefault(require("../../../components/user-selector"));

var _level2Input = _interopRequireDefault(require("./level2-input"));

var _precls = _interopRequireDefault(require("../precls"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _default(props) {
  var selected = props.selected,
      onSelect = props.onSelect,
      forceRender = props.forceRender,
      destroyPopupOnHide = props.destroyPopupOnHide;

  var onSelectHandler = function onSelectHandler(keys, node) {
    var n = node.node;
    onSelect && onSelect(n);
  };

  var onGetTreeDataDoneHandler = function onGetTreeDataDoneHandler(nodes) {
    // 如果当前用户的部门是 “默认部门”，则获取部门树的第一个节点作为搜索部门
    if (selected.id == 0) {
      var n = nodes[0];
      onSelect && onSelect(n);
    }
  };

  return /*#__PURE__*/_react["default"].createElement("span", {
    className: (0, _classnames["default"])("".concat(_precls["default"], "__depart-search"))
  }, /*#__PURE__*/_react["default"].createElement(_userSelector["default"].Depart, {
    popupVisible: false,
    position: "bottomLeft",
    onSelect: onSelectHandler,
    forceRender: forceRender,
    destroyPopupOnHide: destroyPopupOnHide,
    onGetTreeDataDone: onGetTreeDataDoneHandler
  }, /*#__PURE__*/_react["default"].createElement(_level2Input["default"], {
    selectText: selected.name,
    selected: selected,
    type: "depart"
  })));
}