@lambo-design/shared 1.0.0-beta.241 → 1.0.0-beta.243

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 (170) hide show
  1. package/config/config.js +51 -51
  2. package/config/env.js +4 -4
  3. package/config/index.js +7 -7
  4. package/config/themes/atrovirens/atrovirens.less +667 -667
  5. package/config/themes/atrovirens/var.less +674 -674
  6. package/config/themes/blue/blue.less +669 -669
  7. package/config/themes/blue/var.less +677 -677
  8. package/config/themes/blue-white/blue-white.less +669 -669
  9. package/config/themes/blue-white/var.less +676 -676
  10. package/config/themes/blue-white-tight/blue-white-tight.less +672 -672
  11. package/config/themes/blue-white-tight/var.less +677 -677
  12. package/config/themes/danqing/danqing.less +668 -668
  13. package/config/themes/danqing/danqing.wxss +572 -572
  14. package/config/themes/danqing/var.less +679 -679
  15. package/config/themes/deep/deep.less +669 -669
  16. package/config/themes/deep/var.less +677 -677
  17. package/config/themes/default/default.less +671 -671
  18. package/config/themes/default/var.less +677 -677
  19. package/config/themes/eap/eap.less +671 -671
  20. package/config/themes/eap/var.less +677 -677
  21. package/config/themes/gold/gold.less +671 -671
  22. package/config/themes/gold/var.less +677 -677
  23. package/config/themes/index.js +28 -28
  24. package/config/themes/lime/lime.less +671 -671
  25. package/config/themes/lime/var.less +678 -678
  26. package/config/themes/orange/orange.less +671 -671
  27. package/config/themes/orange/var.less +678 -678
  28. package/config/themes/red/red.less +671 -671
  29. package/config/themes/red/var.less +677 -677
  30. package/config/themes/theme-atrovirens.js +558 -558
  31. package/config/themes/theme-blue.js +558 -558
  32. package/config/themes/theme-bw.js +558 -558
  33. package/config/themes/theme-bwt.js +559 -559
  34. package/config/themes/theme-danqing.js +558 -558
  35. package/config/themes/theme-deep.js +558 -558
  36. package/config/themes/theme-default.js +558 -558
  37. package/config/themes/theme-eap.js +558 -558
  38. package/config/themes/theme-gold.js +558 -558
  39. package/config/themes/theme-lime.js +558 -558
  40. package/config/themes/theme-orange.js +559 -559
  41. package/config/themes/theme-red.js +558 -558
  42. package/config/themes/theme-white.js +557 -557
  43. package/config/themes/white/var.less +675 -675
  44. package/config/themes/white/white.less +668 -668
  45. package/directives/index.js +23 -23
  46. package/directives/module/draggable.js +56 -56
  47. package/directives/module/permission.js +49 -49
  48. package/directives/module/print.js +1 -1
  49. package/directives/module/vue-print-nb/README.md +63 -63
  50. package/directives/module/vue-print-nb/print.js +94 -94
  51. package/directives/module/vue-print-nb/printarea.js +532 -532
  52. package/index.js +10 -10
  53. package/nstyles/common.less +197 -197
  54. package/nstyles/components/404.less +46 -46
  55. package/nstyles/components/button.less +34 -34
  56. package/nstyles/components/date-picker.less +37 -37
  57. package/nstyles/components/drawer.less +20 -20
  58. package/nstyles/components/dropdown.less +18 -18
  59. package/nstyles/components/excel-flow.less +72 -72
  60. package/nstyles/components/form.less +313 -313
  61. package/nstyles/components/index.less +23 -23
  62. package/nstyles/components/layout/collect.less +10 -10
  63. package/nstyles/components/layout/detail-view.less +107 -107
  64. package/nstyles/components/layout/full-screen.less +7 -7
  65. package/nstyles/components/layout/index.less +7 -7
  66. package/nstyles/components/layout/other-menu.less +142 -142
  67. package/nstyles/components/layout/page-view.less +101 -101
  68. package/nstyles/components/layout/sider-trigger.less +41 -41
  69. package/nstyles/components/layout/tags-nav.less +113 -113
  70. package/nstyles/components/modal.less +85 -85
  71. package/nstyles/components/n-button.less +131 -131
  72. package/nstyles/components/n-image-preview.less +131 -131
  73. package/nstyles/components/n-model/index.less +19 -19
  74. package/nstyles/components/n-model/report-index.less +43 -43
  75. package/nstyles/components/n-panel.less +40 -40
  76. package/nstyles/components/n-picker.less +37 -37
  77. package/nstyles/components/n-sign.less +17 -17
  78. package/nstyles/components/n-tooltip.less +10 -10
  79. package/nstyles/components/panel.less +31 -31
  80. package/nstyles/components/select.less +3 -3
  81. package/nstyles/components/sign.less +27 -27
  82. package/nstyles/components/table.less +315 -315
  83. package/nstyles/components/tree.less +158 -158
  84. package/nstyles/components/upload.less +164 -164
  85. package/nstyles/index.less +5 -5
  86. package/nstyles/reset.less +65 -65
  87. package/nstyles/third/ag.less +174 -174
  88. package/nstyles/third/index.less +11 -11
  89. package/nstyles/third/view-design.less +366 -366
  90. package/nstyles/variables/base.less +143 -143
  91. package/nstyles/variables/index.less +4 -4
  92. package/nstyles/variables/theme/default/button.less +7 -7
  93. package/nstyles/variables/theme/default/common.less +57 -57
  94. package/nstyles/variables/theme/default/index.less +7 -7
  95. package/nstyles/variables/theme/default/layout.less +40 -40
  96. package/nstyles/variables/theme/default/table.less +37 -37
  97. package/nstyles/variables/theme/default/tag.less +3 -3
  98. package/nstyles/variables/theme/default/upload.less +3 -3
  99. package/nstyles/variables/theme/index.less +13 -13
  100. package/nstyles/variables/theme/small/button.less +7 -7
  101. package/nstyles/variables/theme/small/common.less +39 -39
  102. package/nstyles/variables/theme/small/index.less +5 -5
  103. package/nstyles/variables/theme/small/layout.less +21 -21
  104. package/nstyles/variables/theme/small/table.less +17 -17
  105. package/nstyles/variables/theme/small/tag.less +3 -3
  106. package/package.json +1 -1
  107. package/plugin/index.js +12 -12
  108. package/plugin/module/date-format.js +30 -30
  109. package/plugin/module/loading.js +26 -26
  110. package/plugin/module/warn-handler.js +11 -11
  111. package/styles/variables.less +21 -21
  112. package/utils/ajax/cacheconf.js +19 -19
  113. package/utils/ajax/content-type.js +30 -30
  114. package/utils/ajax/index.js +12 -12
  115. package/utils/ajax/interceptors.js +97 -97
  116. package/utils/assist.js +147 -147
  117. package/utils/base64.js +126 -126
  118. package/utils/blob.js +47 -47
  119. package/utils/bus.js +3 -3
  120. package/utils/crypto/index.js +48 -48
  121. package/utils/crypto/md5.js +152 -152
  122. package/utils/crypto/sm3.js +235 -235
  123. package/utils/date.js +381 -381
  124. package/utils/dict/built-in-dict.js +20 -20
  125. package/utils/dict/index.js +167 -167
  126. package/utils/dom.js +38 -38
  127. package/utils/event.js +72 -72
  128. package/utils/excel.js +655 -655
  129. package/utils/file.js +19 -19
  130. package/utils/form/validate.js +29 -29
  131. package/utils/half-year.js +68 -68
  132. package/utils/index.js +41 -41
  133. package/utils/json.js +29 -29
  134. package/utils/lodop.js +165 -165
  135. package/utils/menu/before-close.js +17 -17
  136. package/utils/menu/index.js +395 -395
  137. package/utils/mime_type.js +67 -67
  138. package/utils/modelerUtil.js +227 -227
  139. package/utils/n/api.js +22 -22
  140. package/utils/n/date.js +57 -57
  141. package/utils/n/index.js +9 -9
  142. package/utils/n/is-type.js +176 -176
  143. package/utils/n/number.js +144 -144
  144. package/utils/n/permission-cache.js +11 -11
  145. package/utils/n/reuqest/axiosN.js +17 -17
  146. package/utils/n/reuqest/content-type.js +19 -19
  147. package/utils/n/reuqest/interceptors.js +95 -95
  148. package/utils/n/reuqest/url-params.js +12 -12
  149. package/utils/n/storage.js +51 -51
  150. package/utils/n/token.js +51 -51
  151. package/utils/n/user-cache.js +11 -11
  152. package/utils/n/user.js +34 -34
  153. package/utils/n/uuid.js +16 -16
  154. package/utils/n-generator-routers.js +208 -208
  155. package/utils/n-router.js +205 -205
  156. package/utils/n-theme.js +30 -30
  157. package/utils/number.js +180 -180
  158. package/utils/oss.js +57 -57
  159. package/utils/platform.js +1334 -1334
  160. package/utils/quarter.js +58 -58
  161. package/utils/storage.js +198 -198
  162. package/utils/style.js +24 -24
  163. package/utils/theme.js +138 -138
  164. package/utils/transfer-queue.js +7 -7
  165. package/utils/transform.js +204 -204
  166. package/utils/type.js +102 -102
  167. package/utils/util.js +795 -795
  168. package/utils/validator.js +181 -181
  169. package/utils/vxetable/index.js +25 -25
  170. package/utils/zoomScroll.js +9 -9
