ming-demo3
Version:
mdf metaui web
119 lines (92 loc) • 3.85 kB
JavaScript
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _react = _interopRequireWildcard(require("react"));
var _redux = require("redux");
var _reactRedux = require("react-redux");
var _antd = require("antd");
var formulaActions = _interopRequireWildcard(require("../../redux/formula"));
var TreeNode = _antd.Tree.TreeNode;
var LeftContent = function (_Component) {
(0, _inherits2["default"])(LeftContent, _Component);
function LeftContent(props) {
var _this;
(0, _classCallCheck2["default"])(this, LeftContent);
_this = (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(LeftContent).call(this, props));
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onSelect", function (selectedKeys) {
if (!selectedKeys.length) selectedKeys = _this.state.selectedKeys;
_this.setState({
selectedKeys: selectedKeys
});
_this.props.formulaActions.select(selectedKeys[0]);
});
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onLoadData", function (treeNode) {
_this.props.formulaActions.getEntityInfo(treeNode.props.eventKey);
});
_this.state = {
selectedKeys: []
};
return _this;
}
(0, _createClass2["default"])(LeftContent, [{
key: "renderTreeNodes",
value: function renderTreeNodes(treeData) {
var _this2 = this;
return treeData.map(function (item) {
var mergeCode = item.mergeCode,
title = item.title,
isExpand = item.isExpand,
children = item.children;
if (isExpand) return _react["default"].createElement(TreeNode, {
title: title,
key: mergeCode
}, _this2.renderTreeNodes(children || []));
return _react["default"].createElement(TreeNode, {
title: title,
key: mergeCode,
isLeaf: true
});
});
}
}, {
key: "render",
value: function render() {
var _this$props$formula = this.props.formula,
treeData = _this$props$formula.treeData,
billNo = _this$props$formula.billNo;
if (!treeData || !treeData.length) return null;
var treeNodes = this.renderTreeNodes(treeData);
return _react["default"].createElement(_antd.Tree, {
key: billNo,
selectedKeys: this.state.selectedKeys,
onSelect: this.onSelect,
loadData: this.onLoadData
}, treeNodes);
}
}]);
return LeftContent;
}(_react.Component);
function mapStateToProps(state) {
return {
formula: state.formula.toJS()
};
}
function mapDispatchToProps(dispatch) {
return {
formulaActions: (0, _redux.bindActionCreators)(formulaActions, dispatch)
};
}
var _default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(LeftContent);
exports["default"] = _default;
//# sourceMappingURL=LeftContent.js.map
;