eoss-ui 0.5.80 → 0.5.81-beta1

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