"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var antd_1 = require("antd");
var DynamicTree_1 = require("../../_common/VTree/DynamicTree");
// 安全域选择器
var default_1 = /** @class */ (function (_super) {
    __extends(default_1, _super);
    function default_1() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.state = {
            show: false,
            currentNode: null,
            treeData: [],
        };
        return _this;
    }
    default_1.prototype.componentDidMount = function () {
        if (this.props.domainInfo && this.props.domainInfo.code) {
            this.setState({ currentNode: this.props.domainInfo });
        }
    };
    default_1.prototype.show = function () {
        this.setState({ show: true });
    };
    default_1.prototype.onChooseNode = function (currentNode) {
        this.setState({ show: false });
        this.props.onSelect(currentNode);
    };
    default_1.prototype.render = function () {
        var _this = this;
        var param = {};
        if (this.props.domainInfo && this.props.domainInfo.code) {
            param = {
                defaultSelectedKeys: [this.props.domainInfo.code],
            };
        }
        return React.createElement(antd_1.Modal, { visible: this.state.show, title: '请选择区域', bodyStyle: { maxHeight: 560, overflow: 'auto' }, footer: React.createElement("div", null,
                this.state.currentNode && React.createElement("span", { style: { marginRight: 12 } },
                    "\u5DF2\u9009\u62E9 ",
                    React.createElement("b", null, this.state.currentNode.domainName)),
                React.createElement(antd_1.Button, { disabled: this.props.required && this.state.currentNode == null, type: "primary", onClick: function () { return _this.onChooseNode(_this.state.currentNode); } }, "\u786E\u5B9A")), onCancel: function () { return _this.setState({ show: false }); } },
            React.createElement(DynamicTree_1.default, __assign({}, param, { mustSelect: this.props.required, root: "/api-common/secruity/domain", child: "/api-common/secruity/domain/", onSelect: function (currentNode) {
                    if (currentNode) {
                        _this.setState({ currentNode: currentNode });
                    }
                    else {
                        _this.props.onSelect({ currentNode: null });
                    }
                }, keyField: 'code', nameField: 'domainName', parentField: 'parentCode', checkChild: "hasChildren" })));
    };
    return default_1;
}(React.PureComponent));
exports.default = default_1;
