eoss-ui 0.5.80 → 0.5.81-beta

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 (119) hide show
  1. package/lib/button-group.js +278 -264
  2. package/lib/button.js +70 -68
  3. package/lib/calendar.js +2 -2
  4. package/lib/card.js +2 -2
  5. package/lib/cascader.js +2 -2
  6. package/lib/checkbox-group.js +70 -69
  7. package/lib/clients.js +2 -2
  8. package/lib/config/api.js +1 -0
  9. package/lib/data-table-form.js +68 -66
  10. package/lib/data-table.js +76 -74
  11. package/lib/date-picker.js +70 -68
  12. package/lib/dialog.js +70 -69
  13. package/lib/enterprise.js +2 -2
  14. package/lib/eoss-ui.common.js +5670 -797
  15. package/lib/error-page.js +2 -2
  16. package/lib/flow-group.js +70 -68
  17. package/lib/flow-list.js +73 -71
  18. package/lib/flow.js +94 -92
  19. package/lib/form.js +70 -69
  20. package/lib/handle-user.js +71 -69
  21. package/lib/handler.js +74 -72
  22. package/lib/icon.js +3731 -12
  23. package/lib/icons.js +3 -3
  24. package/lib/index.js +1 -1
  25. package/lib/input-number.js +70 -68
  26. package/lib/input.js +70 -68
  27. package/lib/label.js +2 -2
  28. package/lib/layout.js +2 -2
  29. package/lib/login.js +146 -104
  30. package/lib/main.js +5643 -825
  31. package/lib/menu.js +2 -2
  32. package/lib/nav.js +70 -68
  33. package/lib/notify.js +72 -70
  34. package/lib/page.js +70 -68
  35. package/lib/pagination.js +2 -2
  36. package/lib/player.js +74 -72
  37. package/lib/qr-code.js +72 -70
  38. package/lib/radio-group.js +70 -68
  39. package/lib/retrial-auth.js +72 -70
  40. package/lib/select-ganged.js +70 -68
  41. package/lib/select.js +70 -68
  42. package/lib/selector-panel.js +73 -72
  43. package/lib/selector.js +79 -77
  44. package/lib/sizer.js +70 -68
  45. package/lib/steps.js +70 -68
  46. package/lib/switch.js +77 -75
  47. package/lib/table-form.js +70 -68
  48. package/lib/tabs-panel.js +2 -2
  49. package/lib/tabs.js +70 -68
  50. package/lib/theme-chalk/base.css +1 -1
  51. package/lib/theme-chalk/fonts/iconfont.ttf +0 -0
  52. package/lib/theme-chalk/fonts/iconfont.woff +0 -0
  53. package/lib/theme-chalk/icon.css +1 -1
  54. package/lib/theme-chalk/index.css +1 -1
  55. package/lib/theme-chalk/login.css +1 -1
  56. package/lib/theme-chalk/main.css +1 -1
  57. package/lib/theme-chalk/menu.css +1 -1
  58. package/lib/theme-chalk/simplicity.css +1 -0
  59. package/lib/theme-chalk/sizer.css +1 -1
  60. package/lib/theme-chalk/upload.css +1 -1
  61. package/lib/tips.js +71 -69
  62. package/lib/toolbar.js +2 -2
  63. package/lib/tree-group.js +70 -68
  64. package/lib/tree.js +70 -68
  65. package/lib/upload.js +93 -92
  66. package/lib/utils/util.js +1 -1
  67. package/lib/wujie.js +70 -68
  68. package/lib/wxlogin.js +213 -211
  69. package/package.json +2 -2
  70. package/packages/data-table/src/main.vue +1 -0
  71. package/packages/handler/src/main.vue +3 -1
  72. package/packages/icon/src/main.vue +31 -10
  73. package/packages/icons/src/icon.json +1 -1
  74. package/packages/login/src/main.vue +13 -6
  75. package/packages/main/src/default/index.vue +2199 -0
  76. package/packages/main/src/main.vue +30 -2210
  77. package/packages/main/src/simplicity/apps.vue +301 -0
  78. package/packages/main/src/simplicity/avatar.vue +68 -0
  79. package/packages/main/src/simplicity/handler.vue +148 -0
  80. package/packages/main/src/simplicity/index.vue +1515 -0
  81. package/packages/main/src/simplicity/lists.vue +84 -0
  82. package/packages/main/src/simplicity/menu-list.vue +74 -0
  83. package/packages/main/src/simplicity/message.vue +237 -0
  84. package/packages/main/src/simplicity/notice.vue +145 -0
  85. package/packages/main/src/simplicity/settings.vue +119 -0
  86. package/packages/main/src/simplicity/sub-menu.vue +120 -0
  87. package/packages/main/src/simplicity/user.vue +243 -0
  88. package/packages/main/src/simplicity/userinfo.vue +302 -0
  89. package/packages/theme-chalk/lib/base.css +1 -1
  90. package/packages/theme-chalk/lib/fonts/iconfont.ttf +0 -0
  91. package/packages/theme-chalk/lib/fonts/iconfont.woff +0 -0
  92. package/packages/theme-chalk/lib/icon.css +1 -1
  93. package/packages/theme-chalk/lib/index.css +1 -1
  94. package/packages/theme-chalk/lib/login.css +1 -1
  95. package/packages/theme-chalk/lib/main.css +1 -1
  96. package/packages/theme-chalk/lib/menu.css +1 -1
  97. package/packages/theme-chalk/lib/simplicity.css +1 -0
  98. package/packages/theme-chalk/lib/sizer.css +1 -1
  99. package/packages/theme-chalk/lib/upload.css +1 -1
  100. package/packages/theme-chalk/src/base.scss +1 -0
  101. package/packages/theme-chalk/src/common/var.scss +4 -0
  102. package/packages/theme-chalk/src/fonts/iconfont.ttf +0 -0
  103. package/packages/theme-chalk/src/fonts/iconfont.woff +0 -0
  104. package/packages/theme-chalk/src/icon.scss +4 -4
  105. package/packages/theme-chalk/src/login.scss +644 -632
  106. package/packages/theme-chalk/src/main.scss +6 -2
  107. package/packages/theme-chalk/src/simplicity.scss +545 -0
  108. package/packages/upload/src/main.vue +15 -17
  109. package/src/config/api.js +1 -0
  110. package/src/index.js +1 -1
  111. package/src/utils/util.js +1 -1
  112. package/lib/theme-chalk/mainComp.css +0 -0
  113. package/packages/main/src/async-component/index.vue +0 -87
  114. package/packages/theme-chalk/lib/mainComp.css +0 -0
  115. package/packages/theme-chalk/src/mainComp.scss +0 -0
  116. /package/packages/main/src/{message.vue → default/message.vue} +0 -0
  117. /package/packages/main/src/{notice.vue → default/notice.vue} +0 -0
  118. /package/packages/main/src/{settings.vue → default/settings.vue} +0 -0
  119. /package/packages/main/src/{userinfo.vue → default/userinfo.vue} +0 -0
