"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

exports.__esModule = true;
exports.default = void 0;

var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));

var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _popup = _interopRequireDefault(require("../popup"));

var _orgTree = _interopRequireDefault(require("../org-tree"));

require("./style");

var __vue_render__ = function __vue_render__() {
  var _vm = this;

  var _h = _vm.$createElement;

  var _c = _vm._self._c || _h;

  return _c('ks-popup', {
    ref: "pop",
    staticClass: "ks-pop-org-tree",
    style: (0, _extends2.default)({}, _vm.defaultStyle),
    attrs: {
      "value": _vm.value,
      "position": _vm.position,
      "overlay": _vm.overlay,
      "overlay-style": _vm.overlayStyle,
      "get-container": _vm.getContainer,
      "lazy-render": _vm.lazyRender,
      "closeable": _vm.closeable,
      "close-on-click-overlay": _vm.closeOnClickOverlay
    },
    on: {
      "click-overlay": _vm.onClose,
      "open": _vm.open
    }
  }, [_c('ks-org-tree', {
    ref: "KsOrgTree",
    staticStyle: {
      "height": "100%"
    },
    attrs: {
      "show-title": _vm.showTitle,
      "default-checked-keys": _vm.defaultCheckedKeys,
      "tree-id": _vm.treeId,
      "multiple": _vm.multiple
    },
    on: {
      "node-click": _vm.treeNodeClick,
      "handleChange": _vm.handleChange,
      "clear": _vm.clear,
      "onClose": _vm.onClose
    },
    scopedSlots: _vm._u([{
      key: "treeNode",
      fn: function fn(ref) {
        var node = ref.node;
        var attrs = ref.attrs;
        return [_vm._t("treeNode", null, {
          "node": node,
          "attrs": attrs
        })];
      }
    }], null, true)
  }, [_c('template', {
    slot: "title"
  }, [_vm._t("title")], 2)], 2)], 1);
};

var __vue_staticRenderFns__ = [];
var _default2 = {
  render: __vue_render__,
  staticRenderFns: __vue_staticRenderFns__,
  name: 'ks-org-tree-pop',
  components: {
    KsOrgTree: _orgTree.default
  },
  props: {
    defaultStyle: {
      type: Object,
      default: function _default() {
        return {
          height: '100%',
          borderRadius: '12px 0px 0px 12px',
          width: '90%'
        };
      }
    },
    overlay: {
      type: Boolean,
      default: false
    },
    closeable: {
      type: Boolean,
      default: false
    },
    lazyRender: {
      type: Boolean,
      default: false
    },
    closeOnClickOverlay: {
      type: Boolean,
      default: false
    },
    getContainer: {
      type: String,
      default: 'body'
    },
    position: {
      type: String,
      default: 'right'
    },
    defaultCheckedKeys: {
      type: Array,
      default: function _default() {
        return [];
      }
    },
    treeId: String,
    value: Boolean,
    multiple: {
      type: Boolean,
      default: false
    },
    showTitle: {
      type: Boolean,
      default: true
    }
  },
  data: function data() {
    return {
      height: 0,
      overlayStyle: {
        zIndex: 99
      }
    };
  },
  methods: {
    treeNodeClick: function treeNodeClick(item) {
      this.$emit('node-click', item);
    },
    clear: function clear() {
      this.$emit('clear');
    },
    queryNodeDetail: function queryNodeDetail(id) {
      return this.$refs.KsOrgTree.$refs.tree.queryNodeDetail(id);
    },
    getTreeData: function getTreeData() {
      return this.$refs.KsOrgTree.$refs.tree.treeData;
    },
    open: function open() {
      var _this = this;

      this.$nextTick(function () {
        _this.$refs.KsOrgTree.open();
      });
    },

    /*
    * 确定
    */
    handleChange: function handleChange(v) {
      var _this2 = this;

      return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
        return _regenerator.default.wrap(function _callee$(_context) {
          while (1) {
            switch (_context.prev = _context.next) {
              case 0:
                _this2.$emit('handleChange', v);

                _this2.$emit('input', false);

              case 2:
              case "end":
                return _context.stop();
            }
          }
        }, _callee);
      }))();
    },

    /*
    * 关闭
    */
    onClose: function onClose() {
      this.$emit('input', false);
      this.$emit('onClose');
    }
  }
};
exports.default = _default2;