|
@@ -113,24 +113,8 @@ export class Scope {
|
|
|
const config = _.defaultsDeep({
|
|
|
animateTarget: sender,
|
|
|
viewModel: this.viewModel,
|
|
|
- listeners: {
|
|
|
- show(sender) {
|
|
|
- // 记录句柄
|
|
|
- if (sender && !that._handle) {
|
|
|
- that._handle = sender
|
|
|
- }
|
|
|
-
|
|
|
- // 调用onLoad回调
|
|
|
- try {
|
|
|
- that.onLoad()
|
|
|
- } catch (e) {
|
|
|
- console.error('errorAt onLoad', e)
|
|
|
- }
|
|
|
-
|
|
|
- // 如果vjson中配置了 afterrender ,需要恢复状态
|
|
|
- invokeMethod(that.vjson.listeners?.show, that, arguments)
|
|
|
- }
|
|
|
- },
|
|
|
+ yvanScope: this,
|
|
|
+ referenceHolder: true,
|
|
|
|
|
|
}, vjsonOption, that.vjson, windows)
|
|
|
|
|
@@ -146,6 +130,22 @@ export class Scope {
|
|
|
if (holder) {
|
|
|
holder.add(win)
|
|
|
}
|
|
|
+
|
|
|
+ win.addListener('show', function (sender) {
|
|
|
+ // 记录句柄
|
|
|
+ if (sender && !that._handle) {
|
|
|
+ that._handle = sender
|
|
|
+ }
|
|
|
+
|
|
|
+ // 调用onLoad回调
|
|
|
+ try {
|
|
|
+ that.onLoad()
|
|
|
+ } catch (e) {
|
|
|
+ console.error('errorAt onLoad', e)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ win.addListener('destroy', this._destroy.bind(this))
|
|
|
+
|
|
|
win.show();
|
|
|
}
|
|
|
|
|
@@ -154,7 +154,7 @@ export class Scope {
|
|
|
* @param vjsonOption 界面覆盖选项(可以为空)
|
|
|
* @param dataOption 数据覆盖选项(可以为空)
|
|
|
*/
|
|
|
- showPage(vjsonOption, dataOption, reload = false) {
|
|
|
+ showPage(vjsonOption, dataOption) {
|
|
|
const that = this
|
|
|
this._vjsonOption = vjsonOption;
|
|
|
this._dataOption = dataOption;
|
|
@@ -168,31 +168,30 @@ export class Scope {
|
|
|
|
|
|
const config = _.defaultsDeep({
|
|
|
viewModel: this.viewModel,
|
|
|
- listeners: {
|
|
|
- added(sender) {
|
|
|
- // 记录句柄
|
|
|
- if (sender && !that._handle) {
|
|
|
- that._handle = sender
|
|
|
- }
|
|
|
-
|
|
|
- // 调用onLoad回调
|
|
|
- try {
|
|
|
- that.onLoad()
|
|
|
- } catch (e) {
|
|
|
- console.error('errorAt onLoad', e)
|
|
|
- }
|
|
|
-
|
|
|
- // 如果vjson中配置了 afterrender ,需要恢复状态
|
|
|
- invokeMethod(that.vjson.listeners?.added, that, arguments)
|
|
|
- }
|
|
|
- },
|
|
|
+ yvanScope: this,
|
|
|
+ referenceHolder: true,
|
|
|
|
|
|
}, vjsonOption, that.vjson)
|
|
|
|
|
|
const tt = Ext.getCmp('TT')
|
|
|
- tt.addScope(this, config, reload)
|
|
|
+ const handle = tt.addScope(this, config, (handle) => {
|
|
|
+ handle.addListener('added', function (sender) {
|
|
|
+ // 记录句柄
|
|
|
+ if (sender && !that._handle) {
|
|
|
+ that._handle = sender
|
|
|
+ }
|
|
|
|
|
|
- return config
|
|
|
+ // 调用onLoad回调
|
|
|
+ try {
|
|
|
+ that.onLoad()
|
|
|
+ } catch (e) {
|
|
|
+ console.error('errorAt onLoad', e)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ handle.addListener('destroy', this._destroy.bind(this))
|
|
|
+ })
|
|
|
+
|
|
|
+ return handle
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -215,7 +214,10 @@ export class Scope {
|
|
|
|
|
|
const config = _.defaultsDeep({
|
|
|
viewModel: this.viewModel,
|
|
|
+ yvanScope: this,
|
|
|
+ referenceHolder: true,
|
|
|
renderTo: element,
|
|
|
+
|
|
|
listeners: {
|
|
|
afterrender(sender) {
|
|
|
// 记录句柄
|
|
@@ -232,7 +234,8 @@ export class Scope {
|
|
|
|
|
|
// 如果vjson中配置了 afterrender ,需要恢复状态
|
|
|
invokeMethod(that.vjson.listeners?.afterrender, that, arguments)
|
|
|
- }
|
|
|
+ },
|
|
|
+
|
|
|
},
|
|
|
|
|
|
}, vjsonOption, that.vjson)
|
|
@@ -240,11 +243,6 @@ export class Scope {
|
|
|
new Ext.container.Viewport(config);
|
|
|
}
|
|
|
|
|
|
- reRender() {
|
|
|
- this.vjson = this.buildVjson()
|
|
|
- this.showPage(this._vjsonOption, this._dataOption, true)
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 关闭对话框(或标签页)
|
|
|
*/
|
|
@@ -283,78 +281,19 @@ export class Scope {
|
|
|
return this._handle.getReferences()
|
|
|
}
|
|
|
|
|
|
- constructor({model, vjson}) {
|
|
|
+ _destroy() {
|
|
|
const that = this
|
|
|
- this.model = model
|
|
|
- this.originalVjson = _.cloneDeep(vjson)
|
|
|
- this.vjson = this.buildVjson()
|
|
|
+
|
|
|
+ that.onDestroy()
|
|
|
+ delete that._watchList
|
|
|
+ delete that._handle
|
|
|
}
|
|
|
|
|
|
- buildVjson() {
|
|
|
+ constructor({model, vjson}) {
|
|
|
const that = this
|
|
|
- return _.defaultsDeep({
|
|
|
- closable: true,
|
|
|
- listeners: {
|
|
|
- afterrender(sender) {
|
|
|
- // 记录句柄
|
|
|
- if (sender && !that._handle) {
|
|
|
- that._handle = sender
|
|
|
- }
|
|
|
-
|
|
|
- // 调用 onRender 回调
|
|
|
- that.onRender()
|
|
|
-
|
|
|
- // 如果vjson中配置了 afterrender ,需要恢复状态
|
|
|
- invokeMethod(that.originalVjson.listeners?.afterrender, that, arguments)
|
|
|
- },
|
|
|
- activate(sender) {
|
|
|
- // 调用 onActivate 回调
|
|
|
- that.onActivate()
|
|
|
-
|
|
|
- const vm = sender.lookupViewModel()
|
|
|
- if (vm) {
|
|
|
- window['currentScope'] = sender.lookupViewModel().yvanScope
|
|
|
- }
|
|
|
- // 如果vjson中配置了 afterrender ,需要恢复状态
|
|
|
- invokeMethod(that.originalVjson.listeners?.activate, that, arguments)
|
|
|
- },
|
|
|
- deactivate(sender) {
|
|
|
- // 调用 onActivate 回调
|
|
|
- that.onDeactivate()
|
|
|
- // 如果vjson中配置了 afterrender ,需要恢复状态
|
|
|
- invokeMethod(that.originalVjson.listeners?.deactivate, that, arguments)
|
|
|
- },
|
|
|
- beforedestroy(sender) {
|
|
|
- // 调用 onBeforeDestroy 回调
|
|
|
- that.onBeforeDestroy()
|
|
|
- // 如果vjson中配置了 afterrender ,需要恢复状态
|
|
|
- invokeMethod(that.originalVjson.listeners?.beforedestroy, that, arguments)
|
|
|
- },
|
|
|
- beforeclose(sender) {
|
|
|
- // 调用 onActivate 回调
|
|
|
- that.onBeforeClose()
|
|
|
- // 如果vjson中配置了 afterrender ,需要恢复状态
|
|
|
- invokeMethod(that.originalVjson.listeners?.beforeclose, that, arguments)
|
|
|
- },
|
|
|
- destroy(sender) {
|
|
|
- // 调用 onActivate 回调
|
|
|
- that.onDestroy()
|
|
|
-
|
|
|
- // 销毁 viewModel
|
|
|
- // that.viewModel.destroy()
|
|
|
- // 如果vjson中配置了 afterrender ,需要恢复状态
|
|
|
- invokeMethod(that.originalVjson.listeners?.destroy, that, arguments)
|
|
|
- // delete that.viewModel
|
|
|
- // delete that.vjson
|
|
|
- // delete that.originalVjson
|
|
|
- delete that._watchList
|
|
|
- delete that._handle
|
|
|
- },
|
|
|
- },
|
|
|
- yvanScope: this,
|
|
|
- referenceHolder: true,
|
|
|
-
|
|
|
- }, this.originalVjson)
|
|
|
+ this.model = model
|
|
|
+ this.originalVjson = _.cloneDeep(vjson)
|
|
|
+ this.vjson = this.originalVjson // this.buildVjson()
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -364,36 +303,6 @@ export class Scope {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 渲染完成之后的回调
|
|
|
- */
|
|
|
- onRender() {
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 被激活时的回调(可能执行多次)
|
|
|
- */
|
|
|
- onActivate() {
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 进入未激活状态之前回调的函数
|
|
|
- */
|
|
|
- onDeactivate() {
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 关闭之前的回调(只有 tab 选项卡有这个选项)
|
|
|
- */
|
|
|
- onBeforeClose() {
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 组件被卸载之前的回调
|
|
|
- */
|
|
|
- onBeforeDestroy() {
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
* 组件卸载之后的回调
|
|
|
*/
|
|
|
onDestroy() {
|