@@ -0,0 +1,2199 @@
1
+ <template>
2
+ <div class="es-main" :class="{ 'es-main-topside': layout === 'topside' }">
3
+ <div
4
+ v-if="showHeader"
5
+ class="es-main-header"
6
+ :style="{ backgroundImage: headerImg ? 'url(' + headerImg + ')' : '' }"
7
+ >
8
+ <img
9
+ class="es-main-logo"
10
+ :src="logoUrl"
11
+ v-if="layout !== 'topside' && logoUrl && showDefault"
12
+ />
13
+ <div class="es-main-top-nav">
14
+ <es-menu
15
+ v-if="navs.length"
16
+ class="es-fourth-tabs"
17
+ mode="horizontal"
18
+ :icons="icons"
19
+ :menu-icon="menuIcon"
20
+ :sub-icon="subIcon"
21
+ :popperClass="`el-menu--popup-${layout}`"
22
+ :data="navs"
23
+ :deep="layout === 'topnav'"
24
+ :height="layout === 'topnav' ? '370px' : undefined"
25
+ :default-active="topActive"
26
+ @select="
27
+ (res) => {
28
+ handleSelect(res, 'nav');
29
+ }
30
+ "
31
+ ></es-menu>
32
+ </div>
33
+ <es-handler
34
+ v-if="showDefault"
35
+ :userModel="userModel"
36
+ :hide="hide"
37
+ :subSystem="subsystem"
38
+ :online="online"
39
+ :application="application"
40
+ :storage="storage"
41
+ :notice="notice"
42
+ :data="handleData"
43
+ :max-height="_maxHeight"
44
+ @change="handleJobChange"
45
+ @select="
46
+ (res) => {
47
+ handleSelect(res, 'sys');
48
+ }
49
+ "
50
+ @click="handleClick"
51
+ ></es-handler>
52
+ </div>
53
+ <div class="es-main-box" v-if="reset">
54
+ <div class="es-main-left" v-if="layout !== 'topnav' && showSide">
55
+ <div
56
+ class="es-main-side"
57
+ :class="{ 'es-main-topside': layout === 'topside' }"
58
+ v-if="layout === 'topside' || layout === 'side'"
59
+ >
60
+ <div class="es-main-side-logo" v-if="layout === 'topside'">
61
+ <img class="es-main-logo" :src="logoUrl" v-if="logoUrl" />
62
+ </div>
63
+ <es-handle-user
64
+ :data="{ type: 'user' }"
65
+ :userModel="userModel"
66
+ @click="handleClick"
67
+ ></es-handle-user>
68
+ </div>
69
+ <es-nav
70
+ v-if="showMenu && showDefault"
71
+ :hide-sub-menu="hideSubMenu"
72
+ :is-top="layout == 'topside'"
73
+ :overlap="layout == 'side'"
74
+ :data="menu"
75
+ :default-active="active"
76
+ :width="navsWidth"
77
+ :nav-width="_navWidth"
78
+ :icons="icons"
79
+ :menu-icon="menuIcon"
80
+ :sub-icon="subIcon"
81
+ :biserial="biserial"
82
+ :title="showNavTitle ? title : false"
83
+ :showCollapse="
84
+ showNavTitle ? (layout == 'side' ? false : showCollapse) : false
85
+ "
86
+ :menu-tips="menuTips"
87
+ :is-default="isDefault"
88
+ :paddingLeft="navPaddingLeft"
89
+ @open="
90
+ (res) => {
91
+ handleSelect(res, 'menu', true);
92
+ }
93
+ "
94
+ @trigger="
95
+ (res) => {
96
+ handleSelect(res, 'sub');
97
+ }
98
+ "
99
+ @select="
100
+ (res) => {
101
+ handleSelect(res, 'menu');
102
+ }
103
+ "
104
+ >
105
+ </es-nav>
106
+ </div>
107
+ <div class="es-main-body">
108
+ <div v-if="fourthTabs" class="es-fourth-tabs">
109
+ <es-menu
110
+ mode="horizontal"
111
+ :data="tabs"
112
+ :titleIcons="false"
113
+ :default-active="tabsId"
114
+ :menu-icon="menuIcon"
115
+ :menu-tips="menuTips"
116
+ @select="
117
+ (res) => {
118
+ handleSelect(res, 'tabs');
119
+ }
120
+ "
121
+ ></es-menu>
122
+ </div>
123
+ <div class="es-body">
124
+ <div
125
+ class="es-body-main"
126
+ v-loading="pageLoading"
127
+ element-loading-background="rgba(0, 0, 0, 0.5)"
128
+ v-if="showPage"
129
+ >
130
+ <iframe
131
+ v-if="method === 'iframe'"
132
+ :id="iframeId"
133
+ :name="iframeId"
134
+ frameborder="0"
135
+ width="100%"
136
+ height="100%"
137
+ :src="page"
138
+ ></iframe>
139
+ <template v-else-if="method === 'wujie' && refresh">
140
+ <es-wujie
141
+ :show="true"
142
+ :props="wjProps"
143
+ :attrs="wjAttrs"
144
+ :name="wjName"
145
+ :url="page"
146
+ ></es-wujie>
147
+ </template>
148
+ <template v-else-if="method === 'router' && refresh">
149
+ <router-view v-if="!isKeepAlive" :key="routerKey" />
150
+ <keep-alive>
151
+ <router-view v-if="isKeepAlive" :key="routerKey"
152
+ /></keep-alive>
153
+ </template>
154
+ </div>
155
+ <message
156
+ v-if="showMsg"
157
+ ref="message"
158
+ :total.sync="notice"
159
+ :visible.sync="showMsg"
160
+ :winopen="winopen"
161
+ @ignore="handleChange"
162
+ @handle="handleMenuTips"
163
+ ></message>
164
+ </div>
165
+ </div>
166
+ </div>
167
+ <settings
168
+ v-bind="$attrs"
169
+ :theme="color"
170
+ :predefine="themes"
171
+ :visible.sync="showSet"
172
+ :layout="layout"
173
+ @change="handleChange"
174
+ @layout="handleLayout"
175
+ ></settings>
176
+ <es-dialog
177
+ v-if="showUserInfo"
178
+ title="用户信息配置"
179
+ :height="userHeight"
180
+ :visible.sync="showUserInfo"
181
+ >
182
+ <slot name="user">
183
+ <userinfo
184
+ v-bind="$attrs"
185
+ :contents="userInfoContents"
186
+ @change="handleUserModel"
187
+ @reGetConfig="reGetConfig"
188
+ >
189
+ <slot name="userInfo"></slot>
190
+ </userinfo>
191
+ </slot>
192
+ </es-dialog>
193
+ <notice :data="sysMsg" :winopen="winopen" @opened="handleOpened"></notice>
194
+ <es-dialog :title="dialog.title" :visible.sync="dialog.show" size="md">
195
+ <iframe
196
+ v-if="dialog.show"
197
+ width="100%"
198
+ height="100%"
199
+ frameborder="0"
200
+ :src="dialog.src"
201
+ ></iframe>
202
+ </es-dialog>
203
+ </div>
204
+ </template>
205
+ <script>
206
+ import userinfo from './userinfo.vue';
207
+ import settings from './settings.vue';
208
+ import message from './message.vue';
209
+ import notice from './notice.vue';
210
+ import {
211
+ //authCenter,
212
+ wss,
213
+ topic,
214
+ mainConfig,
215
+ updateUserCustomInfo,
216
+ getComplexApplications,
217
+ getComplexApplicationsNew,
218
+ mainDetail
219
+ } from 'eoss-ui/src/config/api.js';
220
+ import store from 'eoss-ui/src/utils/store';
221
+ import util from 'eoss-ui/src/utils/util';
222
+ const isIE = navigator.userAgent.indexOf('MSIE') != -1;
223
+ const log = util.getParams('console');
224
+ const appCode = util.getParams('appCode') || util.getParams('appcode');
225
+ export default {
226
+ name: 'EsMainDefault',
227
+ inheritAttrs: false,
228
+ provide() {
229
+ return {
230
+ esMain: this
231
+ };
232
+ },
233
+ components: {
234
+ userinfo,
235
+ settings,
236
+ message,
237
+ notice
238
+ },
239
+ props: {
240
+ maxHeight: String,
241
+ //菜单导航地址
242
+ menuUrl: String,
243
+ //菜单展开关闭图标
244
+ icons: Object,
245
+ //菜单前置默认图标
246
+ menuIcon: String,
247
+ //子菜单是否显示前置图标
248
+ subIcon: {
249
+ type: Boolean,
250
+ default: true
251
+ },
252
+ //logo
253
+ logo: String,
254
+ //菜单显示类型
255
+ scene: {
256
+ type: String,
257
+ default: 'default'
258
+ },
259
+ //host
260
+ host: {
261
+ type: String,
262
+ default: ''
263
+ },
264
+ param: {
265
+ type: Object,
266
+ default() {
267
+ return {};
268
+ }
269
+ },
270
+ header: {
271
+ type: Boolean,
272
+ default: true
273
+ },
274
+ sideNav: {
275
+ type: Boolean,
276
+ default: true
277
+ },
278
+ //操作栏配置
279
+ handleData: Array,
280
+ //本地导航
281
+ data: Array,
282
+ //头部背景图片
283
+ headerImage: String,
284
+ //默认主题颜色
285
+ theme: {
286
+ type: String,
287
+ default: '#409eff'
288
+ },
289
+ //主题颜色选择颜色集合
290
+ themes: Array,
291
+ //需要隐藏的头部功能
292
+ hides: Object,
293
+ //储存数据
294
+ storage: {
295
+ type: String,
296
+ default() {
297
+ return util.getStorage('storage');
298
+ }
299
+ },
300
+ //是否启用子应用菜单接口
301
+ application: {
302
+ type: Boolean,
303
+ default: false
304
+ },
305
+ //是否显示设置按钮
306
+ set: {
307
+ type: Boolean,
308
+ default: false
309
+ },
310
+ //websocket
311
+ socket: {
312
+ type: Boolean,
313
+ default: true
314
+ },
315
+ //无界微前端属性
316
+ wjProps: Object,
317
+ wjAttrs: Object,
318
+ //socket调试
319
+ console: Boolean,
320
+ //消息办理是否采用window.open的方式打开
321
+ winopen: {
322
+ type: Boolean,
323
+ default: true
324
+ },
325
+ //获取用户信息的接口
326
+ mainConfig: {
327
+ type: String,
328
+ default: mainConfig
329
+ },
330
+ iframeId: {
331
+ type: String,
332
+ default: 'stage'
333
+ },
334
+ routePath: {
335
+ type: String,
336
+ default: '/main'
337
+ },
338
+ setFirstAsDefault: {
339
+ type: Boolean,
340
+ default: true
341
+ },
342
+ pathUrl: {
343
+ type: String,
344
+ default: '/primary'
345
+ },
346
+ keepAlive: Boolean,
347
+ loadWujie: {
348
+ type: Boolean,
349
+ default: true
350
+ },
351
+ downgrade: {
352
+ type: Boolean,
353
+ default: true
354
+ },
355
+ remote: {
356
+ type: Boolean,
357
+ default: true
358
+ },
359
+ isCustomMain: {
360
+ type: Boolean,
361
+ default: false
362
+ },
363
+ userHeight: {
364
+ type: String,
365
+ default: '740px'
366
+ },
367
+ history: {
368
+ type: Boolean,
369
+ default: true
370
+ },
371
+ loadHomePage: {
372
+ type: [Boolean, String],
373
+ default: true
374
+ },
375
+ appCode: String,
376
+ //菜单左边距
377
+ navPaddingLeft: Number,
378
+ navBoxWidth: {
379
+ type: String,
380
+ default: '230px'
381
+ },
382
+ navWidth: String,
383
+ showCollapse: {
384
+ type: Boolean,
385
+ default: true
386
+ },
387
+ onlineView: {
388
+ type: [String, Boolean],
389
+ default: true
390
+ }
391
+ },
392
+ computed: {
393
+ showHeader() {
394
+ return this.isHeader == 0 ? false : this.header;
395
+ },
396
+ _maxHeight() {
397
+ if (this.maxHeight) {
398
+ return this.maxHeight;
399
+ }
400
+ return String(document.body.clientHeight - 77);
401
+ },
402
+ showSide() {
403
+ return this.isSide !== null ? this.isSide : this.sideNav;
404
+ },
405
+ isHomePage() {
406
+ if (util.getParams('applicationid') || util.getParams('applicationId')) {
407
+ return false;
408
+ }
409
+ if (util.getStorage('mainConfig')) {
410
+ let hash = util.win.location.hash;
411
+ if (
412
+ hash &&
413
+ hash.split('?')[0] !== '#/' &&
414
+ hash.split('?')[0] !== '#/main'
415
+ ) {
416
+ return false;
417
+ }
418
+ }
419
+ return true;
420
+ },
421
+ navsWidth() {
422
+ return this.layout === 'topside' ? this.navBoxWidth : undefined;
423
+ },
424
+ _navWidth() {
425
+ return this.layout === 'side'
426
+ ? this.navBoxWidth
427
+ : this.layout === 'topside'
428
+ ? '0'
429
+ : this.navWidth;
430
+ },
431
+ showNavTitle() {
432
+ return this.layout !== 'topside';
433
+ },
434
+ //tabs菜单
435
+ fourthTabs() {
436
+ return this.tabs.length;
437
+ },
438
+ //菜单接口
439
+ action() {
440
+ if (this.menuUrl) {
441
+ return this.menuUrl;
442
+ }
443
+ if (this.application) {
444
+ return getComplexApplicationsNew;
445
+ }
446
+ return getComplexApplications;
447
+ },
448
+ //是否双列右侧菜单
449
+ biserial() {
450
+ if (
451
+ this.layout === 'subsystem' ||
452
+ this.layout === 'topside' ||
453
+ this.application
454
+ ) {
455
+ return false;
456
+ } else {
457
+ return true;
458
+ }
459
+ },
460
+ //隐藏操作按键
461
+ hide() {
462
+ let mainConfig = JSON.parse(util.getStorage('mainConfig'));
463
+ let topRightToolHide = '';
464
+ if (
465
+ mainConfig &&
466
+ mainConfig.subsystemExtend &&
467
+ mainConfig.subsystemExtend.topRightToolHide
468
+ ) {
469
+ topRightToolHide = JSON.parse(
470
+ mainConfig.subsystemExtend.topRightToolHide.replace(
471
+ /(['"])?([a-zA-Z0-9_]+)(['"])?:/g,
472
+ '"$2":'
473
+ )
474
+ );
475
+ }
476
+ if (this.layout === 'subsystem' || this.application) {
477
+ if (this.hides && Object.keys(this.hides).length) {
478
+ return { ...this.hides, set: !this.set, system: false };
479
+ } else if (topRightToolHide && Object.keys(topRightToolHide).length) {
480
+ return { ...topRightToolHide, set: !this.set, system: false };
481
+ } else {
482
+ return { set: !this.set, system: false };
483
+ }
484
+ } else if (this.layout === 'topside' || this.layout === 'side') {
485
+ if (this.hides && Object.keys(this.hides).length) {
486
+ return {
487
+ ...this.hides,
488
+ set: !this.set,
489
+ system: true,
490
+ user: true
491
+ };
492
+ } else if (topRightToolHide && Object.keys(topRightToolHide).length) {
493
+ return {
494
+ ...topRightToolHide,
495
+ set: !this.set,
496
+ system: true,
497
+ user: true
498
+ };
499
+ } else {
500
+ return { set: !this.set, system: true, user: true };
501
+ }
502
+ } else {
503
+ if (this.hides && Object.keys(this.hides).length) {
504
+ return {
505
+ ...this.hides,
506
+ set: !this.set,
507
+ system: true,
508
+ user: true
509
+ };
510
+ } else if (topRightToolHide && Object.keys(topRightToolHide).length) {
511
+ return {
512
+ ...topRightToolHide,
513
+ set: !this.set,
514
+ system: true,
515
+ user: true
516
+ };
517
+ } else {
518
+ return { set: !this.set, system: true };
519
+ }
520
+ }
521
+ },
522
+ logoUrl() {
523
+ if (this.mainLogo) {
524
+ return this.mainLogo;
525
+ }
526
+ return this.logo;
527
+ },
528
+ isConsole() {
529
+ return log ? true : this.console;
530
+ },
531
+ menuCode() {
532
+ return appCode || this.appCode;
533
+ },
534
+ onlineUrl() {
535
+ if (this.onlineView) {
536
+ return typeof this.onlineView == 'string'
537
+ ? this.onlineView
538
+ : '/main/sysuseronline/list.dhtml';
539
+ }
540
+ return false;
541
+ }
542
+ },
543
+ watch: {
544
+ data: {
545
+ deep: true,
546
+ handler() {
547
+ !this.remote && this.renderMenu();
548
+ }
549
+ },
550
+ menuTips: {
551
+ immediate: true,
552
+ deep: true,
553
+ handler(val) {
554
+ if (Object.keys(val).length && this.menus.length) {
555
+ this.setTips(this.menus);
556
+ }
557
+ }
558
+ },
559
+ color: {
560
+ immediate: true,
561
+ handler(val) {
562
+ if (this.set) {
563
+ localStorage.setItem('theme', val);
564
+ util.updateTheme(val);
565
+ }
566
+ }
567
+ }
568
+ },
569
+ data() {
570
+ return {
571
+ layout: this.scene.toLowerCase(),
572
+ showDefault: false,
573
+ themeJSON: {
574
+ logo: { comp: '', data: {} },
575
+ topNav: { comp: '', data: {} },
576
+ leftNav: { comp: '', data: {} },
577
+ copyright: { comp: '', data: {} }
578
+ },
579
+ pageLoading: false,
580
+ wjName: 'singlespa',
581
+ menus: '',
582
+ //头部导航
583
+ navs: [],
584
+ //头部默认选择
585
+ topActive: '',
586
+ //子系统菜单
587
+ subsystem: [],
588
+ //头部子系统子导航默认选中项
589
+ sysId: '',
590
+ //导航默认选择
591
+ active: [],
592
+ //完整导航选中的ID
593
+ actives: [],
594
+ //初始默认选中菜单id
595
+ defaultActive: [],
596
+ //侧边导航
597
+ menu: [],
598
+ //菜单名称
599
+ title: '',
600
+ //菜单提醒气泡
601
+ menuTips: {},
602
+ //面包屑导航
603
+ tabs: [],
604
+ //页签导航默认选中值
605
+ tabsId: '',
606
+ //路由类型
607
+ method: 'router',
608
+ //页面地址
609
+ page: '',
610
+ //选中的地址
611
+ selectPage: '',
612
+ //主页面
613
+ homePage: '',
614
+ //header背景
615
+ mainLogo: null,
616
+ headerImg: this.headerImage,
617
+ //在线人数
618
+ online: 1,
619
+ //通知数
620
+ notice: 0,
621
+ //是否显示消息列表框
622
+ showMsg: false,
623
+ //即时消息
624
+ sysMsg: [],
625
+ //定时关闭及时消息对象
626
+ sysMsgOut: null,
627
+ //额外信息数据
628
+ extraData: '',
629
+ //用户信息
630
+ userModel: null,
631
+ //刷新路由
632
+ refresh: true,
633
+ //显示设置面板
634
+ showSet: false,
635
+ //当前设置的主题
636
+ color: util.getStorage('theme') ? util.getStorage('theme') : this.theme,
637
+ //显示用户信息
638
+ showUserInfo: false,
639
+ userInfoContents: undefined,
640
+ //是否展示侧边导航
641
+ showMenu: true,
642
+ props: {},
643
+ menuType: '',
644
+ customMenu: [],
645
+ //是否首次加载
646
+ isDefault: true,
647
+ reset: true,
648
+ isKeepAlive: this.keepAlive,
649
+ routerKey: '',
650
+ defaultwjprops: {},
651
+ isTabs: false,
652
+ isHeader: '',
653
+ isSide: null,
654
+ navIds: null,
655
+ timer: null,
656
+ pid: null,
657
+ showPage: false,
658
+ webSocket: null,
659
+ dialog: {},
660
+ hideSubMenu: false
661
+ };
662
+ },
663
+ created() {
664
+ let params = util.getParams() || {};
665
+ if (typeof this.loadHomePage === 'string') {
666
+ this.homePage = this.loadHomePage;
667
+ }
668
+ this.isHeader = params.header;
669
+ let sysLogoIco = sessionStorage.getItem('sysLogoIco');
670
+ sysLogoIco && util.setFavicon(sysLogoIco);
671
+ this.getConfig(params);
672
+ },
673
+ mounted() {
674
+ util.win.reLogin = this.handleReLogin;
675
+ this.handleListener();
676
+ util.win.refresh = this.handleRefresh;
677
+ util.win.jumpMenu = this.jumpMenu;
678
+ if (util.win.$wujie) {
679
+ util.win.$wujie.bus.$on('changeTheme', (res) => {
680
+ util.updateTheme(res);
681
+ });
682
+ }
683
+ util.win.windowOpen = this.openPage;
684
+ util.win.addEventListener('popstate', this.stateHandle, false);
685
+ },
686
+ methods: {
687
+ stateHandle() {
688
+ util.win.location.reload();
689
+ },
690
+ menuSuccess(res) {
691
+ this.menuType = 'custom';
692
+ if (res && res.length) {
693
+ this.customMenu = res;
694
+ this.setMenu(res);
695
+ }
696
+ },
697
+ //获取主题模板JSON
698
+ getMainDetail(id) {
699
+ let params = {
700
+ url: mainDetail,
701
+ params: { id }
702
+ };
703
+ util
704
+ .ajax(params)
705
+ .then((res) => {
706
+ let _that = this;
707
+ if (!res.results) {
708
+ _that.showDefault = true;
709
+ }
710
+ if (res.rCode == 0) {
711
+ if (res.results && JSON.parse(res.results.layout)) {
712
+ // 初始化布局器
713
+ _that.themeJSON = JSON.parse(res.results.layout);
714
+ let count = 0;
715
+ for (let key in _that.themeJSON) {
716
+ if (_that.themeJSON[key].comp) {
717
+ count++;
718
+ }
719
+ }
720
+ if (count == 0) {
721
+ _that.showDefault = true;
722
+ }
723
+ let theme = JSON.parse(res.results.theme);
724
+
725
+ util.updateTheme(theme.primaryColor);
726
+ _that.handleColorToPage(theme.globalThalk);
727
+ }
728
+ } else {
729
+ _that.$message.error('主题加载发生错误');
730
+ throw res.msg || '系统错误,请联系管理员!';
731
+ }
732
+ if (_that.showDefault && _that.data === undefined) {
733
+ _that.getMenu();
734
+ } else if (_that.showDefault) {
735
+ if (_that.data && _that.data.length) {
736
+ _that.menus = JSON.parse(JSON.stringify(_that.data));
737
+ _that.setMenu(_that.data);
738
+ }
739
+ }
740
+ })
741
+ .catch((err) => {
742
+ if (err.message && err.message !== 'canceled') {
743
+ this.$message.error(err.message);
744
+ }
745
+ });
746
+ },
747
+ // 将chalk写入到页面中
748
+ handleColorToPage(globalThalk) {
749
+ const thalk = document.getElementById('chalk-style');
750
+ if (!thalk) {
751
+ let ele = document.createElement('style');
752
+ ele.setAttribute('id', 'chalk-style');
753
+ ele.innerText = globalThalk;
754
+ document.head.appendChild(ele);
755
+ }
756
+ // 如果设置过主题的话
757
+ else {
758
+ thalk.innerText = globalThalk;
759
+ }
760
+ },
761
+ setTitle(id) {
762
+ let node;
763
+ for (let i = 0; i < this.menus.length; i++) {
764
+ let item = this.menus[i];
765
+ if (item.id == id) {
766
+ this.title = item.text;
767
+ node = item;
768
+ break;
769
+ }
770
+ }
771
+ return node;
772
+ },
773
+ renderMenu() {
774
+ if (this.data !== undefined && this.data.length) {
775
+ this.menus = JSON.parse(JSON.stringify(this.data));
776
+ let applicationid =
777
+ util.getParams('applicationid') || util.getParams('applicationId');
778
+ if (applicationid) {
779
+ var ids = this.getId(this.menus, applicationid);
780
+ if (ids) {
781
+ this.defaultActive = ids;
782
+ //this.navIds = ids;
783
+ this.setTitle(ids[0]);
784
+ }
785
+ } else if (sessionStorage.getItem('jump') && this.isHistory) {
786
+ let ids = this.getId(this.menus, sessionStorage.getItem('jump'));
787
+ if (ids) {
788
+ this.defaultActive = ids;
789
+ //this.navIds = ids;
790
+ this.setTitle(ids[0]);
791
+ }
792
+ } else if (util.win.location.hash) {
793
+ let hash = util.win.location.hash;
794
+ if (hash) {
795
+ hash = hash.split('?')[0];
796
+ }
797
+ if (hash !== '#/' && hash !== '#/main') {
798
+ let ids = this.getId(this.menus, util.win.location.hash);
799
+ if (ids) {
800
+ this.defaultActive = ids;
801
+ //this.navIds = ids;
802
+ this.setTitle(ids[0]);
803
+ }
804
+ } else if (sessionStorage.getItem('jump') && this.isHistory) {
805
+ let ids = this.getId(this.menus, sessionStorage.getItem('jump'));
806
+ if (ids) {
807
+ this.defaultActive = ids;
808
+ //this.navIds = ids;
809
+ this.setTitle(ids[0]);
810
+ }
811
+ }
812
+ }
813
+ this.setMenu(this.menus);
814
+ }
815
+ },
816
+ //设置主题颜色
817
+ setTheme(color) {
818
+ if (!color) {
819
+ return;
820
+ }
821
+ util
822
+ .ajax({
823
+ url: updateUserCustomInfo,
824
+ params: { color: escape(color.toLowerCase()) },
825
+ data: { color: escape(color.toLowerCase()) }
826
+ })
827
+ .then((res) => {
828
+ if (res.rCode === 0) {
829
+ this.color = color;
830
+ localStorage.setItem('theme', color);
831
+ let mainConfig = JSON.parse(util.getStorage('mainConfig'));
832
+ mainConfig.userStyle.color = this.color;
833
+ sessionStorage.setItem('mainConfig', JSON.stringify(mainConfig));
834
+ this.$emit('setting', 'theme', this.color);
835
+ this.$message({
836
+ message: res.msg,
837
+ type: 'success',
838
+ duration: 2000
839
+ });
840
+ } else {
841
+ let msg = res.msg || '系统错误,请联系管理员!';
842
+ this.$message.error(msg);
843
+ }
844
+ })
845
+ .catch((err) => {
846
+ if (err.message && err.message !== 'canceled') {
847
+ this.$message.error(err.message);
848
+ }
849
+ });
850
+ },
851
+ //切换兼职身份
852
+ handleJobChange() {
853
+ if (this.webSocket) {
854
+ this.webSocket.destroy();
855
+ }
856
+ },
857
+ //显示隐藏设置面板
858
+ handleSet() {
859
+ this.showSet = !this.showSet;
860
+ },
861
+ setConfig(results, flag) {
862
+ if (this.socket) {
863
+ this.initWebSocket();
864
+ }
865
+ if (flag) {
866
+ sessionStorage.setItem('mainConfig', JSON.stringify(results));
867
+ util.setStorage({
868
+ type: this.storage,
869
+ key: {
870
+ userId: results.userModel.userId,
871
+ userName: results.userModel.username,
872
+ useCaseCodes:
873
+ results.resourceCodes || results.userModel.resourceCodes
874
+ }
875
+ });
876
+ }
877
+ for (let i in results) {
878
+ if (i === 'mainLogoUrl' && results[i]) {
879
+ this.mainLogo = results[i];
880
+ }
881
+ if (
882
+ i === 'mainBannerUrl' &&
883
+ results[i] &&
884
+ this.headerImage === undefined
885
+ ) {
886
+ this.headerImg = results[i];
887
+ }
888
+ if (i === 'initApplication' && results[i]) {
889
+ this.results[i] = results[i].split(',');
890
+ }
891
+ if (i === 'indexUrl' && results[i] && this.loadHomePage) {
892
+ let applicationid =
893
+ util.getParams('applicationid') || util.getParams('applicationId');
894
+ let hash = util.win.location.hash;
895
+ if (hash) {
896
+ hash = hash.split('?')[0];
897
+ }
898
+ let jump = sessionStorage.getItem('jump');
899
+ if (
900
+ (!applicationid &&
901
+ (!jump || !this.isHistory) &&
902
+ (hash === '#/' || hash === '#/main')) ||
903
+ jump == results[i]
904
+ ) {
905
+ this.homePage =
906
+ typeof this.loadHomePage === 'string'
907
+ ? this.loadHomePage
908
+ : results[i];
909
+ if (this.isHomePage && this.homePage) {
910
+ if (this.menus && this.menus.length) {
911
+ let ids = null;
912
+ this.homePage && (ids = this.getId(this.menus, this.homePage));
913
+ if (ids) {
914
+ this.defaultActive = ids;
915
+ } else if (this.homePage) {
916
+ this.handleJump(this.homePage);
917
+ }
918
+ this.setMenu(this.menus);
919
+ }
920
+ }
921
+ } else if (this.menus && this.menus.length) {
922
+ this.setMenu(this.menus);
923
+ }
924
+ }
925
+ if (i === 'doorIndex' && results[i]) {
926
+ window.open(results[i]);
927
+ }
928
+ if (i === 'subsystemName' && results[i]) {
929
+ document.title = results[i];
930
+ }
931
+ if (i === 'loginPage' && results[i]) {
932
+ util.setStorage('loginPage', results[i]);
933
+ }
934
+ if (i === 'sysLogoIco' && results[i]) {
935
+ sessionStorage.setItem('sysLogoIco', results[i]);
936
+ util.setFavicon(results[i]);
937
+ }
938
+ if (i === 'userStyle' && results[i] && results[i].color) {
939
+ let color = unescape(results[i].color).toLowerCase();
940
+ if (util.startWith(color, '#')) {
941
+ this.color = color;
942
+ }
943
+ }
944
+ if (i === 'subsystemExtend' && results[i]) {
945
+ if (results[i].themeColor) {
946
+ this.color = unescape(results[i].themeColor).toLowerCase();
947
+ }
948
+ if (results[i].userInfoContents) {
949
+ this.userInfoContents = results[i].userInfoContents;
950
+ }
951
+ if (results[i].webPageWatermark) {
952
+ try {
953
+ util.win.top.webPageWatermark = results[i].webPageWatermark;
954
+ util.watermark(results[i].webPageWatermark);
955
+ } catch (error) {
956
+ util.win.postMessage(
957
+ { type: 2, content: results[i].webPageWatermark },
958
+ '*'
959
+ );
960
+ }
961
+ }
962
+ if (results[i].loginPage) {
963
+ util.setStorage('loginPage', results[i].loginPage);
964
+ }
965
+ }
966
+ store.set(i, results[i]);
967
+ }
968
+ this.userModel = results.userModel;
969
+ let mainFrameLayout = results.mainFrameLayout;
970
+ if (results.userStyle.layout && this.isCustomMain) {
971
+ this.getMainDetail(results.userStyle.layout);
972
+ } else if (this.isCustomMain) {
973
+ this.getMainDetail(mainFrameLayout);
974
+ } else {
975
+ this.showDefault = true;
976
+ }
977
+ },
978
+ //获取用户配置及信息
979
+ getConfig(query) {
980
+ const token =
981
+ util.getStorage('token') || util.getStorage('Authorization');
982
+ if (
983
+ !token &&
984
+ Object.prototype.hasOwnProperty.call(query, 'serverId') &&
985
+ Object.prototype.hasOwnProperty.call(query, 'authType')
986
+ ) {
987
+ return false;
988
+ }
989
+ if (util.getStorage('mainConfig')) {
990
+ const results = JSON.parse(util.getStorage('mainConfig'));
991
+ this.setConfig(results);
992
+ if (this.remote) {
993
+ this.getMenu();
994
+ } else {
995
+ this.renderMenu();
996
+ }
997
+ return true;
998
+ }
999
+ util.getMainConfig((res) => {
1000
+ this.setConfig(res, 1);
1001
+ if (this.remote) {
1002
+ this.getMenu();
1003
+ } else {
1004
+ this.renderMenu();
1005
+ }
1006
+ });
1007
+ },
1008
+ reGetConfig() {
1009
+ util
1010
+ .ajax({ url: this.mainConfig })
1011
+ .then((res) => {
1012
+ if (res && res.rCode === 0) {
1013
+ const results = JSON.parse(JSON.stringify(res.results));
1014
+ this.setConfig(results, 1);
1015
+ } else {
1016
+ let msg = res.msg || '系统错误,请联系管理员!';
1017
+ this.$message.error(msg);
1018
+ }
1019
+ })
1020
+ .catch((err) => {
1021
+ if (err.message && err.message !== 'canceled') {
1022
+ this.$message.error(err.message);
1023
+ }
1024
+ });
1025
+ },
1026
+ /**
1027
+ * @desc 跳转菜单
1028
+ * @param {Object/String} [res] - 菜单id(多个用,隔开)或url地址或系统菜单数据对象
1029
+ * @param {Boolean} [isUrl] - res是否是url地址
1030
+ * @param {Object} [param] - 拼接地址后的参数
1031
+ */
1032
+ jumpMenu(res, isUrl, param, hide) {
1033
+ if (this.showSide === false) {
1034
+ this.isSide = true;
1035
+ }
1036
+ if (hide !== undefined && hide !== null && hide !== '') {
1037
+ this.hideSubMenu = hide;
1038
+ }
1039
+ let option = { url: res, isUrl: isUrl, param: param };
1040
+ if (util.isObject(res)) {
1041
+ if (res.urlopenmode == 1) {
1042
+ util.win.open(res.url);
1043
+ return;
1044
+ } else if (res.urlopenmode == 2) {
1045
+ location.href = res.url;
1046
+ return;
1047
+ } else {
1048
+ option = { ...option, ...res };
1049
+ }
1050
+ }
1051
+ let ids;
1052
+ if (typeof option.url === 'string') {
1053
+ if (
1054
+ option.isUrl ||
1055
+ option.url.indexOf('.html') > -1 ||
1056
+ option.url.indexOf('.dhtml') > -1 ||
1057
+ option.url.indexOf('/#/') > -1 ||
1058
+ option.url.indexOf('#/') > -1
1059
+ ) {
1060
+ option.isUrlc = true;
1061
+ ids = this.getId(this.menus, option.url);
1062
+ if (!ids) {
1063
+ if (
1064
+ option.url.indexOf('.html') === -1 &&
1065
+ option.url.indexOf('#/') === -1
1066
+ ) {
1067
+ this.method = 'iframe';
1068
+ this.refresh = false;
1069
+ this.page = option.url;
1070
+ } else {
1071
+ this.method = 'router';
1072
+ const routes = this.$router.options.routes;
1073
+ if (routes) {
1074
+ let path = this.hasRouter(routes, option.url);
1075
+ if (path) {
1076
+ let params = util.getParams({ url: option.url });
1077
+ this.$router.push({
1078
+ path: path,
1079
+ query: params
1080
+ });
1081
+ } else {
1082
+ if (this.loadWujie === false || (this.downgrade && isIE)) {
1083
+ this.method = 'iframe';
1084
+ this.refresh = false;
1085
+ this.page = option.url;
1086
+ } else {
1087
+ this.method = 'wujie';
1088
+ this.wjName = 'application' + Date.now();
1089
+ this.page = this.host + option.url;
1090
+ }
1091
+ }
1092
+ }
1093
+ }
1094
+ this.$nextTick(() => {
1095
+ this.refresh = true;
1096
+ });
1097
+ return;
1098
+ }
1099
+ } else {
1100
+ ids = option.url.split(',');
1101
+ }
1102
+ } else {
1103
+ ids = option.url;
1104
+ }
1105
+ this.setDefault(this.menus, ids, option.param);
1106
+ },
1107
+ /**
1108
+ * @desc 获取菜单层级id
1109
+ * @param {Array} [menus] - 系统菜单数据对象
1110
+ * @param {String} [url] - 菜单id或url地址
1111
+ */
1112
+ getId(menus, url) {
1113
+ if (!url) {
1114
+ return false;
1115
+ }
1116
+ for (let i = 0; i < menus.length; i++) {
1117
+ let item = menus[i];
1118
+ if (
1119
+ Object.prototype.hasOwnProperty.call(item, 'children') &&
1120
+ item.children.length
1121
+ ) {
1122
+ let id = this.getId(item.children, url);
1123
+ if (id) {
1124
+ if (typeof id === 'string') {
1125
+ this.isTabs = false;
1126
+ }
1127
+ if (item.pid === 'root' || Array.isArray(id)) {
1128
+ return [item.id].concat(id);
1129
+ } else if (typeof id === 'string') {
1130
+ return [item.id, id];
1131
+ }
1132
+ return id;
1133
+ }
1134
+ } else if (
1135
+ Object.prototype.hasOwnProperty.call(item, 'fourthTabs') &&
1136
+ item.fourthTabs.length
1137
+ ) {
1138
+ let id = this.getId(item.fourthTabs, url);
1139
+ if (id) {
1140
+ if (typeof id === 'string') {
1141
+ this.isTabs = true;
1142
+ }
1143
+ if (item.pid === 'root') {
1144
+ return [item.id].concat(id);
1145
+ } else if (typeof id === 'string') {
1146
+ return [item.id, id];
1147
+ }
1148
+ return id;
1149
+ }
1150
+ } else if (item.id === url || item.url == url) {
1151
+ return item.id;
1152
+ } else {
1153
+ if (item.url) {
1154
+ try {
1155
+ let _url = new URL(item.url, window.location.origin);
1156
+ if (_url.hash == url) {
1157
+ return item.id;
1158
+ }
1159
+ } catch (error) {
1160
+ console.error(error, item);
1161
+ }
1162
+ }
1163
+ }
1164
+ }
1165
+ return false;
1166
+ },
1167
+ //获取应用导航菜单
1168
+ getMenu() {
1169
+ let param = this.menuCode ? { menuCode: this.menuCode } : {};
1170
+ let params = { ...this.param, ...param };
1171
+ util
1172
+ .ajax({ url: this.action, params: params })
1173
+ .then((res) => {
1174
+ if (res.rCode === 0) {
1175
+ if (res.results && res.results.length) {
1176
+ this.menus = JSON.parse(JSON.stringify(res.results));
1177
+ this.setTips(this.menus);
1178
+ store.set('nav', this.menus);
1179
+ this.setMenu(this.menus);
1180
+ } else {
1181
+ this.$message.error('未分配菜单权限,请联系管理员!');
1182
+ }
1183
+ } else {
1184
+ let msg = res.msg || '系统错误,请联系管理员!';
1185
+ this.$message.error(msg);
1186
+ }
1187
+ })
1188
+ .catch((err) => {
1189
+ if (err.message && err.message !== 'canceled') {
1190
+ this.$message.error(err.message);
1191
+ }
1192
+ });
1193
+ },
1194
+ //设置默认左侧导航
1195
+ setMenu(res) {
1196
+ let applicationid =
1197
+ util.getParams('applicationid') || util.getParams('applicationId');
1198
+ if (applicationid) {
1199
+ let ids = this.getId(this.menus, applicationid);
1200
+ if (ids) {
1201
+ this.defaultActive = ids;
1202
+ }
1203
+ } else if (util.win.location.hash) {
1204
+ let hash = util.win.location.hash;
1205
+ if (hash) {
1206
+ hash = hash.split('?')[0];
1207
+ }
1208
+ if (hash !== '#/' && hash !== '#/main') {
1209
+ let ids = this.getId(this.menus, util.win.location.hash);
1210
+ if (ids) {
1211
+ this.defaultActive = ids;
1212
+ //this.navIds = ids;
1213
+ this.setTitle(ids[0]);
1214
+ }
1215
+ }
1216
+ } else if (sessionStorage.getItem('jump') && this.isHistory) {
1217
+ let ids = this.getId(this.menus, sessionStorage.getItem('jump'));
1218
+ if (ids) {
1219
+ this.defaultActive = ids;
1220
+ //this.navIds = ids;
1221
+ this.setTitle(ids[0]);
1222
+ }
1223
+ }
1224
+ if (this.defaultActive && this.defaultActive.length) {
1225
+ this.isDefault = false;
1226
+ this.setDefault(res, this.defaultActive);
1227
+ } else {
1228
+ if (this.homePage || !util.getStorage('mainConfig')) {
1229
+ this.isDefault = true;
1230
+ if (
1231
+ this.homePage &&
1232
+ (!this.defaultActive || !this.defaultActive.length)
1233
+ ) {
1234
+ let ids = this.getId(this.menus, this.homePage);
1235
+ if (ids) {
1236
+ this.defaultActive = ids;
1237
+ this.isDefault = false;
1238
+ this.setDefault(res, this.defaultActive);
1239
+ return false;
1240
+ } else {
1241
+ this.handleJump(this.homePage);
1242
+ }
1243
+ }
1244
+ } else {
1245
+ this.isDefault = false;
1246
+ }
1247
+ if (this.layout === 'subsystem' || this.layout === 'topside') {
1248
+ if (this.layout === 'subsystem') {
1249
+ this.navs = [];
1250
+ if (this.menuType === 'custom') {
1251
+ this.subsystem = this.customMenu;
1252
+ } else {
1253
+ this.subsystem = res;
1254
+ }
1255
+ } else if (this.layout === 'topside') {
1256
+ this.subsystem = [];
1257
+ if (this.menuType === 'custom') {
1258
+ this.navs = this.customMenu;
1259
+ this.topActive = res[0].id;
1260
+ } else {
1261
+ this.navs = res;
1262
+ this.topActive = res[0].id;
1263
+ }
1264
+ }
1265
+ if (this.application) {
1266
+ for (let i = 0; i < res.length; i++) {
1267
+ if (res[i].hasPermission) {
1268
+ this.menu = res[i].children;
1269
+ this.title = res[i].text;
1270
+ break;
1271
+ }
1272
+ }
1273
+ } else {
1274
+ this.menu = res[0].children;
1275
+ this.title = res[0].text;
1276
+ }
1277
+ if (!this.isDefault || (this.isDefault && !this.homePage)) {
1278
+ this.active = this.getFirst(this.menu[0]).id;
1279
+ }
1280
+ } else if (this.layout === 'topnav') {
1281
+ if (this.menuType === 'custom') {
1282
+ this.navs = this.customMenu;
1283
+ this.topActive = this.getFirst(res[0]).id;
1284
+ } else {
1285
+ this.navs = res;
1286
+ this.topActive = this.getFirst(res[0]).id;
1287
+ }
1288
+ } else {
1289
+ this.nav = [];
1290
+ this.subsystem = [];
1291
+ this.menu = res;
1292
+ if (!this.isDefault || (this.isDefault && !this.homePage)) {
1293
+ this.active = [this.menu[0].id];
1294
+ let id = this.getFirst(this.menu[0]).id;
1295
+ if (id && this.menu[0].id !== id) {
1296
+ this.active.push(id);
1297
+ } else {
1298
+ let hash = util.win.location.hash;
1299
+ if (hash) {
1300
+ hash = hash.split('?')[0];
1301
+ if (hash !== '#/' && hash !== '#/main') {
1302
+ this.handleJump(hash);
1303
+ return;
1304
+ }
1305
+ }
1306
+ let jump = sessionStorage.getItem('jump');
1307
+ if (jump) {
1308
+ this.handleJump(jump);
1309
+ } else {
1310
+ this.handleJump(
1311
+ this.menu[0].url,
1312
+ this.menu[0].urlopenmode,
1313
+ this.menu[0]
1314
+ );
1315
+ }
1316
+ }
1317
+ }
1318
+ }
1319
+ }
1320
+ },
1321
+ //获取菜单第一条数据
1322
+ getFirst(obj) {
1323
+ if (!obj) {
1324
+ return '';
1325
+ }
1326
+ let openIdex = 0;
1327
+ if (
1328
+ obj.extendData &&
1329
+ (obj.extendData.subDefOpenIndex || obj.extendData.subDefOpen)
1330
+ ) {
1331
+ openIdex = parseInt(
1332
+ obj.extendData.subDefOpenIndex || obj.extendData.subDefOpen,
1333
+ 10
1334
+ );
1335
+ }
1336
+ if (obj.children && obj.children.length) {
1337
+ return this.getFirst(obj.children[openIdex]);
1338
+ } else if (obj.fourthTabs && obj.fourthTabs.length) {
1339
+ if (this.layout === 'topnav') {
1340
+ return this.getFirst(obj.fourthTabs[openIdex]);
1341
+ } else {
1342
+ this.tabs = obj.fourthTabs;
1343
+ if (obj.url) {
1344
+ let tab = obj.fourthTabs.filter((item) => {
1345
+ return item.url === obj.url;
1346
+ })[0];
1347
+ if (tab) {
1348
+ this.tabsId = tab.id;
1349
+ this.handleJump(tab.url, tab.urlopenmode, tab);
1350
+ }
1351
+ } else {
1352
+ this.tabsId = this.tabs[0].id;
1353
+ this.handleJump(
1354
+ this.tabs[0].url,
1355
+ this.tabs[0].urlopenmode,
1356
+ this.tabs[0]
1357
+ );
1358
+ }
1359
+ }
1360
+ } else {
1361
+ this.tabs = [];
1362
+ this.handleJump(obj.url, obj.urlopenmode, obj);
1363
+ }
1364
+ return obj;
1365
+ },
1366
+ //遍历设置菜单气泡提醒
1367
+ setTips(obj) {
1368
+ if (Array.isArray(obj)) {
1369
+ obj.forEach((item) => {
1370
+ this.setTips(item);
1371
+ });
1372
+ } else {
1373
+ if (
1374
+ obj &&
1375
+ Object.prototype.hasOwnProperty.call(obj, 'tips') &&
1376
+ obj.tips
1377
+ ) {
1378
+ this.$set(obj, 'tips', false);
1379
+ delete obj.tips;
1380
+ }
1381
+ let flag = false;
1382
+ if (obj.children && obj.children.length) {
1383
+ obj.children.forEach((item) => {
1384
+ if (this.setTips(item)) {
1385
+ flag = true;
1386
+ }
1387
+ });
1388
+ if (flag) {
1389
+ this.$set(obj, 'tips', true);
1390
+ return true;
1391
+ }
1392
+ } else if (obj.fourthTabs && obj.fourthTabs.length) {
1393
+ obj.fourthTabs.forEach((item) => {
1394
+ if (this.setTips(item)) {
1395
+ flag = true;
1396
+ }
1397
+ });
1398
+ if (flag) {
1399
+ this.$set(obj, 'tips', true);
1400
+ return true;
1401
+ }
1402
+ } else {
1403
+ if (this.menuTips[obj.id] && Number(this.menuTips[obj.id])) {
1404
+ this.$set(obj, 'tips', Number(this.menuTips[obj.id]));
1405
+ return true;
1406
+ }
1407
+ }
1408
+ }
1409
+ return false;
1410
+ },
1411
+ //设置默认导航页面
1412
+ setDefault(res, active, param) {
1413
+ this.navIds = JSON.parse(JSON.stringify(active));
1414
+ this.sysId = '';
1415
+ this.tabsId = '';
1416
+ this.active = '';
1417
+ this.getUrl(res, active, param);
1418
+ if (
1419
+ this.layout === 'subsystem' ||
1420
+ this.layout === 'subSystem' ||
1421
+ this.layout === 'topnav' ||
1422
+ this.layout === 'topNav' ||
1423
+ this.layout === 'topside' ||
1424
+ this.layout === 'topSide'
1425
+ ) {
1426
+ if (this.layout === 'subsystem' || this.layout === 'subSystem') {
1427
+ this.navs = [];
1428
+ if (this.menuType === 'custom') {
1429
+ this.subsystem = this.customMenu;
1430
+ this.sysId = active[0];
1431
+ } else {
1432
+ this.subsystem = res;
1433
+ this.sysId = active[0];
1434
+ }
1435
+ } else if (
1436
+ this.layout === 'topnav' ||
1437
+ this.layout === 'topNav' ||
1438
+ this.layout === 'topside' ||
1439
+ this.layout === 'topSide'
1440
+ ) {
1441
+ this.subsystem = [];
1442
+ if (this.menuType === 'custom') {
1443
+ this.navs = this.customMenu;
1444
+ this.topActive = active[0];
1445
+ } else {
1446
+ this.navs = res;
1447
+ this.topActive = active[0];
1448
+ }
1449
+ }
1450
+ if (this.tabs.length || this.isTabs) {
1451
+ this.tabsId = active[active.length - 1];
1452
+ this.active = active.slice(1, active.length - 1);
1453
+ } else {
1454
+ this.active = active.slice(1);
1455
+ }
1456
+ for (let i = 0; i < res.length; i++) {
1457
+ if (res[i].id === active[0]) {
1458
+ this.menu = res[i].children;
1459
+ this.title = res[i].text;
1460
+ break;
1461
+ }
1462
+ }
1463
+ } else if (active && active.length) {
1464
+ this.navs = [];
1465
+ this.subsystem = [];
1466
+ this.menu = res;
1467
+ if (this.biserial) {
1468
+ this.active = active.slice(
1469
+ 0,
1470
+ active.length > 2 ? active.length - 1 : active.length
1471
+ );
1472
+ } else {
1473
+ this.active = active.slice(1);
1474
+ }
1475
+ this.tabsId = active[active.length - 1];
1476
+ }
1477
+ this.showPage = true;
1478
+ },
1479
+ //获取页面类型及地址
1480
+ getUrl(res, active, index, param) {
1481
+ index = index === undefined ? 0 : index;
1482
+ for (let i = 0; i < res.length; i++) {
1483
+ let item = res[i];
1484
+ if (item.id === active[index]) {
1485
+ if (index === active.length - 1) {
1486
+ this.handleJump(item.url, item.urlopenmode, item, param);
1487
+ return item.url;
1488
+ } else {
1489
+ if (item.children && item.children.length) {
1490
+ index++;
1491
+ let url = this.getUrl(item.children, active, index, param);
1492
+ if (url && index === active.length - 1) {
1493
+ this.tabs = '';
1494
+ }
1495
+ return url;
1496
+ }
1497
+ if (item.fourthTabs && item.fourthTabs.length) {
1498
+ index++;
1499
+ let url = this.getUrl(item.fourthTabs, active, index, param);
1500
+ if (url) {
1501
+ this.$set(this, 'tabs', item.fourthTabs);
1502
+ }
1503
+ return url;
1504
+ }
1505
+ }
1506
+ } else if (item.children && item.children.length) {
1507
+ this.getUrl(item.children, active, index, param);
1508
+ }
1509
+ }
1510
+ return false;
1511
+ },
1512
+
1513
+ setUrl(url, param) {
1514
+ let obj = param ? param : {};
1515
+ let params = util.getParams({ url: url }, true);
1516
+ for (let i in params) {
1517
+ if (i != 'model' && i != 'view' && i != '_baseUrl') {
1518
+ obj[i] = params[i];
1519
+ }
1520
+ }
1521
+ let _url = params._baseUrl ? params._baseUrl : './primary.html';
1522
+ return util.urlJoinParams({ url: _url, param: obj });
1523
+ },
1524
+ //应用导航交互
1525
+ handleSelect(res, type, open) {
1526
+ const { node, fourthTabs } = res;
1527
+ if (!open) {
1528
+ if (
1529
+ node.extendData &&
1530
+ node.extendData.businessStatus == 0 &&
1531
+ node.extendData.businessWarnMsg
1532
+ ) {
1533
+ this.$alert(node.extendData.businessWarnMsg, '提示', {
1534
+ type: 'warning'
1535
+ });
1536
+ return;
1537
+ }
1538
+ this.isDefault = false;
1539
+ this.tabsId = '';
1540
+ }
1541
+ switch (type) {
1542
+ case 'nav':
1543
+ this.tabs = [];
1544
+ //this.active = '';
1545
+ if (this.layout === 'topside') {
1546
+ if (this.title !== node.text) {
1547
+ //this.navIds = [node.id];
1548
+ this.menu = node.children;
1549
+ this.active = node.id;
1550
+ this.title = node.text;
1551
+ }
1552
+ if (this.setFirstAsDefault) {
1553
+ let subNode = this.getFirst(node);
1554
+ if (subNode) {
1555
+ this.active = subNode.id;
1556
+ // this.navIds = [
1557
+ // node.id,
1558
+ // ...this.getId(node.children, subNode.url)
1559
+ // ];
1560
+ }
1561
+ }
1562
+ } else {
1563
+ //this.navIds = this.getId(this.menus, node.url);
1564
+ this.setTitle(this.navIds[0]);
1565
+ this.tabsId = fourthTabs ? node.id : '';
1566
+ }
1567
+ break;
1568
+ case 'sys':
1569
+ if (Number(node.urlopenmode) !== 1) {
1570
+ //this.navIds = [node.id];
1571
+ this.tabs = [];
1572
+ this.menu = node.children;
1573
+ if (this.title !== node.text) {
1574
+ this.active = '';
1575
+ this.title = node.text;
1576
+ }
1577
+ if (this.setFirstAsDefault) {
1578
+ let subNode = this.getFirst(node);
1579
+ if (subNode) {
1580
+ this.active = subNode.id;
1581
+ // this.navIds = [
1582
+ // node.id,
1583
+ // ...this.getId(node.children, subNode.url)
1584
+ // ];
1585
+ }
1586
+ }
1587
+ this.isSide = true;
1588
+ }
1589
+ break;
1590
+ case 'sub':
1591
+ this.hideSubMenu = false;
1592
+ //this.navIds = [node.id];
1593
+ if (node.url) {
1594
+ this.tabs = [];
1595
+ }
1596
+ if (this.title !== node.text) {
1597
+ this.active = [node.id];
1598
+ this.title = node.text;
1599
+ }
1600
+ if (this.setFirstAsDefault) {
1601
+ let subNode = this.getFirst(node);
1602
+ this.active = [node.id];
1603
+ if (subNode && node.id !== subNode.id) {
1604
+ //this.navIds = this.getId(this.menus, subNode.url);
1605
+ this.$set(this.active, 1, subNode.id);
1606
+ }
1607
+ }
1608
+ break;
1609
+ case 'menu':
1610
+ if (!open) {
1611
+ this.tabs = [];
1612
+ if (this.biserial) {
1613
+ this.$set(this.active, 1, node.id);
1614
+ } else {
1615
+ this.active = node.id;
1616
+ }
1617
+ if (node.url) {
1618
+ if (node.children && node.children.length) {
1619
+ let tab = node.children.filter((item) => {
1620
+ return item.url === node.url;
1621
+ })[0];
1622
+ if (tab) {
1623
+ if (this.biserial) {
1624
+ this.$set(this.active, 1, tab.id);
1625
+ } else {
1626
+ this.active = tab.id;
1627
+ }
1628
+ //this.navIds = this.getId(this.menus, tab.url);
1629
+ }
1630
+ } else {
1631
+ let tab = (node.fourthTabs || []).filter((item) => {
1632
+ return item.url === node.url;
1633
+ })[0];
1634
+ if (tab) {
1635
+ this.tabs = node.fourthTabs;
1636
+ this.tabsId = tab.id;
1637
+ //this.navIds = this.getId(this.menus, tab.url);
1638
+ } else {
1639
+ //this.navIds = this.getId(this.menus, node.url);
1640
+ }
1641
+ }
1642
+ } else {
1643
+ if (node.fourthTabs.length) {
1644
+ this.tabs = node.fourthTabs;
1645
+ this.tabsId = this.tabs[0].id;
1646
+ this.handleJump(
1647
+ this.tabs[0].url,
1648
+ this.tabs[0].urlopenmode,
1649
+ this.tabs[0]
1650
+ );
1651
+ //this.navIds = this.getId(this.menus, this.tabs[0].url);
1652
+ }
1653
+ }
1654
+ } else {
1655
+ if (this.setFirstAsDefault) {
1656
+ this.tabs = [];
1657
+ let subNode = this.getFirst(node);
1658
+ if (subNode) {
1659
+ if (this.biserial) {
1660
+ this.$set(this.active, 1, subNode.id);
1661
+ } else {
1662
+ this.active = subNode.id;
1663
+ }
1664
+ //this.navIds = this.getId(this.menus, subNode.url);
1665
+ }
1666
+ }
1667
+ }
1668
+ break;
1669
+ case 'tabs':
1670
+ this.tabsId = node.id;
1671
+ //this.navIds = this.getId(this.menus, node.url);
1672
+ break;
1673
+ }
1674
+ if (node.url) {
1675
+ this.selectPage = node.url;
1676
+ this.refresh = false;
1677
+ this.handleJump(node.url, Number(node.urlopenmode), node);
1678
+ }
1679
+ },
1680
+ hasRouter(res, url) {
1681
+ if (!url) {
1682
+ return false;
1683
+ }
1684
+ if (Array.isArray(res)) {
1685
+ for (let i in res) {
1686
+ let path = this.hasRouter(res[i], url);
1687
+ if (path) {
1688
+ return path;
1689
+ }
1690
+ }
1691
+ } else {
1692
+ let path = res.path;
1693
+ if (path !== '/' && path !== '/404') {
1694
+ path = path.replace(path[1], path[1].toLowerCase());
1695
+ }
1696
+ let pathname = url.substring(url.indexOf('#/') + 1);
1697
+ pathname = pathname
1698
+ .replace(pathname[1], pathname[1].toLowerCase())
1699
+ .split('?')[0];
1700
+ if (res.path !== '/' && pathname == path) {
1701
+ return pathname;
1702
+ }
1703
+ if (res && Object.prototype.hasOwnProperty.call(res, 'children')) {
1704
+ let path = this.hasRouter(res.children, url);
1705
+ if (path) {
1706
+ return path;
1707
+ }
1708
+ }
1709
+ }
1710
+ return false;
1711
+ },
1712
+ //头部工具交互事件
1713
+ handleClick(res) {
1714
+ const { type } = res;
1715
+ switch (type) {
1716
+ //刷新
1717
+ case 'refresh':
1718
+ this.handleRefresh();
1719
+ break;
1720
+ case 'home':
1721
+ this.reset = false;
1722
+ if (this.homePage) {
1723
+ this.handleJump(this.homePage);
1724
+ }
1725
+ this.active = [];
1726
+ this.defaultActive = [];
1727
+ this.tabs = [];
1728
+ if (this.menus && this.menus.length) {
1729
+ this.setMenu(this.menus);
1730
+ }
1731
+ this.$nextTick(() => {
1732
+ this.reset = true;
1733
+ });
1734
+ break;
1735
+ case 'user':
1736
+ this.showUserInfo = true;
1737
+ break;
1738
+ case 'online':
1739
+ if (this.onlineUrl) {
1740
+ this.dialog = {
1741
+ title: '查看在线人员',
1742
+ show: true,
1743
+ src: this.onlineUrl
1744
+ };
1745
+ }
1746
+ break;
1747
+ case 'notice':
1748
+ this.showMsg = !this.showMsg;
1749
+ break;
1750
+ case 'set':
1751
+ this.handleSet();
1752
+ break;
1753
+ case 'goView':
1754
+ util.win.open(res.path, '_blank');
1755
+ break;
1756
+ }
1757
+ this.$emit('handler-click', res);
1758
+ },
1759
+ //刷新子页面、子路由
1760
+ handleRefresh() {
1761
+ if (this.method === 'iframe') {
1762
+ this.page = util.handlerUrl(this.page);
1763
+ } else {
1764
+ this.refresh = false;
1765
+ this.$nextTick(() => {
1766
+ this.refresh = true;
1767
+ });
1768
+ }
1769
+ },
1770
+ //跳转页面
1771
+ handleJump(page, type, res, param) {
1772
+ this.navIds = this.getId(this.menus, page);
1773
+ console.log(page);
1774
+ let prevPage = sessionStorage.getItem('jump');
1775
+ sessionStorage.setItem('jump', page);
1776
+ if (res) {
1777
+ if (res.fourthTabs && res.fourthTabs.length) {
1778
+ this.pid = res.id;
1779
+ } else {
1780
+ this.pid = res.pid;
1781
+ }
1782
+ }
1783
+ if (util.win.location.hash === page && prevPage === page) {
1784
+ this.refresh = true;
1785
+ return;
1786
+ }
1787
+ if (type == 1) {
1788
+ util.win.open(page);
1789
+ } else if (type == 2) {
1790
+ location.href = page;
1791
+ } else if (
1792
+ type == 3 ||
1793
+ this.loadWujie === false ||
1794
+ (this.downgrade && isIE)
1795
+ ) {
1796
+ this.method = 'iframe';
1797
+ this.refresh = false;
1798
+ this.page = util.handlerUrl(page, param);
1799
+ } else if (page) {
1800
+ let urls = page.split('?');
1801
+ if (urls[0].indexOf('.js') > 1) {
1802
+ this.method = 'wujie';
1803
+ this.wjName = 'singlespa';
1804
+ this.page = this.host + page;
1805
+ this.$nextTick(() => {
1806
+ this.refresh = true;
1807
+ });
1808
+ } else if (
1809
+ urls[0].indexOf('.dhtml') > 0 ||
1810
+ (urls[0].indexOf('.html') > 0 && urls[0].indexOf('.html#') === -1)
1811
+ ) {
1812
+ this.method = 'iframe';
1813
+ this.refresh = false;
1814
+ this.page = util.handlerUrl(page, param);
1815
+ } else {
1816
+ if (urls[0].indexOf('.html') === -1 && urls[0].indexOf('#/') === -1) {
1817
+ this.method = 'iframe';
1818
+ this.refresh = false;
1819
+ this.page = util.handlerUrl(page, param);
1820
+ } else {
1821
+ this.method = 'router';
1822
+ const routes = this.$router.options.routes;
1823
+ if (routes) {
1824
+ let path = this.hasRouter(routes, urls[0]);
1825
+ if (path) {
1826
+ let params = util.getParams({ url: page });
1827
+ if (param) {
1828
+ params = { ...params, ...param };
1829
+ }
1830
+ if (res) {
1831
+ this.routerKey = res.id;
1832
+ if (Object.prototype.hasOwnProperty.call(res, 'keepAlive')) {
1833
+ this.isKeepAlive = res.keepAlive;
1834
+ }
1835
+ }
1836
+ this.$router.push({
1837
+ path: path,
1838
+ query: params
1839
+ });
1840
+ this.$nextTick(() => {
1841
+ this.refresh = true;
1842
+ });
1843
+ } else {
1844
+ let urlopenmode = util.getParams({
1845
+ url: page,
1846
+ name: 'urlopenmode'
1847
+ });
1848
+ if (
1849
+ this.loadWujie === false ||
1850
+ (this.downgrade && isIE) ||
1851
+ urlopenmode == 3
1852
+ ) {
1853
+ this.method = 'iframe';
1854
+ this.refresh = false;
1855
+ this.page = util.handlerUrl(page, param);
1856
+ } else {
1857
+ this.method = 'wujie';
1858
+ this.wjName =
1859
+ res && res.appCode ? res.appCode : 'application';
1860
+ this.page = this.host + page;
1861
+ this.$nextTick(() => {
1862
+ this.refresh = true;
1863
+ });
1864
+ }
1865
+ }
1866
+ } else {
1867
+ this.method = 'iframe';
1868
+ this.refresh = false;
1869
+ this.page = util.handlerUrl(page, param);
1870
+ this.$nextTick(() => {
1871
+ this.refresh = true;
1872
+ });
1873
+ }
1874
+ }
1875
+ }
1876
+ }
1877
+ this.$nextTick(() => {
1878
+ this.showPage = true;
1879
+ });
1880
+ },
1881
+ //设置回调
1882
+ handleChange(res) {
1883
+ const { type, value } = res;
1884
+ switch (type) {
1885
+ case 'theme':
1886
+ this.setTheme(value);
1887
+ break;
1888
+ case 'ignore':
1889
+ this.notice = 0;
1890
+ break;
1891
+ }
1892
+ },
1893
+ getFourthTabs(menus, id) {
1894
+ if (Array.isArray(menus)) {
1895
+ for (let i = 0; i < menus.length; i++) {
1896
+ let fourth = this.getFourthTabs(menus[i], id);
1897
+ if (fourth) {
1898
+ return fourth;
1899
+ }
1900
+ }
1901
+ } else {
1902
+ if (menus.fourthTabs && menus.fourthTabs.length && menus.id === id) {
1903
+ return menus;
1904
+ }
1905
+ if (menus.children && menus.children.length) {
1906
+ for (let i = 0; i < menus.children.length; i++) {
1907
+ let fourth = this.getFourthTabs(menus.children[i], id);
1908
+ if (fourth) {
1909
+ return fourth;
1910
+ }
1911
+ }
1912
+ }
1913
+ }
1914
+ return false;
1915
+ },
1916
+ handleLayout(res, old) {
1917
+ if (res == old) {
1918
+ return;
1919
+ }
1920
+ this.layout = res;
1921
+ switch (res) {
1922
+ case 'topnav':
1923
+ this.navs = this.menus;
1924
+ this.tabs = [];
1925
+ this.subsystem = [];
1926
+ this.topActive =
1927
+ this.navIds && this.navIds.length
1928
+ ? this.navIds[this.navIds.length - 1]
1929
+ : '';
1930
+ break;
1931
+ case 'subsystem':
1932
+ this.subsystem = this.menus;
1933
+ this.navs = [];
1934
+ this.tabs = [];
1935
+ if (this.navIds && this.navIds.length) {
1936
+ let node = this.setTitle(this.navIds[0]);
1937
+ this.active = JSON.parse(JSON.stringify(this.navIds)).slice(1);
1938
+ let tabs = this.getFourthTabs(this.menus, this.pid);
1939
+ if (tabs) {
1940
+ this.active.pop();
1941
+ this.tabs = tabs.fourthTabs;
1942
+ this.tabsId = this.navIds[this.navIds.length - 1];
1943
+ }
1944
+ this.menu = node.children;
1945
+ this.title = node.text;
1946
+ } else {
1947
+ //this.navIds = [this.menus[0].id]
1948
+ this.menu = this.menus[0].children;
1949
+ this.title = this.menus[0].text;
1950
+ }
1951
+ break;
1952
+ case 'topside':
1953
+ this.navs = this.menus;
1954
+ this.subsystem = [];
1955
+ this.tabs = [];
1956
+ if (this.navIds && this.navIds.length) {
1957
+ let node = this.setTitle(this.navIds[0]);
1958
+ this.active = JSON.parse(JSON.stringify(this.navIds)).slice(1);
1959
+ let tabs = this.getFourthTabs(this.menus, this.pid);
1960
+ if (tabs) {
1961
+ this.active.pop();
1962
+ this.tabs = tabs.fourthTabs;
1963
+ this.tabsId = this.navIds[this.navIds.length - 1];
1964
+ }
1965
+ this.topActive = this.navIds[0];
1966
+ this.menu = node.children;
1967
+ } else {
1968
+ this.menu = this.menus[0].children;
1969
+ this.topActive = this.menus[0].id;
1970
+ }
1971
+ break;
1972
+ default:
1973
+ this.navs = [];
1974
+ this.subsystem = [];
1975
+ this.menu = this.menus;
1976
+ if (this.navIds && this.navIds.length) {
1977
+ this.active = JSON.parse(JSON.stringify(this.navIds));
1978
+ let tabs = this.getFourthTabs(this.menus, this.pid);
1979
+ if (tabs) {
1980
+ this.active.pop();
1981
+ this.tabs = tabs.fourthTabs;
1982
+ this.tabsId = this.navIds[this.navIds.length - 1];
1983
+ }
1984
+ }
1985
+ }
1986
+ },
1987
+ //监听改变菜单
1988
+ handleListener() {
1989
+ util.win.addEventListener(
1990
+ 'message',
1991
+ (e) => {
1992
+ var msg = e.data;
1993
+ if (msg.key == 'jump_Menu') {
1994
+ let res = msg.data1;
1995
+ if (typeof res === 'string') {
1996
+ res = res.split(',');
1997
+ }
1998
+ this.setDefault(this.menus, res);
1999
+ }
2000
+ },
2001
+ false
2002
+ );
2003
+ },
2004
+ //开启weosocket
2005
+ initWebSocket() {
2006
+ this.webSocket = util.socket({
2007
+ url: wss,
2008
+ take: topic,
2009
+ success: (res) => {
2010
+ let data = res.data || {};
2011
+ for (let i in data) {
2012
+ if (data[i] !== null && data[i] !== undefined) {
2013
+ if (i === 'onlineUserNums' && data[i] > 0) {
2014
+ this.online = data[i];
2015
+ }
2016
+ if (i === 'sysMsgNums') {
2017
+ this.notice = data[i];
2018
+ if (this.showMsg) {
2019
+ this.$refs.message.getMsg(true);
2020
+ }
2021
+ }
2022
+ if (i === 'menuTipsMap') {
2023
+ this.menuTips = data[i];
2024
+ }
2025
+ if (i === 'sysMsgList') {
2026
+ this.sysMsg = data[i];
2027
+ }
2028
+ if (i === 'extraData') {
2029
+ this.extraData = data[i];
2030
+ }
2031
+ }
2032
+ }
2033
+ if (this.$store) {
2034
+ try {
2035
+ this.$store.commit('websocket', data);
2036
+ } catch (error) {}
2037
+ }
2038
+ if (this.$eventBus) {
2039
+ this.$eventBus.$emit('websocket', data);
2040
+ }
2041
+ if (util.win.eventBus) {
2042
+ util.win.eventBus.$emit('websocket', data);
2043
+ }
2044
+ }
2045
+ });
2046
+ },
2047
+ handleOpened(res) {
2048
+ if (res === undefined) {
2049
+ this.sysMsg = [];
2050
+ } else if (res == false && this.sysMsg.length) {
2051
+ this.sysMsgOut = setTimeout(() => {
2052
+ this.sysMsg = [];
2053
+ }, 3000);
2054
+ } else if (this.sysMsgOut) {
2055
+ clearTimeout(this.sysMsgOut);
2056
+ }
2057
+ },
2058
+ // handleDialog(obj) {
2059
+ // this.dialog = obj;
2060
+ // },
2061
+ handleUserModel(name, val) {
2062
+ this.$set(this.userModel, name, val);
2063
+ },
2064
+ handleMenuTips(id, num) {
2065
+ if (num) {
2066
+ this.$set(this.menuTips, id, num);
2067
+ } else {
2068
+ let n = parseInt(this.menuTips[id], 10) - 1;
2069
+ this.$set(this.menuTips, id, n);
2070
+ }
2071
+ },
2072
+ handleReLogin(res) {
2073
+ if (res && typeof res == 'string') {
2074
+ res = JSON.parse(res);
2075
+ }
2076
+ let msg = '提示';
2077
+ let btn = {
2078
+ confirmButtonText: '确定',
2079
+ cancelButtonText: '取消',
2080
+ closeOnClickModal: false,
2081
+ type: 'warning'
2082
+ };
2083
+ if (res) {
2084
+ if (res.rCode === 69) {
2085
+ msg = '该账号在其他地方已登陆!';
2086
+ btn = {
2087
+ confirmButtonText: '确定',
2088
+ closeOnClickModal: false,
2089
+ type: 'warning'
2090
+ };
2091
+ } else {
2092
+ msg = '登录已过期,请重新登录!';
2093
+ }
2094
+ }
2095
+ cl;
2096
+ let remind = sessionStorage.getItem('remind');
2097
+ if (!remind) {
2098
+ clearTimeout(this.timer);
2099
+ this.timer = setTimeout(() => {
2100
+ console.log('handleReLogin');
2101
+ sessionStorage.setItem('remind', 1);
2102
+ this.$confirm(msg, btn)
2103
+ .then(() => {
2104
+ util.removeStorage([
2105
+ 'Authorization',
2106
+ 'token',
2107
+ 'ssId',
2108
+ 'userId',
2109
+ 'userName',
2110
+ 'auth',
2111
+ 'deviceUnique',
2112
+ 'menus',
2113
+ 'useCaseCodes',
2114
+ 'mainConfig',
2115
+ 'jump'
2116
+ ]);
2117
+ const loginPage =
2118
+ util.getStorage('login') || util.getStorage('loginPage');
2119
+ try {
2120
+ if (loginPage) {
2121
+ let src;
2122
+ if (!util.startWith(loginPage, ['http', '/'], true)) {
2123
+ let pathname = util.win.top.location.pathname;
2124
+ if (pathname !== '/') {
2125
+ pathname = pathname.split('/');
2126
+ pathname.splice(pathname.length - 1);
2127
+ pathname = pathname.join('/');
2128
+ src = pathname + '/' + loginPage.replace('./', '');
2129
+ } else {
2130
+ src = pathname + loginPage.replace('./', '');
2131
+ }
2132
+ } else {
2133
+ src = loginPage;
2134
+ }
2135
+ util.win.top.location.href = src;
2136
+ } else if (
2137
+ util.win.top.location.href.indexOf('main.html') > -1
2138
+ ) {
2139
+ util.win.top.location.href = './login.html';
2140
+ } else {
2141
+ const hash = util.win.top.location.hash;
2142
+ if (hash) {
2143
+ const len = util.win.top.location.href.indexOf(hash);
2144
+ util.win.top.location.href =
2145
+ util.win.location.href.slice(0, len) + '#/login';
2146
+ } else {
2147
+ util.win.top.location.href = '/login.html';
2148
+ }
2149
+ }
2150
+ } catch (error) {
2151
+ util.win.postMessage({ type: 1 }, '*');
2152
+ }
2153
+ })
2154
+ .catch((e) => {
2155
+ sessionStorage.removeItem('remind');
2156
+ });
2157
+ }, 2000);
2158
+ }
2159
+ },
2160
+ openPage(url, name, width, height) {
2161
+ let src = url;
2162
+ if (!util.startWith(url, ['http', '/'], true)) {
2163
+ let pathname = window.location.pathname;
2164
+ if (pathname !== '/') {
2165
+ pathname = pathname.split('/');
2166
+ pathname.splice(pathname.length - 1);
2167
+ pathname = pathname.join('/');
2168
+ }
2169
+ src = pathname + url.replace('./', '/');
2170
+ }
2171
+ if (name) {
2172
+ let w = 0;
2173
+ let h = 0;
2174
+ try {
2175
+ w = width ? width : util.win.top.screen.availWidth - 10;
2176
+ h = height ? height : util.win.top.screen.availHeight - 60;
2177
+ } catch (error) {
2178
+ w = width ? width : util.win.screen.availWidth - 10;
2179
+ h = height ? height : util.win.screen.availHeight - 60;
2180
+ }
2181
+ return util.win.open(
2182
+ src,
2183
+ name,
2184
+ `width=${w}px,height=${h}px,resizable=yes,status=yes,menubar=no,scrollbars=yes`
2185
+ );
2186
+ } else {
2187
+ return util.win.open(src);
2188
+ }
2189
+ }
2190
+ },
2191
+ beforeDestroy() {
2192
+ this.timer = null;
2193
+ if (this.webSocket) {
2194
+ this.webSocket.destroy();
2195
+ }
2196
+ util.win.removeEventListener('popstate', this.tateHandle);
2197
+ }
2198
+ };
2199
+ </script>