1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import { Vue } from 'vue-property-decorator';
import { Subject, Observable } from 'rxjs';
import { AppServiceBase } from 'ibiz-core';
import { Util } from 'ibiz-core';
import { AppTopDrawer } from './app-top-drawer';
/**
* 模态
*
* @export
* @class AppTopDrawerContainer
*/
export class AppTopDrawerContainer {
/**
* 唯一实例
*
* @protected
* @static
* @type {AppTopDrawerContainer}
* @memberof AppTopDrawerContainer
*/
protected static readonly instance: AppTopDrawerContainer = new AppTopDrawerContainer();
/**
* 模态承载容器
*
* @protected
* @type {HTMLDivElement}
* @memberof AppTopDrawerContainer
*/
protected modalContainer: HTMLDivElement;
/**
* store对象
*
* @private
* @memberof AppTopDrawerContainer
*/
private store: any;
/**
* i18n对象
*
* @private
* @memberof AppTopDrawerContainer
*/
private i18n: any;
/**
* 路由对象
*
* @private
* @memberof AppTopDrawerContainer
*/
private router: any;
/**
* Vue实例
*
* @protected
* @type {*}
* @memberof AppTopDrawerContainer
*/
protected vueInstance!: any;
/**
* Creates an instance of AppTopDrawerContainer.
* @memberof AppTopDrawerContainer
*/
constructor() {
this.modalContainer = document.createElement('div');
document.body.appendChild(this.modalContainer);
}
/**
* 初始化基础数据
*
* @memberof AppTopDrawerContainer
*/
private initBasicData() {
const appService = AppServiceBase.getInstance();
this.store = appService.getAppStore();
this.i18n = appService.getI18n();
this.router = appService.getRouter();
}
/**
* 初始化
*
* @protected
* @memberof AppTopDrawerContainer
*/
protected init(): void {
this.vueInstance = new Vue({
store: this.store,
router: this.router,
i18n: this.i18n,
render: (h: any) => h(AppTopDrawer, { ref: 'AppTopDrawer' }),
}).$mount(this.modalContainer);
}
/**
* 顶部抽屉模式打开视图
*
* @param {{ viewname: string, title: string, width?: number, height?: number }} view 视图
* @param {*} [viewParam={}] 视图参数
* @param {any[]} deResParameters 关系实体参数对象
* @param {any[]} parameters 当前应用视图参数对象
* @param {any[]} args 多项数据
* @param {*} [data={}] 行为参数
* @returns {Observable<any>}
* @memberof AppTopDrawerContainer
*/
public openDrawer(
view: { viewname: string; title: string; width?: number; height?: number; placement?: string },
dynamicProps: any = {},
staticProps: any = {}
): Observable<any> {
view.viewname = 'app-view-shell';
const subject: Subject<any> = new Subject();
this.initBasicData();
this.getVueInstance()
.$refs.AppTopDrawer.openModal({ ...view, dynamicProps: dynamicProps, staticProps: staticProps })
.then((data: any) => {
subject.next(data);
subject.complete();
subject.unsubscribe();
});
return subject.asObservable();
}
/**
* 获取Vue容器实例
*
* @protected
* @returns {*}
* @memberof AppTopDrawerContainer
*/
protected getVueInstance(): any {
if (!this.vueInstance) {
this.init();
}
return this.vueInstance;
}
}
// 模态服务控制器实例
export const appTopDrawerContainer: AppTopDrawerContainer = new AppTopDrawerContainer();