|
@@ -16,7 +16,7 @@ export class Scope {
|
|
|
/**
|
|
|
* 一个 ExtJS 能接受的配置对象
|
|
|
*/
|
|
|
- config
|
|
|
+ vjson
|
|
|
|
|
|
/**
|
|
|
* 双向绑定的模型对象
|
|
@@ -47,26 +47,84 @@ export class Scope {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- constructor({model, vjson}) {
|
|
|
- this.viewModel = new Ext.app.ViewModel(model);
|
|
|
- this.viewModel.yvanScope = this
|
|
|
- this._applyWatchList()
|
|
|
+ /**
|
|
|
+ * 以对话框模式打开当前模块
|
|
|
+ * @param sender 发送者(按钮或Scope对象)
|
|
|
+ * @param option 覆盖选项(可以为空)
|
|
|
+ */
|
|
|
+ showDialog(sender, option) {
|
|
|
+ const that = this
|
|
|
|
|
|
+ const config = _.defaultsDeep({
|
|
|
+ animateTarget: sender,
|
|
|
+ listeners: {
|
|
|
+ show(sender) {
|
|
|
+ // 记录句柄
|
|
|
+ if (sender && !that._handle) {
|
|
|
+ that._handle = sender
|
|
|
+ }
|
|
|
+
|
|
|
+ // 调用onLoad回调
|
|
|
+ that.onLoad()
|
|
|
+
|
|
|
+ // 如果vjson中配置了 afterrender ,需要恢复状态
|
|
|
+ invokeMethod(that.vjson.listeners?.show, that, arguments)
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ }, option, that.vjson)
|
|
|
+
|
|
|
+ const win = new Ext.Window(config);
|
|
|
+ win.show();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 以标签模式打开当前模块
|
|
|
+ * @param option 覆盖选项(可以为空)
|
|
|
+ */
|
|
|
+ showPage(option) {
|
|
|
const that = this
|
|
|
- this.config = _.defaultsDeep({
|
|
|
- closable: true,
|
|
|
+
|
|
|
+ const config = _.defaultsDeep({
|
|
|
listeners: {
|
|
|
added(sender) {
|
|
|
// 记录句柄
|
|
|
if (sender && !that._handle) {
|
|
|
that._handle = sender
|
|
|
}
|
|
|
+
|
|
|
// 调用onLoad回调
|
|
|
that.onLoad()
|
|
|
|
|
|
// 如果vjson中配置了 afterrender ,需要恢复状态
|
|
|
- invokeMethod(vjson.listeners?.added, that, arguments)
|
|
|
- },
|
|
|
+ invokeMethod(that.vjson.listeners?.show, that, arguments)
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ }, option, that.vjson)
|
|
|
+
|
|
|
+ const tt = Ext.getCmp('TT')
|
|
|
+ tt.addScope(this, config)
|
|
|
+
|
|
|
+ return config
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 关闭对话框(或标签页)
|
|
|
+ */
|
|
|
+ close() {
|
|
|
+ this._handle.close()
|
|
|
+ }
|
|
|
+
|
|
|
+ constructor({model, vjson}) {
|
|
|
+ this.viewModel = new Ext.app.ViewModel(model);
|
|
|
+ this.viewModel.yvanScope = this
|
|
|
+ this._applyWatchList()
|
|
|
+
|
|
|
+ const that = this
|
|
|
+ this.vjson = _.defaultsDeep({
|
|
|
+ closable: true,
|
|
|
+ listeners: {
|
|
|
afterrender(sender) {
|
|
|
// 记录句柄
|
|
|
if (sender && !that._handle) {
|
|
@@ -115,7 +173,7 @@ export class Scope {
|
|
|
// 销毁 viewModel
|
|
|
that.viewModel.destroy()
|
|
|
delete that.viewModel
|
|
|
- delete that.config
|
|
|
+ delete that.vjson
|
|
|
delete that._watchList
|
|
|
delete that._handle
|
|
|
|