|
@@ -9,6 +9,8 @@ export class Scope {
|
|
|
*/
|
|
|
id = _.uniqueId('scope_')
|
|
|
|
|
|
+ originalVjson
|
|
|
+
|
|
|
/**
|
|
|
* 一个 ExtJS 能接受的配置对象
|
|
|
*/
|
|
@@ -35,6 +37,12 @@ export class Scope {
|
|
|
*/
|
|
|
_watchList
|
|
|
|
|
|
+ /**
|
|
|
+ * 页面显示的时候带的参数 在设计刷新的时候使用
|
|
|
+ */
|
|
|
+ _vjsonOption
|
|
|
+ _dataOption
|
|
|
+
|
|
|
_addWatch(tplExpress, fn) {
|
|
|
if (!this._watchList) {
|
|
|
this._watchList = []
|
|
@@ -106,9 +114,10 @@ export class Scope {
|
|
|
* @param vjsonOption 界面覆盖选项(可以为空)
|
|
|
* @param dataOption 数据覆盖选项(可以为空)
|
|
|
*/
|
|
|
- showPage(vjsonOption, dataOption) {
|
|
|
+ showPage(vjsonOption, dataOption, reload = false) {
|
|
|
const that = this
|
|
|
-
|
|
|
+ this._vjsonOption = vjsonOption;
|
|
|
+ this._dataOption = dataOption;
|
|
|
const vmodel = _.defaultsDeep({
|
|
|
data: {}
|
|
|
}, dataOption, that.model)
|
|
@@ -137,7 +146,7 @@ export class Scope {
|
|
|
}, vjsonOption, that.vjson)
|
|
|
|
|
|
const tt = Ext.getCmp('TT')
|
|
|
- tt.addScope(this, config)
|
|
|
+ tt.addScope(this, config, reload)
|
|
|
|
|
|
return config
|
|
|
}
|
|
@@ -150,7 +159,8 @@ export class Scope {
|
|
|
*/
|
|
|
renderTo(element, vjsonOption, dataOption) {
|
|
|
const that = this
|
|
|
-
|
|
|
+ this._vjsonOption = vjsonOption;
|
|
|
+ this._dataOption = dataOption;
|
|
|
const vmodel = _.defaultsDeep({
|
|
|
data: {}
|
|
|
}, dataOption, that.model)
|
|
@@ -182,6 +192,11 @@ export class Scope {
|
|
|
new Ext.container.Viewport(config);
|
|
|
}
|
|
|
|
|
|
+ reRender() {
|
|
|
+ this.vjson = this.buildVjson()
|
|
|
+ this.showPage(this._vjsonOption,this._dataOption, true)
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 关闭对话框(或标签页)
|
|
|
*/
|
|
@@ -223,7 +238,13 @@ export class Scope {
|
|
|
constructor({model, vjson}) {
|
|
|
const that = this
|
|
|
this.model = model
|
|
|
- this.vjson = _.defaultsDeep({
|
|
|
+ this.originalVjson = _.cloneDeep(vjson)
|
|
|
+ this.vjson = this.buildVjson()
|
|
|
+ }
|
|
|
+
|
|
|
+ buildVjson() {
|
|
|
+ const that = this
|
|
|
+ return _.defaultsDeep({
|
|
|
closable: true,
|
|
|
listeners: {
|
|
|
afterrender(sender) {
|
|
@@ -236,7 +257,7 @@ export class Scope {
|
|
|
that.onRender()
|
|
|
|
|
|
// 如果vjson中配置了 afterrender ,需要恢复状态
|
|
|
- invokeMethod(vjson.listeners?.afterrender, that, arguments)
|
|
|
+ invokeMethod(that.originalVjson.listeners?.afterrender, that, arguments)
|
|
|
},
|
|
|
activate(sender) {
|
|
|
// 调用 onActivate 回调
|
|
@@ -247,45 +268,45 @@ export class Scope {
|
|
|
window['currentScope'] = sender.lookupViewModel().yvanScope
|
|
|
}
|
|
|
// 如果vjson中配置了 afterrender ,需要恢复状态
|
|
|
- invokeMethod(vjson.listeners?.activate, that, arguments)
|
|
|
+ invokeMethod(that.originalVjson.listeners?.activate, that, arguments)
|
|
|
},
|
|
|
deactivate(sender) {
|
|
|
// 调用 onActivate 回调
|
|
|
that.onDeactivate()
|
|
|
// 如果vjson中配置了 afterrender ,需要恢复状态
|
|
|
- invokeMethod(vjson.listeners?.deactivate, that, arguments)
|
|
|
+ invokeMethod(that.originalVjson.listeners?.deactivate, that, arguments)
|
|
|
},
|
|
|
beforedestroy(sender) {
|
|
|
// 调用 onBeforeDestroy 回调
|
|
|
that.onBeforeDestroy()
|
|
|
// 如果vjson中配置了 afterrender ,需要恢复状态
|
|
|
- invokeMethod(vjson.listeners?.beforedestroy, that, arguments)
|
|
|
+ invokeMethod(that.originalVjson.listeners?.beforedestroy, that, arguments)
|
|
|
},
|
|
|
beforeclose(sender) {
|
|
|
// 调用 onActivate 回调
|
|
|
that.onBeforeClose()
|
|
|
// 如果vjson中配置了 afterrender ,需要恢复状态
|
|
|
- invokeMethod(vjson.listeners?.beforeclose, that, arguments)
|
|
|
+ invokeMethod(that.originalVjson.listeners?.beforeclose, that, arguments)
|
|
|
},
|
|
|
destroy(sender) {
|
|
|
// 调用 onActivate 回调
|
|
|
that.onDestroy()
|
|
|
|
|
|
// 销毁 viewModel
|
|
|
- that.viewModel.destroy()
|
|
|
- delete that.viewModel
|
|
|
- delete that.vjson
|
|
|
+ // 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
|
|
|
-
|
|
|
- // 如果vjson中配置了 afterrender ,需要恢复状态
|
|
|
- invokeMethod(vjson.listeners?.destroy, that, arguments)
|
|
|
},
|
|
|
},
|
|
|
yvanScope: this,
|
|
|
referenceHolder: true,
|
|
|
|
|
|
- }, vjson)
|
|
|
+ }, this.originalVjson)
|
|
|
}
|
|
|
|
|
|
/**
|