|
@@ -1,10 +1,61 @@
|
|
|
+import _ from 'lodash'
|
|
|
+import {invokeMethod} from "./utils";
|
|
|
+
|
|
|
export class Scope {
|
|
|
|
|
|
+ /**
|
|
|
+ * 业务模块的唯一编号
|
|
|
+ */
|
|
|
+ id = _.uniqueId('scope_')
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 一个 ExtJS 能接受的配置对象
|
|
|
+ */
|
|
|
+ config
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 双向绑定的模型对象
|
|
|
+ */
|
|
|
viewModel
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 构建完成之后的 Ext控件句柄
|
|
|
+ */
|
|
|
_handle
|
|
|
|
|
|
- constructor({model}) {
|
|
|
+ constructor({model, vjson}) {
|
|
|
this.viewModel = new Ext.app.ViewModel(model);
|
|
|
this.viewModel.yvanScope = this
|
|
|
+
|
|
|
+ const that = this
|
|
|
+ this.config = _.defaultsDeep({
|
|
|
+ closable: true,
|
|
|
+ listeners: {
|
|
|
+ afterrender(sender) {
|
|
|
+ // 记录句柄
|
|
|
+ that._handle = sender
|
|
|
+ // 调用onLoad回调
|
|
|
+ that.onLoad()
|
|
|
+ // 如果vjson中配置了 afterrender ,需要恢复状态
|
|
|
+ invokeMethod(vjson.listeners?.afterrender, that, arguments)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ yvanScope: this,
|
|
|
+ viewModel: this.viewModel,
|
|
|
+ }, vjson)
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 模块载入完成之后的回调
|
|
|
+ */
|
|
|
+ onLoad() {
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 产生一个当前模块有效的唯一id
|
|
|
+ * @param key 唯一编号
|
|
|
+ */
|
|
|
+ uid(key) {
|
|
|
+ return this.id + key
|
|
|
}
|
|
|
}
|