@yelon/bis 12.0.17 → 13.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/LICENSE +21 -21
  2. package/bis.d.ts +5 -4
  3. package/{esm2015/bis.js → esm2020/bis.mjs} +4 -4
  4. package/esm2020/layout/act.guard.mjs +108 -0
  5. package/{esm2015/layout/bis.config.js → esm2020/layout/bis.config.mjs} +10 -10
  6. package/esm2020/layout/contact/contact.component.mjs +492 -0
  7. package/esm2020/layout/contact/contact.service.mjs +146 -0
  8. package/esm2020/layout/layout.mjs +5 -0
  9. package/esm2020/layout/layout.module.mjs +73 -0
  10. package/{esm2015/layout/path-to-regexp.service.js → esm2020/layout/path-to-regexp.service.mjs} +238 -237
  11. package/{esm2015/layout/public_api.js → esm2020/layout/public_api.mjs} +15 -15
  12. package/esm2020/layout/stomp.config.mjs +18 -0
  13. package/{esm2015/layout/widgets/index.js → esm2020/layout/widgets/index.mjs} +7 -7
  14. package/esm2020/layout/widgets/yz.application.component.mjs +271 -0
  15. package/esm2020/layout/widgets/yz.clear-storage.component.mjs +45 -0
  16. package/esm2020/layout/widgets/yz.fullscreen.component.mjs +45 -0
  17. package/esm2020/layout/widgets/yz.i18n.component.mjs +115 -0
  18. package/esm2020/layout/widgets/yz.notify.component.mjs +184 -0
  19. package/esm2020/layout/widgets/yz.them-btn.component.mjs +196 -0
  20. package/esm2020/layout/widgets/yz.user.component.mjs +112 -0
  21. package/esm2020/layout/yz.auth.service.mjs +156 -0
  22. package/esm2020/layout/yz.basic.component.mjs +207 -0
  23. package/esm2020/layout/yz.default.interceptor.mjs +203 -0
  24. package/esm2020/layout/yz.i18n.service.mjs +93 -0
  25. package/esm2020/layout/yz.startup.service.mjs +137 -0
  26. package/esm2020/layout/yz.stomp.service.mjs +88 -0
  27. package/{esm2015/public_api.js → esm2020/public_api.mjs} +1 -1
  28. package/{esm2015/shared/public_api.js → esm2020/shared/public_api.mjs} +4 -4
  29. package/{esm2015/shared/shared-yelon.module.js → esm2020/shared/shared-yelon.module.mjs} +107 -107
  30. package/{esm2015/shared/shared-zorro.module.js → esm2020/shared/shared-zorro.module.mjs} +80 -80
  31. package/{esm2015/shared/shared.js → esm2020/shared/shared.mjs} +4 -4
  32. package/esm2020/shared/shared.module.mjs +116 -0
  33. package/{esm2015/shared/style-icons.js → esm2020/shared/style-icons.mjs} +795 -795
  34. package/fesm2015/{bis.js → bis.mjs} +3 -3
  35. package/fesm2015/bis.mjs.map +1 -0
  36. package/fesm2015/{layout.js → layout.mjs} +2514 -2181
  37. package/fesm2015/layout.mjs.map +1 -0
  38. package/fesm2015/{shared.js → shared.mjs} +1004 -910
  39. package/fesm2015/shared.mjs.map +1 -0
  40. package/fesm2020/bis.mjs +6 -0
  41. package/fesm2020/bis.mjs.map +1 -0
  42. package/fesm2020/layout.mjs +2796 -0
  43. package/fesm2020/layout.mjs.map +1 -0
  44. package/fesm2020/shared.mjs +1106 -0
  45. package/fesm2020/shared.mjs.map +1 -0
  46. package/layout/act.guard.d.ts +23 -20
  47. package/layout/bis.config.d.ts +3 -3
  48. package/layout/contact/contact.component.d.ts +169 -166
  49. package/layout/contact/contact.service.d.ts +118 -115
  50. package/layout/layout.d.ts +5 -7
  51. package/layout/layout.module.d.ts +20 -2
  52. package/layout/package.json +5 -6
  53. package/layout/path-to-regexp.service.d.ts +26 -23
  54. package/layout/public_api.d.ts +14 -12
  55. package/layout/stomp.config.d.ts +3 -3
  56. package/layout/widgets/index.d.ts +7 -7
  57. package/layout/widgets/yz.application.component.d.ts +48 -45
  58. package/layout/widgets/yz.clear-storage.component.d.ts +11 -8
  59. package/layout/widgets/yz.fullscreen.component.d.ts +8 -6
  60. package/layout/widgets/yz.i18n.component.d.ts +22 -19
  61. package/layout/widgets/yz.notify.component.d.ts +30 -25
  62. package/layout/widgets/yz.them-btn.component.d.ts +32 -29
  63. package/layout/widgets/yz.user.component.d.ts +28 -25
  64. package/layout/yz.auth.service.d.ts +22 -19
  65. package/layout/yz.basic.component.d.ts +24 -15
  66. package/layout/yz.default.interceptor.d.ts +29 -26
  67. package/layout/yz.i18n.service.d.ts +27 -24
  68. package/layout/yz.startup.service.d.ts +34 -31
  69. package/layout/yz.stomp.service.d.ts +42 -39
  70. package/package.json +46 -18
  71. package/public_api.d.ts +2 -2
  72. package/shared/package.json +5 -6
  73. package/shared/public_api.d.ts +4 -4
  74. package/shared/shared-yelon.module.d.ts +3 -3
  75. package/shared/shared-zorro.module.d.ts +2 -2
  76. package/shared/shared.d.ts +5 -4
  77. package/shared/shared.module.d.ts +95 -2
  78. package/shared/style-icons.d.ts +1 -1
  79. package/bis.metadata.json +0 -1
  80. package/bundles/bis.umd.js +0 -18
  81. package/bundles/bis.umd.js.map +0 -1
  82. package/bundles/layout.umd.js +0 -2669
  83. package/bundles/layout.umd.js.map +0 -1
  84. package/bundles/shared.umd.js +0 -1249
  85. package/bundles/shared.umd.js.map +0 -1
  86. package/esm2015/layout/act.guard.js +0 -115
  87. package/esm2015/layout/contact/contact.component.js +0 -434
  88. package/esm2015/layout/contact/contact.service.js +0 -150
  89. package/esm2015/layout/layout.js +0 -8
  90. package/esm2015/layout/layout.module.js +0 -47
  91. package/esm2015/layout/stomp.config.js +0 -20
  92. package/esm2015/layout/widgets/yz.application.component.js +0 -200
  93. package/esm2015/layout/widgets/yz.clear-storage.component.js +0 -39
  94. package/esm2015/layout/widgets/yz.fullscreen.component.js +0 -36
  95. package/esm2015/layout/widgets/yz.i18n.component.js +0 -78
  96. package/esm2015/layout/widgets/yz.notify.component.js +0 -154
  97. package/esm2015/layout/widgets/yz.them-btn.component.js +0 -146
  98. package/esm2015/layout/widgets/yz.user.component.js +0 -81
  99. package/esm2015/layout/yz.auth.service.js +0 -158
  100. package/esm2015/layout/yz.basic.component.js +0 -101
  101. package/esm2015/layout/yz.default.interceptor.js +0 -204
  102. package/esm2015/layout/yz.i18n.service.js +0 -102
  103. package/esm2015/layout/yz.startup.service.js +0 -138
  104. package/esm2015/layout/yz.stomp.service.js +0 -91
  105. package/esm2015/shared/shared.module.js +0 -22
  106. package/fesm2015/bis.js.map +0 -1
  107. package/fesm2015/layout.js.map +0 -1
  108. package/fesm2015/shared.js.map +0 -1
  109. package/layout/layout.metadata.json +0 -1
  110. package/shared/shared.metadata.json +0 -1
@@ -1,249 +1,260 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Injectable, Component, ChangeDetectionStrategy, Injector, Inject, Input, ChangeDetectorRef, Renderer2, Optional, HostListener, EventEmitter, ViewChild, Output, isDevMode, NgModule, APP_INITIALIZER } from '@angular/core';
2
+ import { Injectable, Component, ChangeDetectionStrategy, Inject, Input, Optional, HostListener, EventEmitter, ViewChild, Output, isDevMode, NgModule, APP_INITIALIZER } from '@angular/core';
3
+ import * as i1$2 from '@yelon/util';
4
+ import { WINDOW, log as log$1, deepCopy } from '@yelon/util';
3
5
  import * as i2$1 from '@yelon/cache';
4
6
  import { CacheService } from '@yelon/cache';
5
- import * as i1 from '@yelon/theme';
6
- import { zh_CN as zh_CN$1, zh_TW as zh_TW$1, en_US as en_US$1, YunzaiI18nBaseService, _HttpClient, SettingsService, YelonLocaleService, YUNZAI_I18N_TOKEN, MenuService, TitleService } from '@yelon/theme';
7
- import { WINDOW, YunzaiConfigService as YunzaiConfigService$1, log as log$1, deepCopy } from '@yelon/util';
8
- import * as i3 from '@angular/cdk/platform';
9
- import { Platform } from '@angular/cdk/platform';
7
+ import * as i9$1 from '@angular/common';
10
8
  import { registerLocaleData, DOCUMENT, CommonModule } from '@angular/common';
11
9
  import ngEn from '@angular/common/locales/en';
12
10
  import ngZh from '@angular/common/locales/zh';
13
11
  import ngZhTw from '@angular/common/locales/zh-Hant';
14
12
  import { zhCN, zhTW, enUS } from 'date-fns/locale';
15
- import * as i1$1 from '@yelon/util/config';
16
- import { YunzaiConfigService } from '@yelon/util/config';
13
+ import * as i1 from '@yelon/theme';
14
+ import { zh_CN as zh_CN$1, zh_TW as zh_TW$1, en_US as en_US$1, YunzaiI18nBaseService, YUNZAI_I18N_TOKEN, _HttpClient } from '@yelon/theme';
17
15
  import * as i2 from 'ng-zorro-antd/i18n';
18
- import { zh_CN, zh_TW, en_US, NzI18nService } from 'ng-zorro-antd/i18n';
16
+ import { zh_CN, zh_TW, en_US } from 'ng-zorro-antd/i18n';
17
+ import * as i3 from '@angular/cdk/platform';
18
+ import * as i4 from '@yelon/util/config';
19
+ import { YunzaiConfigService } from '@yelon/util/config';
20
+ import * as i4$1 from 'ng-zorro-antd/input';
21
+ import * as i5 from 'ng-zorro-antd/grid';
22
+ import * as i8 from 'ng-zorro-antd/core/transition-patch';
23
+ import * as i7 from '@angular/forms';
24
+ import { FormsModule, ReactiveFormsModule } from '@angular/forms';
25
+ import * as i9 from 'ng-zorro-antd/icon';
19
26
  import { __decorate } from 'tslib';
20
27
  import { InputBoolean } from '@yelon/util/decorator';
28
+ import * as i2$2 from 'ng-zorro-antd/dropdown';
29
+ import * as i6 from 'ng-zorro-antd/menu';
21
30
  import { forkJoin, Subject, of, BehaviorSubject, throwError } from 'rxjs';
22
31
  import { map, takeUntil, mergeMap, mergeAll, filter, take, switchMap, catchError } from 'rxjs/operators';
23
32
  import { formatDistanceToNow } from 'date-fns';
24
- import { NzMessageService } from 'ng-zorro-antd/message';
25
33
  import { log } from '@yelon/util/other';
26
- import { Directionality } from '@angular/cdk/bidi';
34
+ import * as i1$1 from 'ng-zorro-antd/message';
35
+ import * as i4$2 from '@yelon/abc/notice-icon';
27
36
  import { YUNZAI_THEME_BTN_KEYS } from '@yelon/theme/theme-btn';
37
+ import * as i3$1 from '@angular/cdk/bidi';
38
+ import * as i5$1 from 'ng-zorro-antd/tooltip';
28
39
  import { YA_SERVICE_TOKEN, mergeConfig } from '@yelon/auth';
29
- import { NzModalService } from 'ng-zorro-antd/modal';
30
- import * as screenfull from 'screenfull';
40
+ import * as i4$3 from 'ng-zorro-antd/avatar';
41
+ import * as i1$3 from 'ng-zorro-antd/modal';
42
+ import screenfull from 'screenfull';
31
43
  import { HttpClientModule, HttpErrorResponse, HttpResponse, HttpResponseBase } from '@angular/common/http';
32
- import { FormsModule, ReactiveFormsModule } from '@angular/forms';
33
- import * as i4 from '@angular/router';
44
+ import * as i17 from '@angular/router';
34
45
  import { RouterModule, Router } from '@angular/router';
35
46
  import { YzSharedModule, ICONS } from '@yelon/bis/shared';
47
+ import * as i2$3 from 'ng-zorro-antd/tabs';
48
+ import * as i3$2 from '@yelon/abc/sg';
49
+ import * as i5$2 from 'ng-zorro-antd/spin';
50
+ import * as i6$1 from 'ng-zorro-antd/tree';
51
+ import * as i7$1 from 'ng-zorro-antd/list';
52
+ import * as i8$1 from '@yelon/abc/st';
53
+ import * as i9$2 from 'ng-zorro-antd/button';
54
+ import * as i14 from 'ng-zorro-antd/core/wave';
36
55
  import { RxStomp } from '@stomp/rx-stomp';
37
- import * as i3$1 from 'ng-zorro-antd/notification';
56
+ import * as i3$3 from 'ng-zorro-antd/notification';
38
57
  import { NzNotificationService } from 'ng-zorro-antd/notification';
39
- import { NzIconService } from 'ng-zorro-antd/icon';
40
- import { ACLService } from '@yelon/acl';
58
+ import * as i3$4 from '@yelon/theme/layout-default';
59
+ import * as i13 from '@yelon/abc/reuse-tab';
60
+ import * as i3$5 from '@yelon/acl';
41
61
 
42
- // 请参考:https://ng.yunzainfo.com/docs/i18n
43
- const DEFAULT = 'zh-CN';
44
- const LANGS = {
45
- 'zh-CN': {
46
- text: '简体中文',
47
- ng: ngZh,
48
- zorro: zh_CN,
49
- date: zhCN,
50
- yelon: zh_CN$1,
51
- abbr: '🇨🇳'
52
- },
53
- 'zh-TW': {
54
- text: '繁体中文',
55
- ng: ngZhTw,
56
- zorro: zh_TW,
57
- date: zhTW,
58
- yelon: zh_TW$1,
59
- abbr: '🇭🇰'
60
- },
61
- 'en-US': {
62
- text: 'English',
63
- ng: ngEn,
64
- zorro: en_US,
65
- date: enUS,
66
- yelon: en_US$1,
67
- abbr: '🇬🇧'
68
- }
69
- };
70
- class YzI18NService extends YunzaiI18nBaseService {
71
- constructor(http, settings, nzI18nService, yelonLocaleService, platform, cogSrv) {
72
- super(cogSrv);
73
- this.http = http;
74
- this.settings = settings;
75
- this.nzI18nService = nzI18nService;
76
- this.yelonLocaleService = yelonLocaleService;
77
- this.platform = platform;
78
- this._defaultLang = DEFAULT;
79
- this._langs = Object.keys(LANGS).map(code => {
80
- const item = LANGS[code];
81
- return { code, text: item.text, abbr: item.abbr };
82
- });
83
- const defaultLang = this.getDefaultLang();
84
- this._defaultLang = this._langs.findIndex(w => w.code === defaultLang) === -1 ? DEFAULT : defaultLang;
85
- }
86
- getDefaultLang() {
87
- if (!this.platform.isBrowser) {
88
- return DEFAULT;
89
- }
90
- if (this.settings.layout.lang) {
91
- return this.settings.layout.lang;
92
- }
93
- let res = (navigator.languages ? navigator.languages[0] : null) || navigator.language;
94
- const arr = res.split('-');
95
- return arr.length <= 1 ? res : `${arr[0]}-${arr[1].toUpperCase()}`;
96
- }
97
- loadLangData(lang) {
98
- return this.http.get(`assets/tmp/i18n/${lang}.json`);
99
- }
100
- use(lang, data) {
101
- if (this._currentLang === lang)
102
- return;
103
- this._data = this.flatData(data, []);
104
- const item = LANGS[lang];
105
- registerLocaleData(item.ng);
106
- this.nzI18nService.setLocale(item.zorro);
107
- this.nzI18nService.setDateLocale(item.date);
108
- this.yelonLocaleService.setLocale(item.yelon);
109
- this._currentLang = lang;
110
- this._change$.next(lang);
111
- }
112
- getLangs() {
113
- return this._langs;
114
- }
115
- }
116
- YzI18NService.ɵprov = i0.ɵɵdefineInjectable({ factory: function YzI18NService_Factory() { return new YzI18NService(i0.ɵɵinject(i1._HttpClient), i0.ɵɵinject(i1.SettingsService), i0.ɵɵinject(i2.NzI18nService), i0.ɵɵinject(i1.YelonLocaleService), i0.ɵɵinject(i3.Platform), i0.ɵɵinject(i1$1.YunzaiConfigService)); }, token: YzI18NService, providedIn: "root" });
117
- YzI18NService.decorators = [
118
- { type: Injectable, args: [{ providedIn: 'root' },] }
119
- ];
120
- YzI18NService.ctorParameters = () => [
121
- { type: _HttpClient },
122
- { type: SettingsService },
123
- { type: NzI18nService },
124
- { type: YelonLocaleService },
125
- { type: Platform },
126
- { type: YunzaiConfigService }
127
- ];
62
+ const DEFAULT = 'zh-CN';
63
+ const LANGS = {
64
+ 'zh-CN': {
65
+ text: '简体中文',
66
+ ng: ngZh,
67
+ zorro: zh_CN,
68
+ date: zhCN,
69
+ yelon: zh_CN$1,
70
+ abbr: '🇨🇳'
71
+ },
72
+ 'zh-TW': {
73
+ text: '繁体中文',
74
+ ng: ngZhTw,
75
+ zorro: zh_TW,
76
+ date: zhTW,
77
+ yelon: zh_TW$1,
78
+ abbr: '🇭🇰'
79
+ },
80
+ 'en-US': {
81
+ text: 'English',
82
+ ng: ngEn,
83
+ zorro: en_US,
84
+ date: enUS,
85
+ yelon: en_US$1,
86
+ abbr: '🇬🇧'
87
+ }
88
+ };
89
+ class YzI18NService extends YunzaiI18nBaseService {
90
+ constructor(http, settings, nzI18nService, yelonLocaleService, platform, cogSrv) {
91
+ super(cogSrv);
92
+ this.http = http;
93
+ this.settings = settings;
94
+ this.nzI18nService = nzI18nService;
95
+ this.yelonLocaleService = yelonLocaleService;
96
+ this.platform = platform;
97
+ this._defaultLang = DEFAULT;
98
+ this._langs = Object.keys(LANGS).map(code => {
99
+ const item = LANGS[code];
100
+ return { code, text: item.text, abbr: item.abbr };
101
+ });
102
+ const defaultLang = this.getDefaultLang();
103
+ this._defaultLang = this._langs.findIndex(w => w.code === defaultLang) === -1 ? DEFAULT : defaultLang;
104
+ }
105
+ getDefaultLang() {
106
+ if (!this.platform.isBrowser) {
107
+ return DEFAULT;
108
+ }
109
+ if (this.settings.layout.lang) {
110
+ return this.settings.layout.lang;
111
+ }
112
+ let res = (navigator.languages ? navigator.languages[0] : null) || navigator.language;
113
+ const arr = res.split('-');
114
+ return arr.length <= 1 ? res : `${arr[0]}-${arr[1].toUpperCase()}`;
115
+ }
116
+ loadLangData(lang) {
117
+ return this.http.get(`assets/tmp/i18n/${lang}.json`);
118
+ }
119
+ use(lang, data) {
120
+ if (this._currentLang === lang)
121
+ return;
122
+ this._data = this.flatData(data, []);
123
+ const item = LANGS[lang];
124
+ registerLocaleData(item.ng);
125
+ this.nzI18nService.setLocale(item.zorro);
126
+ this.nzI18nService.setDateLocale(item.date);
127
+ this.yelonLocaleService.setLocale(item.yelon);
128
+ this._currentLang = lang;
129
+ this._change$.next(lang);
130
+ }
131
+ getLangs() {
132
+ return this._langs;
133
+ }
134
+ }
135
+ YzI18NService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YzI18NService, deps: [{ token: i1._HttpClient }, { token: i1.SettingsService }, { token: i2.NzI18nService }, { token: i1.YelonLocaleService }, { token: i3.Platform }, { token: i4.YunzaiConfigService }], target: i0.ɵɵFactoryTarget.Injectable });
136
+ YzI18NService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YzI18NService, providedIn: 'root' });
137
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YzI18NService, decorators: [{
138
+ type: Injectable,
139
+ args: [{ providedIn: 'root' }]
140
+ }], ctorParameters: function () { return [{ type: i1._HttpClient }, { type: i1.SettingsService }, { type: i2.NzI18nService }, { type: i1.YelonLocaleService }, { type: i3.Platform }, { type: i4.YunzaiConfigService }]; } });
128
141
 