@@ -1,395 +1,395 @@
1
- import config from "../../config/config"
2
- import {deepCopy} from "../assist";
3
- import {getUrlParams} from "../platform"
4
- /**
5
- * 判断是否存在路由
6
- * @param $router
7
- * @param name
8
- * @returns {*|boolean}
9
- */
10
- export const hasRoute = ($router, name) => {
11
- let routes = $router.getRoutes();
12
- let res = routes.filter(item => item.name === name)
13
- return res && res.length > 0
14
- }
15
- /**
16
- * 判断是否存在路由并且页面存在
17
- * @param $router
18
- * @param path
19
- * @returns {*|boolean}
20
- */
21
- export const hasRoutePath = ($router, path) => {
22
- if ($router && path) {
23
- let routes = $router.getRoutes();
24
- if (path.trim().startsWith("dida/")) {
25
- path = path.trim().replace("dida/","");
26
- if (!path.startsWith("/")) {
27
- path = "/" + path;
28
- }
29
- } else if (path.trim().startsWith("dareport/")) {
30
- path = path.trim().replace("dareport/","");
31
- if (!path.startsWith("/")) {
32
- path = "/" + path;
33
- }
34
- } else if (path.trim().startsWith("/" + config.routerBase + "/")) {
35
- path = "/" + path.replace("/" + config.routerBase + "/","")
36
- }
37
- let res = routes.filter(item => item.path === path)
38
- return res && res.length > 0
39
- }
40
- return false
41
- }
42
- /**
43
- * 动态生成菜单
44
- * @param permissionList
45
- * @returns []
46
- */
47
- export const generatorMenuList = (permissionList,appId,generateType = 'router') => {
48
- let menuRouter = generatorMenuRouter(permissionList,appId,generateType);
49
- return menuRouter && menuRouter.menuData ? menuRouter.menuData : [];
50
- };
51
- /**
52
- * 动态生成菜单
53
- * @param generatorMenuRouter
54
- * @returns []
55
- */
56
- export const generatorMenuRouter = (permissionList,appId,generateType = 'router') => {
57
- let menuData = [],
58
- pageNode = {
59
- path: "/page",
60
- name: "page",
61
- meta: {
62
- hideInMenu: true,
63
- notCache: true
64
- },
65
- component: "Main",
66
- children: []
67
- };
68
- listToMenuTree(permissionList, menuData, pageNode, "0", [], true,appId,generateType);
69
- return {menuData,pageNode};
70
- };
71
-
72
-
73
- /**
74
- * 数组转树形结构
75
- */
76
- const listToMenuTree = (list, menuTree, pageNode, parentId, crumbs, root, appId,generateType = 'router') => {
77
- if (list == null) {
78
- return;
79
- }
80
- list.forEach(item => {
81
- let appIdCondition = !appId || item.appId == appId || appId.indexOf(item.appId) > -1;//过滤是否要求的应用
82
- let hideInMenuCondition = !(item.hasOwnProperty("hideInMenu") && item.hideInMenu);//过滤是否隐藏的菜单
83
- if ((generateType && generateType == 'router' && appIdCondition) ||
84
- (generateType == 'menu' && appIdCondition && hideInMenuCondition)) {
85
- // 判断是否为父级菜单
86
- if (item.pid === parentId) {
87
- if (item.type === 1 || item.type === 2) {
88
- let node = {
89
- meta: {
90
- data: deepCopy(item),
91
- appId: item.appId,
92
- title: item.label,
93
- icon: item.icon,
94
- crumbs: [...crumbs],
95
- activeName: item.name,
96
- notCache: item.notCache ? true : false,
97
- hideInMenu: item.hideInMenu ? true : false
98
- },
99
- permissionId: item.permissionId,
100
- type: item.type,
101
- pid: item.pid,
102
- component: item.name,
103
- name: item.name,
104
- uri: item.uri,
105
- children: []
106
- };
107
- node.meta.crumbs.push({
108
- icon: item.icon,
109
- name: item.name,
110
- title: item.label,
111
- type: item.type
112
- });
113
-
114
- if (item.type === 1) {
115
- if (root) {
116
- node.component = "Main";
117
- } else {
118
- node.component = "parentView";
119
- }
120
- }
121
- // 迭代 list, 找到当前菜单相符合的所有子菜单
122
- listToMenuTree(
123
- list,
124
- node.children,
125
- pageNode,
126
- item.permissionId,
127
- node.meta.crumbs,
128
- false,
129
- appId,
130
- generateType
131
- );
132
- // 删掉不存在 children 值的属性
133
- if (node.children.length <= 0) {
134
- delete node.children;
135
- }
136
- // 加入到树中
137
- menuTree.push(node);
138
- }
139
- if (item.type === 4) {
140
- let child = {
141
- meta: {
142
- data: deepCopy(item),
143
- appId: item.appId,
144
- title: item.label,
145
- hideInMenu: true,
146
- notCache: true,
147
- crumbs: [...crumbs],
148
- type: item.type
149
- },
150
- permissionId: item.permissionId,
151
- type: item.type,
152
- pid: item.pid,
153
- component: item.name,
154
- name: item.name,
155
- uri: item.uri
156
- };
157
- child.meta.crumbs.push({
158
- icon: item.icon,
159
- name: item.name,
160
- title: item.label,
161
- type: item.type
162
- });
163
- pageNode.children.push(child);
164
- }
165
- }
166
- }
167
- });
168
- };
169
-
170
- /**
171
- * 动态生成路由
172
- * @param generatorMenuRouter
173
- * @returns []
174
- */
175
- export const generatorDynamicRouter = (permissionList,constantRouterComponents,appIds = null,generateType = 'router') => {
176
- let allMenu = generatorMenuRouter(permissionList, appIds,generateType);
177
- let menuData = allMenu.menuData;
178
- let pageNode = allMenu.pageNode;
179
- if (menuData && pageNode && pageNode.children.length > 0) {
180
- menuData.push(pageNode);
181
- }
182
- //给路由添加面包屑属性,解决示例页面左侧菜单点击不选中的问题
183
- //routesAddCrumbs(exampleMenuData,[]);
184
- //menuData = menuData.concat(exampleMenuData)
185
- let dynamicRouter = generator(menuData,constantRouterComponents);
186
-
187
- return dynamicRouter;
188
- }
189
- /**
190
- * 路由添加面包屑属性
191
- */
192
- export const routesAddCrumbs = (routes ,crumbs) => {
193
- routes.forEach(item => {
194
- if (item.meta.hasOwnProperty('crumbs')){
195
- item.meta.crumbs.push({
196
- icon: item.meta.icon,
197
- name: item.name,
198
- title: item.meta.title,
199
- type: item.type
200
- });
201
- }else{
202
- item.meta['crumbs'] = [...crumbs];
203
- item.meta.crumbs.push({
204
- icon: item.meta.icon,
205
- name: item.name,
206
- title: item.meta.title,
207
- type: item.type
208
- });
209
- }
210
- if (item.hasOwnProperty("children")){
211
- routesAddCrumbs(item.children,item.meta.crumbs)
212
- }
213
- });
214
- }
215
-
216
- /*
217
- 生成 vue-router 层级路由表
218
- */
219
- const generator = (menuData,constantRouterComponents) => {
220
- for (let item of menuData) {
221
- if (item.component && typeof item.component == "string") {
222
- const target = constantRouterComponents[item.component];
223
- if (target) {
224
- if (target.component) {
225
- if (typeof target.component == "string") {
226
- // 解决路由name与组件name不一致导致的keeplive不生效的问题
227
- try {
228
- //let componentPath = '@/view/' + target.component;
229
- item.component = resolve =>
230
- require(['@/view/'+ target.component], data => {
231
- data.default.name = item.name;
232
- resolve(data);
233
- });
234
- }catch (e) {
235
- delete item.component
236
- }
237
- } else {
238
- item.component = target.component;
239
- }
240
- }
241
- if (target.url) {
242
- let path = target.url;
243
- let query = {};
244
- if (path.indexOf("?") > -1) {
245
- query = getUrlParams(path.substr(path.indexOf("?")));
246
- item.query = query;
247
- path = path.substr(0,path.indexOf("?"));
248
- }
249
- item.path = path;
250
- }
251
- if (item.uri) {
252
- item.meta.uriParam = item.uri;
253
- }
254
- if (target.notCache) {
255
- item.meta.notCache = target.notCache;
256
- }
257
- if (target.hideInMenu) {
258
- item.meta.hideInMenu = target.hideInMenu;
259
- }
260
- }
261
- if (item.uri) {
262
- if (item.uri.startsWith("/")) {
263
- item.uri = item.uri.substr(1);
264
- }
265
- let uri = item.uri;
266
- if (uri.startsWith(config.routerBase + "/")) {
267
- uri = uri.replace(config.routerBase + "/","")
268
- }
269
- if (uri.startsWith("dida/")) {
270
- item.meta.notCache = true;
271
- let path = uri;
272
- let query = {};
273
- if (path.indexOf("?") > -1) {
274
- query = getUrlParams(path.substr(path.indexOf("?")));
275
- item.query = query;
276
- path = path.substr(0,path.indexOf("?"));
277
- }
278
- try{
279
- //let path = '@/view/dida/dida-page';
280
- item.component = resolve => {
281
- require(['@/view/dida/dida-page'], data => {
282
- data.default.name = item.name;
283
- resolve(data);
284
- });
285
- };
286
- }catch (e){
287
- delete item.component
288
- }
289
- item.path = "/" + path;
290
- } else if(uri.startsWith("dareport/")){
291
- item.meta.notCache = true;
292
- let path = uri;
293
- let query = {};
294
- if (path.indexOf("?") > -1) {
295
- query = getUrlParams(path.substr(path.indexOf("?")));
296
- item.query = query;
297
- path = path.substr(0,path.indexOf("?"));
298
- }
299
- try{
300
- item.component = resolve => {
301
- require(['@/view/dida/dida-page'], data => {
302
- data.default.name = item.name;
303
- resolve(data);
304
- });
305
- };
306
- }catch (e){
307
- delete item.component
308
- }
309
- item.path = "/" + path;
310
- } else {
311
- try{
312
- let path = item.uri;
313
- if (item.uri.startsWith(config.routerBase + "/")) {
314
- path = path.replace(config.routerBase + "/","")
315
- }
316
- let query = {};
317
- if (path.indexOf("?") > -1) {
318
- query = getUrlParams(path.substr(path.indexOf("?")));
319
- path = path.substr(0,path.indexOf("?"));
320
- }
321
- if (target && target.component) {
322
-
323
- } else {
324
- let component = require('@/view/' + path);
325
- if (component) {
326
- item.component = resolve => {
327
- require(['@/view/' + path], data => {
328
- data.default.name = item.name;
329
- resolve(data);
330
- });
331
- };
332
- } else {
333
- //console.warn(`${item.name}(${item.uri})页面不存在`)
334
- delete item.component;
335
- }
336
- }
337
- if (target && target.url) {
338
-
339
- } else {
340
- item.path = "/" + path;
341
- item.query = query;
342
- }
343
- }catch (e){
344
- //console.warn(`${item.name}(${item.uri})页面不存在`)
345
- delete item.component;
346
- }
347
- }
348
- }
349
- if (item.path == null) {
350
- item.path = "";
351
- }
352
- if (item.component && typeof item.component == "string") {
353
- delete item.component;
354
- }
355
- if (item.children && item.children.length > 0) {
356
- generator(item.children,constantRouterComponents);
357
- }
358
- }
359
- }
360
- return menuData;
361
- };
362
-
363
- /**
364
- * 根据权限组织tab数据
365
- * @param originMenuList
366
- * @param name
367
- * @param appId
368
- * @returns {{}}
369
- */
370
- export const generateTabDataFromPermission = (originMenuList,name,appId) => {
371
- let menuItem = {};
372
- if (name && originMenuList) {
373
- let originalMenu = originMenuList.find(item => item.name == name && item.type && item.type == '2' && (appId && item.appId == appId || !appId));
374
- if (originalMenu && originalMenu.name) {
375
- menuItem = {
376
- meta: {
377
- data: originalMenu,
378
- appId: originalMenu.appId,
379
- title: originalMenu.label,
380
- icon: originalMenu.icon,
381
- crumbs: [],
382
- activeName: originalMenu.name
383
- },
384
- permissionId: originalMenu.permissionId,
385
- pid: originalMenu.pid,
386
- type: originalMenu.type,
387
- name: originalMenu.name,
388
- uri: originalMenu.uri
389
- }
390
- }
391
- }
392
- return menuItem;
393
- }
394
-
395
- export default generatorMenuList;
1
+ import config from "../../config/config"
2
+ import {deepCopy} from "../assist";
3
+ import {getUrlParams} from "../platform"
4
+ /**
5
+ * 判断是否存在路由
6
+ * @param $router
7
+ * @param name
8
+ * @returns {*|boolean}
9
+ */
10
+ export const hasRoute = ($router, name) => {
11
+ let routes = $router.getRoutes();
12
+ let res = routes.filter(item => item.name === name)
13
+ return res && res.length > 0
14
+ }
15
+ /**
16
+ * 判断是否存在路由并且页面存在
17
+ * @param $router
18
+ * @param path
19
+ * @returns {*|boolean}
20
+ */
21
+ export const hasRoutePath = ($router, path) => {
22
+ if ($router && path) {
23
+ let routes = $router.getRoutes();
24
+ if (path.trim().startsWith("dida/")) {
25
+ path = path.trim().replace("dida/","");
26
+ if (!path.startsWith("/")) {
27
+ path = "/" + path;
28
+ }
29
+ } else if (path.trim().startsWith("dareport/")) {
30
+ path = path.trim().replace("dareport/","");
31
+ if (!path.startsWith("/")) {
32
+ path = "/" + path;
33
+ }
34
+ } else if (path.trim().startsWith("/" + config.routerBase + "/")) {
35
+ path = "/" + path.replace("/" + config.routerBase + "/","")
36
+ }
37
+ let res = routes.filter(item => item.path === path)
38
+ return res && res.length > 0
39
+ }
40
+ return false
41
+ }
42
+ /**
43
+ * 动态生成菜单
44
+ * @param permissionList
45
+ * @returns []
46
+ */
47
+ export const generatorMenuList = (permissionList,appId,generateType = 'router') => {
48
+ let menuRouter = generatorMenuRouter(permissionList,appId,generateType);
49
+ return menuRouter && menuRouter.menuData ? menuRouter.menuData : [];
50
+ };
51
+ /**
52
+ * 动态生成菜单
53
+ * @param generatorMenuRouter
54
+ * @returns []
55
+ */
56
+ export const generatorMenuRouter = (permissionList,appId,generateType = 'router') => {
57
+ let menuData = [],
58
+ pageNode = {
59
+ path: "/page",
60
+ name: "page",
61
+ meta: {
62
+ hideInMenu: true,
63
+ notCache: true
64
+ },
65
+ component: "Main",
66
+ children: []
67
+ };
68
+ listToMenuTree(permissionList, menuData, pageNode, "0", [], true,appId,generateType);
69
+ return {menuData,pageNode};
70
+ };
71
+
72
+
73
+ /**
74
+ * 数组转树形结构
75
+ */
76
+ const listToMenuTree = (list, menuTree, pageNode, parentId, crumbs, root, appId,generateType = 'router') => {
77
+ if (list == null) {
78
+ return;
79
+ }
80
+ list.forEach(item => {
81
+ let appIdCondition = !appId || item.appId == appId || appId.indexOf(item.appId) > -1;//过滤是否要求的应用
82
+ let hideInMenuCondition = !(item.hasOwnProperty("hideInMenu") && item.hideInMenu);//过滤是否隐藏的菜单
83
+ if ((generateType && generateType == 'router' && appIdCondition) ||
84
+ (generateType == 'menu' && appIdCondition && hideInMenuCondition)) {
85
+ // 判断是否为父级菜单
86
+ if (item.pid === parentId) {
87
+ if (item.type === 1 || item.type === 2) {
88
+ let node = {
89
+ meta: {
90
+ data: deepCopy(item),
91
+ appId: item.appId,
92
+ title: item.label,
93
+ icon: item.icon,
94
+ crumbs: [...crumbs],
95
+ activeName: item.name,
96
+ notCache: item.notCache ? true : false,
97
+ hideInMenu: item.hideInMenu ? true : false
98
+ },
99
+ permissionId: item.permissionId,
100
+ type: item.type,
101
+ pid: item.pid,
102
+ component: item.name,
103
+ name: item.name,
104
+ uri: item.uri,
105
+ children: []
106
+ };
107
+ node.meta.crumbs.push({
108
+ icon: item.icon,
109
+ name: item.name,
110
+ title: item.label,
111
+ type: item.type
112
+ });
113
+
114
+ if (item.type === 1) {
115
+ if (root) {
116
+ node.component = "Main";
117
+ } else {
118
+ node.component = "parentView";
119
+ }
120
+ }
121
+ // 迭代 list, 找到当前菜单相符合的所有子菜单
122
+ listToMenuTree(
123
+ list,
124
+ node.children,
125
+ pageNode,
126
+ item.permissionId,
127
+ node.meta.crumbs,
128
+ false,
129
+ appId,
130
+ generateType
131
+ );
132
+ // 删掉不存在 children 值的属性
133
+ if (node.children.length <= 0) {
134
+ delete node.children;
135
+ }
136
+ // 加入到树中
137
+ menuTree.push(node);
138
+ }
139
+ if (item.type === 4) {
140
+ let child = {
141
+ meta: {
142
+ data: deepCopy(item),
143
+ appId: item.appId,
144
+ title: item.label,
145
+ hideInMenu: true,
146
+ notCache: true,
147
+ crumbs: [...crumbs],
148
+ type: item.type
149
+ },
150
+ permissionId: item.permissionId,
151
+ type: item.type,
152
+ pid: item.pid,
153
+ component: item.name,
154
+ name: item.name,
155
+ uri: item.uri
156
+ };
157
+ child.meta.crumbs.push({
158
+ icon: item.icon,
159
+ name: item.name,
160
+ title: item.label,
161
+ type: item.type
162
+ });
163
+ pageNode.children.push(child);
164
+ }
165
+ }
166
+ }
167
+ });
168
+ };
169
+
170
+ /**
171
+ * 动态生成路由
172
+ * @param generatorMenuRouter
173
+ * @returns []
174
+ */
175
+ export const generatorDynamicRouter = (permissionList,constantRouterComponents,appIds = null,generateType = 'router') => {
176
+ let allMenu = generatorMenuRouter(permissionList, appIds,generateType);
177
+ let menuData = allMenu.menuData;
178
+ let pageNode = allMenu.pageNode;
179
+ if (menuData && pageNode && pageNode.children.length > 0) {
180
+ menuData.push(pageNode);
181
+ }
182
+ //给路由添加面包屑属性,解决示例页面左侧菜单点击不选中的问题
183
+ //routesAddCrumbs(exampleMenuData,[]);
184
+ //menuData = menuData.concat(exampleMenuData)
185
+ let dynamicRouter = generator(menuData,constantRouterComponents);
186
+
187
+ return dynamicRouter;
188
+ }
189
+ /**
190
+ * 路由添加面包屑属性
191
+ */
192
+ export const routesAddCrumbs = (routes ,crumbs) => {
193
+ routes.forEach(item => {
194
+ if (item.meta.hasOwnProperty('crumbs')){
195
+ item.meta.crumbs.push({
196
+ icon: item.meta.icon,
197
+ name: item.name,
198
+ title: item.meta.title,
199
+ type: item.type
200
+ });
201
+ }else{
202
+ item.meta['crumbs'] = [...crumbs];
203
+ item.meta.crumbs.push({
204
+ icon: item.meta.icon,
205
+ name: item.name,
206
+ title: item.meta.title,
207
+ type: item.type
208
+ });
209
+ }
210
+ if (item.hasOwnProperty("children")){
211
+ routesAddCrumbs(item.children,item.meta.crumbs)
212
+ }
213
+ });
214
+ }
215
+
216
+ /*
217
+ 生成 vue-router 层级路由表
218
+ */
219
+ const generator = (menuData,constantRouterComponents) => {
220
+ for (let item of menuData) {
221
+ if (item.component && typeof item.component == "string") {
222
+ const target = constantRouterComponents[item.component];
223
+ if (target) {
224
+ if (target.component) {
225
+ if (typeof target.component == "string") {
226
+ // 解决路由name与组件name不一致导致的keeplive不生效的问题
227
+ try {
228
+ //let componentPath = '@/view/' + target.component;
229
+ item.component = resolve =>
230
+ require(['@/view/'+ target.component], data => {
231
+ data.default.name = item.name;
232
+ resolve(data);
233
+ });
234
+ }catch (e) {
235
+ delete item.component
236
+ }
237
+ } else {
238
+ item.component = target.component;
239
+ }
240
+ }
241
+ if (target.url) {
242
+ let path = target.url;
243
+ let query = {};
244
+ if (path.indexOf("?") > -1) {
245
+ query = getUrlParams(path.substr(path.indexOf("?")));
246
+ item.query = query;
247
+ path = path.substr(0,path.indexOf("?"));
248
+ }
249
+ item.path = path;
250
+ }
251
+ if (item.uri) {
252
+ item.meta.uriParam = item.uri;
253
+ }
254
+ if (target.notCache) {
255
+ item.meta.notCache = target.notCache;
256
+ }
257
+ if (target.hideInMenu) {
258
+ item.meta.hideInMenu = target.hideInMenu;
259
+ }
260
+ }
261
+ if (item.uri) {
262
+ if (item.uri.startsWith("/")) {
263
+ item.uri = item.uri.substr(1);
264
+ }
265
+ let uri = item.uri;
266
+ if (uri.startsWith(config.routerBase + "/")) {
267
+ uri = uri.replace(config.routerBase + "/","")
268
+ }
269
+ if (uri.startsWith("dida/")) {
270
+ item.meta.notCache = true;
271
+ let path = uri;
272
+ let query = {};
273
+ if (path.indexOf("?") > -1) {
274
+ query = getUrlParams(path.substr(path.indexOf("?")));
275
+ item.query = query;
276
+ path = path.substr(0,path.indexOf("?"));
277
+ }
278
+ try{
279
+ //let path = '@/view/dida/dida-page';
280
+ item.component = resolve => {
281
+ require(['@/view/dida/dida-page'], data => {
282
+ data.default.name = item.name;
283
+ resolve(data);
284
+ });
285
+ };
286
+ }catch (e){
287
+ delete item.component
288
+ }
289
+ item.path = "/" + path;
290
+ } else if(uri.startsWith("dareport/")){
291
+ item.meta.notCache = true;
292
+ let path = uri;
293
+ let query = {};
294
+ if (path.indexOf("?") > -1) {
295
+ query = getUrlParams(path.substr(path.indexOf("?")));
296
+ item.query = query;
297
+ path = path.substr(0,path.indexOf("?"));
298
+ }
299
+ try{
300
+ item.component = resolve => {
301
+ require(['@/view/dida/dida-page'], data => {
302
+ data.default.name = item.name;
303
+ resolve(data);
304
+ });
305
+ };
306
+ }catch (e){
307
+ delete item.component
308
+ }
309
+ item.path = "/" + path;
310
+ } else {
311
+ try{
312
+ let path = item.uri;
313
+ if (item.uri.startsWith(config.routerBase + "/")) {
314
+ path = path.replace(config.routerBase + "/","")
315
+ }
316
+ let query = {};
317
+ if (path.indexOf("?") > -1) {
318
+ query = getUrlParams(path.substr(path.indexOf("?")));
319
+ path = path.substr(0,path.indexOf("?"));
320
+ }
321
+ if (target && target.component) {
322
+
323
+ } else {
324
+ let component = require('@/view/' + path);
325
+ if (component) {
326
+ item.component = resolve => {
327
+ require(['@/view/' + path], data => {
328
+ data.default.name = item.name;
329
+ resolve(data);
330
+ });
331
+ };
332
+ } else {
333
+ //console.warn(`${item.name}(${item.uri})页面不存在`)
334
+ delete item.component;
335
+ }
336
+ }
337
+ if (target && target.url) {
338
+
339
+ } else {
340
+ item.path = "/" + path;
341
+ item.query = query;
342
+ }
343
+ }catch (e){
344
+ //console.warn(`${item.name}(${item.uri})页面不存在`)
345
+ delete item.component;
346
+ }
347
+ }
348
+ }
349
+ if (item.path == null) {
350
+ item.path = "";
351
+ }
352
+ if (item.component && typeof item.component == "string") {
353
+ delete item.component;
354
+ }
355
+ if (item.children && item.children.length > 0) {
356
+ generator(item.children,constantRouterComponents);
357
+ }
358
+ }
359
+ }
360
+ return menuData;
361
+ };
362
+
363
+ /**
364
+ * 根据权限组织tab数据
365
+ * @param originMenuList
366
+ * @param name
367
+ * @param appId
368
+ * @returns {{}}
369
+ */
370
+ export const generateTabDataFromPermission = (originMenuList,name,appId) => {
371
+ let menuItem = {};
372
+ if (name && originMenuList) {
373
+ let originalMenu = originMenuList.find(item => item.name == name && item.type && item.type == '2' && (appId && item.appId == appId || !appId));
374
+ if (originalMenu && originalMenu.name) {
375
+ menuItem = {
376
+ meta: {
377
+ data: originalMenu,
378
+ appId: originalMenu.appId,
379
+ title: originalMenu.label,
380
+ icon: originalMenu.icon,
381
+ crumbs: [],
382
+ activeName: originalMenu.name
383
+ },
384
+ permissionId: originalMenu.permissionId,
385
+ pid: originalMenu.pid,
386
+ type: originalMenu.type,
387
+ name: originalMenu.name,
388
+ uri: originalMenu.uri
389
+ }
390
+ }
391
+ }
392
+ return menuItem;
393
+ }
394
+
395
+ export default generatorMenuList;