wiz-frameworks
Version:
wizlong react framework
153 lines (122 loc) • 7.93 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _utils = require('../../utils');
require('antd/dist/antd.css');
var _tool = require('../../tool');
var _WizContainer2 = require('../WizContainer');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* WizLayoutTemplate 通用布局模版
* @author mll
* @date 2019-10-15
*/
var WizLayout = _tool.component_tool.WizLayout;
var log = _tool.utils_tool.log,
Session = _tool.utils_tool.Session;
var WizLayoutTemplate = function (_WizContainer) {
_inherits(WizLayoutTemplate, _WizContainer);
function WizLayoutTemplate(props) {
_classCallCheck(this, WizLayoutTemplate);
var _this = _possibleConstructorReturn(this, (WizLayoutTemplate.__proto__ || Object.getPrototypeOf(WizLayoutTemplate)).call(this, props));
_this.componentName = '';
_this._layout = function (key, node) {
var params = _this.props.params;
var Comp = WizLayout[key];
if (node) {
return _react2['default'].createElement(
Comp,
_extends({ key: _this.componentName + '@' + key }, node['componentProps']),
_utils.templateUtils.getComponentByConfig(node, _extends({}, _this, { jumpPage: _this.jumpPage, accessBtns: _this.state.accessBtns, params: params }))
);
}
return null;
};
_this.state = {};
return _this;
}
_createClass(WizLayoutTemplate, [{
key: '_componentWillMount',
value: function _componentWillMount() {
var _this2 = this;
var _componentName = this.props.componentName;
if (_componentName && _componentName !== '') {
this.componentName = _componentName;
} else {
log.error('WizLayoutTemplate: 必须传入 容器名称(componentName)!');
}
//获取页面的按钮权限
var accessBtns = this.getMenuBtn(function (accessBtns) {
_this2.setState({ accessBtns: accessBtns });
});
this.setState({ accessBtns: accessBtns });
}
}, {
key: '_render',
value: function _render() {
var _props = this.props,
mainProps = _props.mainProps,
header = _props.header,
content = _props.content,
sider = _props.sider,
footer = _props.footer;
if (sider) {
return _react2['default'].createElement(
WizLayout,
_extends({ key: this.componentName + '@Layout', className: 'full-layout' }, mainProps),
this._layout('Sider', sider),
_react2['default'].createElement(
WizLayout,
_extends({ key: this.componentName + '@Layout' }, mainProps),
this._layout('Header', header),
this._layout('Content', content),
this._layout('Footer', footer)
)
);
} else {
return _react2['default'].createElement(
WizLayout,
_extends({ key: this.componentName + '@Layout', className: 'full-layout' }, mainProps),
this._layout('Header', header),
this._layout('Content', content),
this._layout('Footer', footer)
);
}
}
}]);
return WizLayoutTemplate;
}(_WizContainer2.WizContainer);
exports['default'] = WizLayoutTemplate;
/**
* 参数定义
* isRequired 是必传标示
* mainProps:主题容器的属性(基于antd-Layout的属性)
* componentName:必传⭐️,容器名称
* header:头部组件,布局容器
* content:必传⭐️,主要组件,布局容器
* sider:侧边栏组件,布局容器
* footer:页脚组件,布局容器
*
* 具体配置请看文档:sgm_template.md
*/
WizLayoutTemplate.propTypes = {
mainProps: _propTypes2['default'].any,
componentName: _propTypes2['default'].string.isRequired,
header: _propTypes2['default'].any,
content: _propTypes2['default'].any.isRequired,
sider: _propTypes2['default'].any,
footer: _propTypes2['default'].any
/**
* 默认值
*/
};WizLayoutTemplate.defaultProps = {};
module.exports = exports['default'];