129
- var TOPIC;
130
- (function (TOPIC) {
131
- TOPIC[TOPIC["FULL"] = 0] = "FULL";
132
- TOPIC[TOPIC["OWN"] = 1] = "OWN";
133
- TOPIC[TOPIC["EVERY"] = 2] = "EVERY";
134
- })(TOPIC || (TOPIC = {}));
135
- class YzHeaderApplicationComponent {
136
- constructor(inject, cacheService, i18n, http) {
137
- this.inject = inject;
138
- this.cacheService = cacheService;
139
- this.i18n = i18n;
140
- this.http = http;
141
- this.T = TOPIC;
142
- this.active = false;
143
- this.topicData = [];
144
- this.listData = [];
145
- this.topic = TOPIC.FULL;
146
- this.searchValue = null;
147
- this.subs = [];
148
- }
149
- ngOnInit() {
150
- this.topicData = this.cacheService.get('_yz_header', { mode: 'none' });
151
- this.listData = this.cacheService.get('_yz_header', { mode: 'none' });
152
- }
153
- ngOnDestroy() {
154
- this.subs.forEach(f => f.unsubscribe());
155
- }
156
- diffChange(flag) {
157
- if (flag) {
158
- this.active = flag;
159
- }
160
- else {
161
- this.active = !this.active;
162
- }
163
- }
164
- initTopic(topic) {
165
- this.searchValue = null;
166
- this.listData = this.cacheService.get('_yz_header', { mode: 'none' });
167
- this.topic = topic;
168
- }
169
- full() {
170
- this.initTopic(TOPIC.FULL);
171
- }
172
- own() {
173
- this.initTopic(TOPIC.OWN);
174
- const temp = this.cacheService.get('_yz_header', { mode: 'none' });
175
- this.listData = temp
176
- .filter((topic) => {
177
- topic.children = topic.children.filter((child) => {
178
- return child.auth;
179
- });
180
- return topic;
181
- })
182
- .filter((topic) => {
183
- return topic.children.length > 0;
184
- });
185
- }
186
- every(e) {
187
- this.initTopic(TOPIC.EVERY);
188
- this.choosed = e;
189
- const temp = this.cacheService.get('_yz_header', { mode: 'none' });
190
- this.listData = [...temp.filter(t => t.key === e.key)[0].children];
191
- }
192
- onSearch() {
193
- const temp = this.cacheService.get('_yz_header', { mode: 'none' });
194
- // 如果搜索输入的有值
195
- if (this.searchValue) {
196
- // 过滤菜单过滤出搜索的值
197
- this.listData = temp
198
- .filter((topic) => {
199
- if (this.i18n.fanyi(topic.name).includes(this.searchValue)) {
200
- return topic;
201
- }
202
- else {
203
- topic.children = topic.children.filter((child) => {
204
- return this.i18n.fanyi(child.name).includes(this.searchValue);
205
- });
206
- return topic;
207
- }
208
- })
209
- .filter((topic) => {
210
- return topic.children.length > 0;
211
- });
212
- }
213
- else {
214
- // 如果没有值,取消搜索
215
- this.listData = this.cacheService.get('_yz_header', { mode: 'none' });
216
- }
217
- }
218
- open(topic) {
219
- if (topic.key) {
220
- this.subs.push(this.http
221
- .post(`/app-manager/web-scan/save`, {
222
- appId: topic.key,
223
- createDate: new Date()
224
- })
225
- .subscribe());
226
- }
227
- switch (topic.target) {
228
- case 'href':
229
- this.inject.get(WINDOW).location.href = topic.url;
230
- break;
231
- case 'blank':
232
- this.inject.get(WINDOW).location.href = topic.url;
233
- break;
234
- case 'target':
235
- this.inject.get(WINDOW).location.href = topic.url;
236
- break;
237
- default:
238
- this.inject.get(WINDOW).location.href = topic.url;
239
- break;
240
- }
241
- }
242
- }
243
- YzHeaderApplicationComponent.decorators = [
244
- { type: Component, args: [{
245
- selector: 'yz-header-application',
246
- template: `
142
+ var TOPIC;
143
+ (function (TOPIC) {
144
+ TOPIC[TOPIC["FULL"] = 0] = "FULL";
145
+ TOPIC[TOPIC["OWN"] = 1] = "OWN";
146
+ TOPIC[TOPIC["EVERY"] = 2] = "EVERY";
147
+ })(TOPIC || (TOPIC = {}));
148
+ class YzHeaderApplicationComponent {
149
+ constructor(inject, cacheService, i18n, http) {
150
+ this.inject = inject;
151
+ this.cacheService = cacheService;
152
+ this.i18n = i18n;
153
+ this.http = http;
154
+ this.T = TOPIC;
155
+ this.active = false;
156
+ this.topicData = [];
157
+ this.listData = [];
158
+ this.topic = TOPIC.FULL;
159
+ this.searchValue = null;
160
+ this.subs = [];
161
+ }
162
+ ngOnInit() {
163
+ this.topicData = this.cacheService.get('_yz_header', { mode: 'none' });
164
+ this.listData = this.cacheService.get('_yz_header', { mode: 'none' });
165
+ }
166
+ ngOnDestroy() {
167
+ this.subs.forEach(f => f.unsubscribe());
168
+ }
169
+ diffChange(flag) {
170
+ if (flag) {
171
+ this.active = flag;
172
+ }
173
+ else {
174
+ this.active = !this.active;
175
+ }
176
+ }
177
+ initTopic(topic) {
178
+ this.searchValue = null;
179
+ this.listData = this.cacheService.get('_yz_header', { mode: 'none' });
180
+ this.topic = topic;
181
+ }
182
+ full() {
183
+ this.initTopic(TOPIC.FULL);
184
+ }
185
+ own() {
186
+ this.initTopic(TOPIC.OWN);
187
+ const temp = this.cacheService.get('_yz_header', { mode: 'none' });
188
+ this.listData = temp
189
+ .filter((topic) => {
190
+ topic.children = topic.children.filter((child) => {
191
+ return child.auth;
192
+ });
193
+ return topic;
194
+ })
195
+ .filter((topic) => {
196
+ return topic.children.length > 0;
197
+ });
198
+ }
199
+ every(e) {
200
+ this.initTopic(TOPIC.EVERY);
201
+ this.choosed = e;
202
+ const temp = this.cacheService.get('_yz_header', { mode: 'none' });
203
+ this.listData = [...temp.filter(t => t.key === e.key)[0].children];
204
+ }
205
+ onSearch() {
206
+ const temp = this.cacheService.get('_yz_header', { mode: 'none' });
207
+ // 如果搜索输入的有值
208
+ if (this.searchValue) {
209
+ // 过滤菜单过滤出搜索的值
210
+ this.listData = temp
211
+ .filter((topic) => {
212
+ if (this.i18n.fanyi(topic.name).includes(this.searchValue)) {
213
+ return topic;
214
+ }
215
+ else {
216
+ topic.children = topic.children.filter((child) => {
217
+ return this.i18n.fanyi(child.name).includes(this.searchValue);
218
+ });
219
+ return topic;
220
+ }
221
+ })
222
+ .filter((topic) => {
223
+ return topic.children.length > 0;
224
+ });
225
+ }
226
+ else {
227
+ // 如果没有值,取消搜索
228
+ this.listData = this.cacheService.get('_yz_header', { mode: 'none' });
229
+ }
230
+ }
231
+ open(topic) {
232
+ if (topic.key) {
233
+ this.subs.push(this.http
234
+ .post(`/app-manager/web-scan/save`, {
235
+ appId: topic.key,
236
+ createDate: new Date()
237
+ })
238
+ .subscribe());
239
+ }
240
+ switch (topic.target) {
241
+ case 'href':
242
+ this.inject.get(WINDOW).location.href = topic.url;
243
+ break;
244
+ case 'blank':
245
+ this.inject.get(WINDOW).location.href = topic.url;
246
+ break;
247
+ case 'target':
248
+ this.inject.get(WINDOW).location.href = topic.url;
249
+ break;
250
+ default:
251
+ this.inject.get(WINDOW).location.href = topic.url;
252
+ break;
253
+ }
254
+ }
255
+ }
256
+ YzHeaderApplicationComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YzHeaderApplicationComponent, deps: [{ token: i0.Injector }, { token: i2$1.CacheService }, { token: YzI18NService }, { token: i1._HttpClient }], target: i0.ɵɵFactoryTarget.Component });
257
+ YzHeaderApplicationComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.1", type: YzHeaderApplicationComponent, selector: "yz-header-application", ngImport: i0, template: `
247
258
  <!-- template start-->
248
259
  <ng-template #search>
249
260
  <div nz-row class="yz-application-list-search">
@@ -310,47 +321,111 @@ YzHeaderApplicationComponent.decorators = [
310
321
  </div>
311
322
  </div>
312
323
  <!-- header end-->
313
- `,
314
- changeDetection: ChangeDetectionStrategy.OnPush
315
- },] }
316
- ];
317
- YzHeaderApplicationComponent.ctorParameters = () => [
318
- { type: Injector },
319
- { type: CacheService },
320
- { type: YzI18NService },
321
- { type: _HttpClient }
322
- ];
324
+ `, isInline: true, components: [{ type: i4$1.NzInputGroupComponent, selector: "nz-input-group", inputs: ["nzAddOnBeforeIcon", "nzAddOnAfterIcon", "nzPrefixIcon", "nzSuffixIcon", "nzAddOnBefore", "nzAddOnAfter", "nzPrefix", "nzSuffix", "nzSize", "nzSearch", "nzCompact"], exportAs: ["nzInputGroup"] }], directives: [{ type: i5.NzRowDirective, selector: "[nz-row],nz-row,nz-form-item", inputs: ["nzAlign", "nzJustify", "nzGutter"], exportAs: ["nzRow"] }, { type: i8.ɵNzTransitionPatchDirective, selector: "[nz-button], nz-button-group, [nz-icon], [nz-menu-item], [nz-submenu], nz-select-top-control, nz-select-placeholder, nz-input-group", inputs: ["hidden"] }, { type: i4$1.NzInputGroupWhitSuffixOrPrefixDirective, selector: "nz-input-group[nzSuffix], nz-input-group[nzPrefix]" }, { type: i4$1.NzInputDirective, selector: "input[nz-input],textarea[nz-input]", inputs: ["nzBorderless", "nzSize", "disabled"], exportAs: ["nzInput"] }, { type: i7.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i7.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i7.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i9.NzIconDirective, selector: "[nz-icon]", inputs: ["nzSpin", "nzRotate", "nzType", "nzTheme", "nzTwotoneColor", "nzIconfont"], exportAs: ["nzIcon"] }, { type: i9$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i9$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i5.NzColDirective, selector: "[nz-col],nz-col,nz-form-control,nz-form-label", inputs: ["nzFlex", "nzSpan", "nzOrder", "nzOffset", "nzPush", "nzPull", "nzXs", "nzSm", "nzMd", "nzLg", "nzXl", "nzXXl"], exportAs: ["nzCol"] }, { type: i9$1.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i9$1.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i9$1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }], pipes: { "i18n": i1.I18nPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
325
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YzHeaderApplicationComponent, decorators: [{
326
+ type: Component,
327
+ args: [{
328
+ selector: 'yz-header-application',
329
+ template: `
330
+ <!-- template start-->
331
+ <ng-template #search>
332
+ <div nz-row class="yz-application-list-search">
333
+ <nz-input-group [nzPrefix]="prefixTemplate">
334
+ <input
335
+ type="text"
336
+ nz-input
337
+ placeholder="{{ 'application.search' | i18n }}"
338
+ [(ngModel)]="searchValue"
339
+ (ngModelChange)="onSearch()"
340
+ />
341
+ <ng-template #prefixTemplate>
342
+ <i nz-icon nzType="search" nzTheme="outline"></i>
343
+ </ng-template>
344
+ </nz-input-group>
345
+ </div>
346
+ </ng-template>
347
+ <ng-template #ld>
348
+ <div class="yz-application-list">
349
+ <ul>
350
+ <li *ngFor="let d of listData">
351
+ <h5>{{ d.name }}</h5>
352
+ <a href="javascript:;" *ngFor="let cd of d.children" (click)="open(cd)">{{ cd.name }}</a>
353
+ </li>
354
+ </ul>
355
+ </div>
356
+ </ng-template>
357
+ <!-- template end-->
358
+
359
+ <!-- button start-->
360
+ <div class="yunzai-default__nav-item" (click)="diffChange()"> {{ 'application.button' | i18n }}</div>
361
+ <!-- button end-->
362
+
363
+ <!-- header start-->
364
+ <div class="yz-application" nz-row *ngIf="active">
365
+ <div nz-col [nzSpan]="3" class="yz-application-topic">
366
+ <div class="yz-application-text" (click)="full()">{{ 'application.all' | i18n }}</div>
367
+ <div class="yz-application-text" (click)="own()">{{ 'application.mine' | i18n }}</div>
368
+ <div class="yz-application-text" *ngFor="let d of topicData" (click)="every(d)">
369
+ {{ d.name }}
370
+ </div>
371
+ </div>
372
+ <div nz-col [nzSpan]="21" [ngSwitch]="topic" class="yz-application-container">
373
+ <div *ngSwitchCase="T.FULL">
374
+ <ng-template [ngTemplateOutlet]="search"></ng-template>
375
+ <ng-template [ngTemplateOutlet]="ld"></ng-template>
376
+ </div>
377
+ <div *ngSwitchCase="T.OWN">
378
+ <ng-template [ngTemplateOutlet]="search"></ng-template>
379
+ <ng-template [ngTemplateOutlet]="ld"></ng-template>
380
+ </div>
381
+ <div *ngSwitchCase="T.EVERY" class="yz-application-list">
382
+ <div class="yz-application-list-item">
383
+ <ul>
384
+ <li *ngFor="let d of listData" (click)="open(d)">
385
+ <a href="javascript:;">
386
+ <h4>{{ d.name }}</h4>
387
+ <p>{{ d.intro }}</p>
388
+ </a>
389
+ </li>
390
+ </ul>
391
+ </div>
392
+ </div>
393
+ </div>
394
+ </div>
395
+ <!-- header end-->
396
+ `,
397
+ changeDetection: ChangeDetectionStrategy.OnPush
398
+ }]
399
+ }], ctorParameters: function () { return [{ type: i0.Injector }, { type: i2$1.CacheService }, { type: YzI18NService }, { type: i1._HttpClient }]; } });
323
400
 
324
- class YzHeaderI18NComponent {
325
- constructor(settings, i18n, doc) {
326
- this.settings = settings;
327
- this.i18n = i18n;
328
- this.doc = doc;
329
- /** Whether to display language text */
330
- this.showLangText = true;
331
- }
332
- get langs() {
333
- return this.i18n.getLangs();
334
- }
335
- get curLangCode() {
336
- return this.settings.layout.lang;
337
- }
338
- change(lang) {
339
- const spinEl = this.doc.createElement('div');
340
- spinEl.setAttribute('class', `page-loading ant-spin ant-spin-lg ant-spin-spinning`);
341
- spinEl.innerHTML = `<span class="ant-spin-dot ant-spin-dot-spin"><i></i><i></i><i></i><i></i></span>`;
342
- this.doc.body.appendChild(spinEl);
343
- this.i18n.loadLangData(lang).subscribe(res => {
344
- this.i18n.use(lang, res);
345
- this.settings.setLayout('lang', lang);
346
- setTimeout(() => this.doc.location.reload());
347
- });
348
- }
349
- }
350
- YzHeaderI18NComponent.decorators = [
351
- { type: Component, args: [{
352
- selector: 'yz-header-i18n',
353
- template: `
401
+ class YzHeaderI18NComponent {
402
+ constructor(settings, i18n, doc) {
403
+ this.settings = settings;
404
+ this.i18n = i18n;
405
+ this.doc = doc;
406
+ /** Whether to display language text */
407
+ this.showLangText = true;
408
+ }
409
+ get langs() {
410
+ return this.i18n.getLangs();
411
+ }
412
+ get curLangCode() {
413
+ return this.settings.layout.lang;
414
+ }
415
+ change(lang) {
416
+ const spinEl = this.doc.createElement('div');
417
+ spinEl.setAttribute('class', `page-loading ant-spin ant-spin-lg ant-spin-spinning`);
418
+ spinEl.innerHTML = `<span class="ant-spin-dot ant-spin-dot-spin"><i></i><i></i><i></i><i></i></span>`;
419
+ this.doc.body.appendChild(spinEl);
420
+ this.i18n.loadLangData(lang).subscribe(res => {
421
+ this.i18n.use(lang, res);
422
+ this.settings.setLayout('lang', lang);
423
+ setTimeout(() => this.doc.location.reload());
424
+ });
425
+ }
426
+ }
427
+ YzHeaderI18NComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YzHeaderI18NComponent, deps: [{ token: i1.SettingsService }, { token: YUNZAI_I18N_TOKEN }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Component });
428
+ YzHeaderI18NComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.1", type: YzHeaderI18NComponent, selector: "yz-header-i18n", inputs: { showLangText: "showLangText" }, ngImport: i0, template: `
354
429
  <div *ngIf="showLangText" nz-dropdown [nzDropdownMenu]="langMenu" nzPlacement="bottomRight">
355
430
  <i nz-icon nzType="global"></i>
356
431
  {{ 'menu.lang' | i18n }}
@@ -377,146 +452,179 @@ YzHeaderI18NComponent.decorators = [
377
452
  </li>
378
453
  </ul>
379
454
  </nz-dropdown-menu>
380
- `,
381
- changeDetection: ChangeDetectionStrategy.OnPush
382
- },] }
383
- ];
384
- YzHeaderI18NComponent.ctorParameters = () => [
385
- { type: SettingsService },
386
- { type: YzI18NService, decorators: [{ type: Inject, args: [YUNZAI_I18N_TOKEN,] }] },
387
- { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
388
- ];
389
- YzHeaderI18NComponent.propDecorators = {
390
- showLangText: [{ type: Input }]
391
- };
392
- __decorate([
393
- InputBoolean()
455
+ `, isInline: true, components: [{ type: i2$2.NzDropdownMenuComponent, selector: "nz-dropdown-menu", exportAs: ["nzDropdownMenu"] }], directives: [{ type: i9$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2$2.NzDropDownDirective, selector: "[nz-dropdown]", inputs: ["nzDropdownMenu", "nzTrigger", "nzMatchWidthElement", "nzBackdrop", "nzClickHide", "nzDisabled", "nzVisible", "nzOverlayClassName", "nzOverlayStyle", "nzPlacement"], outputs: ["nzVisibleChange"], exportAs: ["nzDropdown"] }, { type: i8.ɵNzTransitionPatchDirective, selector: "[nz-button], nz-button-group, [nz-icon], [nz-menu-item], [nz-submenu], nz-select-top-control, nz-select-placeholder, nz-input-group", inputs: ["hidden"] }, { type: i9.NzIconDirective, selector: "[nz-icon]", inputs: ["nzSpin", "nzRotate", "nzType", "nzTheme", "nzTwotoneColor", "nzIconfont"], exportAs: ["nzIcon"] }, { type: i6.NzMenuDirective, selector: "[nz-menu]", inputs: ["nzInlineIndent", "nzTheme", "nzMode", "nzInlineCollapsed", "nzSelectable"], outputs: ["nzClick"], exportAs: ["nzMenu"] }, { type: i9$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i6.NzMenuItemDirective, selector: "[nz-menu-item]", inputs: ["nzPaddingLeft", "nzDisabled", "nzSelected", "nzDanger", "nzMatchRouterExact", "nzMatchRouter"], exportAs: ["nzMenuItem"] }], pipes: { "i18n": i1.I18nPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
456
+ __decorate([
457
+ InputBoolean()
394
458
  ], YzHeaderI18NComponent.prototype, "showLangText", void 0);
459
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YzHeaderI18NComponent, decorators: [{
460
+ type: Component,
461
+ args: [{
462
+ selector: 'yz-header-i18n',
463
+ template: `
464
+ <div *ngIf="showLangText" nz-dropdown [nzDropdownMenu]="langMenu" nzPlacement="bottomRight">
465
+ <i nz-icon nzType="global"></i>
466
+ {{ 'menu.lang' | i18n }}
467
+ <i nz-icon nzType="down"></i>
468
+ </div>
469
+ <i
470
+ *ngIf="!showLangText"
471
+ nz-dropdown
472
+ [nzDropdownMenu]="langMenu"
473
+ nzPlacement="bottomRight"
474
+ nz-icon
475
+ nzType="global"
476
+ ></i>
477
+ <nz-dropdown-menu #langMenu="nzDropdownMenu">
478
+ <ul nz-menu>
479
+ <li
480
+ nz-menu-item
481
+ *ngFor="let item of langs"
482
+ [nzSelected]="item.code === curLangCode"
483
+ (click)="change(item.code)"
484
+ >
485
+ <span role="img" [attr.aria-label]="item.text" class="pr-xs">{{ item.abbr }}</span>
486
+ {{ item.text }}
487
+ </li>
488
+ </ul>
489
+ </nz-dropdown-menu>
490
+ `,
491
+ changeDetection: ChangeDetectionStrategy.OnPush
492
+ }]
493
+ }], ctorParameters: function () {
494
+ return [{ type: i1.SettingsService }, { type: YzI18NService, decorators: [{
495
+ type: Inject,
496
+ args: [YUNZAI_I18N_TOKEN]
497
+ }] }, { type: undefined, decorators: [{
498
+ type: Inject,
499
+ args: [DOCUMENT]
500
+ }] }];
501
+ }, propDecorators: { showLangText: [{
502
+ type: Input
503
+ }] } });
395
504
 
396
- class YzHeaderNotifyComponent {
397
- constructor(injector, msg, nzI18n, cdr, httpClient) {
398
- this.injector = injector;
399
- this.msg = msg;
400
- this.nzI18n = nzI18n;
401
- this.cdr = cdr;
402
- this.httpClient = httpClient;
403
- this.data = [
404
- {
405
- key: 'msg',
406
- title: '消息',
407
- list: [],
408
- emptyText: '您已读完所有消息',
409
- emptyImage: './assets/tmp/img/message.svg',
410
- clearText: '清空消息'
411
- },
412
- {
413
- key: 'todo',
414
- title: '待办',
415
- list: [],
416
- emptyText: '你已完成所有待办',
417
- emptyImage: './assets/tmp/img/todo.svg',
418
- clearText: '重新加载'
419
- },
420
- {
421
- key: 'notice',
422
- title: '通知',
423
- list: [],
424
- emptyText: '你已查看所有通知',
425
- emptyImage: './assets/tmp/img/notice.svg',
426
- clearText: '重新加载'
427
- }
428
- ];
429
- this.loading = false;
430
- this.count = 0;
431
- this.subs = [];
432
- }
433
- ngOnInit() {
434
- this.loadData();
435
- }
436
- loadData() {
437
- this.count = 0;
438
- this.loading = true;
439
- this.subs.push(forkJoin(this.loadTodo(), this.loadMessage()).subscribe(() => {
440
- this.loading = false;
441
- this.cdr.detectChanges();
442
- }));
443
- }
444
- loadMessage() {
445
- log('notify.component: ', 'fetch message list');
446
- const formatMessageStatus = (status) => {
447
- switch (status) {
448
- case '0':
449
- return { extra: '未读', color: 'red' };
450
- case '1':
451
- return { extra: '已读', color: 'green' };
452
- default:
453
- return { extra: '无状态', color: 'primary' };
454
- }
455
- };
456
- return this.httpClient
457
- .post(`/message-center-3/my-msg-and-todo/msg-list`, {
458
- pageNum: 1,
459
- pageSize: 10,
460
- status: '0'
461
- })
462
- .pipe(map((response) => {
463
- const viewMessage = this.data.filter(d => d.key === 'msg')[0];
464
- viewMessage.list = response.data.list.map((m) => {
465
- return Object.assign(Object.assign({}, m), { avatar: (m === null || m === void 0 ? void 0 : m.imgUrl) || './assets/tmp/img/message.png', title: m.systemName, description: m.content, extra: formatMessageStatus(m.status).extra, color: formatMessageStatus(m.status).color, datetime: formatDistanceToNow(new Date(m.date), { locale: this.nzI18n.getDateLocale() }) });
466
- });
467
- this.count += viewMessage.list.length;
468
- }));
469
- }
470
- loadTodo() {
471
- log('notify.component: ', 'fetch todo list');
472
- const formatTodoStatus = (status) => {
473
- switch (status) {
474
- case '0':
475
- return { extra: '未开始', color: 'red' };
476
- case '1':
477
- return { extra: '已开始', color: 'green' };
478
- default:
479
- return { extra: '无状态', color: 'primary' };
480
- }
481
- };
482
- return this.httpClient
483
- .post(`/message-center-3/my-msg-and-todo/todo-list`, {
484
- pageNum: 1,
485
- pageSize: 10,
486
- status: '0'
487
- })
488
- .pipe(map((response) => {
489
- const viewTodo = this.data.filter(d => d.key === 'todo')[0];
490
- viewTodo.list = response.data.list.map((t) => {
491
- return Object.assign(Object.assign({}, t), { avatar: (t === null || t === void 0 ? void 0 : t.imgUrl) || './assets/tmp/img/todo.png', title: t.systemName, description: t.content, datetime: formatDistanceToNow(new Date(t.date), { locale: this.nzI18n.getDateLocale() }), extra: formatTodoStatus(t.status).extra, color: formatTodoStatus(t.status).color });
492
- });
493
- this.count += viewTodo.list.length;
494
- }));
495
- }
496
- clear(type) {
497
- const t = this.data.filter(d => d.title === type)[0];
498
- if (t.key == 'msg' || t.key == 'notice') {
499
- this.subs.push(this.httpClient.post(`/message-center-3/my-msg-and-todo/msg-clear`, {}).subscribe(_ => {
500
- this.msg.success(`清空了 ${type}`);
501
- this.loadData();
502
- }));
503
- }
504
- if (t.key == 'todo') {
505
- this.loadData();
506
- }
507
- }
508
- select(res) {
509
- this.injector.get(WINDOW).open(res.item.url);
510
- this.loadData();
511
- }
512
- ngOnDestroy() {
513
- this.subs.forEach(a => a.unsubscribe());
514
- }
515
- }
516
- YzHeaderNotifyComponent.decorators = [
517
- { type: Component, args: [{
518
- selector: 'yz-header-notify',
519
- template: `
505
+ class YzHeaderNotifyComponent {
506
+ constructor(injector, msg, y18n, nzI18n, cdr, httpClient) {
507
+ this.injector = injector;
508
+ this.msg = msg;
509
+ this.y18n = y18n;
510
+ this.nzI18n = nzI18n;
511
+ this.cdr = cdr;
512
+ this.httpClient = httpClient;
513
+ this.data = [
514
+ {
515
+ key: 'msg',
516
+ title: this.y18n.fanyi('notify.message'),
517
+ list: [],
518
+ emptyText: this.y18n.fanyi('notify.message.emptyText'),
519
+ emptyImage: './assets/tmp/img/message.svg',
520
+ clearText: this.y18n.fanyi('notify.message.clearText')
521
+ },
522
+ {
523
+ key: 'todo',
524
+ title: this.y18n.fanyi('notify.todo'),
525
+ list: [],
526
+ emptyText: this.y18n.fanyi('notify.todo.emptyText'),
527
+ emptyImage: './assets/tmp/img/todo.svg',
528
+ clearText: this.y18n.fanyi('notify.todo.clearText')
529
+ },
530
+ {
531
+ key: 'notice',
532
+ title: this.y18n.fanyi('notify.notice'),
533
+ list: [],
534
+ emptyText: this.y18n.fanyi('notify.notice.emptyText'),
535
+ emptyImage: './assets/tmp/img/notice.svg',
536
+ clearText: this.y18n.fanyi('notify.notice.clearText')
537
+ }
538
+ ];
539
+ this.loading = false;
540
+ this.count = 0;
541
+ this.subs = [];
542
+ }
543
+ ngOnInit() {
544
+ this.loadData();
545
+ }
546
+ loadData() {
547
+ this.count = 0;
548
+ this.loading = true;
549
+ this.subs.push(forkJoin(this.loadTodo(), this.loadMessage()).subscribe(() => {
550
+ this.loading = false;
551
+ this.cdr.detectChanges();
552
+ }));
553
+ }
554
+ loadMessage() {
555
+ log('notify.component: ', 'fetch message list');
556
+ const formatMessageStatus = (status) => {
557
+ switch (status) {
558
+ case '0':
559
+ return { extra: this.y18n.fanyi('notify.unread'), color: 'red' };
560
+ case '1':
561
+ return { extra: this.y18n.fanyi('notify.readed'), color: 'green' };
562
+ default:
563
+ return { extra: this.y18n.fanyi('notify.nostatus'), color: 'primary' };
564
+ }
565
+ };
566
+ return this.httpClient
567
+ .post(`/message-center-3/my-msg-and-todo/msg-list`, {
568
+ pageNum: 1,
569
+ pageSize: 10,
570
+ status: '0'
571
+ })
572
+ .pipe(map((response) => {
573
+ const viewMessage = this.data.filter(d => d.key === 'msg')[0];
574
+ viewMessage.list = response.data.list.map((m) => {
575
+ return Object.assign(Object.assign({}, m), { avatar: (m === null || m === void 0 ? void 0 : m.imgUrl) || './assets/tmp/img/message.png', title: m.systemName, description: m.content, extra: formatMessageStatus(m.status).extra, color: formatMessageStatus(m.status).color, datetime: formatDistanceToNow(new Date(m.date), { locale: this.nzI18n.getDateLocale() }) });
576
+ });
577
+ this.count += viewMessage.list.length;
578
+ }));
579
+ }
580
+ loadTodo() {
581
+ log('notify.component: ', 'fetch todo list');
582
+ const formatTodoStatus = (status) => {
583
+ switch (status) {
584
+ case '0':
585
+ return { extra: this.y18n.fanyi('notify.unstart'), color: 'red' };
586
+ case '1':
587
+ return { extra: this.y18n.fanyi('notify.started'), color: 'green' };
588
+ default:
589
+ return { extra: this.y18n.fanyi('notify.nostatus'), color: 'primary' };
590
+ }
591
+ };
592
+ return this.httpClient
593
+ .post(`/message-center-3/my-msg-and-todo/todo-list`, {
594
+ pageNum: 1,
595
+ pageSize: 10,
596
+ status: '0'
597
+ })
598
+ .pipe(map((response) => {
599
+ const viewTodo = this.data.filter(d => d.key === 'todo')[0];
600
+ viewTodo.list = response.data.list.map((t) => {
601
+ return Object.assign(Object.assign({}, t), { avatar: (t === null || t === void 0 ? void 0 : t.imgUrl) || './assets/tmp/img/todo.png', title: t.systemName, description: t.content, datetime: formatDistanceToNow(new Date(t.date), { locale: this.nzI18n.getDateLocale() }), extra: formatTodoStatus(t.status).extra, color: formatTodoStatus(t.status).color });
602
+ });
603
+ this.count += viewTodo.list.length;
604
+ }));
605
+ }
606
+ clear(type) {
607
+ const t = this.data.filter(d => d.title === type)[0];
608
+ if (t.key == 'msg' || t.key == 'notice') {
609
+ this.subs.push(this.httpClient.post(`/message-center-3/my-msg-and-todo/msg-clear`, {}).subscribe(_ => {
610
+ this.msg.success(`${this.y18n.fanyi('notify.clear')} ${type}`);
611
+ this.loadData();
612
+ }));
613
+ }
614
+ if (t.key == 'todo') {
615
+ this.loadData();
616
+ }
617
+ }
618
+ select(res) {
619
+ this.injector.get(WINDOW).open(res.item.url);
620
+ this.loadData();
621
+ }
622
+ ngOnDestroy() {
623
+ this.subs.forEach(a => a.unsubscribe());
624
+ }
625
+ }
626
+ YzHeaderNotifyComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YzHeaderNotifyComponent, deps: [{ token: i0.Injector }, { token: i1$1.NzMessageService }, { token: YUNZAI_I18N_TOKEN }, { token: i2.NzI18nService }, { token: i0.ChangeDetectorRef }, { token: i1._HttpClient }], target: i0.ɵɵFactoryTarget.Component });
627
+ YzHeaderNotifyComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.1", type: YzHeaderNotifyComponent, selector: "yz-header-notify", ngImport: i0, template: `
520
628
  <notice-icon
521
629
  [data]="data"
522
630
  [count]="count"
@@ -526,100 +634,111 @@ YzHeaderNotifyComponent.decorators = [
526
634
  (select)="select($event)"
527
635
  (clear)="clear($event)"
528
636
  ></notice-icon>
529
- `,
530
- changeDetection: ChangeDetectionStrategy.OnPush
531
- },] }
532
- ];
533
- YzHeaderNotifyComponent.ctorParameters = () => [
534
- { type: Injector },
535
- { type: NzMessageService },
536
- { type: NzI18nService },
537
- { type: ChangeDetectorRef },
538
- { type: _HttpClient }
539
- ];
637
+ `, isInline: true, components: [{ type: i4$2.NoticeIconComponent, selector: "notice-icon", inputs: ["data", "count", "loading", "popoverVisible", "btnClass", "btnIconClass"], outputs: ["select", "clear", "popoverVisibleChange"], exportAs: ["noticeIcon"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
638
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YzHeaderNotifyComponent, decorators: [{
639
+ type: Component,
640
+ args: [{
641
+ selector: 'yz-header-notify',
642
+ template: `
643
+ <notice-icon
644
+ [data]="data"
645
+ [count]="count"
646
+ [loading]="loading"
647
+ btnClass="yunzai-default__nav-item"
648
+ btnIconClass="yunzai-default__nav-item-icon"
649
+ (select)="select($event)"
650
+ (clear)="clear($event)"
651
+ ></notice-icon>
652
+ `,
653
+ changeDetection: ChangeDetectionStrategy.OnPush
654
+ }]
655
+ }], ctorParameters: function () {
656
+ return [{ type: i0.Injector }, { type: i1$1.NzMessageService }, { type: YzI18NService, decorators: [{
657
+ type: Inject,
658
+ args: [YUNZAI_I18N_TOKEN]
659
+ }] }, { type: i2.NzI18nService }, { type: i0.ChangeDetectorRef }, { type: i1._HttpClient }];
660
+ } });
540
661
 
541
- class YzHeaderThemBtnComponent {
542
- constructor(renderer, configSrv, platform, doc, directionality, KEYS) {
543
- this.renderer = renderer;
544
- this.configSrv = configSrv;
545
- this.platform = platform;
546
- this.doc = doc;
547
- this.directionality = directionality;
548
- this.KEYS = KEYS;
549
- this.theme = 'default';
550
- this.types = [
551
- { key: 'default', text: 'theme.default', color: '#2163ff' },
552
- { key: 'compact', text: 'theme.compact', color: '#2163ff' },
553
- { key: 'dark', text: 'theme.dark', color: '#020202' },
554
- { key: 'yuhong', text: 'theme.yuhong', color: '#C04851' },
555
- { key: 'danjuhuang', text: 'theme.danjuhuang', color: '#FBA414' },
556
- { key: 'xinghuang', text: 'theme.xinghuang', color: '#F28E16' },
557
- { key: 'shilv', text: 'theme.shilv', color: '#57C3C2' },
558
- { key: 'zhulv', text: 'theme.zhulv', color: '#1BA784' },
559
- { key: 'youlan', text: 'theme.youlan', color: '#1781B5' },
560
- { key: 'dianqing', text: 'theme.dianqing', color: '#1661AB' },
561
- { key: 'shangengzi', text: 'theme.shangengzi', color: '#61649F' },
562
- { key: 'shuiniuhui', text: 'theme.shuiniuhui', color: '#2F2F35' }
563
- ];
564
- this.devTips = `When the dark.css file can't be found, you need to run it once: npm run theme`;
565
- this.deployUrl = '';
566
- this.destroy$ = new Subject();
567
- this.dir = 'ltr';
568
- }
569
- ngOnInit() {
570
- var _a;
571
- this.dir = this.directionality.value;
572
- (_a = this.directionality.change) === null || _a === void 0 ? void 0 : _a.pipe(takeUntil(this.destroy$)).subscribe((direction) => {
573
- this.dir = direction;
574
- });
575
- this.initTheme();
576
- }
577
- initTheme() {
578
- if (!this.platform.isBrowser) {
579
- return;
580
- }
581
- this.theme = localStorage.getItem(this.KEYS) || 'default';
582
- this.updateChartTheme();
583
- this.onThemeChange(this.theme);
584
- }
585
- updateChartTheme() {
586
- this.configSrv.set('chart', { theme: this.theme === 'dark' ? 'dark' : '' });
587
- }
588
- onThemeChange(theme) {
589
- if (!this.platform.isBrowser) {
590
- return;
591
- }
592
- this.theme = theme;
593
- this.renderer.setAttribute(this.doc.body, 'data-theme', theme);
594
- const dom = this.doc.getElementById(this.KEYS);
595
- if (dom) {
596
- dom.remove();
597
- }
598
- localStorage.removeItem(this.KEYS);
599
- if (theme !== 'default') {
600
- const el = this.doc.createElement('link');
601
- el.type = 'text/css';
602
- el.rel = 'stylesheet';
603
- el.id = this.KEYS;
604
- el.href = `${this.deployUrl}assets/style.${theme}.css`;
605
- localStorage.setItem(this.KEYS, theme);
606
- this.doc.body.append(el);
607
- }
608
- this.updateChartTheme();
609
- }
610
- ngOnDestroy() {
611
- const el = this.doc.getElementById(this.KEYS);
612
- if (el != null) {
613
- this.doc.body.removeChild(el);
614
- }
615
- this.destroy$.next();
616
- this.destroy$.complete();
617
- }
618
- }
619
- YzHeaderThemBtnComponent.decorators = [
620
- { type: Component, args: [{
621
- selector: 'yz-header-theme-btn',
622
- template: `
662
+ class YzHeaderThemBtnComponent {
663
+ constructor(renderer, configSrv, platform, doc, directionality, KEYS) {
664
+ this.renderer = renderer;
665
+ this.configSrv = configSrv;
666
+ this.platform = platform;
667
+ this.doc = doc;
668
+ this.directionality = directionality;
669
+ this.KEYS = KEYS;
670
+ this.theme = 'default';
671
+ this.types = [
672
+ { key: 'default', text: 'theme.default', color: '#2163ff' },
673
+ { key: 'compact', text: 'theme.compact', color: '#2163ff' },
674
+ { key: 'dark', text: 'theme.dark', color: '#020202' },
675
+ { key: 'yuhong', text: 'theme.yuhong', color: '#C04851' },
676
+ { key: 'danjuhuang', text: 'theme.danjuhuang', color: '#FBA414' },
677
+ { key: 'xinghuang', text: 'theme.xinghuang', color: '#F28E16' },
678
+ { key: 'shilv', text: 'theme.shilv', color: '#57C3C2' },
679
+ { key: 'zhulv', text: 'theme.zhulv', color: '#1BA784' },
680
+ { key: 'youlan', text: 'theme.youlan', color: '#1781B5' },
681
+ { key: 'dianqing', text: 'theme.dianqing', color: '#1661AB' },
682
+ { key: 'shangengzi', text: 'theme.shangengzi', color: '#61649F' },
683
+ { key: 'shuiniuhui', text: 'theme.shuiniuhui', color: '#2F2F35' }
684
+ ];
685
+ this.devTips = `When the dark.css file can't be found, you need to run it once: npm run theme`;
686
+ this.deployUrl = '';
687
+ this.destroy$ = new Subject();
688
+ this.dir = 'ltr';
689
+ }
690
+ ngOnInit() {
691
+ var _a;
692
+ this.dir = this.directionality.value;
693
+ (_a = this.directionality.change) === null || _a === void 0 ? void 0 : _a.pipe(takeUntil(this.destroy$)).subscribe((direction) => {
694
+ this.dir = direction;
695
+ });
696
+ this.initTheme();
697
+ }
698
+ initTheme() {
699
+ if (!this.platform.isBrowser) {
700
+ return;
701
+ }
702
+ this.theme = localStorage.getItem(this.KEYS) || 'default';
703
+ this.updateChartTheme();
704
+ this.onThemeChange(this.theme);
705
+ }
706
+ updateChartTheme() {
707
+ this.configSrv.set('chart', { theme: this.theme === 'dark' ? 'dark' : '' });
708
+ }
709
+ onThemeChange(theme) {
710
+ if (!this.platform.isBrowser) {
711
+ return;
712
+ }
713
+ this.theme = theme;
714
+ this.renderer.setAttribute(this.doc.body, 'data-theme', theme);
715
+ const dom = this.doc.getElementById(this.KEYS);
716
+ if (dom) {
717
+ dom.remove();
718
+ }
719
+ localStorage.removeItem(this.KEYS);
720
+ if (theme !== 'default') {
721
+ const el = this.doc.createElement('link');
722
+ el.type = 'text/css';
723
+ el.rel = 'stylesheet';
724
+ el.id = this.KEYS;
725
+ el.href = `${this.deployUrl}assets/style.${theme}.css`;
726
+ localStorage.setItem(this.KEYS, theme);
727
+ this.doc.body.append(el);
728
+ }
729
+ this.updateChartTheme();
730
+ }
731
+ ngOnDestroy() {
732
+ const el = this.doc.getElementById(this.KEYS);
733
+ if (el != null) {
734
+ this.doc.body.removeChild(el);
735
+ }
736
+ this.destroy$.next();
737
+ this.destroy$.complete();
738
+ }
739
+ }
740
+ YzHeaderThemBtnComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YzHeaderThemBtnComponent, deps: [{ token: i0.Renderer2 }, { token: i4.YunzaiConfigService }, { token: i3.Platform }, { token: DOCUMENT }, { token: i3$1.Directionality, optional: true }, { token: YUNZAI_THEME_BTN_KEYS }], target: i0.ɵɵFactoryTarget.Component });
741
+ YzHeaderThemBtnComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.1", type: YzHeaderThemBtnComponent, selector: "yz-header-theme-btn", inputs: { types: "types", devTips: "devTips", deployUrl: "deployUrl" }, ngImport: i0, template: `
623
742
  <div
624
743
  class="yunzai-default__nav-item"
625
744
  nz-dropdown
@@ -658,76 +777,121 @@ YzHeaderThemBtnComponent.decorators = [
658
777
  <!-- </div>-->
659
778
  <!-- </div>-->
660
779
  </nz-dropdown-menu>
661
- `,
662
- changeDetection: ChangeDetectionStrategy.OnPush
663
- },] }
664
- ];
665
- YzHeaderThemBtnComponent.ctorParameters = () => [
666
- { type: Renderer2 },
667
- { type: YunzaiConfigService },
668
- { type: Platform },
669
- { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
670
- { type: Directionality, decorators: [{ type: Optional }] },
671
- { type: String, decorators: [{ type: Inject, args: [YUNZAI_THEME_BTN_KEYS,] }] }
672
- ];
673
- YzHeaderThemBtnComponent.propDecorators = {
674
- types: [{ type: Input }],
675
- devTips: [{ type: Input }],
676
- deployUrl: [{ type: Input }]
677
- };
780
+ `, isInline: true, components: [{ type: i2$2.NzDropdownMenuComponent, selector: "nz-dropdown-menu", exportAs: ["nzDropdownMenu"] }], directives: [{ type: i2$2.NzDropDownDirective, selector: "[nz-dropdown]", inputs: ["nzDropdownMenu", "nzTrigger", "nzMatchWidthElement", "nzBackdrop", "nzClickHide", "nzDisabled", "nzVisible", "nzOverlayClassName", "nzOverlayStyle", "nzPlacement"], outputs: ["nzVisibleChange"], exportAs: ["nzDropdown"] }, { type: i5$1.NzTooltipDirective, selector: "[nz-tooltip]", inputs: ["nzTooltipTitle", "nzTooltipTitleContext", "nz-tooltip", "nzTooltipTrigger", "nzTooltipPlacement", "nzTooltipOrigin", "nzTooltipVisible", "nzTooltipMouseEnterDelay", "nzTooltipMouseLeaveDelay", "nzTooltipOverlayClassName", "nzTooltipOverlayStyle", "nzTooltipArrowPointAtCenter", "nzTooltipColor"], outputs: ["nzTooltipVisibleChange"], exportAs: ["nzTooltip"] }, { type: i6.NzMenuDirective, selector: "[nz-menu]", inputs: ["nzInlineIndent", "nzTheme", "nzMode", "nzInlineCollapsed", "nzSelectable"], outputs: ["nzClick"], exportAs: ["nzMenu"] }, { type: i9$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i8.ɵNzTransitionPatchDirective, selector: "[nz-button], nz-button-group, [nz-icon], [nz-menu-item], [nz-submenu], nz-select-top-control, nz-select-placeholder, nz-input-group", inputs: ["hidden"] }, { type: i6.NzMenuItemDirective, selector: "[nz-menu-item]", inputs: ["nzPaddingLeft", "nzDisabled", "nzSelected", "nzDanger", "nzMatchRouterExact", "nzMatchRouter"], exportAs: ["nzMenuItem"] }, { type: i9.NzIconDirective, selector: "[nz-icon]", inputs: ["nzSpin", "nzRotate", "nzType", "nzTheme", "nzTwotoneColor", "nzIconfont"], exportAs: ["nzIcon"] }], pipes: { "i18n": i1.I18nPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
781
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YzHeaderThemBtnComponent, decorators: [{
782
+ type: Component,
783
+ args: [{
784
+ selector: 'yz-header-theme-btn',
785
+ template: `
786
+ <div
787
+ class="yunzai-default__nav-item"
788
+ nz-dropdown
789
+ [nzDropdownMenu]="iconMenu"
790
+ nzTrigger="click"
791
+ nzPlacement="bottomRight"
792
+ >
793
+ <svg nz-tooltip class="anticon" role="img" width="21" height="21" viewBox="0 0 21 21" fill="currentColor">
794
+ <g fill-rule="evenodd">
795
+ <g fill-rule="nonzero">
796
+ <path
797
+ d="M7.02 3.635l12.518 12.518a1.863 1.863 0 010 2.635l-1.317 1.318a1.863 1.863 0 01-2.635 0L3.068 7.588A2.795 2.795 0 117.02 3.635zm2.09 14.428a.932.932 0 110 1.864.932.932 0 010-1.864zm-.043-9.747L7.75 9.635l9.154 9.153 1.318-1.317-9.154-9.155zM3.52 12.473c.514 0 .931.417.931.931v.932h.932a.932.932 0 110 1.864h-.932v.931a.932.932 0 01-1.863 0l-.001-.931h-.93a.932.932 0 010-1.864h.93v-.932c0-.514.418-.931.933-.931zm15.374-3.727a1.398 1.398 0 110 2.795 1.398 1.398 0 010-2.795zM4.385 4.953a.932.932 0 000 1.317l2.046 2.047L7.75 7 5.703 4.953a.932.932 0 00-1.318 0zM14.701.36a.932.932 0 01.931.932v.931h.932a.932.932 0 010 1.864h-.933l.001.932a.932.932 0 11-1.863 0l-.001-.932h-.93a.932.932 0 110-1.864h.93v-.931a.932.932 0 01.933-.932z"
798
+ ></path>
799
+ </g>
800
+ </g>
801
+ </svg>
802
+ </div>
803
+ <nz-dropdown-menu #iconMenu="nzDropdownMenu">
804
+ <ul nz-menu>
805
+ <li
806
+ nz-menu-item
807
+ *ngFor="let theme of types"
808
+ (click)="onThemeChange(theme.key)"
809
+ [style]="{ color: theme.color }"
810
+ >
811
+ <i nz-icon nzType="bg-colors"></i>
812
+ {{ theme.text | i18n }}
813
+ </li>
814
+ </ul>
815
+ <!-- <div nz-menu class="wd-xl animated jello">-->
816
+ <!-- <div nz-row [nzJustify]="'space-between'" [nzAlign]="'middle'" class="app-icons">-->
817
+ <!-- <div nz-col [nzSpan]="4" *ngFor="let theme of types" (click)="onThemeChange(theme.key)">-->
818
+ <!-- <i nz-icon nzType="bg-colors" class="text-white" [style]="{ backgroundColor: theme.color }"></i>-->
819
+ <!-- <span [ngStyle]="{ color: theme.color }">{{ theme.text | i18n }}</span>-->
820
+ <!-- </div>-->
821
+ <!-- </div>-->
822
+ <!-- </div>-->
823
+ </nz-dropdown-menu>
824
+ `,
825
+ changeDetection: ChangeDetectionStrategy.OnPush
826
+ }]
827
+ }], ctorParameters: function () {
828
+ return [{ type: i0.Renderer2 }, { type: i4.YunzaiConfigService }, { type: i3.Platform }, { type: undefined, decorators: [{
829
+ type: Inject,
830
+ args: [DOCUMENT]
831
+ }] }, { type: i3$1.Directionality, decorators: [{
832
+ type: Optional
833
+ }] }, { type: undefined, decorators: [{
834
+ type: Inject,
835
+ args: [YUNZAI_THEME_BTN_KEYS]
836
+ }] }];
837
+ }, propDecorators: { types: [{
838
+ type: Input
839
+ }], devTips: [{
840
+ type: Input
841
+ }], deployUrl: [{
842
+ type: Input
843
+ }] } });
678
844
 
679
- const BUSINESS_DEFAULT_CONFIG = {
680
- baseUrl: '/backstage',
681
- systemCode: 'portal',
682
- loginForm: null,
683
- refreshTokenEnabled: true,
684
- refreshTokenType: 're-request'
685
- };
686
- function mergeBisConfig(srv) {
687
- return srv.merge('bis', BUSINESS_DEFAULT_CONFIG);
845
+ const BUSINESS_DEFAULT_CONFIG = {
846
+ baseUrl: '/backstage',
847
+ systemCode: 'portal',
848
+ loginForm: null,
849
+ refreshTokenEnabled: true,
850
+ refreshTokenType: 're-request'
851
+ };
852
+ function mergeBisConfig(srv) {
853
+ return srv.merge('bis', BUSINESS_DEFAULT_CONFIG);
688
854
  }
689
855
 
690
- class YzHeaderUserComponent {
691
- constructor(injector, msg, tokenService,
692
- // @ts-ignore
693
- configService, cacheService) {
694
- this.injector = injector;
695
- this.msg = msg;
696
- this.tokenService = tokenService;
697
- this.configService = configService;
698
- this.cacheService = cacheService;
699
- this.icon = '';
700
- this.username = '';
701
- this.menus = [];
702
- this.config = mergeBisConfig(configService);
703
- }
704
- ngOnInit() {
705
- const projectInfo = this.cacheService.get('_yz_project_info', { mode: 'none' });
706
- const user = this.cacheService.get('_yz_user', { mode: 'none' });
707
- this.username = user.realname ? user.realname : '未命名';
708
- this.icon = user.avatarId
709
- ? `${this.config.baseUrl}/filecenter/file/${user.avatarId}`
710
- : `./assets/tmp/img/avatar.jpg`;
711
- this.menus = projectInfo.profileList;
712
- }
713
- logout() {
714
- localStorage.clear();
715
- this.tokenService.clear();
716
- this.injector.get(WINDOW).location.href = `${this.config.baseUrl}/cas-proxy/app/logout`;
717
- }
718
- to(href) {
719
- if (href) {
720
- this.injector.get(WINDOW).open(href);
721
- }
722
- else {
723
- this.msg.error('该菜单没有配置链接!');
724
- }
725
- }
726
- }
727
- YzHeaderUserComponent.decorators = [
728
- { type: Component, args: [{
729
- selector: 'yz-header-user',
730
- template: `
856
+ class YzHeaderUserComponent {
857
+ constructor(injector, msg, tokenService,
858
+ // @ts-ignore
859
+ configService, cacheService) {
860
+ this.injector = injector;
861
+ this.msg = msg;
862
+ this.tokenService = tokenService;
863
+ this.configService = configService;
864
+ this.cacheService = cacheService;
865
+ this.icon = '';
866
+ this.username = '';
867
+ this.menus = [];
868
+ this.config = mergeBisConfig(configService);
869
+ }
870
+ ngOnInit() {
871
+ const projectInfo = this.cacheService.get('_yz_project_info', { mode: 'none' });
872
+ const user = this.cacheService.get('_yz_user', { mode: 'none' });
873
+ this.username = user.realname ? user.realname : '未命名';
874
+ this.icon = user.avatarId
875
+ ? `${this.config.baseUrl}/filecenter/file/${user.avatarId}`
876
+ : `./assets/tmp/img/avatar.jpg`;
877
+ this.menus = projectInfo.profileList;
878
+ }
879
+ logout() {
880
+ localStorage.clear();
881
+ this.tokenService.clear();
882
+ this.injector.get(WINDOW).location.href = `${this.config.baseUrl}/cas-proxy/app/logout`;
883
+ }
884
+ to(href) {
885
+ if (href) {
886
+ this.injector.get(WINDOW).open(href);
887
+ }
888
+ else {
889
+ this.msg.error('该菜单没有配置链接!');
890
+ }
891
+ }
892
+ }
893
+ YzHeaderUserComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YzHeaderUserComponent, deps: [{ token: i0.Injector }, { token: i1$1.NzMessageService }, { token: YA_SERVICE_TOKEN }, { token: i1$2.YunzaiConfigService }, { token: i2$1.CacheService }], target: i0.ɵɵFactoryTarget.Component });
894
+ YzHeaderUserComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.1", type: YzHeaderUserComponent, selector: "yz-header-user", ngImport: i0, template: `
731
895
  <div
732
896
  class="yunzai-default__nav-item d-flex align-items-center px-sm"
733
897
  nz-dropdown
@@ -750,791 +914,880 @@ YzHeaderUserComponent.decorators = [
750
914
  </div>
751
915
  </div>
752
916
  </nz-dropdown-menu>
753
- `,
754
- changeDetection: ChangeDetectionStrategy.OnPush
755
- },] }
756
- ];
757
- YzHeaderUserComponent.ctorParameters = () => [
758
- { type: Injector },
759
- { type: NzMessageService },
760
- { type: undefined, decorators: [{ type: Inject, args: [YA_SERVICE_TOKEN,] }] },
761
- { type: YunzaiConfigService$1 },
762
- { type: CacheService }
763
- ];
917
+ `, isInline: true, components: [{ type: i4$3.NzAvatarComponent, selector: "nz-avatar", inputs: ["nzShape", "nzSize", "nzGap", "nzText", "nzSrc", "nzSrcSet", "nzAlt", "nzIcon"], outputs: ["nzError"], exportAs: ["nzAvatar"] }, { type: i2$2.NzDropdownMenuComponent, selector: "nz-dropdown-menu", exportAs: ["nzDropdownMenu"] }], directives: [{ type: i2$2.NzDropDownDirective, selector: "[nz-dropdown]", inputs: ["nzDropdownMenu", "nzTrigger", "nzMatchWidthElement", "nzBackdrop", "nzClickHide", "nzDisabled", "nzVisible", "nzOverlayClassName", "nzOverlayStyle", "nzPlacement"], outputs: ["nzVisibleChange"], exportAs: ["nzDropdown"] }, { type: i6.NzMenuDirective, selector: "[nz-menu]", inputs: ["nzInlineIndent", "nzTheme", "nzMode", "nzInlineCollapsed", "nzSelectable"], outputs: ["nzClick"], exportAs: ["nzMenu"] }, { type: i9$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i8.ɵNzTransitionPatchDirective, selector: "[nz-button], nz-button-group, [nz-icon], [nz-menu-item], [nz-submenu], nz-select-top-control, nz-select-placeholder, nz-input-group", inputs: ["hidden"] }, { type: i6.NzMenuItemDirective, selector: "[nz-menu-item]", inputs: ["nzPaddingLeft", "nzDisabled", "nzSelected", "nzDanger", "nzMatchRouterExact", "nzMatchRouter"], exportAs: ["nzMenuItem"] }, { type: i9.NzIconDirective, selector: "[nz-icon]", inputs: ["nzSpin", "nzRotate", "nzType", "nzTheme", "nzTwotoneColor", "nzIconfont"], exportAs: ["nzIcon"] }, { type: i6.NzMenuDividerDirective, selector: "[nz-menu-divider]", exportAs: ["nzMenuDivider"] }], pipes: { "i18n": i1.I18nPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
918
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YzHeaderUserComponent, decorators: [{
919
+ type: Component,
920
+ args: [{
921
+ selector: 'yz-header-user',
922
+ template: `
923
+ <div
924
+ class="yunzai-default__nav-item d-flex align-items-center px-sm"
925
+ nz-dropdown
926
+ nzPlacement="bottomRight"
927
+ [nzDropdownMenu]="userMenu"
928
+ >
929
+ <nz-avatar [nzSrc]="icon" nzSize="small" class="mr-sm"></nz-avatar>
930
+ {{ username }}
931
+ </div>
932
+ <nz-dropdown-menu #userMenu="nzDropdownMenu">
933
+ <div nz-menu class="width-sm">
934
+ <div nz-menu-item *ngFor="let m of menus" (click)="to(m.url)">
935
+ <i nz-icon [nzType]="m.icon" class="mr-sm"></i>
936
+ {{ m.name | i18n }}
937
+ </div>
938
+ <li nz-menu-divider></li>
939
+ <div nz-menu-item (click)="logout()">
940
+ <i nz-icon nzType="logout" class="mr-sm"></i>
941
+ {{ 'menu.account.logout' | i18n }}
942
+ </div>
943
+ </div>
944
+ </nz-dropdown-menu>
945
+ `,
946
+ changeDetection: ChangeDetectionStrategy.OnPush
947
+ }]
948
+ }], ctorParameters: function () {
949
+ return [{ type: i0.Injector }, { type: i1$1.NzMessageService }, { type: undefined, decorators: [{
950
+ type: Inject,
951
+ args: [YA_SERVICE_TOKEN]
952
+ }] }, { type: i1$2.YunzaiConfigService }, { type: i2$1.CacheService }];
953
+ } });
764
954
 
765
- class YzHeaderClearStorageComponent {
766
- constructor(modalSrv, messageSrv) {
767
- this.modalSrv = modalSrv;
768
- this.messageSrv = messageSrv;
769
- }
770
- _click() {
771
- this.modalSrv.confirm({
772
- nzTitle: 'Make sure clear all local storage?',
773
- nzOnOk: () => {
774
- localStorage.clear();
775
- this.messageSrv.success('Clear Finished!');
776
- }
777
- });
778
- }
779
- }
780
- YzHeaderClearStorageComponent.decorators = [
781
- { type: Component, args: [{
782
- selector: 'yz-header-clear-storage',
783
- template: `
955
+ class YzHeaderClearStorageComponent {
956
+ constructor(modalSrv, messageSrv) {
957
+ this.modalSrv = modalSrv;
958
+ this.messageSrv = messageSrv;
959
+ }
960
+ _click() {
961
+ this.modalSrv.confirm({
962
+ nzTitle: 'Make sure clear all local storage?',
963
+ nzOnOk: () => {
964
+ localStorage.clear();
965
+ this.messageSrv.success('Clear Finished!');
966
+ }
967
+ });
968
+ }
969
+ }
970
+ YzHeaderClearStorageComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YzHeaderClearStorageComponent, deps: [{ token: i1$3.NzModalService }, { token: i1$1.NzMessageService }], target: i0.ɵɵFactoryTarget.Component });
971
+ YzHeaderClearStorageComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.1", type: YzHeaderClearStorageComponent, selector: "yz-header-clear-storage", host: { listeners: { "click": "_click()" }, properties: { "class.d-block": "true" } }, ngImport: i0, template: `
784
972
  <i nz-icon nzType="tool"></i>
785
973
  {{ 'menu.clear.local.storage' | i18n }}
786
- `,
787
- host: {
788
- '[class.d-block]': 'true'
789
- },
790
- changeDetection: ChangeDetectionStrategy.OnPush
791
- },] }
792
- ];
793
- YzHeaderClearStorageComponent.ctorParameters = () => [
794
- { type: NzModalService },
795
- { type: NzMessageService }
796
- ];
797
- YzHeaderClearStorageComponent.propDecorators = {
798
- _click: [{ type: HostListener, args: ['click',] }]
799
- };
974
+ `, isInline: true, directives: [{ type: i8.ɵNzTransitionPatchDirective, selector: "[nz-button], nz-button-group, [nz-icon], [nz-menu-item], [nz-submenu], nz-select-top-control, nz-select-placeholder, nz-input-group", inputs: ["hidden"] }, { type: i9.NzIconDirective, selector: "[nz-icon]", inputs: ["nzSpin", "nzRotate", "nzType", "nzTheme", "nzTwotoneColor", "nzIconfont"], exportAs: ["nzIcon"] }], pipes: { "i18n": i1.I18nPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
975
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YzHeaderClearStorageComponent, decorators: [{
976
+ type: Component,
977
+ args: [{
978
+ selector: 'yz-header-clear-storage',
979
+ template: `
980
+ <i nz-icon nzType="tool"></i>
981
+ {{ 'menu.clear.local.storage' | i18n }}
982
+ `,
983
+ host: {
984
+ '[class.d-block]': 'true'
985
+ },
986
+ changeDetection: ChangeDetectionStrategy.OnPush
987
+ }]
988
+ }], ctorParameters: function () { return [{ type: i1$3.NzModalService }, { type: i1$1.NzMessageService }]; }, propDecorators: { _click: [{
989
+ type: HostListener,
990
+ args: ['click']
991
+ }] } });
800
992
 
801
- class YzHeaderFullScreenComponent {
802
- constructor() {
803
- this.status = false;
804
- }
805
- get sf() {
806
- return screenfull;
807
- }
808
- _resize() {
809
- this.status = this.sf.isFullscreen;
810
- }
811
- _click() {
812
- if (this.sf.isEnabled) {
813
- this.sf.toggle();
814
- }
815
- }
816
- }
817
- YzHeaderFullScreenComponent.decorators = [
818
- { type: Component, args: [{
819
- selector: 'yz-header-fullscreen',
820
- template: `
993
+ class YzHeaderFullScreenComponent {
994
+ constructor() {
995
+ this.status = false;
996
+ }
997
+ _resize() {
998
+ this.status = screenfull.isFullscreen;
999
+ }
1000
+ _click() {
1001
+ if (screenfull.isEnabled) {
1002
+ screenfull.toggle();
1003
+ }
1004
+ }
1005
+ }
1006
+ YzHeaderFullScreenComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YzHeaderFullScreenComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1007
+ YzHeaderFullScreenComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.1", type: YzHeaderFullScreenComponent, selector: "yz-header-fullscreen", host: { listeners: { "window:resize": "_resize()", "click": "_click()" }, properties: { "class.d-block": "true" } }, ngImport: i0, template: `
821
1008
  <i nz-icon [nzType]="status ? 'fullscreen-exit' : 'fullscreen'"></i>
822
1009
  {{ (status ? 'menu.fullscreen.exit' : 'menu.fullscreen') | i18n }}
823
- `,
824
- host: {
825
- '[class.d-block]': 'true'
826
- },
827
- changeDetection: ChangeDetectionStrategy.OnPush
828
- },] }
829
- ];
830
- YzHeaderFullScreenComponent.propDecorators = {
831
- _resize: [{ type: HostListener, args: ['window:resize',] }],
832
- _click: [{ type: HostListener, args: ['click',] }]
833
- };
1010
+ `, isInline: true, directives: [{ type: i8.ɵNzTransitionPatchDirective, selector: "[nz-button], nz-button-group, [nz-icon], [nz-menu-item], [nz-submenu], nz-select-top-control, nz-select-placeholder, nz-input-group", inputs: ["hidden"] }, { type: i9.NzIconDirective, selector: "[nz-icon]", inputs: ["nzSpin", "nzRotate", "nzType", "nzTheme", "nzTwotoneColor", "nzIconfont"], exportAs: ["nzIcon"] }], pipes: { "i18n": i1.I18nPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
1011
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YzHeaderFullScreenComponent, decorators: [{
1012
+ type: Component,
1013
+ args: [{
1014
+ selector: 'yz-header-fullscreen',
1015
+ template: `
1016
+ <i nz-icon [nzType]="status ? 'fullscreen-exit' : 'fullscreen'"></i>
1017
+ {{ (status ? 'menu.fullscreen.exit' : 'menu.fullscreen') | i18n }}
1018
+ `,
1019
+ host: {
1020
+ '[class.d-block]': 'true'
1021
+ },
1022
+ changeDetection: ChangeDetectionStrategy.OnPush
1023
+ }]
1024
+ }], propDecorators: { _resize: [{
1025
+ type: HostListener,
1026
+ args: ['window:resize']
1027
+ }], _click: [{
1028
+ type: HostListener,
1029
+ args: ['click']
1030
+ }] } });
834
1031
 
835
- class ContactService {
836
- constructor(http, cache) {
837
- this.http = http;
838
- this.cache = cache;
839
- }
840
- /**
841
- * 部门树查询
842
- *
843
- * @param clas 包含班级
844
- * @param his 包含历史班级
845
- * @param grade 系部
846
- * @param gradeID 系部ID
847
- * @returns 可观察部门树
848
- */
849
- dept(clas, his, grade, gradeID) {
850
- let baseUrl = `/auth/baseDepartMent/tree?debug=false`;
851
- if (clas) {
852
- baseUrl += `&includeClass=true`;
853
- }
854
- else {
855
- baseUrl += `&includeClass=false`;
856
- }
857
- if (his) {
858
- baseUrl += `&includeHisClass=true`;
859
- }
860
- else {
861
- baseUrl += `&includeHisClass=false`;
862
- }
863
- if (grade) {
864
- baseUrl += `&deptTypes=2,class`;
865
- }
866
- if (gradeID) {
867
- baseUrl += `&gradeId=${gradeID}`;
868
- }
869
- return this.http.get(baseUrl).pipe(map((response) => {
870
- return response.data || [];
871
- }));
872
- }
873
- page(uri, page) {
874
- return this.http.post(`${uri}/queryListForPage`, page);
875
- }
876
- pageBaseUser(page) {
877
- return this.page('/auth/baseUser', page);
878
- }
879
- getUserByIds(ids) {
880
- return this.http
881
- .post('/auth/baseUser/users', {
882
- userIds: ids
883
- })
884
- .pipe((response) => {
885
- return response.data || [];
886
- });
887
- }
888
- /**
889
- * 查询人员信息
890
- *
891
- * @param userIds[] 用户id数组,["aaa","bbb","ccc"]
892
- */
893
- getUserByUserIds(userIds) {
894
- return this.http
895
- .post(`/auth/baseUser/users`, {
896
- userIds: userIds
897
- })
898
- .pipe(map((response) => {
899
- return response.data ? response.data : [];
900
- }));
901
- }
902
- /**
903
- * 获取角色组角色
904
- *
905
- * @param roleGroupCode 角色组code
906
- */
907
- getGroupRole(roleGroupCode) {
908
- return this.http
909
- .post(`/auth/baseRole/findGroupRole`, {
910
- roleGroupCode: roleGroupCode
911
- })
912
- .pipe(map((response) => {
913
- return response.data ? response.data : [];
914
- }));
915
- }
916
- /**
917
- * 查询当前用户好友分组
918
- */
919
- getFriendGroup() {
920
- return this.http.post(`/contact/appcontact/findGroup`, {}).pipe(map((response) => {
921
- return response.data ? response.data : [];
922
- }));
923
- }
924
- /**
925
- * 查询年级
926
- */
927
- getGrade() {
928
- return this.http.get(`/auth/gradeYear/queryListForPage`).pipe(map((response) => {
929
- return response.data ? response.data : [];
930
- }));
931
- }
932
- /**
933
- * 查询人员类别列表
934
- */
935
- getRylbs() {
936
- return this.http.post(`/auth/baseTeacher/queryRylbs`, {}).pipe(map((response) => {
937
- return response.data ? response.data : [];
938
- }));
939
- }
940
- /**
941
- * 获取学生公寓树
942
- *
943
- * @param isPower 是否带有权限,默认false
944
- * @param treeType 树类型 0:宿舍楼 1:宿舍楼+层 2:宿舍楼+层+房间
945
- */
946
- getDormTree(isPower, treeType) {
947
- const user = this.cache.get('_yz_user', { mode: 'none' });
948
- let params = {};
949
- if (isPower) {
950
- params = {
951
- isPower: isPower,
952
- userId: user.userId,
953
- treeType: treeType
954
- };
955
- }
956
- else {
957
- params = {
958
- isPower: isPower,
959
- treeType: treeType
960
- };
961
- }
962
- return this.http.post(`/auth/dorm/tree`, params).pipe(map((response) => {
963
- return response.data ? response.data : [];
964
- }));
965
- }
966
- }
967
- ContactService.ɵprov = i0.ɵɵdefineInjectable({ factory: function ContactService_Factory() { return new ContactService(i0.ɵɵinject(i1._HttpClient), i0.ɵɵinject(i2$1.CacheService)); }, token: ContactService, providedIn: "root" });
968
- ContactService.decorators = [
969
- { type: Injectable, args: [{
970
- providedIn: 'root'
971
- },] }
972
- ];
973
- ContactService.ctorParameters = () => [
974
- { type: _HttpClient },
975
- { type: CacheService }
976
- ];
1032
+ class ContactService {
1033
+ constructor(http, cache) {
1034
+ this.http = http;
1035
+ this.cache = cache;
1036
+ }
1037
+ /**
1038
+ * 部门树查询
1039
+ *
1040
+ * @param clas 包含班级
1041
+ * @param his 包含历史班级
1042
+ * @param grade 系部
1043
+ * @param gradeID 系部ID
1044
+ * @returns 可观察部门树
1045
+ */
1046
+ dept(clas, his, grade, gradeID) {
1047
+ let baseUrl = `/auth/baseDepartMent/tree?debug=false`;
1048
+ if (clas) {
1049
+ baseUrl += `&includeClass=true`;
1050
+ }
1051
+ else {
1052
+ baseUrl += `&includeClass=false`;
1053
+ }
1054
+ if (his) {
1055
+ baseUrl += `&includeHisClass=true`;
1056
+ }
1057
+ else {
1058
+ baseUrl += `&includeHisClass=false`;
1059
+ }
1060
+ if (grade) {
1061
+ baseUrl += `&deptTypes=2,class`;
1062
+ }
1063
+ if (gradeID) {
1064
+ baseUrl += `&gradeId=${gradeID}`;
1065
+ }
1066
+ return this.http.get(baseUrl).pipe(map((response) => {
1067
+ return response.data || [];
1068
+ }));
1069
+ }
1070
+ page(uri, page) {
1071
+ return this.http.post(`${uri}/queryListForPage`, page);
1072
+ }
1073
+ pageBaseUser(page) {
1074
+ return this.page('/auth/baseUser', page);
1075
+ }
1076
+ getUserByIds(ids) {
1077
+ return this.http
1078
+ .post('/auth/baseUser/users', {
1079
+ userIds: ids
1080
+ })
1081
+ .pipe((response) => {
1082
+ return response.data || [];
1083
+ });
1084
+ }
1085
+ /**
1086
+ * 查询人员信息
1087
+ *
1088
+ * @param userIds[] 用户id数组,["aaa","bbb","ccc"]
1089
+ */
1090
+ getUserByUserIds(userIds) {
1091
+ return this.http
1092
+ .post(`/auth/baseUser/users`, {
1093
+ userIds: userIds
1094
+ })
1095
+ .pipe(map((response) => {
1096
+ return response.data ? response.data : [];
1097
+ }));
1098
+ }
1099
+ /**
1100
+ * 获取角色组角色
1101
+ *
1102
+ * @param roleGroupCode 角色组code
1103
+ */
1104
+ getGroupRole(roleGroupCode) {
1105
+ return this.http
1106
+ .post(`/auth/baseRole/findGroupRole`, {
1107
+ roleGroupCode: roleGroupCode
1108
+ })
1109
+ .pipe(map((response) => {
1110
+ return response.data ? response.data : [];
1111
+ }));
1112
+ }
1113
+ /**
1114
+ * 查询当前用户好友分组
1115
+ */
1116
+ getFriendGroup() {
1117
+ return this.http.post(`/contact/appcontact/findGroup`, {}).pipe(map((response) => {
1118
+ return response.data ? response.data : [];
1119
+ }));
1120
+ }
1121
+ /**
1122
+ * 查询年级
1123
+ */
1124
+ getGrade() {
1125
+ return this.http.get(`/auth/gradeYear/queryListForPage`).pipe(map((response) => {
1126
+ return response.data ? response.data : [];
1127
+ }));
1128
+ }
1129
+ /**
1130
+ * 查询人员类别列表
1131
+ */
1132
+ getRylbs() {
1133
+ return this.http.post(`/auth/baseTeacher/queryRylbs`, {}).pipe(map((response) => {
1134
+ return response.data ? response.data : [];
1135
+ }));
1136
+ }
1137
+ /**
1138
+ * 获取学生公寓树
1139
+ *
1140
+ * @param isPower 是否带有权限,默认false
1141
+ * @param treeType 树类型 0:宿舍楼 1:宿舍楼+层 2:宿舍楼+层+房间
1142
+ */
1143
+ getDormTree(isPower, treeType) {
1144
+ const user = this.cache.get('_yz_user', { mode: 'none' });
1145
+ let params = {};
1146
+ if (isPower) {
1147
+ params = {
1148
+ isPower: isPower,
1149
+ userId: user.userId,
1150
+ treeType: treeType
1151
+ };
1152
+ }
1153
+ else {
1154
+ params = {
1155
+ isPower: isPower,
1156
+ treeType: treeType
1157
+ };
1158
+ }
1159
+ return this.http.post(`/auth/dorm/tree`, params).pipe(map((response) => {
1160
+ return response.data ? response.data : [];
1161
+ }));
1162
+ }
1163
+ }
1164
+ ContactService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ContactService, deps: [{ token: i1._HttpClient }, { token: i2$1.CacheService }], target: i0.ɵɵFactoryTarget.Injectable });
1165
+ ContactService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ContactService, providedIn: 'root' });
1166
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ContactService, decorators: [{
1167
+ type: Injectable,
1168
+ args: [{
1169
+ providedIn: 'root'
1170
+ }]
1171
+ }], ctorParameters: function () { return [{ type: i1._HttpClient }, { type: i2$1.CacheService }]; } });
977
1172
 
978
- class ContactComponent {
979
- constructor(contact, changeDetectorRef) {
980
- this.contact = contact;
981
- this.changeDetectorRef = changeDetectorRef;
982
- this.subs = [];
983
- /**
984
- * tabset
985
- */
986
- this.nzTabsetSearch = null;
987
- this.nzTabsetLoading = false;
988
- /**
989
- * 树展开状态
990
- */
991
- this.nzExpandAll = true;
992
- /**
993
- * 部门树和部门查询的一些选项/可传可不传
994
- */
995
- this.nzDepts = [];
996
- this._nzDeptsCopy = [];
997
- this.nzDeptTreeVirtualHeight = null;
998
- this.nzDeptClass = true;
999
- this.nzDeptClassHistory = true;
1000
- this.nzDeptGrade = false;
1001
- /**
1002
- * 角色树
1003
- */
1004
- this.nzRoles = [];
1005
- this._nzRolesCopy = [];
1006
- this.nzRoleTreeVirtualHeight = null;
1007
- /**
1008
- * 好友分组
1009
- */
1010
- this.nzFriendGroups = [];
1011
- this._nzFriendGroupsCopy = [];
1012
- /**
1013
- * 联系人
1014
- */
1015
- this.defaultContacts = [];
1016
- this.nzContacts = [];
1017
- this.nzContactLoading = false;
1018
- /**
1019
- * 提交和提交按钮
1020
- */
1021
- this.button = true;
1022
- this.confirmed = new EventEmitter();
1023
- }
1024
- /**
1025
- * 初始化,首先加载部门树和默认选中的人的数据
1026
- */
1027
- ngOnInit() {
1028
- this.onTabsetDept();
1029
- this.onContactsInit();
1030
- }
1031
- /**
1032
- * 视图初始化完毕后进行table初始化
1033
- */
1034
- ngAfterViewInit() {
1035
- this.onTableInit();
1036
- }
1037
- /**
1038
- * 初始化默认选中联系人
1039
- */
1040
- onContactsInit() {
1041
- if (this.defaultContacts && this.defaultContacts.length > 0) {
1042
- this.nzContactLoading = true;
1043
- this.subs.push(this.contact.getUserByUserIds(this.defaultContacts).subscribe(contacts => {
1044
- this.nzContacts = contacts;
1045
- this.nzContactLoading = false;
1046
- this.refresh();
1047
- }));
1048
- }
1049
- }
1050
- /**
1051
- * table初始化
1052
- */
1053
- onTableInit() {
1054
- // 设置表头
1055
- this.st.resetColumns({
1056
- columns: [
1057
- { title: '选择', type: 'checkbox' },
1058
- { title: '序号', type: 'no' },
1059
- { title: '姓名', index: 'realName' },
1060
- { title: '学号/工号', index: 'userCode' },
1061
- { title: '部门', index: 'dept.deptName' }
1062
- ]
1063
- });
1064
- // 订阅table点击checkbox事件变化
1065
- this.subs.push(this.st.change.subscribe(e => {
1066
- if (e.type === 'checkbox') {
1067
- // 点击checkbox新增联系人
1068
- const contactIds = this.nzContacts.map(c => c.userId);
1069
- this.nzContacts = this.nzContacts.concat(e.checkbox.filter(c => !contactIds.includes(c.userId)));
1070
- // 取消checkbox取消联系人
1071
- const cancelIds = this.st.list.filter(d => !d.checked).map(d => d.userId);
1072
- this.nzContacts = this.nzContacts.filter(d => !cancelIds.includes(d.userId));
1073
- }
1074
- }));
1075
- }
1076
- /**
1077
- * tabset进入加载状态
1078
- */
1079
- onTabsetLoadStart() {
1080
- this.nzTabsetLoading = true;
1081
- }
1082
- /**
1083
- * tabset取消加载状态
1084
- */
1085
- onTabsetLoadEnd() {
1086
- this.nzTabsetLoading = false;
1087
- }
1088
- /**
1089
- * tabset搜索框清除
1090
- */
1091
- onTabsetSearchClean() {
1092
- this.nzDepts = this._nzDeptsCopy;
1093
- this.nzRoles = this._nzRolesCopy;
1094
- this.nzFriendGroups = this._nzFriendGroupsCopy;
1095
- this.nzTabsetSearch = null;
1096
- }
1097
- /**
1098
- * tabset搜索框输入
1099
- *
1100
- * @param type 类型
1101
- * @param value
1102
- */
1103
- onTabsetSearchChange(type, value) {
1104
- this.onTabsetLoadStart();
1105
- if (!value || value === '') {
1106
- this.nzDepts = this._nzDeptsCopy;
1107
- this.nzRoles = this._nzRolesCopy;
1108
- this.nzFriendGroups = this._nzFriendGroupsCopy;
1109
- }
1110
- else {
1111
- const trees = [];
1112
- if (type === 'dept') {
1113
- this.searchTree(value, this._nzDeptsCopy, trees);
1114
- this.nzDepts = trees;
1115
- }
1116
- if (type === 'role') {
1117
- this.searchTree(value, this._nzRolesCopy, trees);
1118
- this.nzRoles = trees;
1119
- }
1120
- if (type === 'friendGroup') {
1121
- this.nzFriendGroups = this._nzFriendGroupsCopy.filter(f => {
1122
- return !f.name.indexOf(value);
1123
- });
1124
- }
1125
- }
1126
- this.onTabsetLoadEnd();
1127
- this.refresh();
1128
- }
1129
- /**
1130
- * tabset切换到部门
1131
- */
1132
- onTabsetDept() {
1133
- this.onTabsetSearchClean();
1134
- if (!this.nzDepts || this.nzDepts.length === 0) {
1135
- this.onTabsetDeptFlush();
1136
- }
1137
- }
1138
- /**
1139
- * tabset切换到角色
1140
- */
1141
- onTabsetRole() {
1142
- this.onTabsetSearchClean();
1143
- if (!this.nzRoles || this.nzRoles.length === 0) {
1144
- this.onTabsetRoleFlush(null);
1145
- }
1146
- }
1147
- /**
1148
- * tabset切换到好友分组
1149
- */
1150
- onTabsetFriendGroup() {
1151
- this.onTabsetSearchClean();
1152
- if (!this.nzFriendGroups || this.nzFriendGroups.length === 0) {
1153
- this.onTabsetFriendGroupFlush();
1154
- }
1155
- }
1156
- /**
1157
- * 获取部门树
1158
- */
1159
- onTabsetDeptFlush() {
1160
- this.onTabsetLoadStart();
1161
- this.subs.push(this.contact
1162
- .dept(this.nzDeptClass, this.nzDeptClassHistory, this.nzDeptGrade, this.nzDeptGradeID)
1163
- .subscribe((trees) => {
1164
- this.expandTree(trees);
1165
- this.nzDepts = trees;
1166
- this._nzDeptsCopy = trees;
1167
- this.onTabsetLoadEnd();
1168
- this.refresh();
1169
- }));
1170
- }
1171
- // 获取角色树
1172
- onTabsetRoleFlush(groupRoleCode) {
1173
- this.onTabsetLoadStart();
1174
- this.subs.push(this.contact.getGroupRole(groupRoleCode).subscribe((roles) => {
1175
- this.expandTree(roles);
1176
- this.nzRoles = roles;
1177
- this._nzRolesCopy = roles;
1178
- this.onTabsetLoadEnd();
1179
- this.refresh();
1180
- }));
1181
- }
1182
- // 获取好友分组列表
1183
- onTabsetFriendGroupFlush() {
1184
- this.onTabsetLoadStart();
1185
- this.subs.push(this.contact.getFriendGroup().subscribe((group) => {
1186
- this.nzFriendGroups = group;
1187
- this._nzFriendGroupsCopy = group;
1188
- this.onTabsetLoadEnd();
1189
- this.refresh();
1190
- }));
1191
- }
1192
- /**
1193
- * 部门树点击
1194
- *
1195
- * @param e 节点
1196
- */
1197
- onDeptClick(e) {
1198
- var _a;
1199
- // 构造分页请求,直接传入stTable组件,剩下的所有交给组件自己完成
1200
- this.st.data = '/auth/baseUser/queryListForPage';
1201
- this.st.req = {
1202
- allInBody: true,
1203
- method: 'POST',
1204
- type: 'page',
1205
- reName: {
1206
- pi: 'pageNum',
1207
- ps: 'pageSize'
1208
- },
1209
- body: {
1210
- pageParam: {
1211
- deptId: (_a = e.keys) === null || _a === void 0 ? void 0 : _a.pop()
1212
- }
1213
- }
1214
- };
1215
- // table数据预处理
1216
- this.st.res = {
1217
- process: data => {
1218
- this.onTableCheck(data);
1219
- return data;
1220
- }
1221
- };
1222
- // 加载第一页
1223
- this.st.load(1);
1224
- }
1225
- /**
1226
- * 角色树点击
1227
- *
1228
- * @param e 节点
1229
- */
1230
- onRoleClick(e) {
1231
- var _a;
1232
- // 构造分页请求,直接传入stTable组件,剩下的所有交给组件自己完成
1233
- this.st.data = '/auth/baseUser/queryListForPage';
1234
- this.st.req = {
1235
- allInBody: true,
1236
- method: 'POST',
1237
- type: 'page',
1238
- reName: {
1239
- pi: 'pageNum',
1240
- ps: 'pageSize'
1241
- },
1242
- body: {
1243
- pageParam: {
1244
- roleId: (_a = e.keys) === null || _a === void 0 ? void 0 : _a.pop()
1245
- }
1246
- }
1247
- };
1248
- // table数据预处理
1249
- this.st.res = {
1250
- process: data => {
1251
- this.onTableCheck(data);
1252
- return data;
1253
- }
1254
- };
1255
- // 加载第一页
1256
- this.st.load(1);
1257
- }
1258
- /**
1259
- * 好友分组点击
1260
- *
1261
- * @param e 分组
1262
- */
1263
- onFriendGroupClick(e) {
1264
- // 构造分页请求,直接传入stTable组件,剩下的所有交给组件自己完成
1265
- this.st.data = '/auth/baseUser/queryListForPage';
1266
- this.st.req = {
1267
- allInBody: true,
1268
- method: 'POST',
1269
- type: 'page',
1270
- reName: {
1271
- pi: 'pageNum',
1272
- ps: 'pageSize'
1273
- },
1274
- body: {
1275
- pageParam: {
1276
- friendGroupId: e.id
1277
- }
1278
- }
1279
- };
1280
- // table数据预处理
1281
- this.st.res = {
1282
- process: data => {
1283
- this.onTableCheck(data);
1284
- return data;
1285
- }
1286
- };
1287
- // 加载第一页
1288
- this.st.load(1);
1289
- }
1290
- /**
1291
- * 点击右侧联系人进行删除
1292
- *
1293
- * @param c 点击的联系人
1294
- */
1295
- onContactRemove(c) {
1296
- this.nzContacts = this.nzContacts.filter(contact => {
1297
- return contact.userId != c.userId;
1298
- });
1299
- this.st.reload();
1300
- }
1301
- /**
1302
- * 预处理table当前页数据,和nzContat对比,确定checkbox状态
1303
- *
1304
- * @param data 预处理数据
1305
- */
1306
- onTableCheck(data) {
1307
- const ids = this.nzContacts.map(u => u.userId);
1308
- data.forEach(d => {
1309
- if (ids.includes(d.userId)) {
1310
- d.checked = true;
1311
- }
1312
- else {
1313
- d.checked = false;
1314
- }
1315
- });
1316
- }
1317
- /**
1318
- * 递归树寻找name相同节点
1319
- *
1320
- * @param name 名称
1321
- * @param trees 需要递归的树
1322
- * @param list 搜索结果
1323
- */
1324
- searchTree(name, trees, list) {
1325
- if (trees && trees.length && trees.length > 0) {
1326
- trees.forEach((tree) => {
1327
- if (tree.title.indexOf(name) != -1) {
1328
- list.push(tree);
1329
- }
1330
- if (tree.children) {
1331
- this.searchTree(name, tree.children, list);
1332
- }
1333
- });
1334
- }
1335
- }
1336
- /**
1337
- * 递归树展开所有有子节点的节点
1338
- *
1339
- * @param trees 需要展开的树
1340
- */
1341
- expandTree(trees) {
1342
- if (trees && trees.length && trees.length > 0) {
1343
- trees.forEach(tree => {
1344
- if (!tree.children || tree.children.length === 0) {
1345
- tree.expanded = false;
1346
- tree.isLeaf = true;
1347
- }
1348
- if (tree.children) {
1349
- tree.expanded = this.nzExpandAll;
1350
- tree.isLeaf = false;
1351
- this.expandTree(tree.children);
1352
- }
1353
- });
1354
- }
1355
- }
1356
- /**
1357
- * 刷新当前页面
1358
- */
1359
- refresh() {
1360
- this.changeDetectorRef.detectChanges();
1361
- }
1362
- /**
1363
- * 确认按钮output数据
1364
- */
1365
- confirm() {
1366
- this.confirmed.next(this.nzContacts);
1367
- }
1368
- /**
1369
- * 销毁函数
1370
- */
1371
- ngOnDestroy() {
1372
- this.nzDepts = [];
1373
- this.nzRoles = [];
1374
- this.nzContacts = [];
1375
- this.subs.forEach(s => s.unsubscribe());
1376
- }
1377
- }
1378
- ContactComponent.decorators = [
1379
- { type: Component, args: [{
1380
- selector: 'contact',
1381
- template: "<nz-row [nzGutter]=\"16\">\n <nz-col [nzXs]=\"24\" [nzSm]=\"24\" [nzMd]=\"24\" [nzLg]=\"8\" [nzXl]=\"6\" [nzXXl]=\"6\">\n <nz-tabset nzCentered>\n <nz-tab nzTitle=\"\u90E8\u95E8\" (nzSelect)=\"onTabsetDept()\">\n <div sg-container=\"2\">\n <sg col=\"1\" class=\"nz-tabset-sg\">\n <nz-input-group class=\"nz-tabset-input\" [nzSuffix]=\"searchInputTpl\">\n <input\n nz-input\n [(ngModel)]=\"nzTabsetSearch\"\n (ngModelChange)=\"onTabsetSearchChange('dept', $event)\"\n type=\"text\"\n placeholder=\"\u8BF7\u8F93\u5165\u90E8\u95E8\u540D\u79F0\"\n />\n </nz-input-group>\n </sg>\n <sg col=\"1\">\n <nz-spin [nzSpinning]=\"nzTabsetLoading\">\n <nz-tree\n class=\"nz-tabset-content\"\n (nzClick)=\"onDeptClick($event)\"\n [nzBlockNode]=\"true\"\n [nzShowLine]=\"true\"\n [nzHideUnMatched]=\"true\"\n [nzVirtualHeight]=\"nzDeptTreeVirtualHeight\"\n [nzData]=\"nzDepts\"\n ></nz-tree>\n </nz-spin>\n </sg>\n </div>\n </nz-tab>\n <nz-tab nzTitle=\"\u89D2\u8272\" (nzSelect)=\"onTabsetRole()\">\n <div sg-container=\"2\">\n <sg col=\"1\" class=\"nz-tabset-sg\">\n <nz-input-group class=\"nz-tabset-input\" [nzSuffix]=\"searchInputTpl\">\n <input\n nz-input\n [(ngModel)]=\"nzTabsetSearch\"\n (ngModelChange)=\"onTabsetSearchChange('role', $event)\"\n type=\"text\"\n placeholder=\"\u8BF7\u8F93\u5165\u89D2\u8272\u540D\u79F0\"\n />\n </nz-input-group>\n </sg>\n <sg col=\"1\">\n <nz-spin [nzSpinning]=\"nzTabsetLoading\">\n <nz-tree\n class=\"nz-tabset-content\"\n (nzClick)=\"onRoleClick($event)\"\n [nzBlockNode]=\"true\"\n [nzShowLine]=\"true\"\n [nzHideUnMatched]=\"true\"\n [nzVirtualHeight]=\"nzRoleTreeVirtualHeight\"\n [nzData]=\"nzRoles\"\n ></nz-tree>\n </nz-spin>\n </sg>\n </div>\n </nz-tab>\n <nz-tab nzTitle=\"\u597D\u53CB\" (nzSelect)=\"onTabsetFriendGroup()\">\n <div sg-container=\"2\">\n <sg col=\"1\" class=\"nz-tabset-sg\">\n <nz-input-group class=\"nz-tabset-input\" [nzSuffix]=\"searchInputTpl\">\n <input\n nz-input\n [(ngModel)]=\"nzTabsetSearch\"\n (ngModelChange)=\"onTabsetSearchChange('friendGroup', $event)\"\n type=\"text\"\n placeholder=\"\u8BF7\u8F93\u5165\u597D\u53CB\u540D\u79F0\"\n />\n </nz-input-group>\n </sg>\n <sg col=\"1\">\n <nz-spin [nzSpinning]=\"nzTabsetLoading\">\n <nz-list class=\"nz-tabset-content\" nzItemLayout=\"horizontal\" [nzSplit]=\"false\" nzSize=\"small\">\n <nz-list-item\n class=\"nz-tabset-content-item\"\n *ngFor=\"let group of nzFriendGroups\"\n (click)=\"onFriendGroupClick(group)\"\n >\n <nz-list-item-meta>\n <nz-list-item-meta-title>\n {{ group.name }}\n </nz-list-item-meta-title>\n </nz-list-item-meta>\n </nz-list-item>\n </nz-list>\n </nz-spin>\n </sg>\n </div>\n </nz-tab>\n </nz-tabset>\n </nz-col>\n\n <nz-col [nzXs]=\"24\" [nzSm]=\"24\" [nzMd]=\"24\" [nzLg]=\"16\" [nzXl]=\"13\" [nzXXl]=\"13\">\n <st #st responsiveHideHeaderFooter></st>\n </nz-col>\n\n <nz-col [nzXs]=\"24\" [nzSm]=\"24\" [nzMd]=\"24\" [nzLg]=\"24\" [nzXl]=\"5\" [nzXXl]=\"5\">\n <nz-spin [nzSpinning]=\"nzContactLoading\">\n <nz-list nzItemLayout=\"horizontal\" [nzSplit]=\"false\" nzSize=\"small\">\n <nz-list-item\n class=\"nz-tabset-content-item\"\n *ngFor=\"let contact of nzContacts\"\n (click)=\"onContactRemove(contact)\"\n >\n <nz-list-item-meta>\n <nz-list-item-meta-title>\n {{ contact.realName }}\n </nz-list-item-meta-title>\n </nz-list-item-meta>\n </nz-list-item>\n </nz-list>\n </nz-spin>\n </nz-col>\n</nz-row>\n\n<nz-row *ngIf=\"button\">\n <nz-col [nzSpan]=\"4\" [nzOffset]=\"20\">\n <button nz-button nzType=\"primary\" (click)=\"confirm()\">\u786E\u5B9A</button>\n </nz-col>\n</nz-row>\n\n<ng-template #searchInputTpl>\n <i nz-icon nzType=\"close\" nzTheme=\"outline\" *ngIf=\"nzTabsetSearch\" (click)=\"onTabsetSearchClean()\"></i>\n <i nz-icon nzType=\"search\" nzTheme=\"outline\" *ngIf=\"!nzTabsetSearch\"></i>\n</ng-template>\n",
1382
- styles: [".nz-tabset-input{width:100%}.nz-tabset-content{padding:20px}.nz-tabset-sg{padding-right:38px!important;padding-left:38px!important}.nz-tabset-content-item:hover{background-color:#f1f1f1;cursor:pointer}\n"]
1383
- },] }
1384
- ];
1385
- ContactComponent.ctorParameters = () => [
1386
- { type: ContactService },
1387
- { type: ChangeDetectorRef }
1388
- ];
1389
- ContactComponent.propDecorators = {
1390
- nzTabsetSearch: [{ type: Optional }, { type: Input }],
1391
- nzTabsetLoading: [{ type: Optional }, { type: Input }],
1392
- nzExpandAll: [{ type: Optional }, { type: Input }],
1393
- nzDepts: [{ type: Optional }, { type: Input }],
1394
- nzDeptTreeVirtualHeight: [{ type: Optional }, { type: Input }],
1395
- nzDeptClass: [{ type: Optional }, { type: Input }],
1396
- nzDeptClassHistory: [{ type: Optional }, { type: Input }],
1397
- nzDeptGrade: [{ type: Optional }, { type: Input }],
1398
- nzDeptGradeID: [{ type: Optional }, { type: Input }],
1399
- nzRoles: [{ type: Optional }, { type: Input }],
1400
- nzRoleTreeVirtualHeight: [{ type: Optional }, { type: Input }],
1401
- nzFriendGroups: [{ type: Optional }, { type: Input }],
1402
- st: [{ type: ViewChild, args: ['st', { static: false },] }],
1403
- defaultContacts: [{ type: Optional }, { type: Input }],
1404
- nzContacts: [{ type: Optional }, { type: Input }],
1405
- nzContactLoading: [{ type: Optional }, { type: Input }],
1406
- button: [{ type: Optional }, { type: Input }],
1407
- confirmed: [{ type: Output }]
1408
- };
1173
+ class ContactComponent {
1174
+ constructor(contact, changeDetectorRef) {
1175
+ this.contact = contact;
1176
+ this.changeDetectorRef = changeDetectorRef;
1177
+ this.subs = [];
1178
+ /**
1179
+ * tabset
1180
+ */
1181
+ this.nzTabsetSearch = null;
1182
+ this.nzTabsetLoading = false;
1183
+ /**
1184
+ * 树展开状态
1185
+ */
1186
+ this.nzExpandAll = true;
1187
+ /**
1188
+ * 部门树和部门查询的一些选项/可传可不传
1189
+ */
1190
+ this.nzDepts = [];
1191
+ this._nzDeptsCopy = [];
1192
+ this.nzDeptTreeVirtualHeight = null;
1193
+ this.nzDeptClass = true;
1194
+ this.nzDeptClassHistory = true;
1195
+ this.nzDeptGrade = false;
1196
+ this.nzDeptGradeID = null;
1197
+ /**
1198
+ * 角色树
1199
+ */
1200
+ this.nzRoles = [];
1201
+ this._nzRolesCopy = [];
1202
+ this.nzRoleTreeVirtualHeight = null;
1203
+ /**
1204
+ * 好友分组
1205
+ */
1206
+ this.nzFriendGroups = [];
1207
+ this._nzFriendGroupsCopy = [];
1208
+ /**
1209
+ * 联系人
1210
+ */
1211
+ this.defaultContacts = [];
1212
+ this.nzContacts = [];
1213
+ this.nzContactLoading = false;
1214
+ /**
1215
+ * 提交和提交按钮
1216
+ */
1217
+ this.button = true;
1218
+ this.confirmed = new EventEmitter();
1219
+ }
1220
+ /**
1221
+ * 初始化,首先加载部门树和默认选中的人的数据
1222
+ */
1223
+ ngOnInit() {
1224
+ this.onTabsetDept();
1225
+ this.onContactsInit();
1226
+ }
1227
+ /**
1228
+ * 视图初始化完毕后进行table初始化
1229
+ */
1230
+ ngAfterViewInit() {
1231
+ this.onTableInit();
1232
+ }
1233
+ /**
1234
+ * 初始化默认选中联系人
1235
+ */
1236
+ onContactsInit() {
1237
+ if (this.defaultContacts && this.defaultContacts.length > 0) {
1238
+ this.nzContactLoading = true;
1239
+ this.subs.push(this.contact.getUserByUserIds(this.defaultContacts).subscribe(contacts => {
1240
+ this.nzContacts = contacts;
1241
+ this.nzContactLoading = false;
1242
+ this.refresh();
1243
+ }));
1244
+ }
1245
+ }
1246
+ /**
1247
+ * table初始化
1248
+ */
1249
+ onTableInit() {
1250
+ // 设置表头
1251
+ this.st.resetColumns({
1252
+ columns: [
1253
+ { title: '选择', type: 'checkbox' },
1254
+ { title: '序号', type: 'no' },
1255
+ { title: '姓名', index: 'realName' },
1256
+ { title: '学号/工号', index: 'userCode' },
1257
+ { title: '部门', index: 'dept.deptName' }
1258
+ ]
1259
+ });
1260
+ // 订阅table点击checkbox事件变化
1261
+ this.subs.push(this.st.change.subscribe(e => {
1262
+ if (e.type === 'checkbox') {
1263
+ // 点击checkbox新增联系人
1264
+ const contactIds = this.nzContacts.map(c => c.userId);
1265
+ this.nzContacts = this.nzContacts.concat(e.checkbox.filter(c => !contactIds.includes(c.userId)));
1266
+ // 取消checkbox取消联系人
1267
+ const cancelIds = this.st.list.filter(d => !d.checked).map(d => d.userId);
1268
+ this.nzContacts = this.nzContacts.filter(d => !cancelIds.includes(d.userId));
1269
+ }
1270
+ }));
1271
+ }
1272
+ /**
1273
+ * tabset进入加载状态
1274
+ */
1275
+ onTabsetLoadStart() {
1276
+ this.nzTabsetLoading = true;
1277
+ }
1278
+ /**
1279
+ * tabset取消加载状态
1280
+ */
1281
+ onTabsetLoadEnd() {
1282
+ this.nzTabsetLoading = false;
1283
+ }
1284
+ /**
1285
+ * tabset搜索框清除
1286
+ */
1287
+ onTabsetSearchClean() {
1288
+ this.nzDepts = this._nzDeptsCopy;
1289
+ this.nzRoles = this._nzRolesCopy;
1290
+ this.nzFriendGroups = this._nzFriendGroupsCopy;
1291
+ this.nzTabsetSearch = null;
1292
+ }
1293
+ /**
1294
+ * tabset搜索框输入
1295
+ *
1296
+ * @param type 类型
1297
+ * @param value 值
1298
+ */
1299
+ onTabsetSearchChange(type, value) {
1300
+ this.onTabsetLoadStart();
1301
+ if (!value || value === '') {
1302
+ this.nzDepts = this._nzDeptsCopy;
1303
+ this.nzRoles = this._nzRolesCopy;
1304
+ this.nzFriendGroups = this._nzFriendGroupsCopy;
1305
+ }
1306
+ else {
1307
+ const trees = [];
1308
+ if (type === 'dept') {
1309
+ this.searchTree(value, this._nzDeptsCopy, trees);
1310
+ this.nzDepts = trees;
1311
+ }
1312
+ if (type === 'role') {
1313
+ this.searchTree(value, this._nzRolesCopy, trees);
1314
+ this.nzRoles = trees;
1315
+ }
1316
+ if (type === 'friendGroup') {
1317
+ this.nzFriendGroups = this._nzFriendGroupsCopy.filter(f => {
1318
+ return !f.name.indexOf(value);
1319
+ });
1320
+ }
1321
+ }
1322
+ this.onTabsetLoadEnd();
1323
+ this.refresh();
1324
+ }
1325
+ /**
1326
+ * tabset切换到部门
1327
+ */
1328
+ onTabsetDept() {
1329
+ this.onTabsetSearchClean();
1330
+ if (!this.nzDepts || this.nzDepts.length === 0) {
1331
+ this.onTabsetDeptFlush();
1332
+ }
1333
+ }
1334
+ /**
1335
+ * tabset切换到角色
1336
+ */
1337
+ onTabsetRole() {
1338
+ this.onTabsetSearchClean();
1339
+ if (!this.nzRoles || this.nzRoles.length === 0) {
1340
+ this.onTabsetRoleFlush(null);
1341
+ }
1342
+ }
1343
+ /**
1344
+ * tabset切换到好友分组
1345
+ */
1346
+ onTabsetFriendGroup() {
1347
+ this.onTabsetSearchClean();
1348
+ if (!this.nzFriendGroups || this.nzFriendGroups.length === 0) {
1349
+ this.onTabsetFriendGroupFlush();
1350
+ }
1351
+ }
1352
+ /**
1353
+ * 获取部门树
1354
+ */
1355
+ onTabsetDeptFlush() {
1356
+ this.onTabsetLoadStart();
1357
+ this.subs.push(this.contact
1358
+ .dept(this.nzDeptClass, this.nzDeptClassHistory, this.nzDeptGrade, this.nzDeptGradeID)
1359
+ .subscribe((trees) => {
1360
+ this.expandTree(trees);
1361
+ this.nzDepts = trees;
1362
+ this._nzDeptsCopy = trees;
1363
+ this.onTabsetLoadEnd();
1364
+ this.refresh();
1365
+ }));
1366
+ }
1367
+ // 获取角色树
1368
+ onTabsetRoleFlush(groupRoleCode) {
1369
+ this.onTabsetLoadStart();
1370
+ this.subs.push(this.contact.getGroupRole(groupRoleCode).subscribe((roles) => {
1371
+ this.expandTree(roles);
1372
+ this.nzRoles = roles;
1373
+ this._nzRolesCopy = roles;
1374
+ this.onTabsetLoadEnd();
1375
+ this.refresh();
1376
+ }));
1377
+ }
1378
+ // 获取好友分组列表
1379
+ onTabsetFriendGroupFlush() {
1380
+ this.onTabsetLoadStart();
1381
+ this.subs.push(this.contact.getFriendGroup().subscribe((group) => {
1382
+ this.nzFriendGroups = group;
1383
+ this._nzFriendGroupsCopy = group;
1384
+ this.onTabsetLoadEnd();
1385
+ this.refresh();
1386
+ }));
1387
+ }
1388
+ /**
1389
+ * 部门树点击
1390
+ *
1391
+ * @param e 节点
1392
+ */
1393
+ onDeptClick(e) {
1394
+ var _a;
1395
+ // 构造分页请求,直接传入stTable组件,剩下的所有交给组件自己完成
1396
+ this.st.data = '/auth/baseUser/queryListForPage';
1397
+ this.st.req = {
1398
+ allInBody: true,
1399
+ method: 'POST',
1400
+ type: 'page',
1401
+ reName: {
1402
+ pi: 'pageNum',
1403
+ ps: 'pageSize'
1404
+ },
1405
+ body: {
1406
+ pageParam: {
1407
+ deptId: (_a = e.keys) === null || _a === void 0 ? void 0 : _a.pop()
1408
+ }
1409
+ }
1410
+ };
1411
+ // table数据预处理
1412
+ this.st.res = {
1413
+ process: data => {
1414
+ this.onTableCheck(data);
1415
+ return data;
1416
+ }
1417
+ };
1418
+ // 加载第一页
1419
+ this.st.load(1);
1420
+ }
1421
+ /**
1422
+ * 角色树点击
1423
+ *
1424
+ * @param e 节点
1425
+ */
1426
+ onRoleClick(e) {
1427
+ var _a;
1428
+ // 构造分页请求,直接传入stTable组件,剩下的所有交给组件自己完成
1429
+ this.st.data = '/auth/baseUser/queryListForPage';
1430
+ this.st.req = {
1431
+ allInBody: true,
1432
+ method: 'POST',
1433
+ type: 'page',
1434
+ reName: {
1435
+ pi: 'pageNum',
1436
+ ps: 'pageSize'
1437
+ },
1438
+ body: {
1439
+ pageParam: {
1440
+ roleId: (_a = e.keys) === null || _a === void 0 ? void 0 : _a.pop()
1441
+ }
1442
+ }
1443
+ };
1444
+ // table数据预处理
1445
+ this.st.res = {
1446
+ process: data => {
1447
+ this.onTableCheck(data);
1448
+ return data;
1449
+ }
1450
+ };
1451
+ // 加载第一页
1452
+ this.st.load(1);
1453
+ }
1454
+ /**
1455
+ * 好友分组点击
1456
+ *
1457
+ * @param e 分组
1458
+ */
1459
+ onFriendGroupClick(e) {
1460
+ // 构造分页请求,直接传入stTable组件,剩下的所有交给组件自己完成
1461
+ this.st.data = '/auth/baseUser/queryListForPage';
1462
+ this.st.req = {
1463
+ allInBody: true,
1464
+ method: 'POST',
1465
+ type: 'page',
1466
+ reName: {
1467
+ pi: 'pageNum',
1468
+ ps: 'pageSize'
1469
+ },
1470
+ body: {
1471
+ pageParam: {
1472
+ friendGroupId: e.id
1473
+ }
1474
+ }
1475
+ };
1476
+ // table数据预处理
1477
+ this.st.res = {
1478
+ process: data => {
1479
+ this.onTableCheck(data);
1480
+ return data;
1481
+ }
1482
+ };
1483
+ // 加载第一页
1484
+ this.st.load(1);
1485
+ }
1486
+ /**
1487
+ * 点击右侧联系人进行删除
1488
+ *
1489
+ * @param c 点击的联系人
1490
+ */
1491
+ onContactRemove(c) {
1492
+ this.nzContacts = this.nzContacts.filter(contact => {
1493
+ return contact.userId != c.userId;
1494
+ });
1495
+ this.st.reload();
1496
+ }
1497
+ /**
1498
+ * 预处理table当前页数据,和nzContat对比,确定checkbox状态
1499
+ *
1500
+ * @param data 预处理数据
1501
+ */
1502
+ onTableCheck(data) {
1503
+ const ids = this.nzContacts.map(u => u.userId);
1504
+ data.forEach(d => {
1505
+ if (ids.includes(d.userId)) {
1506
+ d.checked = true;
1507
+ }
1508
+ else {
1509
+ d.checked = false;
1510
+ }
1511
+ });
1512
+ }
1513
+ /**
1514
+ * 递归树寻找name相同节点
1515
+ *
1516
+ * @param name 名称
1517
+ * @param trees 需要递归的树
1518
+ * @param list 搜索结果
1519
+ */
1520
+ searchTree(name, trees, list) {
1521
+ if (trees && trees.length && trees.length > 0) {
1522
+ trees.forEach((tree) => {
1523
+ if (tree.title.indexOf(name) != -1) {
1524
+ list.push(tree);
1525
+ }
1526
+ if (tree.children) {
1527
+ this.searchTree(name, tree.children, list);
1528
+ }
1529
+ });
1530
+ }
1531
+ }
1532
+ /**
1533
+ * 递归树展开所有有子节点的节点
1534
+ *
1535
+ * @param trees 需要展开的树
1536
+ */
1537
+ expandTree(trees) {
1538
+ if (trees && trees.length && trees.length > 0) {
1539
+ trees.forEach(tree => {
1540
+ if (!tree.children || tree.children.length === 0) {
1541
+ tree.expanded = false;
1542
+ tree.isLeaf = true;
1543
+ }
1544
+ if (tree.children) {
1545
+ tree.expanded = this.nzExpandAll;
1546
+ tree.isLeaf = false;
1547
+ this.expandTree(tree.children);
1548
+ }
1549
+ });
1550
+ }
1551
+ }
1552
+ /**
1553
+ * 刷新当前页面
1554
+ */
1555
+ refresh() {
1556
+ this.changeDetectorRef.detectChanges();
1557
+ }
1558
+ /**
1559
+ * 确认按钮output数据
1560
+ */
1561
+ confirm() {
1562
+ this.confirmed.next(this.nzContacts);
1563
+ }
1564
+ /**
1565
+ * 销毁函数
1566
+ */
1567
+ ngOnDestroy() {
1568
+ this.nzDepts = [];
1569
+ this.nzRoles = [];
1570
+ this.nzContacts = [];
1571
+ this.subs.forEach(s => s.unsubscribe());
1572
+ }
1573
+ }
1574
+ ContactComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ContactComponent, deps: [{ token: ContactService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
1575
+ ContactComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.1", type: ContactComponent, selector: "contact", inputs: { nzTabsetSearch: "nzTabsetSearch", nzTabsetLoading: "nzTabsetLoading", nzExpandAll: "nzExpandAll", nzDepts: "nzDepts", nzDeptTreeVirtualHeight: "nzDeptTreeVirtualHeight", nzDeptClass: "nzDeptClass", nzDeptClassHistory: "nzDeptClassHistory", nzDeptGrade: "nzDeptGrade", nzDeptGradeID: "nzDeptGradeID", nzRoles: "nzRoles", nzRoleTreeVirtualHeight: "nzRoleTreeVirtualHeight", nzFriendGroups: "nzFriendGroups", defaultContacts: "defaultContacts", nzContacts: "nzContacts", nzContactLoading: "nzContactLoading", button: "button" }, outputs: { confirmed: "confirmed" }, viewQueries: [{ propertyName: "st", first: true, predicate: ["st"], descendants: true }], ngImport: i0, template: "<nz-row [nzGutter]=\"16\">\n <nz-col [nzXs]=\"24\" [nzSm]=\"24\" [nzMd]=\"24\" [nzLg]=\"8\" [nzXl]=\"6\" [nzXXl]=\"6\">\n <nz-tabset nzCentered>\n <nz-tab nzTitle=\"\u90E8\u95E8\" (nzSelect)=\"onTabsetDept()\">\n <div sg-container=\"2\">\n <sg col=\"1\" class=\"nz-tabset-sg\">\n <nz-input-group class=\"nz-tabset-input\" [nzSuffix]=\"searchInputTpl\">\n <input\n nz-input\n [(ngModel)]=\"nzTabsetSearch\"\n (ngModelChange)=\"onTabsetSearchChange('dept', $event)\"\n type=\"text\"\n placeholder=\"\u8BF7\u8F93\u5165\u90E8\u95E8\u540D\u79F0\"\n />\n </nz-input-group>\n </sg>\n <sg col=\"1\">\n <nz-spin [nzSpinning]=\"nzTabsetLoading\">\n <nz-tree\n class=\"nz-tabset-content\"\n (nzClick)=\"onDeptClick($event)\"\n [nzBlockNode]=\"true\"\n [nzShowLine]=\"true\"\n [nzHideUnMatched]=\"true\"\n [nzVirtualHeight]=\"nzDeptTreeVirtualHeight\"\n [nzData]=\"nzDepts\"\n ></nz-tree>\n </nz-spin>\n </sg>\n </div>\n </nz-tab>\n <nz-tab nzTitle=\"\u89D2\u8272\" (nzSelect)=\"onTabsetRole()\">\n <div sg-container=\"2\">\n <sg col=\"1\" class=\"nz-tabset-sg\">\n <nz-input-group class=\"nz-tabset-input\" [nzSuffix]=\"searchInputTpl\">\n <input\n nz-input\n [(ngModel)]=\"nzTabsetSearch\"\n (ngModelChange)=\"onTabsetSearchChange('role', $event)\"\n type=\"text\"\n placeholder=\"\u8BF7\u8F93\u5165\u89D2\u8272\u540D\u79F0\"\n />\n </nz-input-group>\n </sg>\n <sg col=\"1\">\n <nz-spin [nzSpinning]=\"nzTabsetLoading\">\n <nz-tree\n class=\"nz-tabset-content\"\n (nzClick)=\"onRoleClick($event)\"\n [nzBlockNode]=\"true\"\n [nzShowLine]=\"true\"\n [nzHideUnMatched]=\"true\"\n [nzVirtualHeight]=\"nzRoleTreeVirtualHeight\"\n [nzData]=\"nzRoles\"\n ></nz-tree>\n </nz-spin>\n </sg>\n </div>\n </nz-tab>\n <nz-tab nzTitle=\"\u597D\u53CB\" (nzSelect)=\"onTabsetFriendGroup()\">\n <div sg-container=\"2\">\n <sg col=\"1\" class=\"nz-tabset-sg\">\n <nz-input-group class=\"nz-tabset-input\" [nzSuffix]=\"searchInputTpl\">\n <input\n nz-input\n [(ngModel)]=\"nzTabsetSearch\"\n (ngModelChange)=\"onTabsetSearchChange('friendGroup', $event)\"\n type=\"text\"\n placeholder=\"\u8BF7\u8F93\u5165\u597D\u53CB\u540D\u79F0\"\n />\n </nz-input-group>\n </sg>\n <sg col=\"1\">\n <nz-spin [nzSpinning]=\"nzTabsetLoading\">\n <nz-list class=\"nz-tabset-content\" nzItemLayout=\"horizontal\" [nzSplit]=\"false\" nzSize=\"small\">\n <nz-list-item\n class=\"nz-tabset-content-item\"\n *ngFor=\"let group of nzFriendGroups\"\n (click)=\"onFriendGroupClick(group)\"\n >\n <nz-list-item-meta>\n <nz-list-item-meta-title>\n {{ group.name }}\n </nz-list-item-meta-title>\n </nz-list-item-meta>\n </nz-list-item>\n </nz-list>\n </nz-spin>\n </sg>\n </div>\n </nz-tab>\n </nz-tabset>\n </nz-col>\n\n <nz-col [nzXs]=\"24\" [nzSm]=\"24\" [nzMd]=\"24\" [nzLg]=\"16\" [nzXl]=\"13\" [nzXXl]=\"13\">\n <st #st responsiveHideHeaderFooter></st>\n </nz-col>\n\n <nz-col [nzXs]=\"24\" [nzSm]=\"24\" [nzMd]=\"24\" [nzLg]=\"24\" [nzXl]=\"5\" [nzXXl]=\"5\">\n <nz-spin [nzSpinning]=\"nzContactLoading\">\n <nz-list nzItemLayout=\"horizontal\" [nzSplit]=\"false\" nzSize=\"small\">\n <nz-list-item\n class=\"nz-tabset-content-item\"\n *ngFor=\"let contact of nzContacts\"\n (click)=\"onContactRemove(contact)\"\n >\n <nz-list-item-meta>\n <nz-list-item-meta-title>\n {{ contact.realName }}\n </nz-list-item-meta-title>\n </nz-list-item-meta>\n </nz-list-item>\n </nz-list>\n </nz-spin>\n </nz-col>\n</nz-row>\n\n<nz-row *ngIf=\"button\">\n <nz-col [nzSpan]=\"4\" [nzOffset]=\"20\">\n <button nz-button nzType=\"primary\" (click)=\"confirm()\">\u786E\u5B9A</button>\n </nz-col>\n</nz-row>\n\n<ng-template #searchInputTpl>\n <i nz-icon nzType=\"close\" nzTheme=\"outline\" *ngIf=\"nzTabsetSearch\" (click)=\"onTabsetSearchClean()\"></i>\n <i nz-icon nzType=\"search\" nzTheme=\"outline\" *ngIf=\"!nzTabsetSearch\"></i>\n</ng-template>\n", styles: [".nz-tabset-input{width:100%}.nz-tabset-content{padding:20px}.nz-tabset-sg{padding-right:38px!important;padding-left:38px!important}.nz-tabset-content-item:hover{background-color:#f1f1f1;cursor:pointer}\n"], components: [{ type: i2$3.NzTabSetComponent, selector: "nz-tabset", inputs: ["nzSelectedIndex", "nzTabPosition", "nzTabBarExtraContent", "nzCanDeactivate", "nzAddIcon", "nzTabBarStyle", "nzType", "nzSize", "nzAnimated", "nzTabBarGutter", "nzHideAdd", "nzCentered", "nzHideAll", "nzLinkRouter", "nzLinkExact"], outputs: ["nzSelectChange", "nzSelectedIndexChange", "nzTabListScroll", "nzClose", "nzAdd"], exportAs: ["nzTabset"] }, { type: i2$3.NzTabComponent, selector: "nz-tab", inputs: ["nzTitle", "nzClosable", "nzCloseIcon", "nzDisabled", "nzForceRender"], outputs: ["nzSelect", "nzDeselect", "nzClick", "nzContextmenu"], exportAs: ["nzTab"] }, { type: i3$2.SGContainerComponent, selector: "sg-container, [sg-container]", inputs: ["gutter", "sg-container", "col"], exportAs: ["sgContainer"] }, { type: i3$2.SGComponent, selector: "sg", inputs: ["col"], exportAs: ["sg"] }, { type: i4$1.NzInputGroupComponent, selector: "nz-input-group", inputs: ["nzAddOnBeforeIcon", "nzAddOnAfterIcon", "nzPrefixIcon", "nzSuffixIcon", "nzAddOnBefore", "nzAddOnAfter", "nzPrefix", "nzSuffix", "nzSize", "nzSearch", "nzCompact"], exportAs: ["nzInputGroup"] }, { type: i5$2.NzSpinComponent, selector: "nz-spin", inputs: ["nzIndicator", "nzSize", "nzTip", "nzDelay", "nzSimple", "nzSpinning"], exportAs: ["nzSpin"] }, { type: i6$1.NzTreeComponent, selector: "nz-tree", inputs: ["nzShowIcon", "nzHideUnMatched", "nzBlockNode", "nzExpandAll", "nzSelectMode", "nzCheckStrictly", "nzShowExpand", "nzShowLine", "nzCheckable", "nzAsyncData", "nzDraggable", "nzMultiple", "nzExpandedIcon", "nzVirtualItemSize", "nzVirtualMaxBufferPx", "nzVirtualMinBufferPx", "nzVirtualHeight", "nzTreeTemplate", "nzBeforeDrop", "nzData", "nzExpandedKeys", "nzSelectedKeys", "nzCheckedKeys", "nzSearchValue", "nzSearchFunc"], outputs: ["nzExpandedKeysChange", "nzSelectedKeysChange", "nzCheckedKeysChange", "nzSearchValueChange", "nzClick", "nzDblClick", "nzContextMenu", "nzCheckBoxChange", "nzExpandChange", "nzOnDragStart", "nzOnDragEnter", "nzOnDragOver", "nzOnDragLeave", "nzOnDrop", "nzOnDragEnd"], exportAs: ["nzTree"] }, { type: i7$1.NzListComponent, selector: "nz-list, [nz-list]", inputs: ["nzDataSource", "nzBordered", "nzGrid", "nzHeader", "nzFooter", "nzItemLayout", "nzRenderItem", "nzLoading", "nzLoadMore", "nzPagination", "nzSize", "nzSplit", "nzNoResult"], exportAs: ["nzList"] }, { type: i7$1.NzListItemComponent, selector: "nz-list-item, [nz-list-item]", inputs: ["nzActions", "nzContent", "nzExtra", "nzNoFlex"], exportAs: ["nzListItem"] }, { type: i7$1.NzListItemMetaComponent, selector: "nz-list-item-meta, [nz-list-item-meta]", inputs: ["nzAvatar", "nzTitle", "nzDescription"], exportAs: ["nzListItemMeta"] }, { type: i7$1.NzListItemMetaTitleComponent, selector: "nz-list-item-meta-title", exportAs: ["nzListItemMetaTitle"] }, { type: i8$1.STComponent, selector: "st", inputs: ["req", "res", "page", "data", "columns", "contextmenu", "ps", "pi", "total", "loading", "loadingDelay", "loadingIndicator", "bordered", "size", "scroll", "singleSort", "multiSort", "rowClassName", "clickRowClassName", "widthMode", "widthConfig", "resizable", "header", "showHeader", "footer", "bodyHeader", "body", "expandRowByClick", "expandAccordion", "expand", "noResult", "responsive", "responsiveHideHeaderFooter", "virtualScroll", "virtualItemSize", "virtualMaxBufferPx", "virtualMinBufferPx", "customRequest", "virtualForTrackBy"], outputs: ["error", "change"], exportAs: ["st"] }, { type: i9$2.NzButtonComponent, selector: "button[nz-button], a[nz-button]", inputs: ["nzBlock", "nzGhost", "nzSearch", "nzLoading", "nzDanger", "disabled", "tabIndex", "nzType", "nzShape", "nzSize"], exportAs: ["nzButton"] }], directives: [{ type: i5.NzRowDirective, selector: "[nz-row],nz-row,nz-form-item", inputs: ["nzAlign", "nzJustify", "nzGutter"], exportAs: ["nzRow"] }, { type: i5.NzColDirective, selector: "[nz-col],nz-col,nz-form-control,nz-form-label", inputs: ["nzFlex", "nzSpan", "nzOrder", "nzOffset", "nzPush", "nzPull", "nzXs", "nzSm", "nzMd", "nzLg", "nzXl", "nzXXl"], exportAs: ["nzCol"] }, { type: i8.ɵNzTransitionPatchDirective, selector: "[nz-button], nz-button-group, [nz-icon], [nz-menu-item], [nz-submenu], nz-select-top-control, nz-select-placeholder, nz-input-group", inputs: ["hidden"] }, { type: i4$1.NzInputGroupWhitSuffixOrPrefixDirective, selector: "nz-input-group[nzSuffix], nz-input-group[nzPrefix]" }, { type: i4$1.NzInputDirective, selector: "input[nz-input],textarea[nz-input]", inputs: ["nzBorderless", "nzSize", "disabled"], exportAs: ["nzInput"] }, { type: i7.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i7.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i7.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i9$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i9$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i14.NzWaveDirective, selector: "[nz-wave],button[nz-button]:not([nzType=\"link\"]):not([nzType=\"text\"])", inputs: ["nzWaveExtraNode"], exportAs: ["nzWave"] }, { type: i9.NzIconDirective, selector: "[nz-icon]", inputs: ["nzSpin", "nzRotate", "nzType", "nzTheme", "nzTwotoneColor", "nzIconfont"], exportAs: ["nzIcon"] }] });
1576
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ContactComponent, decorators: [{
1577
+ type: Component,
1578
+ args: [{ selector: 'contact', template: "<nz-row [nzGutter]=\"16\">\n <nz-col [nzXs]=\"24\" [nzSm]=\"24\" [nzMd]=\"24\" [nzLg]=\"8\" [nzXl]=\"6\" [nzXXl]=\"6\">\n <nz-tabset nzCentered>\n <nz-tab nzTitle=\"\u90E8\u95E8\" (nzSelect)=\"onTabsetDept()\">\n <div sg-container=\"2\">\n <sg col=\"1\" class=\"nz-tabset-sg\">\n <nz-input-group class=\"nz-tabset-input\" [nzSuffix]=\"searchInputTpl\">\n <input\n nz-input\n [(ngModel)]=\"nzTabsetSearch\"\n (ngModelChange)=\"onTabsetSearchChange('dept', $event)\"\n type=\"text\"\n placeholder=\"\u8BF7\u8F93\u5165\u90E8\u95E8\u540D\u79F0\"\n />\n </nz-input-group>\n </sg>\n <sg col=\"1\">\n <nz-spin [nzSpinning]=\"nzTabsetLoading\">\n <nz-tree\n class=\"nz-tabset-content\"\n (nzClick)=\"onDeptClick($event)\"\n [nzBlockNode]=\"true\"\n [nzShowLine]=\"true\"\n [nzHideUnMatched]=\"true\"\n [nzVirtualHeight]=\"nzDeptTreeVirtualHeight\"\n [nzData]=\"nzDepts\"\n ></nz-tree>\n </nz-spin>\n </sg>\n </div>\n </nz-tab>\n <nz-tab nzTitle=\"\u89D2\u8272\" (nzSelect)=\"onTabsetRole()\">\n <div sg-container=\"2\">\n <sg col=\"1\" class=\"nz-tabset-sg\">\n <nz-input-group class=\"nz-tabset-input\" [nzSuffix]=\"searchInputTpl\">\n <input\n nz-input\n [(ngModel)]=\"nzTabsetSearch\"\n (ngModelChange)=\"onTabsetSearchChange('role', $event)\"\n type=\"text\"\n placeholder=\"\u8BF7\u8F93\u5165\u89D2\u8272\u540D\u79F0\"\n />\n </nz-input-group>\n </sg>\n <sg col=\"1\">\n <nz-spin [nzSpinning]=\"nzTabsetLoading\">\n <nz-tree\n class=\"nz-tabset-content\"\n (nzClick)=\"onRoleClick($event)\"\n [nzBlockNode]=\"true\"\n [nzShowLine]=\"true\"\n [nzHideUnMatched]=\"true\"\n [nzVirtualHeight]=\"nzRoleTreeVirtualHeight\"\n [nzData]=\"nzRoles\"\n ></nz-tree>\n </nz-spin>\n </sg>\n </div>\n </nz-tab>\n <nz-tab nzTitle=\"\u597D\u53CB\" (nzSelect)=\"onTabsetFriendGroup()\">\n <div sg-container=\"2\">\n <sg col=\"1\" class=\"nz-tabset-sg\">\n <nz-input-group class=\"nz-tabset-input\" [nzSuffix]=\"searchInputTpl\">\n <input\n nz-input\n [(ngModel)]=\"nzTabsetSearch\"\n (ngModelChange)=\"onTabsetSearchChange('friendGroup', $event)\"\n type=\"text\"\n placeholder=\"\u8BF7\u8F93\u5165\u597D\u53CB\u540D\u79F0\"\n />\n </nz-input-group>\n </sg>\n <sg col=\"1\">\n <nz-spin [nzSpinning]=\"nzTabsetLoading\">\n <nz-list class=\"nz-tabset-content\" nzItemLayout=\"horizontal\" [nzSplit]=\"false\" nzSize=\"small\">\n <nz-list-item\n class=\"nz-tabset-content-item\"\n *ngFor=\"let group of nzFriendGroups\"\n (click)=\"onFriendGroupClick(group)\"\n >\n <nz-list-item-meta>\n <nz-list-item-meta-title>\n {{ group.name }}\n </nz-list-item-meta-title>\n </nz-list-item-meta>\n </nz-list-item>\n </nz-list>\n </nz-spin>\n </sg>\n </div>\n </nz-tab>\n </nz-tabset>\n </nz-col>\n\n <nz-col [nzXs]=\"24\" [nzSm]=\"24\" [nzMd]=\"24\" [nzLg]=\"16\" [nzXl]=\"13\" [nzXXl]=\"13\">\n <st #st responsiveHideHeaderFooter></st>\n </nz-col>\n\n <nz-col [nzXs]=\"24\" [nzSm]=\"24\" [nzMd]=\"24\" [nzLg]=\"24\" [nzXl]=\"5\" [nzXXl]=\"5\">\n <nz-spin [nzSpinning]=\"nzContactLoading\">\n <nz-list nzItemLayout=\"horizontal\" [nzSplit]=\"false\" nzSize=\"small\">\n <nz-list-item\n class=\"nz-tabset-content-item\"\n *ngFor=\"let contact of nzContacts\"\n (click)=\"onContactRemove(contact)\"\n >\n <nz-list-item-meta>\n <nz-list-item-meta-title>\n {{ contact.realName }}\n </nz-list-item-meta-title>\n </nz-list-item-meta>\n </nz-list-item>\n </nz-list>\n </nz-spin>\n </nz-col>\n</nz-row>\n\n<nz-row *ngIf=\"button\">\n <nz-col [nzSpan]=\"4\" [nzOffset]=\"20\">\n <button nz-button nzType=\"primary\" (click)=\"confirm()\">\u786E\u5B9A</button>\n </nz-col>\n</nz-row>\n\n<ng-template #searchInputTpl>\n <i nz-icon nzType=\"close\" nzTheme=\"outline\" *ngIf=\"nzTabsetSearch\" (click)=\"onTabsetSearchClean()\"></i>\n <i nz-icon nzType=\"search\" nzTheme=\"outline\" *ngIf=\"!nzTabsetSearch\"></i>\n</ng-template>\n", styles: [".nz-tabset-input{width:100%}.nz-tabset-content{padding:20px}.nz-tabset-sg{padding-right:38px!important;padding-left:38px!important}.nz-tabset-content-item:hover{background-color:#f1f1f1;cursor:pointer}\n"] }]
1579
+ }], ctorParameters: function () { return [{ type: ContactService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { nzTabsetSearch: [{
1580
+ type: Optional
1581
+ }, {
1582
+ type: Input
1583
+ }], nzTabsetLoading: [{
1584
+ type: Optional
1585
+ }, {
1586
+ type: Input
1587
+ }], nzExpandAll: [{
1588
+ type: Optional
1589
+ }, {
1590
+ type: Input
1591
+ }], nzDepts: [{
1592
+ type: Optional
1593
+ }, {
1594
+ type: Input
1595
+ }], nzDeptTreeVirtualHeight: [{
1596
+ type: Optional
1597
+ }, {
1598
+ type: Input
1599
+ }], nzDeptClass: [{
1600
+ type: Optional
1601
+ }, {
1602
+ type: Input
1603
+ }], nzDeptClassHistory: [{
1604
+ type: Optional
1605
+ }, {
1606
+ type: Input
1607
+ }], nzDeptGrade: [{
1608
+ type: Optional
1609
+ }, {
1610
+ type: Input
1611
+ }], nzDeptGradeID: [{
1612
+ type: Optional
1613
+ }, {
1614
+ type: Input
1615
+ }], nzRoles: [{
1616
+ type: Optional
1617
+ }, {
1618
+ type: Input
1619
+ }], nzRoleTreeVirtualHeight: [{
1620
+ type: Optional
1621
+ }, {
1622
+ type: Input
1623
+ }], nzFriendGroups: [{
1624
+ type: Optional
1625
+ }, {
1626
+ type: Input
1627
+ }], st: [{
1628
+ type: ViewChild,
1629
+ args: ['st', { static: false }]
1630
+ }], defaultContacts: [{
1631
+ type: Optional
1632
+ }, {
1633
+ type: Input
1634
+ }], nzContacts: [{
1635
+ type: Optional
1636
+ }, {
1637
+ type: Input
1638
+ }], nzContactLoading: [{
1639
+ type: Optional
1640
+ }, {
1641
+ type: Input
1642
+ }], button: [{
1643
+ type: Optional
1644
+ }, {
1645
+ type: Input
1646
+ }], confirmed: [{
1647
+ type: Output
1648
+ }] } });
1409
1649
 
1410
- const ɵ0 = msg => {
1411
- log$1(msg);
1412
- };
1413
- const STOMP_DEFAULT_CONFIG = {
1414
- connectHeaders: {
1415
- login: 'guest',
1416
- passcode: 'guest'
1417
- },
1418
- brokerURL: '/websocket/ws/',
1419
- heartbeatIncoming: 1000 * 60,
1420
- heartbeatOutgoing: 1000 * 60,
1421
- reconnectDelay: 30000000,
1422
- debug: ɵ0
1423
- };
1424
- function mergeStompConfig(srv) {
1425
- return srv.merge('stomp', STOMP_DEFAULT_CONFIG);
1650
+ const STOMP_DEFAULT_CONFIG = {
1651
+ connectHeaders: {
1652
+ login: 'guest',
1653
+ passcode: 'guest'
1654
+ },
1655
+ brokerURL: '/websocket/ws/',
1656
+ heartbeatIncoming: 1000 * 60,
1657
+ heartbeatOutgoing: 1000 * 60,
1658
+ reconnectDelay: 30000000,
1659
+ debug: msg => {
1660
+ log$1(msg);
1661
+ }
1662
+ };
1663
+ function mergeStompConfig(srv) {
1664
+ return srv.merge('stomp', STOMP_DEFAULT_CONFIG);
1426
1665
  }
1427
1666
 
1428
- class YzStompService {
1429
- constructor(csr, cache, injector, notification) {
1430
- this.csr = csr;
1431
- this.cache = cache;
1432
- this.injector = injector;
1433
- this.notification = notification;
1434
- this.subs = [];
1435
- if (!this.user) {
1436
- this.user = this.cache.get('_yz_user', { mode: 'none' });
1437
- }
1438
- if (!this.config) {
1439
- this.config = mergeStompConfig(this.csr);
1440
- }
1441
- if (!this.bisConfig) {
1442
- this.bisConfig = mergeBisConfig(csr);
1443
- }
1444
- if (!this.rxStomp) {
1445
- this.rxStomp = new RxStomp();
1446
- if (isDevMode()) {
1447
- log$1('yz.stomp.service: is dev mode');
1448
- log$1('yz.stomp.service: ', `config is ${JSON.stringify(this.config)}`);
1449
- this.rxStomp.configure(this.config);
1450
- return;
1451
- }
1452
- const { location } = this.injector.get(DOCUMENT);
1453
- const { protocol, host } = location;
1454
- log$1('yz.stomp.service: ', `protocol is ${protocol},host is ${host}`);
1455
- if (protocol.includes('http') && !protocol.includes('https')) {
1456
- this.config.brokerURL = `ws://${host}${this.config.brokerURL}`;
1457
- }
1458
- if (protocol.includes('https')) {
1459
- this.config.brokerURL = `wss://${host}${this.config.brokerURL}`;
1460
- }
1461
- log$1('yz.stomp.service: ', `config is ${this.config}`);
1462
- this.rxStomp.configure(this.config);
1463
- }
1464
- }
1465
- listen() {
1466
- this.subs.push(this.rxStomp.watch(`/topic/layout_${this.user.username}`).subscribe(message => {
1467
- this.createNotification(JSON.parse(message.body));
1468
- }));
1469
- this.subs.push(this.rxStomp.watch(`/topic/layout_xx_${this.user.username}`).subscribe((message) => {
1470
- this.logoutNotification(JSON.parse(message.body));
1471
- }));
1472
- this.rxStomp.activate();
1473
- }
1474
- createNotification(message) {
1475
- this.notification.create(message.type, message.title, `<a href=${message.href}>${message.content}</a>`);
1476
- }
1477
- logoutNotification(message) {
1478
- this.notification.create(message.type, message.title, `${message.content},剩余时间5秒`);
1479
- setTimeout(() => {
1480
- this.cache.clear();
1481
- localStorage.clear();
1482
- this.injector.get(WINDOW).location.href = `${this.bisConfig.baseUrl}/cas-proxy/app/logout`;
1483
- }, 5000);
1484
- }
1485
- unListen() {
1486
- this.subs.forEach(s => s.unsubscribe());
1487
- this.rxStomp.deactivate().then();
1488
- }
1489
- publish(parameters) {
1490
- this.rxStomp.publish(parameters);
1491
- }
1492
- watch(destination, headers) {
1493
- return this.rxStomp.watch(destination, headers);
1494
- }
1495
- }
1496
- YzStompService.ɵprov = i0.ɵɵdefineInjectable({ factory: function YzStompService_Factory() { return new YzStompService(i0.ɵɵinject(i1$1.YunzaiConfigService), i0.ɵɵinject(i2$1.CacheService), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(i3$1.NzNotificationService)); }, token: YzStompService, providedIn: "root" });
1497
- YzStompService.decorators = [
1498
- { type: Injectable, args: [{ providedIn: 'root' },] }
1499
- ];
1500
- YzStompService.ctorParameters = () => [
1501
- { type: YunzaiConfigService$1 },
1502
- { type: CacheService },
1503
- { type: Injector },
1504
- { type: NzNotificationService }
1505
- ];
1667
+ class YzStompService {
1668
+ constructor(csr, cache, injector, notification) {
1669
+ this.csr = csr;
1670
+ this.cache = cache;
1671
+ this.injector = injector;
1672
+ this.notification = notification;
1673
+ this.config = null;
1674
+ this.bisConfig = null;
1675
+ this.rxStomp = null;
1676
+ this.subs = [];
1677
+ if (!this.user) {
1678
+ this.user = this.cache.get('_yz_user', { mode: 'none' });
1679
+ }
1680
+ if (!this.config) {
1681
+ this.config = mergeStompConfig(this.csr);
1682
+ }
1683
+ if (!this.bisConfig) {
1684
+ this.bisConfig = mergeBisConfig(csr);
1685
+ }
1686
+ if (!this.rxStomp) {
1687
+ this.rxStomp = new RxStomp();
1688
+ if (isDevMode()) {
1689
+ log$1('yz.stomp.service: is dev mode');
1690
+ log$1('yz.stomp.service: ', `config is ${JSON.stringify(this.config)}`);
1691
+ this.rxStomp.configure(this.config);
1692
+ return;
1693
+ }
1694
+ const { location } = this.injector.get(DOCUMENT);
1695
+ const { protocol, host } = location;
1696
+ log$1('yz.stomp.service: ', `protocol is ${protocol},host is ${host}`);
1697
+ if (protocol.includes('http') && !protocol.includes('https')) {
1698
+ this.config.brokerURL = `ws://${host}${this.config.brokerURL}`;
1699
+ }
1700
+ if (protocol.includes('https')) {
1701
+ this.config.brokerURL = `wss://${host}${this.config.brokerURL}`;
1702
+ }
1703
+ log$1('yz.stomp.service: ', `config is ${this.config}`);
1704
+ this.rxStomp.configure(this.config);
1705
+ }
1706
+ }
1707
+ listen() {
1708
+ this.subs.push(this.rxStomp.watch(`/topic/layout_${this.user.username}`).subscribe(message => {
1709
+ this.createNotification(JSON.parse(message.body));
1710
+ }));
1711
+ this.subs.push(this.rxStomp.watch(`/topic/layout_xx_${this.user.username}`).subscribe((message) => {
1712
+ this.logoutNotification(JSON.parse(message.body));
1713
+ }));
1714
+ this.rxStomp.activate();
1715
+ }
1716
+ createNotification(message) {
1717
+ this.notification.create(message.type, message.title, `<a href=${message.href}>${message.content}</a>`);
1718
+ }
1719
+ logoutNotification(message) {
1720
+ this.notification.create(message.type, message.title, `${message.content},剩余时间5秒`);
1721
+ setTimeout(() => {
1722
+ this.cache.clear();
1723
+ localStorage.clear();
1724
+ this.injector.get(WINDOW).location.href = `${this.bisConfig.baseUrl}/cas-proxy/app/logout`;
1725
+ }, 5000);
1726
+ }
1727
+ unListen() {
1728
+ this.subs.forEach(s => s.unsubscribe());
1729
+ this.rxStomp.deactivate().then();
1730
+ }
1731
+ publish(parameters) {
1732
+ this.rxStomp.publish(parameters);
1733
+ }
1734
+ watch(destination, headers) {
1735
+ return this.rxStomp.watch(destination, headers);
1736
+ }
1737
+ }
1738
+ YzStompService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YzStompService, deps: [{ token: i1$2.YunzaiConfigService }, { token: i2$1.CacheService }, { token: i0.Injector }, { token: i3$3.NzNotificationService }], target: i0.ɵɵFactoryTarget.Injectable });
1739
+ YzStompService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YzStompService, providedIn: 'root' });
1740
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YzStompService, decorators: [{
1741
+ type: Injectable,
1742
+ args: [{ providedIn: 'root' }]
1743
+ }], ctorParameters: function () { return [{ type: i1$2.YunzaiConfigService }, { type: i2$1.CacheService }, { type: i0.Injector }, { type: i3$3.NzNotificationService }]; } });
1506
1744
 
1507
- class YzLayoutBasicComponent {
1508
- constructor(cacheService, yzStompService) {
1509
- this.cacheService = cacheService;
1510
- this.yzStompService = yzStompService;
1511
- this.options = {
1512
- logoExpanded: `./assets/logo-full.svg`,
1513
- logoCollapsed: `./assets/logo.svg`
1514
- };
1515
- this.intro = '';
1516
- this.text = '';
1517
- this.icon = '';
1518
- }
1519
- ngOnInit() {
1520
- const current = this.cacheService.get('_yz_current', { mode: 'none' });
1521
- const project = this.cacheService.get('_yz_project_info', { mode: 'none' });
1522
- this.text = current.text ? current.text : '应用名称';
1523
- this.intro = current.intro ? current.intro : '应用描述';
1524
- this.icon = current.icon ? current.icon : `./assets/tmp/img/avatar.jpg`;
1525
- this.options.logoExpanded = project.maxLogoUrl ? project.maxLogoUrl : `./assets/logo-full.svg`;
1526
- this.options.logoCollapsed = project.miniLogoUrl ? project.miniLogoUrl : `./assets/logo.svg`;
1527
- this.yzStompService.listen();
1528
- }
1529
- ngOnDestroy() {
1530
- this.yzStompService.unListen();
1531
- }
1532
- }
1533
- YzLayoutBasicComponent.decorators = [
1534
- { type: Component, args: [{
1535
- selector: 'yz-layout-basic',
1536
- template: `
1537
- <layout-default [options]="options" [asideUser]="asideUserTpl" [content]="contentTpl">
1745
+ class YzLayoutBasicComponent {
1746
+ constructor(cacheService, yzStompService, layoutService) {
1747
+ this.cacheService = cacheService;
1748
+ this.yzStompService = yzStompService;
1749
+ this.layoutService = layoutService;
1750
+ this.options = {
1751
+ logoExpanded: `./assets/logo-full.svg`,
1752
+ logoCollapsed: `./assets/logo.svg`
1753
+ };
1754
+ this.intro = '';
1755
+ this.text = '';
1756
+ this.icon = '';
1757
+ this.showReuseTab = true;
1758
+ this.showHeader = true;
1759
+ this.showSider = true;
1760
+ }
1761
+ get reuseStyleSheet() {
1762
+ let cascadingStyleSheet = {};
1763
+ if (!this.showHeader) {
1764
+ cascadingStyleSheet = Object.assign(Object.assign({}, cascadingStyleSheet), { top: 0 });
1765
+ }
1766
+ if (!this.showSider) {
1767
+ cascadingStyleSheet = Object.assign(Object.assign({}, cascadingStyleSheet), { left: '24px' });
1768
+ }
1769
+ return cascadingStyleSheet;
1770
+ }
1771
+ ngOnInit() {
1772
+ const current = this.cacheService.get('_yz_current', { mode: 'none' });
1773
+ const project = this.cacheService.get('_yz_project_info', { mode: 'none' });
1774
+ this.text = current.text ? current.text : '应用名称';
1775
+ this.intro = current.intro ? current.intro : '应用描述';
1776
+ this.icon = current.icon ? current.icon : `./assets/tmp/img/avatar.jpg`;
1777
+ this.options.logoExpanded = project.maxLogoUrl ? project.maxLogoUrl : `./assets/logo-full.svg`;
1778
+ this.options.logoCollapsed = project.miniLogoUrl ? project.miniLogoUrl : `./assets/logo.svg`;
1779
+ this.yzStompService.listen();
1780
+ this.layoutService.reuseTab.asObservable().subscribe(show => (this.showReuseTab = show));
1781
+ this.layoutService.header.asObservable().subscribe(show => (this.showHeader = show));
1782
+ this.layoutService.sidebar.asObservable().subscribe(show => (this.showSider = show));
1783
+ }
1784
+ ngOnDestroy() {
1785
+ this.yzStompService.unListen();
1786
+ }
1787
+ }
1788
+ YzLayoutBasicComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YzLayoutBasicComponent, deps: [{ token: i2$1.CacheService }, { token: YzStompService }, { token: i3$4.LayoutService }], target: i0.ɵɵFactoryTarget.Component });
1789
+ YzLayoutBasicComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.1", type: YzLayoutBasicComponent, selector: "yz-layout-basic", ngImport: i0, template: `
1790
+ <layout-default [options]="options" [asideUser]="asideUserTpl" [content]="showReuseTab ? contentTpl : noneTpl">
1538
1791
  <layout-default-header-item direction="left">
1539
1792
  <yz-header-application></yz-header-application>
1540
1793
  </layout-default-header-item>
@@ -1589,866 +1842,946 @@ YzLayoutBasicComponent.decorators = [
1589
1842
  </nz-dropdown-menu>
1590
1843
  </ng-template>
1591
1844
  <ng-template #contentTpl>
1592
- <reuse-tab #reuseTab></reuse-tab>
1845
+ <reuse-tab #reuseTab [ngStyle]="reuseStyleSheet"></reuse-tab>
1593
1846
  <router-outlet (activate)="reuseTab.activate($event)"></router-outlet>
1594
1847
  </ng-template>
1848
+ <ng-template #noneTpl>
1849
+ <router-outlet></router-outlet>
1850
+ </ng-template>
1595
1851
  </layout-default>
1596
- `,
1597
- changeDetection: ChangeDetectionStrategy.OnPush
1598
- },] }
1599
- ];
1600
- YzLayoutBasicComponent.ctorParameters = () => [
1601
- { type: CacheService },
1602
- { type: YzStompService }
1603
- ];
1852
+ `, isInline: true, components: [{ type: i3$4.LayoutDefaultComponent, selector: "layout-default", inputs: ["options", "asideUser", "nav", "content", "customError"], exportAs: ["layoutDefault"] }, { type: i3$4.LayoutDefaultHeaderItemComponent, selector: "layout-default-header-item", inputs: ["hidden", "direction"] }, { type: YzHeaderApplicationComponent, selector: "yz-header-application" }, { type: YzHeaderNotifyComponent, selector: "yz-header-notify" }, { type: YzHeaderThemBtnComponent, selector: "yz-header-theme-btn", inputs: ["types", "devTips", "deployUrl"] }, { type: i2$2.NzDropdownMenuComponent, selector: "nz-dropdown-menu", exportAs: ["nzDropdownMenu"] }, { type: YzHeaderFullScreenComponent, selector: "yz-header-fullscreen" }, { type: YzHeaderClearStorageComponent, selector: "yz-header-clear-storage" }, { type: YzHeaderI18NComponent, selector: "yz-header-i18n", inputs: ["showLangText"] }, { type: YzHeaderUserComponent, selector: "yz-header-user" }, { type: i4$3.NzAvatarComponent, selector: "nz-avatar", inputs: ["nzShape", "nzSize", "nzGap", "nzText", "nzSrc", "nzSrcSet", "nzAlt", "nzIcon"], outputs: ["nzError"], exportAs: ["nzAvatar"] }, { type: i13.ReuseTabComponent, selector: "reuse-tab, [reuse-tab]", inputs: ["mode", "i18n", "debug", "max", "tabMaxWidth", "excludes", "allowClose", "keepingScroll", "keepingScrollContainer", "customContextMenu", "tabBarExtraContent", "tabBarGutter", "tabBarStyle", "tabType", "routeParamMatchMode", "disabled", "titleRender"], outputs: ["change", "close"], exportAs: ["reuseTab"] }], directives: [{ type: i3$4.LayoutDefaultHeaderItemTriggerDirective, selector: "[layout-default-header-item-trigger]" }, { type: i2$2.NzDropDownDirective, selector: "[nz-dropdown]", inputs: ["nzDropdownMenu", "nzTrigger", "nzMatchWidthElement", "nzBackdrop", "nzClickHide", "nzDisabled", "nzVisible", "nzOverlayClassName", "nzOverlayStyle", "nzPlacement"], outputs: ["nzVisibleChange"], exportAs: ["nzDropdown"] }, { type: i8.ɵNzTransitionPatchDirective, selector: "[nz-button], nz-button-group, [nz-icon], [nz-menu-item], [nz-submenu], nz-select-top-control, nz-select-placeholder, nz-input-group", inputs: ["hidden"] }, { type: i9.NzIconDirective, selector: "[nz-icon]", inputs: ["nzSpin", "nzRotate", "nzType", "nzTheme", "nzTwotoneColor", "nzIconfont"], exportAs: ["nzIcon"] }, { type: i6.NzMenuDirective, selector: "[nz-menu]", inputs: ["nzInlineIndent", "nzTheme", "nzMode", "nzInlineCollapsed", "nzSelectable"], outputs: ["nzClick"], exportAs: ["nzMenu"] }, { type: i6.NzMenuItemDirective, selector: "[nz-menu-item]", inputs: ["nzPaddingLeft", "nzDisabled", "nzSelected", "nzDanger", "nzMatchRouterExact", "nzMatchRouter"], exportAs: ["nzMenuItem"] }, { type: i17.RouterLink, selector: ":not(a):not(area)[routerLink]", inputs: ["queryParams", "fragment", "queryParamsHandling", "preserveFragment", "skipLocationChange", "replaceUrl", "state", "relativeTo", "routerLink"] }, { type: i9$1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i17.RouterOutlet, selector: "router-outlet", outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }], pipes: { "i18n": i1.I18nPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
1853
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YzLayoutBasicComponent, decorators: [{
1854
+ type: Component,
1855
+ args: [{
1856
+ selector: 'yz-layout-basic',
1857
+ template: `
1858
+ <layout-default [options]="options" [asideUser]="asideUserTpl" [content]="showReuseTab ? contentTpl : noneTpl">
1859
+ <layout-default-header-item direction="left">
1860
+ <yz-header-application></yz-header-application>
1861
+ </layout-default-header-item>
1604
1862
 
1605
- /*
1606
- * @Author: cui <devcui@outlook.com>
1607
- * @Editor: microsoft vscode
1608
- * @Date: 2021-11-27 11:30:50
1609
- * @LastEditTime: 2021-11-27 14:38:46
1610
- * @LastEditors: cui <devcui@outlook.com>
1611
- * @Description: empty description
1612
- * @FilePath: \yelon\packages\bis\layout\layout.module.ts
1613
- * LICENSE HERE
1614
- */
1615
- const COMPONENTS = [
1616
- ContactComponent,
1617
- YzLayoutBasicComponent,
1618
- YzHeaderApplicationComponent,
1619
- YzHeaderNotifyComponent,
1620
- YzHeaderThemBtnComponent,
1621
- YzHeaderUserComponent,
1622
- YzHeaderFullScreenComponent,
1623
- YzHeaderClearStorageComponent,
1624
- YzHeaderI18NComponent
1625
- ];
1626
- class YunzaiLayoutModule {
1627
- }
1628
- YunzaiLayoutModule.decorators = [
1629
- { type: NgModule, args: [{
1630
- imports: [HttpClientModule, CommonModule, FormsModule, RouterModule, ReactiveFormsModule, YzSharedModule],
1631
- providers: [
1632
- {
1633
- provide: YUNZAI_THEME_BTN_KEYS,
1634
- useValue: 'site-theme'
1635
- }
1636
- ],
1637
- declarations: [...COMPONENTS],
1638
- exports: [...COMPONENTS]
1639
- },] }
1640
- ];
1863
+ <layout-default-header-item direction="right" hidden="mobile">
1864
+ <yz-header-notify></yz-header-notify>
1865
+ </layout-default-header-item>
1641
1866
 
1642
- class YzAuthService {
1643
- constructor(injector) {
1644
- this.injector = injector;
1645
- this.option = mergeConfig(this.csr);
1646
- this.bis = mergeBisConfig(this.csr);
1647
- }
1648
- get csr() {
1649
- return this.injector.get(YunzaiConfigService);
1650
- }
1651
- get tokenService() {
1652
- return this.injector.get(YA_SERVICE_TOKEN);
1653
- }
1654
- get httpClient() {
1655
- return this.injector.get(_HttpClient);
1656
- }
1657
- get cacheService() {
1658
- return this.injector.get(CacheService);
1659
- }
1660
- askToken() {
1661
- var _a;
1662
- log('yz.auth.service: ', 'askToken');
1663
- if ((_a = this.tokenService.get()) === null || _a === void 0 ? void 0 : _a.token) {
1664
- return of(this.tokenService.get());
1665
- }
1666
- else {
1667
- if (this.bis.loginForm) {
1668
- return this.fetchTokenByUP();
1669
- }
1670
- else {
1671
- return this.fetchTokenByCas();
1672
- }
1673
- }
1674
- }
1675
- fetchTokenByUP() {
1676
- log('yz.auth.service: ', 'fetchTokenByUP');
1677
- return this.httpClient.post(`/auth/oauth/token?_allow_anonymous=true`, this.bis.loginForm).pipe(map((response) => {
1678
- const { access_token, expires_in, refresh_token, scope, token_type } = response;
1679
- return {
1680
- token: access_token,
1681
- expired: expires_in,
1682
- refreshToken: refresh_token,
1683
- tokenType: token_type,
1684
- scope
1685
- };
1686
- }));
1687
- }
1688
- fetchTokenByCas() {
1689
- log('yz.auth.service: ', 'fetchTokenByCas');
1690
- const uri = encodeURIComponent(this.injector.get(WINDOW).location.href);
1691
- return this.httpClient
1692
- .get(`/cas-proxy/app/validate_full?callback=${uri}&_allow_anonymous=true&timestamp=${new Date().getTime()}`)
1693
- .pipe(map((response) => {
1694
- switch (response.errcode) {
1695
- case 2000:
1696
- const { access_token, expires_in, refresh_token, scope, token_type } = response.data;
1697
- return {
1698
- token: access_token,
1699
- expired: expires_in,
1700
- refreshToken: refresh_token,
1701
- tokenType: token_type,
1702
- scope
1703
- };
1704
- case 2001:
1705
- this.injector.get(WINDOW).location.href = response.msg;
1706
- throw Error("Cookie Error: Can't find Cas Cookie,So jump to login!");
1707
- default:
1708
- if (response.data) {
1709
- console.error(response.data);
1710
- throw Error(response.data);
1711
- }
1712
- else if (response.msg) {
1713
- console.error(response.msg);
1714
- throw Error(response.msg);
1715
- }
1716
- else {
1717
- console.error('cas unknown error');
1718
- throw Error('Unknown Error: Cas auth exception!');
1719
- }
1720
- }
1721
- }));
1722
- }
1723
- login() {
1724
- log('yz.auth.service: ', 'login white login form->', this.bis.loginForm);
1725
- return this.askToken().pipe(mergeMap(token => {
1726
- log('yz.auth.service: get token->', token);
1727
- this.csr.set('auth', {
1728
- token_send_key: 'Authorization',
1729
- token_send_template: `${token.tokenType} \${token}`,
1730
- token_send_place: 'header'
1731
- });
1732
- log('yz.auth.service: ', 'set token');
1733
- this.tokenService.set(token);
1734
- return this.cacheInit();
1735
- }), mergeAll());
1736
- }
1737
- cacheInit() {
1738
- log('yz.auth.service: ', 'cacheInit');
1739
- const user = this.cacheService.get('_yz_user', { mode: 'none' });
1740
- const header = this.cacheService.get('_yz_header', { mode: 'none' });
1741
- const project = this.cacheService.get('_yz_project_info', { mode: 'none' });
1742
- return forkJoin(of(user), of(header), of(project)).pipe(mergeMap(([u, h, p]) => {
1743
- let list = [];
1744
- // user cache
1745
- if (!u) {
1746
- log('yz.auth.service: ', 'fetch user cache');
1747
- list.push(this.httpClient.get(`/auth/user`).pipe(map((user) => {
1748
- this.cacheService.set('_yz_user', user.principal);
1749
- })));
1750
- }
1751
- else {
1752
- log('yz.auth.service: ', 'user recache');
1753
- list.push(of(() => { }));
1754
- }
1755
- // header cache
1756
- if (!h) {
1757
- log('yz.auth.service: ', 'fetch header cache');
1758
- list.push(this.httpClient.get(`/auth/allheader/v2`).pipe(map((header) => {
1759
- this.cacheService.set('_yz_header', header.data);
1760
- })));
1761
- }
1762
- else {
1763
- log('yz.auth.service: ', 'header recache');
1764
- list.push(of(() => { }));
1765
- }
1766
- // project cache
1767
- if (!p) {
1768
- log('yz.auth.service: ', 'fetch project cache');
1769
- list.push(this.httpClient.get(`/app-manager/project/info`).pipe(map((info) => {
1770
- this.cacheService.set('_yz_project_info', info.data);
1771
- })));
1772
- }
1773
- else {
1774
- log('yz.auth.service: ', 'project recache');
1775
- list.push(of(() => { }));
1776
- }
1777
- return forkJoin(list);
1778
- }));
1779
- }
1780
- }
1781
- YzAuthService.ɵprov = i0.ɵɵdefineInjectable({ factory: function YzAuthService_Factory() { return new YzAuthService(i0.ɵɵinject(i0.INJECTOR)); }, token: YzAuthService, providedIn: "root" });
1782
- YzAuthService.decorators = [
1783
- { type: Injectable, args: [{ providedIn: 'root' },] }
1784
- ];
1785
- YzAuthService.ctorParameters = () => [
1786
- { type: Injector }
1787
- ];
1867
+ <layout-default-header-item direction="right" hidden="mobile">
1868
+ <yz-header-theme-btn></yz-header-theme-btn>
1869
+ </layout-default-header-item>
1788
1870
 
1789
- const CODEMESSAGE = {
1790
- 200: '服务器成功返回请求的数据。',
1791
- 201: '新建或修改数据成功。',
1792
- 202: '一个请求已经进入后台排队(异步任务)。',
1793
- 204: '删除数据成功。',
1794
- 400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。',
1795
- 401: '用户没有权限(令牌、用户名、密码错误)。',
1796
- 403: '用户得到授权,但是访问是被禁止的。',
1797
- 404: '发出的请求针对的是不存在的记录,服务器没有进行操作。',
1798
- 406: '请求的格式不可得。',
1799
- 410: '请求的资源被永久删除,且不会再得到的。',
1800
- 422: '当创建一个对象时,发生一个验证错误。',
1801
- 500: '服务器发生错误,请检查服务器。',
1802
- 502: '网关错误。',
1803
- 503: '服务不可用,服务器暂时过载或维护。',
1804
- 504: '网关超时。'
1805
- };
1806
- /**
1807
- * 默认HTTP拦截器,其注册细节见 `app.module.ts`
1808
- */
1809
- class YzDefaultInterceptor {
1810
- constructor(injector) {
1811
- this.injector = injector;
1812
- this.jump = false;
1813
- this.refreshToking = false;
1814
- this.refreshToken$ = new BehaviorSubject(null);
1815
- if (this.config.refreshTokenType === 'auth-refresh') {
1816
- console.error("can't use auth-refresh, please change yz.default.interceptor to default.interceptor!");
1817
- }
1818
- }
1819
- get notification() {
1820
- return this.injector.get(NzNotificationService);
1821
- }
1822
- get tokenSrv() {
1823
- return this.injector.get(YA_SERVICE_TOKEN);
1824
- }
1825
- get http() {
1826
- return this.injector.get(_HttpClient);
1827
- }
1828
- get config() {
1829
- return mergeBisConfig(this.injector.get(YunzaiConfigService));
1830
- }
1831
- goTo(url) {
1832
- setTimeout(() => this.injector.get(Router).navigateByUrl(url));
1833
- }
1834
- checkStatus(ev) {
1835
- if ((ev.status >= 200 && ev.status < 300) || ev.status === 401) {
1836
- return;
1837
- }
1838
- if (ev instanceof HttpErrorResponse && (ev.error.message || ev.error.errorMessage)) {
1839
- if (ev.error.errorMessage) {
1840
- this.notification.error(`发生了一些错误 `, ev.error.errorMessage);
1841
- }
1842
- else {
1843
- this.notification.error(`发生了一些错误 `, ev.error.message);
1844
- }
1845
- return;
1846
- }
1847
- if (ev instanceof HttpResponse && ev.body.errorMessage) {
1848
- this.notification.error(`发生了一些错误 `, ev.body.errorMessage);
1849
- return;
1850
- }
1851
- const errortext = CODEMESSAGE[ev.status] || ev.statusText;
1852
- this.notification.error(`请求错误 ${ev.status}: ${ev.url}`, errortext);
1853
- }
1854
- ToLogin() {
1855
- this.notification.error(`未登录或登录状态已过期,5秒后将跳转到登录页面。`, ``);
1856
- setTimeout(() => {
1857
- localStorage.clear();
1858
- this.injector.get(WINDOW).location.href = `${this.config.baseUrl}/cas-proxy/app/logout`;
1859
- }, 5000);
1860
- }
1861
- reAttachToken(req) {
1862
- var _a;
1863
- const token = (_a = this.tokenSrv.get()) === null || _a === void 0 ? void 0 : _a.token;
1864
- return req.clone({
1865
- setHeaders: {
1866
- Authorization: `Bearer ${token}`
1867
- }
1868
- });
1869
- }
1870
- refreshTokenRequest() {
1871
- const model = this.tokenSrv.get();
1872
- const form = new FormData();
1873
- form.set('refresh_token', model === null || model === void 0 ? void 0 : model.refreshToken);
1874
- log('yz.default.interceptor: use the refresh token to request a new token', model === null || model === void 0 ? void 0 : model.refreshToken);
1875
- return this.http.post(`/auth/user/token/refresh?_allow_anonymous=true`, form);
1876
- }
1877
- tryRefreshToken(ev, req, next) {
1878
- // 连刷新Token的请求都错了,那就是真错了
1879
- if (['/auth/oauth/token'].some(url => req.url.includes(url))) {
1880
- this.ToLogin();
1881
- return throwError(ev);
1882
- }
1883
- // 正在刷新token,所有其他请求排队
1884
- if (this.refreshToking) {
1885
- return this.refreshToken$.pipe(filter(v => !!v), take(1), switchMap(() => next.handle(this.reAttachToken(req))));
1886
- }
1887
- //尝试调用刷新 Token
1888
- this.refreshToking = true;
1889
- this.refreshToken$.next(null);
1890
- // 处理Token
1891
- return this.refreshTokenRequest().pipe(switchMap(res => {
1892
- log('yz.default.interceptor: refresh token accessed -> ', res);
1893
- // 重新保存新 token
1894
- const { access_token, expires_in, refresh_token, scope, token_type } = res;
1895
- this.tokenSrv.set({
1896
- token: access_token,
1897
- expired: expires_in,
1898
- refreshToken: refresh_token,
1899
- tokenType: token_type,
1900
- scope
1901
- });
1902
- // 通知后续请求继续执行
1903
- this.refreshToking = false;
1904
- this.refreshToken$.next(res);
1905
- // 重新发起请求
1906
- return next.handle(this.reAttachToken(req));
1907
- }), catchError(err => {
1908
- this.refreshToking = false;
1909
- this.ToLogin();
1910
- return throwError(err);
1911
- }));
1912
- }
1913
- getAdditionalHeaders(headers) {
1914
- const res = {};
1915
- const lang = this.injector.get(YUNZAI_I18N_TOKEN).currentLang;
1916
- if (!(headers === null || headers === void 0 ? void 0 : headers.has('Accept-Language')) && lang) {
1917
- res['Accept-Language'] = lang;
1918
- }
1919
- return res;
1920
- }
1921
- handleData(ev, req, next) {
1922
- this.checkStatus(ev);
1923
- switch (ev.status) {
1924
- case 200:
1925
- return of(ev);
1926
- case 401:
1927
- if (this.config.refreshTokenEnabled && this.config.refreshTokenType === 're-request') {
1928
- return this.tryRefreshToken(ev, req, next);
1929
- }
1930
- this.ToLogin();
1931
- break;
1932
- case 403:
1933
- case 404:
1934
- case 500:
1935
- if (this.jump) {
1936
- this.goTo(`/exception/${ev.status}`);
1937
- }
1938
- break;
1939
- default:
1940
- if (ev instanceof HttpErrorResponse) {
1941
- console.warn('未可知错误,大部分是由于后端不支持跨域CORS或无效配置引起,请参考 https://ng.yunzainfo.com/docs/server 解决跨域问题', ev);
1942
- }
1943
- break;
1944
- }
1945
- if (ev instanceof HttpErrorResponse) {
1946
- return throwError(ev);
1947
- }
1948
- else {
1949
- return of(ev);
1950
- }
1951
- }
1952
- intercept(req, next) {
1953
- log('yz.default.interceptor.ts: ', 'request ', req);
1954
- // 统一加前缀
1955
- let url = req.url;
1956
- if (!url.startsWith('https://') && !url.startsWith('http://')) {
1957
- url = this.config.baseUrl + url;
1958
- }
1959
- if (url.includes('.json') && url.includes('assets')) {
1960
- url = req.url;
1961
- }
1962
- // 加入语言头
1963
- const newReq = req.clone({ url, setHeaders: this.getAdditionalHeaders(req.headers) });
1964
- return next.handle(newReq).pipe(mergeMap(ev => {
1965
- // 允许统一对请求错误处理
1966
- if (ev instanceof HttpResponseBase) {
1967
- return this.handleData(ev, newReq, next);
1968
- }
1969
- // 若一切都正常,则后续操作
1970
- return of(ev);
1971
- }), catchError((err) => this.handleData(err, newReq, next)));
1972
- }
1973
- }
1974
- YzDefaultInterceptor.decorators = [
1975
- { type: Injectable }
1976
- ];
1977
- YzDefaultInterceptor.ctorParameters = () => [
1978
- { type: Injector }
1979
- ];
1871
+ <layout-default-header-item direction="right" hidden="mobile">
1872
+ <div
1873
+ layout-default-header-item-trigger
1874
+ nz-dropdown
1875
+ [nzDropdownMenu]="settingsMenu"
1876
+ nzTrigger="click"
1877
+ nzPlacement="bottomRight"
1878
+ >
1879
+ <i nz-icon nzType="setting"></i>
1880
+ </div>
1881
+ <nz-dropdown-menu #settingsMenu="nzDropdownMenu">
1882
+ <div nz-menu style="width: 200px;">
1883
+ <div nz-menu-item>
1884
+ <yz-header-fullscreen></yz-header-fullscreen>
1885
+ </div>
1886
+ <div nz-menu-item>
1887
+ <yz-header-clear-storage></yz-header-clear-storage>
1888
+ </div>
1889
+ <div nz-menu-item>
1890
+ <yz-header-i18n></yz-header-i18n>
1891
+ </div>
1892
+ </div>
1893
+ </nz-dropdown-menu>
1894
+ </layout-default-header-item>
1895
+ <layout-default-header-item direction="right">
1896
+ <yz-header-user></yz-header-user>
1897
+ </layout-default-header-item>
1898
+ <ng-template #asideUserTpl>
1899
+ <div nz-dropdown nzTrigger="click" [nzDropdownMenu]="userMenu" class="yunzai-default__aside-user">
1900
+ <nz-avatar class="yunzai-default__aside-user-avatar" [nzSrc]="icon"></nz-avatar>
1901
+ <div class="yunzai-default__aside-user-info">
1902
+ <strong>{{ text }}</strong>
1903
+ <p class="mb0">{{ intro }}</p>
1904
+ </div>
1905
+ </div>
1906
+ <nz-dropdown-menu #userMenu="nzDropdownMenu">
1907
+ <ul nz-menu>
1908
+ <li nz-menu-item routerLink="/">{{ 'menu.backtohome' | i18n }}</li>
1909
+ </ul>
1910
+ </nz-dropdown-menu>
1911
+ </ng-template>
1912
+ <ng-template #contentTpl>
1913
+ <reuse-tab #reuseTab [ngStyle]="reuseStyleSheet"></reuse-tab>
1914
+ <router-outlet (activate)="reuseTab.activate($event)"></router-outlet>
1915
+ </ng-template>
1916
+ <ng-template #noneTpl>
1917
+ <router-outlet></router-outlet>
1918
+ </ng-template>
1919
+ </layout-default>
1920
+ `,
1921
+ changeDetection: ChangeDetectionStrategy.OnPush
1922
+ }]
1923
+ }], ctorParameters: function () { return [{ type: i2$1.CacheService }, { type: YzStompService }, { type: i3$4.LayoutService }]; } });
1980
1924
 
1981
- function mapYzSideToYelonMenu(menus) {
1982
- menus.forEach(menu => {
1983
- menu.badgeDot = menu.badge_dot || null;
1984
- menu.badgeStatus = menu.badge_status || null;
1985
- menu.shortcutRoot = menu.shortcut_root || null;
1986
- menu.reuse = true;
1987
- if (menu.children) {
1988
- mapYzSideToYelonMenu(menu.children);
1989
- }
1990
- });
1991
- }
1992
- function generateAbility(menus, abilities, prefix) {
1993
- menus.forEach(menu => {
1994
- if (menu.link) {
1995
- prefix += menu.link;
1996
- }
1997
- else {
1998
- prefix += '';
1999
- }
2000
- if (menu.menuAuths) {
2001
- menu.menuAuths.forEach((a) => {
2002
- abilities.push(`${prefix}:${a}`);
2003
- abilities.push(a);
2004
- });
2005
- }
2006
- if (menu.children) {
2007
- generateAbility(menu.children, abilities, prefix);
2008
- }
2009
- });
2010
- }
2011
- class YzStartupService {
2012
- constructor(iconSrv, menuService, i18n, settingService, aclService, titleService, yzAuthService, cacheService, configService) {
2013
- this.menuService = menuService;
2014
- this.i18n = i18n;
2015
- this.settingService = settingService;
2016
- this.aclService = aclService;
2017
- this.titleService = titleService;
2018
- this.yzAuthService = yzAuthService;
2019
- this.cacheService = cacheService;
2020
- this.configService = configService;
2021
- this.bis = BUSINESS_DEFAULT_CONFIG;
2022
- this.bis = mergeBisConfig(this.configService);
2023
- iconSrv.addIcon(...ICONS);
2024
- }
2025
- load() {
2026
- log$1('startup.service: ', 'load');
2027
- const defaultLang = this.i18n.defaultLang;
2028
- return this.i18n.loadLangData(defaultLang).pipe(mergeMap(langData => {
2029
- log$1('startup.service: ', 'set i18n, defaultLang->', defaultLang, ' langData->', langData);
2030
- this.i18n.use(defaultLang, langData);
2031
- return of(null);
2032
- }), mergeMap(() => {
2033
- return this.yzAuthService.login();
2034
- }), mergeMap(v => {
2035
- // preloader finish
2036
- this.systemInit();
2037
- log$1('startup.service: preloader finish');
2038
- const win = window;
2039
- if (win && win.appBootstrap) {
2040
- win.appBootstrap();
2041
- }
2042
- return of(v);
2043
- }));
2044
- }
2045
- systemInit() {
2046
- log$1('startup.service: system init');
2047
- // user
2048
- const user = this.cacheService.get('_yz_user', { mode: 'none' });
2049
- // menu
2050
- const ms = deepCopy(user.menu).filter((m) => m.systemCode && m.systemCode === this.bis.systemCode);
2051
- mapYzSideToYelonMenu(ms);
2052
- const currentMenu = ms.pop();
2053
- this.menuService.add([currentMenu]);
2054
- // logo app
2055
- this.settingService.setApp({ name: currentMenu.text, description: currentMenu.intro });
2056
- this.settingService.setUser({
2057
- name: user.realname || 'no name',
2058
- avatar: `${this.bis.baseUrl}/filecenter/file/${user.avatarId}` || '',
2059
- email: user.email || 'no email'
2060
- });
2061
- // title
2062
- this.titleService.default = currentMenu.text || 'default application name';
2063
- this.titleService.setTitle(currentMenu.text || 'no title');
2064
- // acl
2065
- const abilities = [];
2066
- generateAbility([currentMenu], abilities, '');
2067
- this.aclService.attachRole((user === null || user === void 0 ? void 0 : user.roles.map((role) => {
2068
- return role.roleValue;
2069
- }).filter((a) => !!a)) || []);
2070
- this.aclService.attachAbility(abilities);
2071
- // cache current
2072
- this.cacheService.set('_yz_current', {
2073
- text: currentMenu.text,
2074
- intro: currentMenu.intro,
2075
- icon: currentMenu.appIconUrl
2076
- });
2077
- }
2078
- }
2079
- YzStartupService.decorators = [
2080
- { type: Injectable }
2081
- ];
2082
- YzStartupService.ctorParameters = () => [
2083
- { type: NzIconService },
2084
- { type: MenuService },
2085
- { type: YzI18NService, decorators: [{ type: Inject, args: [YUNZAI_I18N_TOKEN,] }] },
2086
- { type: SettingsService },
2087
- { type: ACLService },
2088
- { type: TitleService },
2089
- { type: YzAuthService },
2090
- { type: CacheService },
2091
- { type: YunzaiConfigService$1 }
2092
- ];
2093
- function YzStartupServiceFactory(startupService) {
2094
- return () => startupService.load();
2095
- }
2096
- //@ts-ignore
2097
- const YZ_APPINIT_PROVIDES = [
2098
- YzStartupService,
2099
- {
2100
- provide: APP_INITIALIZER,
2101
- useFactory: YzStartupServiceFactory,
2102
- deps: [YzStartupService],
2103
- multi: true
2104
- }
1925
+ /*
1926
+ * @Author: cui <devcui@outlook.com>
1927
+ * @Editor: microsoft vscode
1928
+ * @Date: 2021-11-27 11:30:50
1929
+ * @LastEditTime: 2021-11-27 14:38:46
1930
+ * @LastEditors: cui <devcui@outlook.com>
1931
+ * @Description: empty description
1932
+ * @FilePath: \yelon\packages\bis\layout\layout.module.ts
1933
+ * LICENSE HERE
1934
+ */
1935
+ const COMPONENTS = [
1936
+ ContactComponent,
1937
+ YzLayoutBasicComponent,
1938
+ YzHeaderApplicationComponent,
1939
+ YzHeaderNotifyComponent,
1940
+ YzHeaderThemBtnComponent,
1941
+ YzHeaderUserComponent,
1942
+ YzHeaderFullScreenComponent,
1943
+ YzHeaderClearStorageComponent,
1944
+ YzHeaderI18NComponent
2105
1945
  ];
1946
+ class YunzaiLayoutModule {
1947
+ }
1948
+ YunzaiLayoutModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YunzaiLayoutModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1949
+ YunzaiLayoutModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YunzaiLayoutModule, declarations: [ContactComponent,
1950
+ YzLayoutBasicComponent,
1951
+ YzHeaderApplicationComponent,
1952
+ YzHeaderNotifyComponent,
1953
+ YzHeaderThemBtnComponent,
1954
+ YzHeaderUserComponent,
1955
+ YzHeaderFullScreenComponent,
1956
+ YzHeaderClearStorageComponent,
1957
+ YzHeaderI18NComponent], imports: [HttpClientModule, CommonModule, FormsModule, RouterModule, ReactiveFormsModule, YzSharedModule], exports: [ContactComponent,
1958
+ YzLayoutBasicComponent,
1959
+ YzHeaderApplicationComponent,
1960
+ YzHeaderNotifyComponent,
1961
+ YzHeaderThemBtnComponent,
1962
+ YzHeaderUserComponent,
1963
+ YzHeaderFullScreenComponent,
1964
+ YzHeaderClearStorageComponent,
1965
+ YzHeaderI18NComponent] });
1966
+ YunzaiLayoutModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YunzaiLayoutModule, providers: [
1967
+ {
1968
+ provide: YUNZAI_THEME_BTN_KEYS,
1969
+ useValue: 'site-theme'
1970
+ }
1971
+ ], imports: [[HttpClientModule, CommonModule, FormsModule, RouterModule, ReactiveFormsModule, YzSharedModule]] });
1972
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YunzaiLayoutModule, decorators: [{
1973
+ type: NgModule,
1974
+ args: [{
1975
+ imports: [HttpClientModule, CommonModule, FormsModule, RouterModule, ReactiveFormsModule, YzSharedModule],
1976
+ providers: [
1977
+ {
1978
+ provide: YUNZAI_THEME_BTN_KEYS,
1979
+ useValue: 'site-theme'
1980
+ }
1981
+ ],
1982
+ declarations: [...COMPONENTS],
1983
+ exports: [...COMPONENTS]
1984
+ }]
1985
+ }] });
2106
1986
 
2107
- class PathToRegexpService {
2108
- constructor() {
2109
- this.DEFAULT_DELIMITER = '/';
2110
- this.PATH_REGEXP = new RegExp(['(\\\\.)', '(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?'].join('|'), 'g');
2111
- }
2112
- parse(str, options) {
2113
- const tokens = [];
2114
- let key = 0;
2115
- let index = 0;
2116
- let path = '';
2117
- const defaultDelimiter = (options && options.delimiter) || this.DEFAULT_DELIMITER;
2118
- const whitelist = (options && options.whitelist) || undefined;
2119
- let pathEscaped = false;
2120
- let res;
2121
- while ((res = this.PATH_REGEXP.exec(str)) !== null) {
2122
- const m = res[0];
2123
- const escaped = res[1];
2124
- const offset = res.index;
2125
- path += str.slice(index, offset);
2126
- index = offset + m.length;
2127
- // Ignore already escaped sequences.
2128
- if (escaped) {
2129
- path += escaped[1];
2130
- pathEscaped = true;
2131
- continue;
2132
- }
2133
- let prev = '';
2134
- const name = res[2];
2135
- const capture = res[3];
2136
- const group = res[4];
2137
- const modifier = res[5];
2138
- if (!pathEscaped && path.length) {
2139
- const k = path.length - 1;
2140
- const c = path[k];
2141
- const matches = whitelist ? whitelist.indexOf(c) > -1 : true;
2142
- if (matches) {
2143
- prev = c;
2144
- path = path.slice(0, k);
2145
- }
2146
- }
2147
- // Push the current path onto the tokens.
2148
- if (path) {
2149
- tokens.push(path);
2150
- path = '';
2151
- pathEscaped = false;
2152
- }
2153
- const repeat = modifier === '+' || modifier === '*';
2154
- const optional = modifier === '?' || modifier === '*';
2155
- const pattern = capture || group;
2156
- const delimiter = prev || defaultDelimiter;
2157
- tokens.push({
2158
- name: name || key++,
2159
- prefix: prev,
2160
- delimiter: delimiter,
2161
- optional: optional,
2162
- repeat: repeat,
2163
- pattern: pattern
2164
- ? this.escapeGroup(pattern)
2165
- : `[^${this.escapeString(delimiter === defaultDelimiter ? delimiter : delimiter + defaultDelimiter)}]+?`
2166
- });
2167
- }
2168
- // Push any remaining characters.
2169
- if (path || index < str.length) {
2170
- tokens.push(path + str.substr(index));
2171
- }
2172
- return tokens;
2173
- }
2174
- compile(str, options) {
2175
- return this.tokensToFunction(this.parse(str, options), options);
2176
- }
2177
- tokensToFunction(tokens, options) {
2178
- const matches = new Array(tokens.length);
2179
- for (let i = 0; i < tokens.length; i++) {
2180
- if (typeof tokens[i] === 'object') {
2181
- matches[i] = new RegExp(`^(?:${tokens[i].pattern})$`, this.flags(options));
2182
- }
2183
- }
2184
- return function (data, options) {
2185
- let path = '';
2186
- const encode = (options && options.encode) || encodeURIComponent;
2187
- const validate = options ? options.validate !== false : true;
2188
- for (let i = 0; i < tokens.length; i++) {
2189
- const token = tokens[i];
2190
- if (typeof token === 'string') {
2191
- path += token;
2192
- continue;
2193
- }
2194
- const value = data ? data[token.name] : undefined;
2195
- let segment;
2196
- if (Array.isArray(value)) {
2197
- if (!token.repeat) {
2198
- throw new TypeError(`Expected "${token.name}" to not repeat, but got array`);
2199
- }
2200
- if (value.length === 0) {
2201
- if (token.optional) {
2202
- continue;
2203
- }
2204
- throw new TypeError(`Expected "${token.name}" to not be empty`);
2205
- }
2206
- for (let j = 0; j < value.length; j++) {
2207
- segment = encode(value[j], token);
2208
- if (validate && !matches[i].test(segment)) {
2209
- throw new TypeError(`Expected all "${token.name}" to match "${token.pattern}"`);
2210
- }
2211
- path += (j === 0 ? token.prefix : token.delimiter) + segment;
2212
- }
2213
- continue;
2214
- }
2215
- if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
2216
- segment = encode(String(value), token);
2217
- if (validate && !matches[i].test(segment)) {
2218
- throw new TypeError(`Expected "${token.name}" to match "${token.pattern}", but got "${segment}"`);
2219
- }
2220
- path += token.prefix + segment;
2221
- continue;
2222
- }
2223
- if (token.optional) {
2224
- continue;
2225
- }
2226
- throw new TypeError(`Expected "${token.name}" to be ${token.repeat ? 'an array' : 'a string'}`);
2227
- }
2228
- return path;
2229
- };
2230
- }
2231
- escapeString(str) {
2232
- return str.replace(/([.+*?=^!:${}()[\]|/\\])/g, '\\$1');
2233
- }
2234
- escapeGroup(group) {
2235
- return group.replace(/([=!:$/()])/g, '\\$1');
2236
- }
2237
- flags(options) {
2238
- return options && options.sensitive ? '' : 'i';
2239
- }
2240
- regexpToRegexp(path, keys) {
2241
- if (!keys) {
2242
- return path;
2243
- }
2244
- const groups = path.source.match(/\((?!\?)/g);
2245
- if (groups) {
2246
- for (let i = 0; i < groups.length; i++) {
2247
- keys.push({
2248
- name: i,
2249
- prefix: null,
2250
- delimiter: null,
2251
- optional: false,
2252
- repeat: false,
2253
- pattern: null
2254
- });
2255
- }
2256
- }
2257
- return path;
2258
- }
2259
- arrayToRegexp(path, keys, options) {
2260
- const parts = [];
2261
- for (let i = 0; i < path.length; i++) {
2262
- parts.push(this.pathToRegexp(path[i], keys, options).source);
2263
- }
2264
- return new RegExp(`(?:${parts.join('|')})`, this.flags(options));
2265
- }
2266
- stringToRegexp(path, keys, options) {
2267
- return this.tokensToRegExp(this.parse(path, options), keys, options);
2268
- }
2269
- tokensToRegExp(tokens, keys, options) {
2270
- options = options || {};
2271
- const strict = options.strict;
2272
- const start = options.start !== false;
2273
- const end = options.end !== false;
2274
- const delimiter = options.delimiter || this.DEFAULT_DELIMITER;
2275
- const endsWith = []
2276
- .concat(options.endsWith || [])
2277
- .map(this.escapeString)
2278
- .concat('$')
2279
- .join('|');
2280
- let route = start ? '^' : '';
2281
- for (let i = 0; i < tokens.length; i++) {
2282
- const token = tokens[i];
2283
- if (typeof token === 'string') {
2284
- route += this.escapeString(token);
2285
- }
2286
- else {
2287
- const capture = token.repeat
2288
- ? `(?:${token.pattern})(?:${this.escapeString(token.delimiter)}(?:${token.pattern}))*`
2289
- : token.pattern;
2290
- if (keys) {
2291
- keys.push(token);
2292
- }
2293
- if (token.optional) {
2294
- if (!token.prefix) {
2295
- route += `(${capture})?`;
2296
- }
2297
- else {
2298
- route += `(?:${this.escapeString(token.prefix)}(${capture}))?`;
2299
- }
2300
- }
2301
- else {
2302
- route += `${this.escapeString(token.prefix)}(${capture})`;
2303
- }
2304
- }
2305
- }
2306
- if (end) {
2307
- if (!strict) {
2308
- route += `(?:${this.escapeString(delimiter)})?`;
2309
- }
2310
- route += endsWith === '$' ? '$' : `(?=${endsWith})`;
2311
- }
2312
- else {
2313
- const endToken = tokens[tokens.length - 1];
2314
- const isEndDelimited = typeof endToken === 'string' ? endToken[endToken.length - 1] === delimiter : endToken === undefined;
2315
- if (!strict) {
2316
- route += `(?:${this.escapeString(delimiter)}(?=${endsWith}))?`;
2317
- }
2318
- if (!isEndDelimited) {
2319
- route += `(?=${this.escapeString(delimiter)}|${endsWith})`;
2320
- }
2321
- }
2322
- return new RegExp(route, this.flags(options));
2323
- }
2324
- pathToRegexp(path, keys, options) {
2325
- if (path instanceof RegExp) {
2326
- return this.regexpToRegexp(path, keys);
2327
- }
2328
- if (Array.isArray(path)) {
2329
- return this.arrayToRegexp(/** @type {!Array} */ path, keys, options);
2330
- }
2331
- return this.stringToRegexp(/** @type {string} */ path, keys, options);
2332
- }
2333
- }
2334
- PathToRegexpService.ɵprov = i0.ɵɵdefineInjectable({ factory: function PathToRegexpService_Factory() { return new PathToRegexpService(); }, token: PathToRegexpService, providedIn: "root" });
2335
- PathToRegexpService.decorators = [
2336
- { type: Injectable, args: [{
2337
- providedIn: 'root'
2338
- },] }
2339
- ];
2340
- PathToRegexpService.ctorParameters = () => [];
1987
+ class YzAuthService {
1988
+ constructor(injector) {
1989
+ this.injector = injector;
1990
+ this.option = mergeConfig(this.csr);
1991
+ this.bis = mergeBisConfig(this.csr);
1992
+ }
1993
+ get csr() {
1994
+ return this.injector.get(YunzaiConfigService);
1995
+ }
1996
+ get tokenService() {
1997
+ return this.injector.get(YA_SERVICE_TOKEN);
1998
+ }
1999
+ get httpClient() {
2000
+ return this.injector.get(_HttpClient);
2001
+ }
2002
+ get cacheService() {
2003
+ return this.injector.get(CacheService);
2004
+ }
2005
+ askToken() {
2006
+ var _a;
2007
+ log('yz.auth.service: ', 'askToken');
2008
+ if ((_a = this.tokenService.get()) === null || _a === void 0 ? void 0 : _a.token) {
2009
+ return of(this.tokenService.get());
2010
+ }
2011
+ else {
2012
+ if (this.bis.loginForm) {
2013
+ return this.fetchTokenByUP();
2014
+ }
2015
+ else {
2016
+ return this.fetchTokenByCas();
2017
+ }
2018
+ }
2019
+ }
2020
+ fetchTokenByUP() {
2021
+ log('yz.auth.service: ', 'fetchTokenByUP');
2022
+ return this.httpClient.post(`/auth/oauth/token?_allow_anonymous=true`, this.bis.loginForm).pipe(map((response) => {
2023
+ const { access_token, expires_in, refresh_token, scope, token_type } = response;
2024
+ return {
2025
+ token: access_token,
2026
+ expired: expires_in,
2027
+ refreshToken: refresh_token,
2028
+ tokenType: token_type,
2029
+ scope
2030
+ };
2031
+ }));
2032
+ }
2033
+ fetchTokenByCas() {
2034
+ log('yz.auth.service: ', 'fetchTokenByCas');
2035
+ const uri = encodeURIComponent(this.injector.get(WINDOW).location.href);
2036
+ return this.httpClient
2037
+ .get(`/cas-proxy/app/validate_full?callback=${uri}&_allow_anonymous=true&timestamp=${new Date().getTime()}`)
2038
+ .pipe(map((response) => {
2039
+ switch (response.errcode) {
2040
+ case 2000:
2041
+ const { access_token, expires_in, refresh_token, scope, token_type } = response.data;
2042
+ return {
2043
+ token: access_token,
2044
+ expired: expires_in,
2045
+ refreshToken: refresh_token,
2046
+ tokenType: token_type,
2047
+ scope
2048
+ };
2049
+ case 2001:
2050
+ this.injector.get(WINDOW).location.href = response.msg;
2051
+ throw Error("Cookie Error: Can't find Cas Cookie,So jump to login!");
2052
+ default:
2053
+ if (response.data) {
2054
+ console.error(response.data);
2055
+ throw Error(response.data);
2056
+ }
2057
+ else if (response.msg) {
2058
+ console.error(response.msg);
2059
+ throw Error(response.msg);
2060
+ }
2061
+ else {
2062
+ console.error('cas unknown error');
2063
+ throw Error('Unknown Error: Cas auth exception!');
2064
+ }
2065
+ }
2066
+ }));
2067
+ }
2068
+ login() {
2069
+ log('yz.auth.service: ', 'login white login form->', this.bis.loginForm);
2070
+ return this.askToken().pipe(mergeMap(token => {
2071
+ log('yz.auth.service: get token->', token);
2072
+ this.csr.set('auth', {
2073
+ token_send_key: 'Authorization',
2074
+ token_send_template: `${token.tokenType} \${token}`,
2075
+ token_send_place: 'header'
2076
+ });
2077
+ log('yz.auth.service: ', 'set token');
2078
+ this.tokenService.set(token);
2079
+ return this.cacheInit();
2080
+ }), mergeAll());
2081
+ }
2082
+ cacheInit() {
2083
+ log('yz.auth.service: ', 'cacheInit');
2084
+ const user = this.cacheService.get('_yz_user', { mode: 'none' });
2085
+ const header = this.cacheService.get('_yz_header', { mode: 'none' });
2086
+ const project = this.cacheService.get('_yz_project_info', { mode: 'none' });
2087
+ return forkJoin(of(user), of(header), of(project)).pipe(mergeMap(([u, h, p]) => {
2088
+ let list = [];
2089
+ // user cache
2090
+ if (!u) {
2091
+ log('yz.auth.service: ', 'fetch user cache');
2092
+ list.push(this.httpClient.get(`/auth/user`).pipe(map((user) => {
2093
+ this.cacheService.set('_yz_user', user.principal);
2094
+ })));
2095
+ }
2096
+ else {
2097
+ log('yz.auth.service: ', 'user recache');
2098
+ list.push(of(() => { }));
2099
+ }
2100
+ // header cache
2101
+ if (!h) {
2102
+ log('yz.auth.service: ', 'fetch header cache');
2103
+ list.push(this.httpClient.get(`/auth/allheader/v2`).pipe(map((header) => {
2104
+ this.cacheService.set('_yz_header', header.data);
2105
+ })));
2106
+ }
2107
+ else {
2108
+ log('yz.auth.service: ', 'header recache');
2109
+ list.push(of(() => { }));
2110
+ }
2111
+ // project cache
2112
+ if (!p) {
2113
+ log('yz.auth.service: ', 'fetch project cache');
2114
+ list.push(this.httpClient.get(`/app-manager/project/info`).pipe(map((info) => {
2115
+ this.cacheService.set('_yz_project_info', info.data);
2116
+ })));
2117
+ }
2118
+ else {
2119
+ log('yz.auth.service: ', 'project recache');
2120
+ list.push(of(() => { }));
2121
+ }
2122
+ return forkJoin(list);
2123
+ }));
2124
+ }
2125
+ }
2126
+ YzAuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YzAuthService, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
2127
+ YzAuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YzAuthService, providedIn: 'root' });
2128
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YzAuthService, decorators: [{
2129
+ type: Injectable,
2130
+ args: [{ providedIn: 'root' }]
2131
+ }], ctorParameters: function () { return [{ type: i0.Injector }]; } });
2341
2132
 
2342
- class ActGuard {
2343
- constructor(configService, cacheService, pathToRegexp, router) {
2344
- this.configService = configService;
2345
- this.cacheService = cacheService;
2346
- this.pathToRegexp = pathToRegexp;
2347
- this.router = router;
2348
- this.bis = BUSINESS_DEFAULT_CONFIG;
2349
- this.menus = [];
2350
- this.links = [];
2351
- log$1('act: ');
2352
- this.bis = mergeBisConfig(this.configService);
2353
- log$1('act: config ', this.bis);
2354
- const user = this.cacheService.get('_yz_user', { mode: 'none' });
2355
- log$1('act: user ', user);
2356
- this.menus = deepCopy(user.menu).filter((m) => m.systemCode && m.systemCode === this.bis.systemCode);
2357
- log$1('act: menus ', this.menus);
2358
- this.getAllLinks(this.menus, this.links);
2359
- log$1('act: links ', this.links);
2360
- }
2361
- canActivate(_, state) {
2362
- log$1('act: can activate ', state);
2363
- if (this.preHandle(state)) {
2364
- return true;
2365
- }
2366
- log$1('act: can activate child prehandle success');
2367
- let canactivate = false;
2368
- this.links.forEach((link) => {
2369
- const regexp = this.pathToRegexp.stringToRegexp(link, null, null);
2370
- log$1(`act: ${link} test ${state.url.split('?')[0]}`);
2371
- if (regexp.test(state.url.split('?')[0])) {
2372
- canactivate = true;
2373
- log$1(`act: test value ${canactivate}`);
2374
- return;
2375
- }
2376
- });
2377
- if (canactivate) {
2378
- log$1(`act: test sucess`);
2379
- return true;
2380
- }
2381
- else {
2382
- log$1(`act: test error`);
2383
- this.router.navigate(['displayIndex']);
2384
- return false;
2385
- }
2386
- }
2387
- canActivateChild(_, state) {
2388
- log$1('act: can activate child ', state);
2389
- if (this.preHandle(state)) {
2390
- return true;
2391
- }
2392
- log$1('act: can activate child prehandle success');
2393
- let canactivate = false;
2394
- this.links.forEach((link) => {
2395
- const regexp = this.pathToRegexp.stringToRegexp(link, null, null);
2396
- if (regexp.test(state.url.split('?')[0])) {
2397
- log$1(`act: ${link} test ${state.url.split('?')[0]}`);
2398
- canactivate = true;
2399
- log$1(`act: test value ${canactivate}`);
2400
- return;
2401
- }
2402
- });
2403
- if (canactivate) {
2404
- log$1(`act: test sucess`);
2405
- return true;
2406
- }
2407
- else {
2408
- log$1(`act: test error`);
2409
- this.router.navigate(['displayIndex']);
2410
- return false;
2411
- }
2412
- }
2413
- preHandle(state) {
2414
- return (state.url.includes('error') ||
2415
- state.url.includes('exception') ||
2416
- state.url.includes('displayIndex') ||
2417
- state.url === '' ||
2418
- state.url === null ||
2419
- state.url === '/' ||
2420
- state.url.includes('iframePage'));
2421
- }
2422
- getAllLinks(menu, links) {
2423
- menu.forEach((sider) => {
2424
- if (sider.link) {
2425
- links.push(sider.link);
2426
- }
2427
- if (sider.children && sider.children.length > 0) {
2428
- this.getAllLinks(sider.children, links);
2429
- }
2430
- });
2431
- }
2432
- }
2433
- ActGuard.ɵprov = i0.ɵɵdefineInjectable({ factory: function ActGuard_Factory() { return new ActGuard(i0.ɵɵinject(i1$1.YunzaiConfigService), i0.ɵɵinject(i2$1.CacheService), i0.ɵɵinject(PathToRegexpService), i0.ɵɵinject(i4.Router)); }, token: ActGuard, providedIn: "root" });
2434
- ActGuard.decorators = [
2435
- { type: Injectable, args: [{
2436
- providedIn: 'root'
2437
- },] }
2438
- ];
2439
- ActGuard.ctorParameters = () => [
2440
- { type: YunzaiConfigService$1 },
2441
- { type: CacheService },
2442
- { type: PathToRegexpService },
2443
- { type: Router }
2133
+ const CODEMESSAGE = {
2134
+ 200: '服务器成功返回请求的数据。',
2135
+ 201: '新建或修改数据成功。',
2136
+ 202: '一个请求已经进入后台排队(异步任务)。',
2137
+ 204: '删除数据成功。',
2138
+ 400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。',
2139
+ 401: '用户没有权限(令牌、用户名、密码错误)。',
2140
+ 403: '用户得到授权,但是访问是被禁止的。',
2141
+ 404: '发出的请求针对的是不存在的记录,服务器没有进行操作。',
2142
+ 406: '请求的格式不可得。',
2143
+ 410: '请求的资源被永久删除,且不会再得到的。',
2144
+ 422: '当创建一个对象时,发生一个验证错误。',
2145
+ 500: '服务器发生错误,请检查服务器。',
2146
+ 502: '网关错误。',
2147
+ 503: '服务不可用,服务器暂时过载或维护。',
2148
+ 504: '网关超时。'
2149
+ };
2150
+ /**
2151
+ * 默认HTTP拦截器,其注册细节见 `app.module.ts`
2152
+ */
2153
+ class YzDefaultInterceptor {
2154
+ constructor(injector) {
2155
+ this.injector = injector;
2156
+ this.jump = false;
2157
+ this.refreshToking = false;
2158
+ this.refreshToken$ = new BehaviorSubject(null);
2159
+ if (this.config.refreshTokenType === 'auth-refresh') {
2160
+ console.error("can't use auth-refresh, please change yz.default.interceptor to default.interceptor!");
2161
+ }
2162
+ }
2163
+ get notification() {
2164
+ return this.injector.get(NzNotificationService);
2165
+ }
2166
+ get tokenSrv() {
2167
+ return this.injector.get(YA_SERVICE_TOKEN);
2168
+ }
2169
+ get http() {
2170
+ return this.injector.get(_HttpClient);
2171
+ }
2172
+ get config() {
2173
+ return mergeBisConfig(this.injector.get(YunzaiConfigService));
2174
+ }
2175
+ goTo(url) {
2176
+ setTimeout(() => this.injector.get(Router).navigateByUrl(url));
2177
+ }
2178
+ checkStatus(ev) {
2179
+ if ((ev.status >= 200 && ev.status < 300) || ev.status === 401) {
2180
+ return;
2181
+ }
2182
+ if (ev instanceof HttpErrorResponse && (ev.error.message || ev.error.errorMessage)) {
2183
+ if (ev.error.errorMessage) {
2184
+ this.notification.error(`发生了一些错误 `, ev.error.errorMessage);
2185
+ }
2186
+ else {
2187
+ this.notification.error(`发生了一些错误 `, ev.error.message);
2188
+ }
2189
+ return;
2190
+ }
2191
+ if (ev instanceof HttpResponse && ev.body.errorMessage) {
2192
+ this.notification.error(`发生了一些错误 `, ev.body.errorMessage);
2193
+ return;
2194
+ }
2195
+ const errortext = CODEMESSAGE[ev.status] || ev.statusText;
2196
+ this.notification.error(`请求错误 ${ev.status}: ${ev.url}`, errortext);
2197
+ }
2198
+ ToLogin() {
2199
+ this.notification.error(`未登录或登录状态已过期,5秒后将跳转到登录页面。`, ``);
2200
+ setTimeout(() => {
2201
+ localStorage.clear();
2202
+ this.injector.get(WINDOW).location.href = `${this.config.baseUrl}/cas-proxy/app/logout`;
2203
+ }, 5000);
2204
+ }
2205
+ reAttachToken(req) {
2206
+ var _a;
2207
+ const token = (_a = this.tokenSrv.get()) === null || _a === void 0 ? void 0 : _a.token;
2208
+ return req.clone({
2209
+ setHeaders: {
2210
+ Authorization: `Bearer ${token}`
2211
+ }
2212
+ });
2213
+ }
2214
+ refreshTokenRequest() {
2215
+ const model = this.tokenSrv.get();
2216
+ const form = new FormData();
2217
+ form.set('refresh_token', model === null || model === void 0 ? void 0 : model.refreshToken);
2218
+ log('yz.default.interceptor: use the refresh token to request a new token', model === null || model === void 0 ? void 0 : model.refreshToken);
2219
+ return this.http.post(`/auth/user/token/refresh?_allow_anonymous=true`, form);
2220
+ }
2221
+ tryRefreshToken(ev, req, next) {
2222
+ // 连刷新Token的请求都错了,那就是真错了
2223
+ if (['/auth/oauth/token'].some(url => req.url.includes(url))) {
2224
+ this.ToLogin();
2225
+ return throwError(ev);
2226
+ }
2227
+ // 正在刷新token,所有其他请求排队
2228
+ if (this.refreshToking) {
2229
+ return this.refreshToken$.pipe(filter(v => !!v), take(1), switchMap(() => next.handle(this.reAttachToken(req))));
2230
+ }
2231
+ //尝试调用刷新 Token
2232
+ this.refreshToking = true;
2233
+ this.refreshToken$.next(null);
2234
+ // 处理Token
2235
+ return this.refreshTokenRequest().pipe(switchMap(res => {
2236
+ log('yz.default.interceptor: refresh token accessed -> ', res);
2237
+ // 重新保存新 token
2238
+ const { access_token, expires_in, refresh_token, scope, token_type } = res;
2239
+ this.tokenSrv.set({
2240
+ token: access_token,
2241
+ expired: expires_in,
2242
+ refreshToken: refresh_token,
2243
+ tokenType: token_type,
2244
+ scope
2245
+ });
2246
+ // 通知后续请求继续执行
2247
+ this.refreshToking = false;
2248
+ this.refreshToken$.next(res);
2249
+ // 重新发起请求
2250
+ return next.handle(this.reAttachToken(req));
2251
+ }), catchError(err => {
2252
+ this.refreshToking = false;
2253
+ this.ToLogin();
2254
+ return throwError(err);
2255
+ }));
2256
+ }
2257
+ getAdditionalHeaders(headers) {
2258
+ const res = {};
2259
+ const lang = this.injector.get(YUNZAI_I18N_TOKEN).currentLang;
2260
+ if (!(headers === null || headers === void 0 ? void 0 : headers.has('Accept-Language')) && lang) {
2261
+ res['Accept-Language'] = lang;
2262
+ }
2263
+ return res;
2264
+ }
2265
+ handleData(ev, req, next) {
2266
+ this.checkStatus(ev);
2267
+ switch (ev.status) {
2268
+ case 200:
2269
+ return of(ev);
2270
+ case 401:
2271
+ if (this.config.refreshTokenEnabled && this.config.refreshTokenType === 're-request') {
2272
+ return this.tryRefreshToken(ev, req, next);
2273
+ }
2274
+ this.ToLogin();
2275
+ break;
2276
+ case 403:
2277
+ case 404:
2278
+ case 500:
2279
+ if (this.jump) {
2280
+ this.goTo(`/exception/${ev.status}`);
2281
+ }
2282
+ break;
2283
+ default:
2284
+ if (ev instanceof HttpErrorResponse) {
2285
+ console.warn('未可知错误,大部分是由于后端不支持跨域CORS或无效配置引起,请参考 https://ng.yunzainfo.com/docs/server 解决跨域问题', ev);
2286
+ }
2287
+ break;
2288
+ }
2289
+ if (ev instanceof HttpErrorResponse) {
2290
+ return throwError(ev);
2291
+ }
2292
+ else {
2293
+ return of(ev);
2294
+ }
2295
+ }
2296
+ intercept(req, next) {
2297
+ log('yz.default.interceptor.ts: ', 'request ', req);
2298
+ // 统一加前缀
2299
+ let url = req.url;
2300
+ if (!url.startsWith('https://') && !url.startsWith('http://')) {
2301
+ url = this.config.baseUrl + url;
2302
+ }
2303
+ if (url.includes('.json') && url.includes('assets')) {
2304
+ url = req.url;
2305
+ }
2306
+ // 加入语言头
2307
+ const newReq = req.clone({ url, setHeaders: this.getAdditionalHeaders(req.headers) });
2308
+ return next.handle(newReq).pipe(mergeMap(ev => {
2309
+ // 允许统一对请求错误处理
2310
+ if (ev instanceof HttpResponseBase) {
2311
+ return this.handleData(ev, newReq, next);
2312
+ }
2313
+ // 若一切都正常,则后续操作
2314
+ return of(ev);
2315
+ }), catchError((err) => this.handleData(err, newReq, next)));
2316
+ }
2317
+ }
2318
+ YzDefaultInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YzDefaultInterceptor, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
2319
+ YzDefaultInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YzDefaultInterceptor });
2320
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YzDefaultInterceptor, decorators: [{
2321
+ type: Injectable
2322
+ }], ctorParameters: function () { return [{ type: i0.Injector }]; } });
2323
+
2324
+ function mapYzSideToYelonMenu(menus) {
2325
+ menus.forEach(menu => {
2326
+ menu.badgeDot = menu.badge_dot || null;
2327
+ menu.badgeStatus = menu.badge_status || null;
2328
+ menu.shortcutRoot = menu.shortcut_root || null;
2329
+ menu.reuse = true;
2330
+ if (menu.children) {
2331
+ mapYzSideToYelonMenu(menu.children);
2332
+ }
2333
+ });
2334
+ }
2335
+ function generateAbility(menus, abilities, prefix) {
2336
+ menus.forEach(menu => {
2337
+ if (menu.link) {
2338
+ prefix += menu.link;
2339
+ }
2340
+ else {
2341
+ prefix += '';
2342
+ }
2343
+ if (menu.menuAuths) {
2344
+ menu.menuAuths.forEach((a) => {
2345
+ abilities.push(`${prefix}:${a}`);
2346
+ abilities.push(a);
2347
+ });
2348
+ }
2349
+ if (menu.children) {
2350
+ generateAbility(menu.children, abilities, prefix);
2351
+ }
2352
+ });
2353
+ }
2354
+ class YzStartupService {
2355
+ constructor(iconSrv, menuService, i18n, settingService, aclService, titleService, yzAuthService, cacheService, configService) {
2356
+ this.menuService = menuService;
2357
+ this.i18n = i18n;
2358
+ this.settingService = settingService;
2359
+ this.aclService = aclService;
2360
+ this.titleService = titleService;
2361
+ this.yzAuthService = yzAuthService;
2362
+ this.cacheService = cacheService;
2363
+ this.configService = configService;
2364
+ this.bis = BUSINESS_DEFAULT_CONFIG;
2365
+ this.bis = mergeBisConfig(this.configService);
2366
+ iconSrv.addIcon(...ICONS);
2367
+ }
2368
+ load() {
2369
+ log$1('startup.service: ', 'load');
2370
+ const defaultLang = this.i18n.defaultLang;
2371
+ return this.i18n.loadLangData(defaultLang).pipe(mergeMap(langData => {
2372
+ log$1('startup.service: ', 'set i18n, defaultLang->', defaultLang, ' langData->', langData);
2373
+ this.i18n.use(defaultLang, langData);
2374
+ return of(null);
2375
+ }), mergeMap(() => {
2376
+ return this.yzAuthService.login();
2377
+ }), mergeMap(v => {
2378
+ // preloader finish
2379
+ this.systemInit();
2380
+ log$1('startup.service: preloader finish');
2381
+ const win = window;
2382
+ if (win && win.appBootstrap) {
2383
+ win.appBootstrap();
2384
+ }
2385
+ return of(v);
2386
+ }));
2387
+ }
2388
+ systemInit() {
2389
+ log$1('startup.service: system init');
2390
+ // user
2391
+ const user = this.cacheService.get('_yz_user', { mode: 'none' });
2392
+ // menu
2393
+ const ms = deepCopy(user.menu).filter((m) => m.systemCode && m.systemCode === this.bis.systemCode);
2394
+ mapYzSideToYelonMenu(ms);
2395
+ const currentMenu = ms.pop() || [];
2396
+ this.menuService.add([currentMenu]);
2397
+ // logo app
2398
+ this.settingService.setApp({ name: currentMenu.text, description: currentMenu.intro });
2399
+ this.settingService.setUser({
2400
+ name: user.realname || 'no name',
2401
+ avatar: `${this.bis.baseUrl}/filecenter/file/${user.avatarId}` || '',
2402
+ email: user.email || 'no email'
2403
+ });
2404
+ // title
2405
+ this.titleService.default = currentMenu && currentMenu.text ? currentMenu.text : 'default application name';
2406
+ this.titleService.setTitle(currentMenu && currentMenu.text ? currentMenu.text : 'no title');
2407
+ // acl
2408
+ const abilities = [];
2409
+ generateAbility([currentMenu], abilities, '');
2410
+ this.aclService.attachRole((user === null || user === void 0 ? void 0 : user.roles.map((role) => {
2411
+ return role.roleValue;
2412
+ }).filter((a) => !!a)) || []);
2413
+ this.aclService.attachAbility(abilities);
2414
+ // cache current
2415
+ this.cacheService.set('_yz_current', {
2416
+ text: currentMenu.text,
2417
+ intro: currentMenu.intro,
2418
+ icon: currentMenu.appIconUrl
2419
+ });
2420
+ }
2421
+ }
2422
+ YzStartupService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YzStartupService, deps: [{ token: i9.NzIconService }, { token: i1.MenuService }, { token: YUNZAI_I18N_TOKEN }, { token: i1.SettingsService }, { token: i3$5.ACLService }, { token: i1.TitleService }, { token: YzAuthService }, { token: i2$1.CacheService }, { token: i1$2.YunzaiConfigService }], target: i0.ɵɵFactoryTarget.Injectable });
2423
+ YzStartupService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YzStartupService });
2424
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: YzStartupService, decorators: [{
2425
+ type: Injectable
2426
+ }], ctorParameters: function () {
2427
+ return [{ type: i9.NzIconService }, { type: i1.MenuService }, { type: YzI18NService, decorators: [{
2428
+ type: Inject,
2429
+ args: [YUNZAI_I18N_TOKEN]
2430
+ }] }, { type: i1.SettingsService }, { type: i3$5.ACLService }, { type: i1.TitleService }, { type: YzAuthService }, { type: i2$1.CacheService }, { type: i1$2.YunzaiConfigService }];
2431
+ } });
2432
+ function YzStartupServiceFactory(startupService) {
2433
+ return () => startupService.load();
2434
+ }
2435
+ //@ts-ignore
2436
+ const YZ_APPINIT_PROVIDES = [
2437
+ YzStartupService,
2438
+ {
2439
+ provide: APP_INITIALIZER,
2440
+ useFactory: YzStartupServiceFactory,
2441
+ deps: [YzStartupService],
2442
+ multi: true
2443
+ }
2444
2444
  ];
2445
2445
 
2446
- // export * from './contact/contact.component';
2447
- // export * from './contact/contact.service';
2446
+ class PathToRegexpService {
2447
+ constructor() {
2448
+ this.DEFAULT_DELIMITER = '/';
2449
+ this.PATH_REGEXP = new RegExp(['(\\\\.)', '(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?'].join('|'), 'g');
2450
+ }
2451
+ parse(str, options) {
2452
+ const tokens = [];
2453
+ let key = 0;
2454
+ let index = 0;
2455
+ let path = '';
2456
+ const defaultDelimiter = (options && options.delimiter) || this.DEFAULT_DELIMITER;
2457
+ const whitelist = (options && options.whitelist) || undefined;
2458
+ let pathEscaped = false;
2459
+ let res;
2460
+ while ((res = this.PATH_REGEXP.exec(str)) !== null) {
2461
+ const m = res[0];
2462
+ const escaped = res[1];
2463
+ const offset = res.index;
2464
+ path += str.slice(index, offset);
2465
+ index = offset + m.length;
2466
+ // Ignore already escaped sequences.
2467
+ if (escaped) {
2468
+ path += escaped[1];
2469
+ pathEscaped = true;
2470
+ continue;
2471
+ }
2472
+ let prev = '';
2473
+ const name = res[2];
2474
+ const capture = res[3];
2475
+ const group = res[4];
2476
+ const modifier = res[5];
2477
+ if (!pathEscaped && path.length) {
2478
+ const k = path.length - 1;
2479
+ const c = path[k];
2480
+ const matches = whitelist ? whitelist.indexOf(c) > -1 : true;
2481
+ if (matches) {
2482
+ prev = c;
2483
+ path = path.slice(0, k);
2484
+ }
2485
+ }
2486
+ // Push the current path onto the tokens.
2487
+ if (path) {
2488
+ tokens.push(path);
2489
+ path = '';
2490
+ pathEscaped = false;
2491
+ }
2492
+ const repeat = modifier === '+' || modifier === '*';
2493
+ const optional = modifier === '?' || modifier === '*';
2494
+ const pattern = capture || group;
2495
+ const delimiter = prev || defaultDelimiter;
2496
+ tokens.push({
2497
+ name: name || key++,
2498
+ prefix: prev,
2499
+ delimiter: delimiter,
2500
+ optional: optional,
2501
+ repeat: repeat,
2502
+ pattern: pattern
2503
+ ? this.escapeGroup(pattern)
2504
+ : `[^${this.escapeString(delimiter === defaultDelimiter ? delimiter : delimiter + defaultDelimiter)}]+?`
2505
+ });
2506
+ }
2507
+ // Push any remaining characters.
2508
+ if (path || index < str.length) {
2509
+ tokens.push(path + str.substr(index));
2510
+ }
2511
+ return tokens;
2512
+ }
2513
+ compile(str, options) {
2514
+ return this.tokensToFunction(this.parse(str, options), options);
2515
+ }
2516
+ tokensToFunction(tokens, options) {
2517
+ const matches = new Array(tokens.length);
2518
+ for (let i = 0; i < tokens.length; i++) {
2519
+ if (typeof tokens[i] === 'object') {
2520
+ matches[i] = new RegExp(`^(?:${tokens[i].pattern})$`, this.flags(options));
2521
+ }
2522
+ }
2523
+ return function (data, options) {
2524
+ let path = '';
2525
+ const encode = (options && options.encode) || encodeURIComponent;
2526
+ const validate = options ? options.validate !== false : true;
2527
+ for (let i = 0; i < tokens.length; i++) {
2528
+ const token = tokens[i];
2529
+ if (typeof token === 'string') {
2530
+ path += token;
2531
+ continue;
2532
+ }
2533
+ const value = data ? data[token.name] : undefined;
2534
+ let segment;
2535
+ if (Array.isArray(value)) {
2536
+ if (!token.repeat) {
2537
+ throw new TypeError(`Expected "${token.name}" to not repeat, but got array`);
2538
+ }
2539
+ if (value.length === 0) {
2540
+ if (token.optional) {
2541
+ continue;
2542
+ }
2543
+ throw new TypeError(`Expected "${token.name}" to not be empty`);
2544
+ }
2545
+ for (let j = 0; j < value.length; j++) {
2546
+ segment = encode(value[j], token);
2547
+ if (validate && !matches[i].test(segment)) {
2548
+ throw new TypeError(`Expected all "${token.name}" to match "${token.pattern}"`);
2549
+ }
2550
+ path += (j === 0 ? token.prefix : token.delimiter) + segment;
2551
+ }
2552
+ continue;
2553
+ }
2554
+ if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
2555
+ segment = encode(String(value), token);
2556
+ if (validate && !matches[i].test(segment)) {
2557
+ throw new TypeError(`Expected "${token.name}" to match "${token.pattern}", but got "${segment}"`);
2558
+ }
2559
+ path += token.prefix + segment;
2560
+ continue;
2561
+ }
2562
+ if (token.optional) {
2563
+ continue;
2564
+ }
2565
+ throw new TypeError(`Expected "${token.name}" to be ${token.repeat ? 'an array' : 'a string'}`);
2566
+ }
2567
+ return path;
2568
+ };
2569
+ }
2570
+ escapeString(str) {
2571
+ return str.replace(/([.+*?=^!:${}()[\]|/\\])/g, '\\$1');
2572
+ }
2573
+ escapeGroup(group) {
2574
+ return group.replace(/([=!:$/()])/g, '\\$1');
2575
+ }
2576
+ flags(options) {
2577
+ return options && options.sensitive ? '' : 'i';
2578
+ }
2579
+ regexpToRegexp(path, keys) {
2580
+ if (!keys) {
2581
+ return path;
2582
+ }
2583
+ const groups = path.source.match(/\((?!\?)/g);
2584
+ if (groups) {
2585
+ for (let i = 0; i < groups.length; i++) {
2586
+ keys.push({
2587
+ name: i,
2588
+ prefix: null,
2589
+ delimiter: null,
2590
+ optional: false,
2591
+ repeat: false,
2592
+ pattern: null
2593
+ });
2594
+ }
2595
+ }
2596
+ return path;
2597
+ }
2598
+ arrayToRegexp(path, keys, options) {
2599
+ const parts = [];
2600
+ for (let i = 0; i < path.length; i++) {
2601
+ parts.push(this.pathToRegexp(path[i], keys, options).source);
2602
+ }
2603
+ return new RegExp(`(?:${parts.join('|')})`, this.flags(options));
2604
+ }
2605
+ stringToRegexp(path, keys, options) {
2606
+ return this.tokensToRegExp(this.parse(path, options), keys, options);
2607
+ }
2608
+ tokensToRegExp(tokens, keys, options) {
2609
+ options = options || {};
2610
+ const strict = options.strict;
2611
+ const start = options.start !== false;
2612
+ const end = options.end !== false;
2613
+ const delimiter = options.delimiter || this.DEFAULT_DELIMITER;
2614
+ const endsWith = []
2615
+ .concat(options.endsWith || [])
2616
+ .map(this.escapeString)
2617
+ .concat('$')
2618
+ .join('|');
2619
+ let route = start ? '^' : '';
2620
+ for (let i = 0; i < tokens.length; i++) {
2621
+ const token = tokens[i];
2622
+ if (typeof token === 'string') {
2623
+ route += this.escapeString(token);
2624
+ }
2625
+ else {
2626
+ const capture = token.repeat
2627
+ ? `(?:${token.pattern})(?:${this.escapeString(token.delimiter)}(?:${token.pattern}))*`
2628
+ : token.pattern;
2629
+ if (keys) {
2630
+ keys.push(token);
2631
+ }
2632
+ if (token.optional) {
2633
+ if (!token.prefix) {
2634
+ route += `(${capture})?`;
2635
+ }
2636
+ else {
2637
+ route += `(?:${this.escapeString(token.prefix)}(${capture}))?`;
2638
+ }
2639
+ }
2640
+ else {
2641
+ route += `${this.escapeString(token.prefix)}(${capture})`;
2642
+ }
2643
+ }
2644
+ }
2645
+ if (end) {
2646
+ if (!strict) {
2647
+ route += `(?:${this.escapeString(delimiter)})?`;
2648
+ }
2649
+ route += endsWith === '$' ? '$' : `(?=${endsWith})`;
2650
+ }
2651
+ else {
2652
+ const endToken = tokens[tokens.length - 1];
2653
+ const isEndDelimited = typeof endToken === 'string' ? endToken[endToken.length - 1] === delimiter : endToken === undefined;
2654
+ if (!strict) {
2655
+ route += `(?:${this.escapeString(delimiter)}(?=${endsWith}))?`;
2656
+ }
2657
+ if (!isEndDelimited) {
2658
+ route += `(?=${this.escapeString(delimiter)}|${endsWith})`;
2659
+ }
2660
+ }
2661
+ return new RegExp(route, this.flags(options));
2662
+ }
2663
+ pathToRegexp(path, keys, options) {
2664
+ if (path instanceof RegExp) {
2665
+ return this.regexpToRegexp(path, keys);
2666
+ }
2667
+ if (Array.isArray(path)) {
2668
+ return this.arrayToRegexp(/** @type {!Array} */ path, keys, options);
2669
+ }
2670
+ return this.stringToRegexp(/** @type {string} */ path, keys, options);
2671
+ }
2672
+ }
2673
+ PathToRegexpService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: PathToRegexpService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2674
+ PathToRegexpService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: PathToRegexpService, providedIn: 'root' });
2675
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: PathToRegexpService, decorators: [{
2676
+ type: Injectable,
2677
+ args: [{
2678
+ providedIn: 'root'
2679
+ }]
2680
+ }], ctorParameters: function () { return []; } });
2681
+
2682
+ class ActGuard {
2683
+ constructor(configService, cacheService, pathToRegexp, router) {
2684
+ this.configService = configService;
2685
+ this.cacheService = cacheService;
2686
+ this.pathToRegexp = pathToRegexp;
2687
+ this.router = router;
2688
+ this.bis = BUSINESS_DEFAULT_CONFIG;
2689
+ this.menus = [];
2690
+ this.links = [];
2691
+ log$1('act: ');
2692
+ this.bis = mergeBisConfig(this.configService);
2693
+ log$1('act: config ', this.bis);
2694
+ const user = this.cacheService.get('_yz_user', { mode: 'none' });
2695
+ log$1('act: user ', user);
2696
+ this.menus = deepCopy(user.menu).filter((m) => m.systemCode && m.systemCode === this.bis.systemCode);
2697
+ log$1('act: menus ', this.menus);
2698
+ this.getAllLinks(this.menus, this.links);
2699
+ log$1('act: links ', this.links);
2700
+ }
2701
+ canActivate(_, state) {
2702
+ log$1('act: can activate ', state);
2703
+ if (this.preHandle(state)) {
2704
+ return true;
2705
+ }
2706
+ log$1('act: can activate child prehandle success');
2707
+ let canactivate = false;
2708
+ this.links.forEach((link) => {
2709
+ const regexp = this.pathToRegexp.stringToRegexp(link, null, null);
2710
+ log$1(`act: ${link} test ${state.url.split('?')[0]}`);
2711
+ if (regexp.test(state.url.split('?')[0])) {
2712
+ canactivate = true;
2713
+ log$1(`act: test value ${canactivate}`);
2714
+ return;
2715
+ }
2716
+ });
2717
+ if (canactivate) {
2718
+ log$1(`act: test sucess`);
2719
+ return true;
2720
+ }
2721
+ else {
2722
+ log$1(`act: test error`);
2723
+ this.router.navigate(['displayIndex']);
2724
+ return false;
2725
+ }
2726
+ }
2727
+ canActivateChild(_, state) {
2728
+ log$1('act: can activate child ', state);
2729
+ if (this.preHandle(state)) {
2730
+ return true;
2731
+ }
2732
+ log$1('act: can activate child prehandle success');
2733
+ let canactivate = false;
2734
+ this.links.forEach((link) => {
2735
+ const regexp = this.pathToRegexp.stringToRegexp(link, null, null);
2736
+ if (regexp.test(state.url.split('?')[0])) {
2737
+ log$1(`act: ${link} test ${state.url.split('?')[0]}`);
2738
+ canactivate = true;
2739
+ log$1(`act: test value ${canactivate}`);
2740
+ return;
2741
+ }
2742
+ });
2743
+ if (canactivate) {
2744
+ log$1(`act: test sucess`);
2745
+ return true;
2746
+ }
2747
+ else {
2748
+ log$1(`act: test error`);
2749
+ this.router.navigate(['displayIndex']);
2750
+ return false;
2751
+ }
2752
+ }
2753
+ preHandle(state) {
2754
+ return (state.url.includes('error') ||
2755
+ state.url.includes('exception') ||
2756
+ state.url.includes('displayIndex') ||
2757
+ state.url === '' ||
2758
+ state.url === null ||
2759
+ state.url === '/' ||
2760
+ state.url.includes('iframePage'));
2761
+ }
2762
+ getAllLinks(menu, links) {
2763
+ menu.forEach((sider) => {
2764
+ if (sider.link) {
2765
+ links.push(sider.link);
2766
+ }
2767
+ if (sider.children && sider.children.length > 0) {
2768
+ this.getAllLinks(sider.children, links);
2769
+ }
2770
+ });
2771
+ }
2772
+ }
2773
+ ActGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ActGuard, deps: [{ token: i1$2.YunzaiConfigService }, { token: i2$1.CacheService }, { token: PathToRegexpService }, { token: i17.Router }], target: i0.ɵɵFactoryTarget.Injectable });
2774
+ ActGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ActGuard, providedIn: 'root' });
2775
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ActGuard, decorators: [{
2776
+ type: Injectable,
2777
+ args: [{
2778
+ providedIn: 'root'
2779
+ }]
2780
+ }], ctorParameters: function () { return [{ type: i1$2.YunzaiConfigService }, { type: i2$1.CacheService }, { type: PathToRegexpService }, { type: i17.Router }]; } });
2448
2781
 
