qm-bus
Version:
千米公有云业务组件库
130 lines (107 loc) • 4.85 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = undefined;
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 _class, _temp; /**
* @author gcy[of1518]
* @date 16/09/30
*
* @description Table service加持
*/
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
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; }
var noop = function noop() {
return undefined;
};
var QMDataViewCore = (_temp = _class = function (_Component) {
_inherits(QMDataViewCore, _Component);
function QMDataViewCore(props) {
_classCallCheck(this, QMDataViewCore);
return _possibleConstructorReturn(this, (QMDataViewCore.__proto__ || Object.getPrototypeOf(QMDataViewCore)).call(this, props));
}
_createClass(QMDataViewCore, [{
key: 'componentWillMount',
value: function componentWillMount() {
var _props = this.props,
netUrl = _props.netUrl,
netHost = _props.netHost,
init = _props.init,
netPre = _props.netPre,
net = _props.net,
netPost = _props.netPost,
defaultDataFilter = _props.defaultDataFilter;
init({ netUrl: netUrl, netHost: netHost, netPre: netPre, net: net, netPost: netPost, dataFilter: defaultDataFilter });
}
}, {
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(nextProps) {
if (nextProps.hash != this.props.hash) {
var _props2 = this.props,
onFetch = _props2.onFetch,
netUrl = _props2.netUrl,
netHost = _props2.netHost,
initial = _props2.initial,
netPre = _props2.netPre,
net = _props2.net,
netPost = _props2.netPost,
hash = _props2.hash,
manual = _props2.manual;
if (!!netUrl && !manual) {
//如果配置异步请求url则开始发送请求
this.props.onRefresh(true);
}
}
}
}, {
key: 'render',
value: function render() {
var className = this.props.className;
return _react2.default.createElement(
'div',
{ className: className },
this.props.children
);
}
}, {
key: 'componentDidMount',
value: function componentDidMount() {
var _props3 = this.props,
onFetch = _props3.onFetch,
netUrl = _props3.netUrl,
netHost = _props3.netHost,
initial = _props3.initial,
netPre = _props3.netPre,
net = _props3.net,
netPost = _props3.netPost,
hash = _props3.hash,
manual = _props3.manual;
initial({ hash: hash });
if (!!netUrl && !manual) {
//如果配置异步请求url则开始发送请求
onFetch({ url: netUrl || '', host: netHost || '', netPre: netPre, net: net, netPost: netPost, clearFilter: false });
}
}
}]);
return QMDataViewCore;
}(_react.Component), _class.defaultProps = {
netUrl: '', //异步请求url
netHost: '', //请求域
netPre: undefined,
net: undefined,
netPost: undefined,
hash: '', //
//private
init: noop,
initial: noop,
onFetch: noop,
onRefresh: noop,
onCurrentRefresh: noop,
manual: false //是否初始化
}, _temp);
exports.default = QMDataViewCore;