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

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 (201) 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.css +576 -575
  5. package/config/themes/atrovirens/atrovirens.css.map +1 -1
  6. package/config/themes/atrovirens/atrovirens.less +668 -667
  7. package/config/themes/atrovirens/var.less +675 -674
  8. package/config/themes/blue/blue.css +576 -575
  9. package/config/themes/blue/blue.css.map +1 -1
  10. package/config/themes/blue/blue.less +670 -669
  11. package/config/themes/blue/var.less +678 -677
  12. package/config/themes/blue-white/blue-white.css +576 -575
  13. package/config/themes/blue-white/blue-white.css.map +1 -1
  14. package/config/themes/blue-white/blue-white.less +670 -669
  15. package/config/themes/blue-white/var.less +677 -676
  16. package/config/themes/blue-white-tight/blue-white-tight.css +577 -576
  17. package/config/themes/blue-white-tight/blue-white-tight.css.map +1 -1
  18. package/config/themes/blue-white-tight/blue-white-tight.less +672 -672
  19. package/config/themes/blue-white-tight/var.less +678 -677
  20. package/config/themes/danqing/danqing.css +576 -575
  21. package/config/themes/danqing/danqing.css.map +1 -1
  22. package/config/themes/danqing/danqing.less +669 -668
  23. package/config/themes/danqing/danqing.wxss +576 -572
  24. package/config/themes/danqing/var.less +680 -679
  25. package/config/themes/deep/deep.css +576 -575
  26. package/config/themes/deep/deep.css.map +1 -1
  27. package/config/themes/deep/deep.less +670 -669
  28. package/config/themes/deep/var.less +678 -677
  29. package/config/themes/default/default.css +576 -575
  30. package/config/themes/default/default.css.map +1 -1
  31. package/config/themes/default/default.less +672 -671
  32. package/config/themes/default/var.less +678 -677
  33. package/config/themes/eap/eap.css +576 -575
  34. package/config/themes/eap/eap.css.map +1 -1
  35. package/config/themes/eap/eap.less +672 -671
  36. package/config/themes/eap/var.less +678 -677
  37. package/config/themes/gold/gold.css +576 -575
  38. package/config/themes/gold/gold.css.map +1 -1
  39. package/config/themes/gold/gold.less +672 -671
  40. package/config/themes/gold/var.less +678 -677
  41. package/config/themes/index.js +28 -28
  42. package/config/themes/lime/lime.css +576 -575
  43. package/config/themes/lime/lime.css.map +1 -1
  44. package/config/themes/lime/lime.less +672 -671
  45. package/config/themes/lime/var.less +679 -678
  46. package/config/themes/orange/orange.css +576 -575
  47. package/config/themes/orange/orange.css.map +1 -1
  48. package/config/themes/orange/orange.less +672 -671
  49. package/config/themes/orange/var.less +679 -678
  50. package/config/themes/red/red.css +576 -575
  51. package/config/themes/red/red.css.map +1 -1
  52. package/config/themes/red/red.less +672 -671
  53. package/config/themes/red/var.less +678 -677
  54. package/config/themes/theme-atrovirens.js +559 -558
  55. package/config/themes/theme-blue.js +559 -558
  56. package/config/themes/theme-bw.js +559 -558
  57. package/config/themes/theme-bwt.js +561 -559
  58. package/config/themes/theme-danqing.js +559 -558
  59. package/config/themes/theme-deep.js +559 -558
  60. package/config/themes/theme-default.js +559 -558
  61. package/config/themes/theme-eap.js +559 -558
  62. package/config/themes/theme-gold.js +559 -558
  63. package/config/themes/theme-lime.js +559 -558
  64. package/config/themes/theme-orange.js +560 -559
  65. package/config/themes/theme-red.js +559 -558
  66. package/config/themes/theme-white.js +558 -557
  67. package/config/themes/white/var.less +676 -675
  68. package/config/themes/white/white.css +576 -575
  69. package/config/themes/white/white.css.map +1 -1
  70. package/config/themes/white/white.less +669 -668
  71. package/directives/index.js +23 -23
  72. package/directives/module/draggable.js +56 -56
  73. package/directives/module/permission.js +49 -49
  74. package/directives/module/print.js +1 -1
  75. package/directives/module/vue-print-nb/README.md +63 -63
  76. package/directives/module/vue-print-nb/print.js +94 -94
  77. package/directives/module/vue-print-nb/printarea.js +532 -532
  78. package/index.js +10 -10
  79. package/nstyles/common.less +197 -197
  80. package/nstyles/components/404.less +46 -46
  81. package/nstyles/components/button.less +34 -34
  82. package/nstyles/components/date-picker.less +37 -37
  83. package/nstyles/components/drawer.less +20 -20
  84. package/nstyles/components/dropdown.less +18 -18
  85. package/nstyles/components/excel-flow.less +72 -72
  86. package/nstyles/components/form.less +313 -313
  87. package/nstyles/components/index.less +23 -23
  88. package/nstyles/components/layout/collect.less +10 -10
  89. package/nstyles/components/layout/detail-view.less +107 -107
  90. package/nstyles/components/layout/full-screen.less +7 -7
  91. package/nstyles/components/layout/index.less +7 -7
  92. package/nstyles/components/layout/other-menu.less +142 -142
  93. package/nstyles/components/layout/page-view.less +101 -101
  94. package/nstyles/components/layout/sider-trigger.less +41 -41
  95. package/nstyles/components/layout/tags-nav.less +113 -113
  96. package/nstyles/components/modal.less +85 -85
  97. package/nstyles/components/n-button.less +131 -131
  98. package/nstyles/components/n-image-preview.less +131 -131
  99. package/nstyles/components/n-model/index.less +19 -19
  100. package/nstyles/components/n-model/report-index.less +43 -43
  101. package/nstyles/components/n-panel.less +40 -40
  102. package/nstyles/components/n-picker.less +37 -37
  103. package/nstyles/components/n-sign.less +17 -17
  104. package/nstyles/components/n-tooltip.less +10 -10
  105. package/nstyles/components/panel.less +31 -31
  106. package/nstyles/components/select.less +3 -3
  107. package/nstyles/components/sign.less +27 -27
  108. package/nstyles/components/table.less +315 -315
  109. package/nstyles/components/tree.less +158 -158
  110. package/nstyles/components/upload.less +164 -164
  111. package/nstyles/index.less +5 -5
  112. package/nstyles/reset.less +65 -65
  113. package/nstyles/third/ag.less +174 -174
  114. package/nstyles/third/index.less +11 -11
  115. package/nstyles/third/view-design.less +366 -366
  116. package/nstyles/variables/base.less +143 -143
  117. package/nstyles/variables/index.less +4 -4
  118. package/nstyles/variables/theme/default/button.less +7 -7
  119. package/nstyles/variables/theme/default/common.less +57 -57
  120. package/nstyles/variables/theme/default/index.less +7 -7
  121. package/nstyles/variables/theme/default/layout.less +40 -40
  122. package/nstyles/variables/theme/default/table.less +37 -37
  123. package/nstyles/variables/theme/default/tag.less +3 -3
  124. package/nstyles/variables/theme/default/upload.less +3 -3
  125. package/nstyles/variables/theme/index.less +13 -13
  126. package/nstyles/variables/theme/lsv/button.less +7 -0
  127. package/nstyles/variables/theme/lsv/common.less +39 -0
  128. package/nstyles/variables/theme/lsv/index.less +5 -0
  129. package/nstyles/variables/theme/lsv/layout.less +21 -0
  130. package/nstyles/variables/theme/lsv/table.less +20 -0
  131. package/nstyles/variables/theme/lsv/tag.less +3 -0
  132. package/nstyles/variables/theme/small/button.less +7 -7
  133. package/nstyles/variables/theme/small/common.less +39 -39
  134. package/nstyles/variables/theme/small/index.less +5 -5
  135. package/nstyles/variables/theme/small/layout.less +21 -21
  136. package/nstyles/variables/theme/small/table.less +17 -17
  137. package/nstyles/variables/theme/small/tag.less +3 -3
  138. package/package.json +1 -1
  139. package/plugin/index.js +12 -12
  140. package/plugin/module/date-format.js +30 -30
  141. package/plugin/module/loading.js +26 -26
  142. package/plugin/module/warn-handler.js +11 -11
  143. package/styles/variables.less +21 -21
  144. package/utils/ajax/cacheconf.js +19 -19
  145. package/utils/ajax/content-type.js +30 -30
  146. package/utils/ajax/index.js +12 -12
  147. package/utils/ajax/interceptors.js +97 -97
  148. package/utils/ajax/sseFetchUtil.js +71 -71
  149. package/utils/assist.js +147 -147
  150. package/utils/base64.js +126 -126
  151. package/utils/blob.js +47 -47
  152. package/utils/bus.js +3 -3
  153. package/utils/crypto/index.js +48 -48
  154. package/utils/crypto/md5.js +152 -152
  155. package/utils/crypto/sm3.js +235 -235
  156. package/utils/date.js +381 -381
  157. package/utils/dict/built-in-dict.js +20 -20
  158. package/utils/dict/index.js +167 -167
  159. package/utils/dom.js +38 -38
  160. package/utils/event.js +72 -72
  161. package/utils/excel.js +655 -655
  162. package/utils/file.js +19 -19
  163. package/utils/form/validate.js +29 -29
  164. package/utils/half-year.js +68 -68
  165. package/utils/index.js +41 -41
  166. package/utils/json.js +29 -29
  167. package/utils/lodop.js +165 -165
  168. package/utils/menu/before-close.js +17 -17
  169. package/utils/menu/index.js +395 -395
  170. package/utils/mime_type.js +67 -67
  171. package/utils/modelerUtil.js +227 -227
  172. package/utils/n/api.js +22 -22
  173. package/utils/n/date.js +57 -57
  174. package/utils/n/index.js +9 -9
  175. package/utils/n/is-type.js +176 -176
  176. package/utils/n/number.js +144 -144
  177. package/utils/n/permission-cache.js +11 -11
  178. package/utils/n/reuqest/axiosN.js +17 -17
  179. package/utils/n/reuqest/content-type.js +19 -19
  180. package/utils/n/reuqest/interceptors.js +95 -95
  181. package/utils/n/reuqest/url-params.js +12 -12
  182. package/utils/n/storage.js +51 -51
  183. package/utils/n/token.js +51 -51
  184. package/utils/n/user-cache.js +11 -11
  185. package/utils/n/user.js +34 -34
  186. package/utils/n/uuid.js +16 -16
  187. package/utils/n-generator-routers.js +208 -208
  188. package/utils/n-router.js +205 -205
  189. package/utils/n-theme.js +30 -30
  190. package/utils/number.js +180 -180
  191. package/utils/oss.js +57 -57
  192. package/utils/platform.js +1343 -1334
  193. package/utils/quarter.js +58 -58
  194. package/utils/storage.js +198 -198
  195. package/utils/theme.js +138 -138
  196. package/utils/transform.js +204 -204
  197. package/utils/type.js +102 -102
  198. package/utils/util.js +795 -795
  199. package/utils/validator.js +181 -181
  200. package/utils/vxetable/index.js +25 -25
  201. 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;