2449
- /**
2450
- * Generated bundle index. Do not edit.
2782
+ /**
2783
+ * Generated bundle index. Do not edit.
2451
2784
  */
2452
2785
 
2453
- export { ActGuard, BUSINESS_DEFAULT_CONFIG, PathToRegexpService, STOMP_DEFAULT_CONFIG, TOPIC, YZ_APPINIT_PROVIDES, YunzaiLayoutModule, YzAuthService, YzDefaultInterceptor, YzHeaderApplicationComponent, YzHeaderClearStorageComponent, YzHeaderFullScreenComponent, YzHeaderI18NComponent, YzHeaderNotifyComponent, YzHeaderThemBtnComponent, YzHeaderUserComponent, YzI18NService, YzLayoutBasicComponent, YzStartupService, YzStartupServiceFactory, YzStompService, generateAbility, mapYzSideToYelonMenu, mergeBisConfig, mergeStompConfig, ɵ0, ContactComponent as ɵa, ContactService as ɵb, YzHeaderApplicationComponent as ɵc, YzHeaderNotifyComponent as ɵd, YzHeaderThemBtnComponent as ɵe, YzHeaderUserComponent as ɵf, YzHeaderFullScreenComponent as ɵg, YzHeaderClearStorageComponent as ɵh, YzHeaderI18NComponent as ɵi };
2454
- //# sourceMappingURL=layout.js.map
2786
+ export { ActGuard, BUSINESS_DEFAULT_CONFIG, ContactComponent, ContactService, PathToRegexpService, STOMP_DEFAULT_CONFIG, TOPIC, YZ_APPINIT_PROVIDES, YunzaiLayoutModule, YzAuthService, YzDefaultInterceptor, YzHeaderApplicationComponent, YzHeaderClearStorageComponent, YzHeaderFullScreenComponent, YzHeaderI18NComponent, YzHeaderNotifyComponent, YzHeaderThemBtnComponent, YzHeaderUserComponent, YzI18NService, YzLayoutBasicComponent, YzStartupService, YzStartupServiceFactory, YzStompService, generateAbility, mapYzSideToYelonMenu, mergeBisConfig, mergeStompConfig };
2787
+ //# sourceMappingURL=layout.mjs.map