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

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 (176) 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/lsv/button.less +7 -0
  101. package/nstyles/variables/theme/lsv/common.less +39 -0
  102. package/nstyles/variables/theme/lsv/index.less +5 -0
  103. package/nstyles/variables/theme/lsv/layout.less +21 -0
  104. package/nstyles/variables/theme/lsv/table.less +20 -0
  105. package/nstyles/variables/theme/lsv/tag.less +3 -0
  106. package/nstyles/variables/theme/small/button.less +7 -7
  107. package/nstyles/variables/theme/small/common.less +39 -39
  108. package/nstyles/variables/theme/small/index.less +5 -5
  109. package/nstyles/variables/theme/small/layout.less +21 -21
  110. package/nstyles/variables/theme/small/table.less +17 -17
  111. package/nstyles/variables/theme/small/tag.less +3 -3
  112. package/package.json +1 -1
  113. package/plugin/index.js +12 -12
  114. package/plugin/module/date-format.js +30 -30
  115. package/plugin/module/loading.js +26 -26
  116. package/plugin/module/warn-handler.js +11 -11
  117. package/styles/variables.less +21 -21
  118. package/utils/ajax/cacheconf.js +19 -19
  119. package/utils/ajax/content-type.js +30 -30
  120. package/utils/ajax/index.js +12 -12
  121. package/utils/ajax/interceptors.js +97 -97
  122. package/utils/assist.js +147 -147
  123. package/utils/base64.js +126 -126
  124. package/utils/blob.js +47 -47
  125. package/utils/bus.js +3 -3
  126. package/utils/crypto/index.js +48 -48
  127. package/utils/crypto/md5.js +152 -152
  128. package/utils/crypto/sm3.js +235 -235
  129. package/utils/date.js +381 -381
  130. package/utils/dict/built-in-dict.js +20 -20
  131. package/utils/dict/index.js +167 -167
  132. package/utils/dom.js +38 -38
  133. package/utils/event.js +72 -72
  134. package/utils/excel.js +655 -655
  135. package/utils/file.js +19 -19
  136. package/utils/form/validate.js +29 -29
  137. package/utils/half-year.js +68 -68
  138. package/utils/index.js +41 -41
  139. package/utils/json.js +29 -29
  140. package/utils/lodop.js +165 -165
  141. package/utils/menu/before-close.js +17 -17
  142. package/utils/menu/index.js +395 -395
  143. package/utils/mime_type.js +67 -67
  144. package/utils/modelerUtil.js +227 -227
  145. package/utils/n/api.js +22 -22
  146. package/utils/n/date.js +57 -57
  147. package/utils/n/index.js +9 -9
  148. package/utils/n/is-type.js +176 -176
  149. package/utils/n/number.js +144 -144
  150. package/utils/n/permission-cache.js +11 -11
  151. package/utils/n/reuqest/axiosN.js +17 -17
  152. package/utils/n/reuqest/content-type.js +19 -19
  153. package/utils/n/reuqest/interceptors.js +95 -95
  154. package/utils/n/reuqest/url-params.js +12 -12
  155. package/utils/n/storage.js +51 -51
  156. package/utils/n/token.js +51 -51
  157. package/utils/n/user-cache.js +11 -11
  158. package/utils/n/user.js +34 -34
  159. package/utils/n/uuid.js +16 -16
  160. package/utils/n-generator-routers.js +208 -208
  161. package/utils/n-router.js +205 -205
  162. package/utils/n-theme.js +30 -30
  163. package/utils/number.js +180 -180
  164. package/utils/oss.js +57 -57
  165. package/utils/platform.js +1343 -1334
  166. package/utils/quarter.js +58 -58
  167. package/utils/storage.js +198 -198
  168. package/utils/style.js +24 -24
  169. package/utils/theme.js +138 -138
  170. package/utils/transfer-queue.js +7 -7
  171. package/utils/transform.js +204 -204
  172. package/utils/type.js +102 -102
  173. package/utils/util.js +795 -795
  174. package/utils/validator.js +181 -181
  175. package/utils/vxetable/index.js +25 -25
  176. package/utils/zoomScroll.js +9 -9
package/utils/platform.js CHANGED
@@ -1,1334 +1,1343 @@
1
- import {deepCopy} from './assist';
2
- import _ from 'lodash';
3
- import config from "../config/config";
4
- import systemLogo from '../styles/image/inspur.png';
5
- import {changeByThemeKey, changeThemeByThemeId} from "./theme";
6
- import ajax from "./ajax";
7
-
8
- export const TOKEN_KEY = 'lambo-token'
9
-
10
- export const COOKIE_KEY = 'lambo-sso-key'
11
-
12
- export const SSO_TOKEN_KEY = 'lambo-sso-token'
13
-
14
- export function objEqual(obj1, obj2) {
15
- const keysArr1 = Object.keys(obj1)
16
- const keysArr2 = Object.keys(obj2)
17
- if (keysArr1.length !== keysArr2.length) return false
18
- else if (keysArr1.length === 0 && keysArr2.length === 0) return true
19
- /* eslint-disable-next-line */
20
- else return !keysArr1.some(key => obj1[key] !== obj2[key])
21
- }
22
-
23
- export function arraysEqual(a, b) {
24
- return _.isEqual(a,b)
25
- }
26
-
27
- /**
28
- * @param {Array} list 标签列表
29
- * @param {String} name 当前关闭的标签的name
30
- */
31
- export function getNextRoute(list, route) {
32
- let res = {}
33
- if (list.length === 2) {
34
- res = getHomeRoute(list)
35
- } else {
36
- const index = list.findIndex(item => routeEqual(item, route))
37
- if (index === list.length - 1) res = list[list.length - 2]
38
- else res = list[index + 1]
39
- }
40
- return res
41
- }
42
-
43
-
44
- export const setToken = (token) => {
45
- typeof sessionStorage != 'undefined' && sessionStorage.setItem(TOKEN_KEY, token)
46
- }
47
-
48
- export const getToken = () => {
49
- const token = typeof sessionStorage != 'undefined' && sessionStorage.getItem(TOKEN_KEY)
50
- if (token) return token
51
- else return false
52
- }
53
-
54
- export const setSessionStorage = (key, value) => {
55
- typeof sessionStorage != 'undefined' && sessionStorage.setItem(key, JSON.stringify(value))
56
- }
57
-
58
- export const getSessionStorage = (key) => {
59
- const value = typeof sessionStorage != 'undefined' && sessionStorage.getItem(key)
60
- if (value) return JSON.parse(value)
61
- else return null
62
- }
63
-
64
- export const removeSessionStorage = (key) => {
65
- return typeof sessionStorage != 'undefined' && sessionStorage.removeItem(key)
66
- }
67
-
68
- export const clearSessionStorage = () => {
69
- return typeof sessionStorage != 'undefined' && sessionStorage.clear()
70
- }
71
-
72
- export const setLocalStorage = (key, localstorage) => {
73
- typeof localStorage != 'undefined' &&localStorage.setItem(key, localstorage)
74
- }
75
-
76
- export const getLocalStorage = (key) => {
77
- return typeof localStorage != 'undefined' &&localStorage.getItem(key)
78
- }
79
-
80
- export const removeLocalStorage = (key) => {
81
- return typeof localStorage != 'undefined' &&localStorage.removeItem(key)
82
- }
83
-
84
- export const clearLocalStorage = () => {
85
- return typeof localStorage != 'undefined' &&localStorage.clear()
86
- }
87
-
88
- export const hasChild = (item) => {
89
- return item.children && item.children.length !== 0
90
- }
91
-
92
- const showThisMenuEle = (item, access) => {
93
- if (item.meta && item.meta.access && item.meta.access.length) {
94
- if (hasOneOf(item.meta.access, access)) return true
95
- else return false
96
- } else return true
97
- }
98
- /**
99
- * @param {Array} list 通过路由列表得到菜单列表
100
- * @returns {Array}
101
- */
102
- export const getMenuByRouter = (list, access) => {
103
- let res = []
104
- forEach(list, item => {
105
- if (!item.meta || (item.meta && !item.meta.hideInMenu)) {
106
- let obj = {
107
- icon: (item.meta && item.meta.icon) || '',
108
- name: item.name,
109
- meta: item.meta
110
- }
111
- if ((hasChild(item) || (item.meta && item.meta.showAlways)) && showThisMenuEle(item, access)) {
112
- obj.children = getMenuByRouter(item.children, access)
113
- }
114
- if (item.meta && item.meta.href) obj.href = item.meta.href
115
- if (showThisMenuEle(item, access)) res.push(obj)
116
- }
117
- })
118
- return res
119
- }
120
-
121
- /**
122
- * @param {Array} routeMetched 当前路由metched
123
- * @returns {Array}
124
- */
125
- export const getBreadCrumbList = (route, homeRoute) => {
126
- let homeItem = {...homeRoute, icon: homeRoute.meta.icon}
127
- const {crumbs} = route.meta
128
- if (crumbs && crumbs.length > 0) {
129
- crumbs.forEach(item => {
130
- item.meta = {
131
- title: item.title
132
- }
133
- if (item.type === 2) {
134
- item.to = item.name
135
- }
136
- })
137
- }
138
- let breadCrumbList = [{...homeItem, to: homeRoute.name}]
139
- if (crumbs && crumbs.length > 0) {
140
- breadCrumbList = breadCrumbList.concat(crumbs)
141
- }
142
- return breadCrumbList
143
- }
144
-
145
- export const getRouteTitleHandled = (route) => {
146
- let router = {...route}
147
- let meta = {...route.meta}
148
- let title = ''
149
- if (meta.title) {
150
- if (typeof meta.title === 'function') {
151
- meta.__titleIsFunction__ = true
152
- title = meta.title(router)
153
- } else title = meta.title
154
- }
155
- meta.title = title
156
- router.meta = meta
157
- return router
158
- }
159
-
160
- export const showTitle = (item, vm) => {
161
- return item.meta.title
162
- }
163
-
164
- /**
165
- * @description 本地存储和获取标签导航列表
166
- */
167
- export const setTagNavListInLocalstorage = (list , key) => {
168
- if (!key) {
169
- key = 'LD-tagNavList';
170
- }
171
- localStorage[key] = JSON.stringify(list)
172
- }
173
- /**
174
- * @returns {Array} 其中的每个元素只包含路由原信息中的name, path, meta三项
175
- */
176
- export const getTagNavListFromLocalstorage = (key) => {
177
- if (!key) {
178
- key = 'LD-tagNavList';
179
- }
180
- const list = localStorage[key]
181
- return list ? JSON.parse(list) : []
182
- }
183
-
184
- /**
185
- * @param {Array} routers 路由列表数组
186
- * @description 用于找到路由列表中name为home的对象
187
- */
188
- export const getHomeRoute = (routers, homeName = 'home') => {
189
- let i = -1
190
- let len = routers.length
191
- let homeRoute = {}
192
- while (++i < len) {
193
- let item = routers[i]
194
- if (item.children && item.children.length) {
195
- let res = getHomeRoute(item.children, homeName)
196
- if (res.name) return res
197
- } else {
198
- if (item.name === homeName) homeRoute = item
199
- }
200
- }
201
- return homeRoute
202
- }
203
-
204
- /**
205
- * @param {*} list 现有标签导航列表
206
- * @param {*} newRoute 新添加的路由原信息对象
207
- * @description 如果该newRoute已经存在则不再添加
208
- */
209
- export const getNewTagList = (list, newRoute) => {
210
- const {name, path, meta} = newRoute
211
- let newList = [...list]
212
- if (newList.findIndex(item => item.name === name) >= 0) return newList
213
- else newList.push({name, path, meta})
214
- return newList
215
- }
216
-
217
- /**
218
- * @param {*} access 用户权限数组,如 ['super_admin', 'admin']
219
- * @param {*} route 路由列表
220
- */
221
- const hasAccess = (access, route) => {
222
- if (route.meta && route.meta.access) return hasOneOf(access, route.meta.access)
223
- else return true
224
- }
225
-
226
- /**
227
- * 权鉴
228
- * @param {*} name 即将跳转的路由name
229
- * @param {*} access 用户权限数组
230
- * @param {*} routes 路由列表
231
- * @description 用户是否可跳转到该页
232
- */
233
- export const canTurnTo = (name, access, routes) => {
234
- const routePermissionJudge = (list) => {
235
- return list.some(item => {
236
- if (item.children && item.children.length) {
237
- return routePermissionJudge(item.children)
238
- } else if (item.name === name) {
239
- return hasAccess(access, item)
240
- }
241
- })
242
- }
243
-
244
- return routePermissionJudge(routes)
245
- }
246
-
247
- /**
248
- * @param {String} url
249
- * @description 从URL中解析参数
250
- */
251
- export const getParams = url => {
252
- const keyValueArr = url.split('?')[1].split('&')
253
- let paramObj = {}
254
- keyValueArr.forEach(item => {
255
- const keyValue = item.split('=')
256
- paramObj[keyValue[0]] = keyValue[1]
257
- })
258
- return paramObj
259
- }
260
-
261
-
262
- /**
263
- * @param {Number} times 回调函数需要执行的次数
264
- * @param {Function} callback 回调函数
265
- */
266
- export const doCustomTimes = (times, callback) => {
267
- let i = -1
268
- while (++i < times) {
269
- callback(i)
270
- }
271
- }
272
-
273
- /**
274
- * @param {Object} file 从上传组件得到的文件对象
275
- * @returns {Promise} resolve参数是解析后的二维数组
276
- * @description 从Csv文件中解析出表格,解析成二维数组
277
- */
278
- export const getArrayFromFile = (file) => {
279
- let nameSplit = file.name.split('.')
280
- let format = nameSplit[nameSplit.length - 1]
281
- return new Promise((resolve, reject) => {
282
- let reader = new FileReader()
283
- reader.readAsText(file) // 以文本格式读取
284
- let arr = []
285
- reader.onload = function (evt) {
286
- let data = evt.target.card // 读到的数据
287
- let pasteData = data.trim()
288
- arr = pasteData.split((/[\n\u0085\u2028\u2029]|\r\n?/g)).map(row => {
289
- return row.split('\t')
290
- }).map(item => {
291
- return item[0].split(',')
292
- })
293
- if (format === 'csv') resolve(arr)
294
- else reject(new Error('[Format Error]:你上传的不是Csv文件'))
295
- }
296
- })
297
- }
298
-
299
- /**
300
- * @param {Array} array 表格数据二维数组
301
- * @returns {Object} { columns, tableData }
302
- * @description 从二维数组中获取表头和表格数据,将第一行作为表头,用于在iView的表格中展示数据
303
- */
304
- export const getTableDataFromArray = (array) => {
305
- let columns = []
306
- let tableData = []
307
- if (array.length > 1) {
308
- let titles = array.shift()
309
- columns = titles.map(item => {
310
- return {
311
- title: item,
312
- key: item
313
- }
314
- })
315
- tableData = array.map(item => {
316
- let res = {}
317
- item.forEach((col, i) => {
318
- res[titles[i]] = col
319
- })
320
- return res
321
- })
322
- }
323
- return {
324
- columns,
325
- tableData
326
- }
327
- }
328
-
329
- /**
330
- * 寻找上级节点
331
- * @param ele
332
- * @param tag
333
- * @returns {*}
334
- */
335
- export const findNodeUpper = (ele, tag) => {
336
- if (ele.parentNode) {
337
- if (ele.parentNode.tagName === tag.toUpperCase()) {
338
- return ele.parentNode
339
- } else {
340
- return findNodeUpper(ele.parentNode, tag)
341
- }
342
- }
343
- }
344
-
345
- /**
346
- * 根据class寻找上级节点
347
- * @param ele
348
- * @param classes
349
- * @returns {*}
350
- */
351
- export const findNodeUpperByClasses = (ele, classes) => {
352
- let parentNode = ele.parentNode
353
- if (parentNode) {
354
- let classList = parentNode.classList
355
- if (classList && classes.every(className => classList.contains(className))) {
356
- return parentNode
357
- } else {
358
- return findNodeUpperByClasses(parentNode, classes)
359
- }
360
- }
361
- }
362
-
363
- /**
364
- * 根据ele寻找下级节点
365
- * @param ele
366
- * @param tag
367
- * @returns {*}
368
- */
369
- export const findNodeDownward = (ele, tag) => {
370
- const tagName = tag.toUpperCase()
371
- if (ele.childNodes.length) {
372
- let i = -1
373
- let len = ele.childNodes.length
374
- while (++i < len) {
375
- let child = ele.childNodes[i]
376
- if (child.tagName === tagName) return child
377
- else return findNodeDownward(child, tag)
378
- }
379
- }
380
- }
381
-
382
- /**
383
- * @description 判断要查询的数组是否至少有一个元素包含在目标数组中
384
- * @param access 需要查询的数组
385
- * @param canViewAccess 目标数组
386
- * @returns {*}
387
- */
388
- export const showByAccess = (access, canViewAccess) => {
389
- return hasOneOf(canViewAccess, access)
390
- }
391
-
392
- /**
393
- * @description 根据name/params/query判断两个路由对象是否相等
394
- * @param {*} route1 路由对象
395
- * @param {*} route2 路由对象
396
- */
397
- export const routeEqual = (route1, route2) => {
398
- const params1 = route1.params || {}
399
- const params2 = route2.params || {}
400
- const query1 = route1.query || {}
401
- const query2 = route2.query || {}
402
- return (route1.name === route2.name) && objEqual(params1, params2) && objEqual(query1, query2)
403
- }
404
-
405
- /**
406
- * 判断打开的标签列表里是否已存在这个新添加的路由对象
407
- */
408
- export const routeHasExist = (tagNavList, routeItem) => {
409
- let len = tagNavList.length
410
- let res = false
411
- doCustomTimes(len, (index) => {
412
- if (routeEqual(tagNavList[index], routeItem)) res = true
413
- })
414
- return res
415
- }
416
-
417
- /**
418
- * scrollTop animation
419
- * @param el
420
- * @param from
421
- * @param to
422
- * @param duration
423
- * @param endCallback
424
- */
425
- export const scrollTop = (el, from = 0, to, duration = 500, endCallback) => {
426
- if (!window.requestAnimationFrame) {
427
- window.requestAnimationFrame = (
428
- window.webkitRequestAnimationFrame ||
429
- window.mozRequestAnimationFrame ||
430
- window.msRequestAnimationFrame ||
431
- function (callback) {
432
- return window.setTimeout(callback, 1000 / 60)
433
- }
434
- )
435
- }
436
- const difference = Math.abs(from - to)
437
- const step = Math.ceil(difference / duration * 50)
438
-
439
- const scroll = (start, end, step) => {
440
- if (start === end) {
441
- endCallback && endCallback()
442
- return
443
- }
444
-
445
- let d = (start + step > end) ? end : start + step
446
- if (start > end) {
447
- d = (start - step < end) ? end : start - step
448
- }
449
-
450
- if (el === window) {
451
- window.scrollTo(d, d)
452
- } else {
453
- el.scrollTop = d
454
- }
455
- window.requestAnimationFrame(() => scroll(d, end, step))
456
- }
457
- scroll(from, to, step)
458
- }
459
-
460
- /**
461
- * @description 根据当前跳转的路由设置显示在浏览器标签的title
462
- * @param {String} configTitle 配置标题
463
- * @param {Object} routeItem 路由对象
464
- * @param {Object} vm Vue实例
465
- */
466
- export const setTitle = (configTitle,routeItem, vm) => {
467
- const handledRoute = getRouteTitleHandled(routeItem)
468
- const pageTitle = showTitle(handledRoute, vm)
469
- const resTitle = pageTitle ? `${configTitle} - ${pageTitle}` : configTitle
470
- window.document.title = resTitle
471
- }
472
-
473
- /**
474
- * 获取浏览器地址url中的参数
475
- * @param url
476
- * @returns {Object}
477
- */
478
- export const getUrlParams = (url) => {
479
- if (!url){
480
- url = location.search;
481
- }
482
- //const url = location.search; //获取url中"?"符后的字串
483
- const theRequest = new Object();
484
- if (url.indexOf("?") != -1) {
485
- const str = url.substr(1);
486
- let strs = str.split("&");
487
- for (let i = 0; i < strs.length; i++) {
488
- theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
489
- }
490
- }
491
- return theRequest;
492
- }
493
-
494
-
495
- export const getChangeTableDatas = (oldData, newData) => {
496
- let list = []
497
- for (let i = 0; i < newData.length; i++) {
498
- if (oldData[i].checked != newData[i].checked) {
499
- let tmpData = {
500
- "id": newData[i].id,
501
- "checked": newData[i].checked
502
- }
503
- if (newData[i].dpType) {
504
- tmpData.dpType = newData[i].dpType
505
- }
506
- if (newData[i].employeeJobIdentityId) {
507
- tmpData.employeeJobIdentityId = newData[i].employeeJobIdentityId
508
- }
509
- if (newData[i].userId) {
510
- tmpData.userId = newData[i].userId
511
- }
512
- list.push(tmpData);
513
- }
514
- if (newData[i].children) {
515
- list = list.concat(getChangeTableDatas(oldData[i].children, newData[i].children))
516
- }
517
- }
518
- return list
519
- }
520
-
521
- /**
522
- * 合并数组并去重
523
- * @param oldRow
524
- * @param newRow
525
- * @param key
526
- * @returns {*[]}
527
- */
528
- export const removeDup = (oldRow,newRow,key) => {
529
- let resultMap = {};
530
- for(let o of oldRow){
531
- resultMap[o[key]] = o;
532
- }
533
- for (let n of newRow) {
534
- resultMap[n[key]] = n;
535
- }
536
- let result = []
537
- for (let row in resultMap) {
538
- result.push(resultMap[row])
539
- }
540
- return result;
541
- }
542
- /**
543
- * 获取数组修改的数据
544
- * @param oldRow
545
- * @param newRow
546
- * @param key
547
- * @returns {{delList: *[], addList: *[]}}
548
- */
549
- export const getChangeData = (oldRow,newRow,key) =>{
550
- let oldMap = {};
551
- for(let o of oldRow){
552
- if (key){
553
- oldMap[o[key]] = o;
554
- } else {
555
- oldMap[o] = o;
556
- }
557
- }
558
- let newMap = {}
559
- for(let n of newRow){
560
- if (key){
561
- newMap[n[key]] = n;
562
- } else {
563
- newMap[n] = n;
564
- }
565
- }
566
- let addList = []
567
- for (let n of newRow) {
568
- if (key){
569
- if (!oldMap[n[key]]) {
570
- addList.push(n);
571
- }
572
- } else {
573
- if (!oldMap[n]) {
574
- addList.push(n);
575
- }
576
- }
577
- }
578
- let delList = []
579
- for (let o of oldRow) {
580
- if (key){
581
- if (!newMap[o[key]]) {
582
- delList.push(o);
583
- }
584
- } else {
585
- if (!newMap[o]) {
586
- delList.push(o);
587
- }
588
- }
589
- }
590
- return {
591
- addList,delList
592
- }
593
- }
594
-
595
- /**
596
- * @param {Array} arr1
597
- * @param {Array} arr2
598
- * @description 得到两个数组的交集, 两个数组的元素为数值或字符串
599
- */
600
- export const getIntersection = (arr1, arr2) => {
601
- let len = Math.min(arr1.length, arr2.length)
602
- let i = -1
603
- let res = []
604
- while (++i < len) {
605
- const item = arr2[i]
606
- if (arr1.indexOf(item) > -1) res.push(item)
607
- }
608
- return res
609
- }
610
-
611
- /**
612
- * @param {Array} arr1
613
- * @param {Array} arr2
614
- * @description 得到两个数组的并集, 两个数组的元素为数值或字符串
615
- */
616
- export const getUnion = (arr1, arr2) => {
617
- return Array.from(new Set([...arr1, ...arr2]))
618
- }
619
-
620
- /**
621
- * @param {Array} target 目标数组
622
- * @param {Array} arr 需要查询的数组
623
- * @description 判断要查询的数组是否至少有一个元素包含在目标数组中
624
- */
625
- const hasOneOf = (targetarr, arr) => {
626
- return targetarr.some(_ => arr.indexOf(_) > -1)
627
- }
628
-
629
- /**
630
- * foreach
631
- * @param arr
632
- * @param fn 回调函数,参数接收arr的元素,索引,arr本身
633
- */
634
- const forEach = (arr, fn) => {
635
- if (!arr.length || !fn) return
636
- let i = -1
637
- let len = arr.length
638
- while (++i < len) {
639
- let item = arr[i]
640
- fn(item, i, arr)
641
- }
642
- }
643
-
644
- /**
645
- * @param {String|Number} value 要验证的字符串或数值
646
- * @param {*} validList 用来验证的列表
647
- */
648
- export function oneOf (value, validList) {
649
- for (let i = 0; i < validList.length; i++) {
650
- if (value === validList[i]) {
651
- return true
652
- }
653
- }
654
- return false
655
- }
656
-
657
- /**
658
- * recursionKeyFindItem
659
- * @param arr
660
- * @param filterKey
661
- * @param filterValue
662
- * @param recursionKey
663
- * @returns {*|null}
664
- */
665
- export const recursionKeyFindItem = (arr, filterKey, filterValue, recursionKey) => {
666
- for (const item of arr) {
667
- if (item[filterKey] && item[filterKey] == filterValue && item['type'] == 2) {
668
- return item;
669
- }
670
- let result = null;
671
- if (item[recursionKey]) {
672
- result = recursionKeyFindItem(item[recursionKey], filterKey, filterValue, recursionKey);
673
- if (result) {
674
- return result;
675
- }
676
- }
677
- }
678
- return null;
679
- };
680
-
681
- /**
682
- * filterMenuName
683
- * @param menuList
684
- * @param name
685
- * @returns {*|null}
686
- */
687
- export const filterMenuName = (menuList, name) => {
688
- return recursionKeyFindItem(menuList, 'name', name, 'children')
689
- };
690
-
691
- /**
692
- * filterMenuUri
693
- * @param menuList
694
- * @param name
695
- * @returns {*|null}
696
- */
697
- export const filterMenuUri = (menuList, name) => {
698
- return recursionKeyFindItem(menuList, 'uri', name, 'children')
699
- };
700
-
701
- /**
702
- * tagExists
703
- * @param taglist
704
- * @param name
705
- * @returns {boolean}
706
- */
707
- export const tagExists = (taglist, name) => {
708
- return taglist && taglist.filter(item => item.name === name).length > 0;
709
- };
710
-
711
- /**
712
- * 判断菜单是否为新窗口打开
713
- * @param menu
714
- */
715
- export const isOpenBlank = (menu) => {
716
- let extendProps = {}
717
- if (menu && menu.meta && menu.meta.data && menu.meta.data.extension) {
718
- extendProps = JSON.parse(menu.meta.data.extension)
719
- }
720
- if (menu && menu.extension) {
721
- extendProps = JSON.parse(menu.extension)
722
- }
723
- if (extendProps && extendProps.target_type && extendProps.target_type == 'blank') {
724
- return true;
725
- }
726
- if (extendProps && extendProps.targetType && extendProps.targetType == 'blank') {
727
- return true;
728
- }
729
- return false;
730
- }
731
-
732
- /**
733
- * 判断应用是否为移动应用
734
- * @param menu
735
- */
736
- export const isMobileApp = (app) => {
737
- try{
738
- let extendProps = {};
739
- if (app.extendProps) {
740
- if (typeof app.extendProps == 'string') {
741
- extendProps = JSON.parse(app.extendProps);
742
- } else {
743
- extendProps = app.extendProps;
744
- }
745
- }
746
- if (app.setting) {
747
- if (typeof app.setting == 'string') {
748
- extendProps = JSON.parse(app.setting);
749
- } else {
750
- extendProps = app.setting;
751
- }
752
- }
753
- if (extendProps && extendProps.is_mobile_app && extendProps.is_mobile_app == '1') {
754
- return true;
755
- }
756
- }catch (e) {
757
- console.error(e)
758
- }
759
- return false;
760
- }
761
-
762
- /**
763
- * 获取pc应用列表
764
- * @param appList
765
- * @returns {*[]}
766
- */
767
- export const getPCAppList = (appList,filterCenter = false) => {
768
- let finalList = []
769
- if(appList) {
770
- for (let app of appList) {
771
- if ((!isMobileApp(app) && filterCenter && isCenterApp(app))
772
- || (!isMobileApp(app) && !filterCenter)) {
773
- finalList.push(app);
774
- }
775
- }
776
- }
777
- return finalList;
778
- }
779
-
780
- /**
781
- * 获取移动应用列表
782
- * @param appList
783
- * @returns {*[]}
784
- */
785
- export const getMobileAppList = (appList,filterCenter= false) => {
786
- let finalList = []
787
- if(appList) {
788
- for (let app of appList) {
789
- if ((isMobileApp(app) && filterCenter && isCenterApp(app))
790
- || (isMobileApp(app) && !filterCenter)) {
791
- finalList.push(app);
792
- }
793
- }
794
- }
795
- return finalList;
796
- }
797
- /**
798
- * 判断应用是否门户应用
799
- * @param menu
800
- */
801
- export const isCenterApp = (app) => {
802
- try{
803
- let extendProps = {};
804
- if (app.extendProps) {
805
- if (typeof app.extendProps == 'string') {
806
- extendProps = JSON.parse(app.extendProps);
807
- } else {
808
- extendProps = app.extendProps;
809
- }
810
- }
811
- if (app.setting) {
812
- if (typeof app.setting == 'string') {
813
- extendProps = JSON.parse(app.setting);
814
- } else {
815
- extendProps = app.setting;
816
- }
817
- }
818
- if (extendProps && extendProps.is_center_app && extendProps.is_center_app == '1') {
819
- return true;
820
- }
821
- }catch (e) {
822
- console.error(e);
823
- }
824
- return false;
825
- }
826
-
827
- /**
828
- * 获取一级菜单作为顶级导航
829
- * @param permissionList
830
- * @param appType
831
- * @returns {*[]}
832
- */
833
- export const buildNavListByMenu = (permissionList,appInfo,appType,defaultHideName = '') => {
834
- let navList = []
835
- if (permissionList && appInfo && appInfo.appId) {
836
- let permissions = permissionList.filter(item => item.hasOwnProperty('pid')
837
- && item.pid == '0' && item.appId == appInfo.appId && item.name != defaultHideName)
838
- for (let per of permissions) {
839
- if (appType && appType == 'sc') {
840
- let nav = {
841
- "data" : deepCopy(per),
842
- "appInfo" : deepCopy(appInfo),
843
- "orderNo": per.orders,
844
- "application": {
845
- "extendProps": per.extension ? JSON.parse(per.extension) : "",
846
- "appId": per.permissionId,
847
- "appBizCode": per.permissionValue,
848
- "appName": per.title,
849
- "appDesc": per.description,
850
- "appUrl": appInfo.basepath,
851
- "icon": per.icon,
852
- "appStatus": 1,
853
- "manageUnitId": "",
854
- "protocolType": null,
855
- "grantTypes": null,
856
- "logoutUrl": null,
857
- "redirectUrls": null,
858
- "codeExpiresIn": null,
859
- "idTokenExpiresIn": null,
860
- "accessTokenExpiresIn": null,
861
- "clientId": "",
862
- "clientSecret": "",
863
- "isEnableSso": false,
864
- "isShare": false,
865
- "referAppId": null,
866
- "externalId": null,
867
- "callerAppId": null,
868
- "orderNo": 1,
869
- "parentId": null,
870
- "appType": null,
871
- "relativeName": null,
872
- "shortName": null,
873
- "authType": "1",
874
- "isLower": null
875
- },
876
- "basepath": appInfo.basepath,
877
- "appId": per.permissionId,
878
- "icon": per.icon,
879
- "name": per.name,
880
- "extendProps": per.extension ? JSON.parse(per.extension) : "",
881
- "title": per.title,
882
- "type": "00",
883
- "status": 1
884
- }
885
- navList.push(nav)
886
- } else {
887
- let nav = {
888
- "data" : deepCopy(per),
889
- "appInfo" : deepCopy(appInfo),
890
- "id": per.id,
891
- "appId": per.permissionId,
892
- "systemId": per.systemId,
893
- "icon": per.icon,
894
- "banner": null,
895
- "theme": null,
896
- "basepath": appInfo.basepath,
897
- "status": 1,
898
- "name": per.name,
899
- "title": per.title,
900
- "type": "00",
901
- "setting": "",
902
- "description": per.description,
903
- "orders": per.orders,
904
- "createTime": 1710772466000,
905
- "updateTime": 1710772466000
906
- }
907
- navList.push(nav)
908
- }
909
- }
910
- }
911
- return navList;
912
- }
913
-
914
- /**
915
- * 判断是否为子菜单
916
- * @param permissionList
917
- * @param pid
918
- * @param per
919
- * @returns {boolean|boolean|*}
920
- */
921
- export const isChildPermission = (permissionList, pid, per) => {
922
- if (permissionList && pid && per && per.pid) {
923
- let res = permissionList.find(item => item.hasOwnProperty('permissionId') && item.permissionId == per.pid)
924
- if (res && res.permissionId && res.permissionId == pid) {
925
- return true;
926
- } else {
927
- return isChildPermission(permissionList, pid, res)
928
- }
929
- }
930
- return false;
931
- }
932
- /**
933
- * 获取所有子菜单
934
- * @param permissionList
935
- * @param pid
936
- */
937
- export const getChildPermissions = (permissionList, pid, appInfo) => {
938
- let res = []
939
- if (permissionList && pid) {
940
- for (let permission of permissionList) {
941
- if (isChildPermission(permissionList, pid, permission)) {
942
- let per2 = deepCopy(permission);
943
- per2.appId = pid;
944
- if (per2.pid == pid) {
945
- per2.pid = "0";
946
- }
947
- per2.appInfo = deepCopy(appInfo)
948
- res.push(per2);
949
- }
950
- }
951
- }
952
- return res;
953
- }
954
- /**
955
- * 恢复权限的原始信息
956
- * @param permission
957
- */
958
- export const getOriginalPermission = (permission) => {
959
- if (permission && permission.meta && permission.meta.data && permission.meta.data.appInfo) {
960
- let per2 = deepCopy(permission);
961
- if (per2.hasOwnProperty('pid') && per2.pid == '0') {
962
- per2.pid = per2.meta.data.appId;
963
- per2.meta.data.pid = per2.meta.data.appId;
964
- }
965
- per2.meta.appId = permission.meta.data.appInfo.appId;
966
- per2.meta.data.appId = permission.meta.data.appInfo.appId;
967
- return per2;
968
- }
969
- return permission
970
- }
971
-
972
- /**
973
- * 单应用时修改源权限信息
974
- * @param permissionList
975
- * @param menu
976
- * @param appInfo
977
- * @returns {*}
978
- */
979
- export const buildSinglePermission = (permissionList, menu) => {
980
- let permission = permissionList.find(item => item.permissionId == menu.permissionId && item.appId == menu.appId)
981
- let rootPermission = getRootPermission(permissionList, permission)
982
- if (rootPermission && rootPermission.permissionId) {
983
- menu.appInfo = {
984
- appId: menu.appId
985
- }
986
- menu.appId = rootPermission.permissionId;
987
- }
988
- return menu;
989
- }
990
- /**
991
- * 获取菜单根节点
992
- * @param permissionList
993
- * @param permission
994
- * @returns {*|{pid}|{}}
995
- */
996
- export const getRootPermission = (permissionList, permission) => {
997
- if (permissionList, permission) {
998
- if (!permission.hasOwnProperty('pid')) {
999
- return permission
1000
- } else if (permission.pid == '0') {
1001
- return permission
1002
- } else {
1003
- let parentPermission = permissionList.find(item => item.permissionId == permission.pid && item.appId == permission.appId)
1004
- return getRootPermission(permissionList, parentPermission);
1005
- }
1006
- }
1007
- return permission;
1008
- }
1009
- /**
1010
- * getPreviousTagIndex
1011
- * @param tagList
1012
- * @param name
1013
- * @returns {number}
1014
- */
1015
- export const getPreviousTagIndex = (tagList, name) => {
1016
- let count = 0;
1017
- if (tagList && name) {
1018
- for (let i = 0 ;i < tagList.length; i++) {
1019
- let item = tagList[i];
1020
- if (item.name == name) {
1021
- count = i - 1;
1022
- if (count < 0) {
1023
- count = 0;
1024
- }
1025
- return count;
1026
- }
1027
- }
1028
- }
1029
- return count;
1030
- };
1031
-
1032
- /**
1033
- * getDelTagIndex
1034
- * @param tagList
1035
- * @param name
1036
- * @returns {number}
1037
- */
1038
- export const getDelTagIndex = (tagList, name) => {
1039
- let count = 1;
1040
- if (tagList && name) {
1041
- for (let i = 1 ;i < tagList.length; i++) {
1042
- let item = tagList[i];
1043
- if (item.name !== name) {
1044
- return count;
1045
- }
1046
- }
1047
- }
1048
- return count;
1049
- }
1050
-
1051
- /**
1052
- * turnToPage
1053
- * @param vm
1054
- * @param name
1055
- * @param url
1056
- */
1057
- export const turnToPage = (vm, name ,url) =>{
1058
- if (window.top && window.top.location.href != window.location.href) {
1059
- typeof sessionStorage != 'undefined' && sessionStorage.removeItem('activeName')
1060
- window.parent.location.href = url;
1061
- } else {
1062
- vm.$router.push({
1063
- name: name
1064
- })
1065
- }
1066
- }
1067
-
1068
-
1069
- /**
1070
- * 获取上级节点的方法
1071
- * @param vm
1072
- * @param methodName
1073
- * @returns {*}
1074
- */
1075
- export const getParentMethod = (vm,methodName) => {
1076
- if (vm.$parent) {
1077
- if (vm.$parent[methodName]) {
1078
- return vm.$parent[methodName];
1079
- } else {
1080
- return getParentMethod(vm.$parent,methodName)
1081
- }
1082
- }
1083
- return undefined;
1084
- }
1085
-
1086
- /**
1087
- * 执行全屏操作
1088
- * @param vm
1089
- */
1090
- export const doParentMethod = (vm,methodName) => {
1091
- let action = getParentMethod(vm,methodName)
1092
- if (action) {
1093
- action()
1094
- }
1095
- }
1096
- /**
1097
- * 替换url中的指定参数
1098
- * @param url
1099
- * @param paramName
1100
- * @param paramValue
1101
- * @returns {string}
1102
- */
1103
- export const replaceUrlParam = (url, paramName, paramValue) => {
1104
- let pattern = new RegExp('(' + paramName + '=)([^&]+)', 'i');
1105
- let queryString = url.split('?')[1];
1106
- if (queryString) {
1107
- let newParam = paramName + '=' + encodeURIComponent(paramValue);
1108
- let newQueryString = queryString.replace(pattern, newParam);
1109
- return url.split('?')[0] + '?' + newQueryString;
1110
- } else {
1111
- return url + '?' + paramName + '=' + encodeURIComponent(paramValue);
1112
- }
1113
- }
1114
- /**
1115
- * 拼接url
1116
- * @param href
1117
- * @param key
1118
- * @param value
1119
- * @returns {string}
1120
- */
1121
- export const buildParams = (href, key, value) =>{
1122
- if (href && key && value) {
1123
- if (!href.includes(key + '=')) {
1124
- if (href.includes('?')) {
1125
- href += '&' + key + '=' + value
1126
- } else {
1127
- href += '?' + key + '=' + value
1128
- }
1129
- } else {
1130
- href = this.replaceUrlParam(href,key,value)
1131
- }
1132
- return href;
1133
- }
1134
- return '';
1135
- }
1136
- /**
1137
- * 组装菜单url
1138
- * @param item
1139
- * @param ssoToken
1140
- * @param ssoid
1141
- * @returns {string}
1142
- */
1143
- export const buildMenuUri = (item,ssoToken,ssoid) => {
1144
- if (!item.uri) {
1145
- return ''
1146
- }
1147
- let href = ''
1148
- let uri = item.uri
1149
- if (uri.startsWith('http')) {
1150
- href = uri
1151
- } else {
1152
- let basepath = ''
1153
- if (item.navList) {
1154
- let navList = deepCopy(item.navList);
1155
- let appId = '';
1156
- if (item.appId) {
1157
- appId = item.appId;
1158
- } else if (item.meta && item.meta.appId) {
1159
- appId = item.meta.appId;
1160
- }
1161
- let appInfo = navList.find(app => app.appId === appId)
1162
- if (appInfo && appInfo.basepath) {
1163
- basepath = appInfo.basepath
1164
- }
1165
- }
1166
- if (!basepath.startsWith('/') && !basepath.startsWith('http')) {
1167
- basepath = '/' + basepath
1168
- }
1169
- if (basepath.endsWith('/')) {
1170
- basepath = basepath.substring(0, basepath.length - 1)
1171
- }
1172
- if (!uri.startsWith('/')) {
1173
- uri = '/' + uri
1174
- }
1175
- href = basepath + uri
1176
- }
1177
- href = buildParams(href,"layout","screen");
1178
- if (ssoToken) {
1179
- href = buildParams(href,"token",ssoToken);
1180
- }
1181
- if (ssoid) {
1182
- href = buildParams(href,"ssoid",ssoid);
1183
- }
1184
- if (item.cts) {
1185
- href = buildParams(href,"cts",item.cts);
1186
- }
1187
- return href
1188
- }
1189
- /**
1190
- * 给query添加时间戳
1191
- */
1192
- export const addTimestamp = ($route) => {
1193
- let query = {};
1194
- if ($route.query) {
1195
- query = $route.query;
1196
- }
1197
- query = Object.assign({},query,{cts:new Date().getTime()})
1198
- $route.query = query;
1199
- return $route;
1200
- }
1201
- /**
1202
- * 根据配置信息修改系统信息
1203
- * @param systemInfo
1204
- */
1205
- export const changeSystemInfo = async (systemInfo) => {
1206
- let defaultSystemInfo = {
1207
- layoutSize: 'small',
1208
- systemLogo: systemLogo,
1209
- logoWidth: '150px',
1210
- systemName: sessionStorage.getItem('systemName') ? sessionStorage.getItem('systemName') : config.title,
1211
- nameSize: 1,
1212
- navType: 'dropdown',
1213
- rightTopOptButtonList: ['collect', 'fullScreen'],
1214
- rightTopShowFunList: ['theme', 'personalCenter', 'noticeList', 'logout'],
1215
- menuLogo: '1',
1216
- titleShow: 'wrap',
1217
- menuScaling: '1',
1218
- footerInfo: 'Copyright © 2021 浪潮数字商业科技有限公司 版权所有<br> 辽ICP备11001865号-3',
1219
- showTheme: '',
1220
- theme: 'default',
1221
- tabNum: 5,
1222
- topMenu: 4,
1223
- };
1224
- if (systemInfo) {
1225
- systemInfo = Object.assign(defaultSystemInfo, systemInfo);
1226
- } else {
1227
- systemInfo = defaultSystemInfo;
1228
- }
1229
- if (systemInfo.logo) {
1230
- systemInfo.systemLogo = config.ossServerContext + '/anon/system/file/get/' + systemInfo.logo
1231
- } else {
1232
- systemInfo.systemLogo = ''
1233
- }
1234
- sessionStorage.setItem('systemLogo', systemInfo.systemLogo)
1235
- if (systemInfo.systemLogo) {
1236
- let link = document.querySelector("link[rel*='icon']") || document.createElement('link');
1237
- link.setAttribute('href', systemInfo.systemLogo);
1238
- if (!link.getAttribute('rel')) {
1239
- link.setAttribute('rel', 'icon');
1240
- }
1241
- if (!link.getAttribute('type')) {
1242
- link.setAttribute('type', 'image/png');
1243
- }
1244
- }
1245
- if (systemInfo.logoWidth) {
1246
- systemInfo.logoWidth = systemInfo.logoWidth + ''
1247
- }
1248
- if (systemInfo.systemName) {
1249
- document.title = systemInfo.systemName
1250
- sessionStorage.setItem('systemName', systemInfo.systemName)
1251
- }
1252
- if (localStorage.getItem('theme')) {
1253
- systemInfo.theme = localStorage.getItem('theme')
1254
- }
1255
- changeByThemeKey(systemInfo.theme)
1256
- if (localStorage.getItem('themeIdCurrent')) {
1257
- systemInfo.showTheme = localStorage.getItem('themeIdCurrent')
1258
- }
1259
- if (systemInfo.showTheme) {
1260
- let showTheme = systemInfo.showTheme
1261
- let split = showTheme.split('-')
1262
- let systemForm = null
1263
- let themeId = split[0];
1264
- let status = split[1];
1265
- let filterStatus = split[2];
1266
- if (themeId) {
1267
- let res = await ajax.get(config.upmsServerContext + '/anon/system/themeInfo?themeId=' + split[0])
1268
- if (res.data.code == 1) {
1269
- systemForm = res.data.data[0]
1270
- if (!status && systemForm.status) {
1271
- status = systemForm.status;
1272
- }
1273
- if (!filterStatus && systemForm.filterStatus) {
1274
- filterStatus = systemForm.filterStatus;
1275
- }
1276
- }
1277
- }
1278
- if (systemForm) {
1279
- changeThemeByThemeId(themeId, status, filterStatus, systemForm)
1280
- }
1281
- }
1282
- if (!systemInfo.rightTopOptButtonList || systemInfo.rightTopOptButtonList.length <= 0) {
1283
- systemInfo.rightTopOptButtonList = ['collect', 'fullScreen'];
1284
- }
1285
- if (!systemInfo.rightTopShowFunList || systemInfo.rightTopShowFunList.length <= 0) {
1286
- systemInfo.rightTopShowFunList = ['theme', 'personalCenter', 'noticeList', 'logout']
1287
- }
1288
- return systemInfo;
1289
- }
1290
-
1291
- export const buildHomeConfigs = (settings) => {
1292
- let result = [];
1293
- if (settings && settings.length > 0) {
1294
- let settingMap = {}
1295
- for (let st of settings) {
1296
- let key = st.categoryCode;
1297
- if (!key) {
1298
- key = "otherCategory";
1299
- }
1300
- if (settingMap[key]) {
1301
- let oldSt = settingMap[key];
1302
- if (st.permit && oldSt.permit
1303
- && (st.permit.permissionType > oldSt.permit.permissionType
1304
- || (st.permit.permissionType == oldSt.permit.permissionType
1305
- && st.permit.createTime > oldSt.permit.createTime))) {
1306
- settingMap[key] = st;
1307
- }
1308
- } else {
1309
- settingMap[key] = st;
1310
- }
1311
- }
1312
- if (settingMap['default']) {
1313
- result.push(settingMap['default']);
1314
- }
1315
- for(let key in settingMap) {
1316
- if (key != 'default') {
1317
- result.push(settingMap[key])
1318
- }
1319
- }
1320
- }
1321
- return result;
1322
- }
1323
-
1324
- export const getAllElements = ( plist = [], result = []) => {
1325
- for (let obj of plist) {
1326
- if (obj.permissionId) {
1327
- result.push(obj.permissionId);
1328
- }
1329
- if (obj.children && obj.children.length > 0) {
1330
- getAllElements(obj.children, result);
1331
- }
1332
- }
1333
- return result;
1334
- }
1
+ import {deepCopy} from './assist';
2
+ import _ from 'lodash';
3
+ import config from "../config/config";
4
+ import systemLogo from '../styles/image/inspur.png';
5
+ import {changeByThemeKey, changeThemeByThemeId} from "./theme";
6
+ import ajax from "./ajax";
7
+
8
+ export const TOKEN_KEY = 'lambo-token'
9
+
10
+ export const COOKIE_KEY = 'lambo-sso-key'
11
+
12
+ export const SSO_TOKEN_KEY = 'lambo-sso-token'
13
+
14
+ export function objEqual(obj1, obj2) {
15
+ const keysArr1 = Object.keys(obj1)
16
+ const keysArr2 = Object.keys(obj2)
17
+ if (keysArr1.length !== keysArr2.length) return false
18
+ else if (keysArr1.length === 0 && keysArr2.length === 0) return true
19
+ /* eslint-disable-next-line */
20
+ else return !keysArr1.some(key => obj1[key] !== obj2[key])
21
+ }
22
+
23
+ export function arraysEqual(a, b) {
24
+ return _.isEqual(a,b)
25
+ }
26
+
27
+ /**
28
+ * @param {Array} list 标签列表
29
+ * @param {String} name 当前关闭的标签的name
30
+ */
31
+ export function getNextRoute(list, route) {
32
+ let res = {}
33
+ if (list.length === 2) {
34
+ res = getHomeRoute(list)
35
+ } else {
36
+ const index = list.findIndex(item => routeEqual(item, route))
37
+ if (index === list.length - 1) res = list[list.length - 2]
38
+ else res = list[index + 1]
39
+ }
40
+ return res
41
+ }
42
+
43
+
44
+ export const setToken = (token) => {
45
+ typeof sessionStorage != 'undefined' && sessionStorage.setItem(TOKEN_KEY, token)
46
+ }
47
+
48
+ export const getToken = () => {
49
+ const token = typeof sessionStorage != 'undefined' && sessionStorage.getItem(TOKEN_KEY)
50
+ if (token) return token
51
+ else return false
52
+ }
53
+
54
+ export const setSessionStorage = (key, value) => {
55
+ typeof sessionStorage != 'undefined' && sessionStorage.setItem(key, JSON.stringify(value))
56
+ }
57
+
58
+ export const getSessionStorage = (key) => {
59
+ const value = typeof sessionStorage != 'undefined' && sessionStorage.getItem(key)
60
+ if (value) return JSON.parse(value)
61
+ else return null
62
+ }
63
+
64
+ export const removeSessionStorage = (key) => {
65
+ return typeof sessionStorage != 'undefined' && sessionStorage.removeItem(key)
66
+ }
67
+
68
+ export const clearSessionStorage = () => {
69
+ return typeof sessionStorage != 'undefined' && sessionStorage.clear()
70
+ }
71
+
72
+ export const setLocalStorage = (key, localstorage) => {
73
+ typeof localStorage != 'undefined' &&localStorage.setItem(key, localstorage)
74
+ }
75
+
76
+ export const getLocalStorage = (key) => {
77
+ return typeof localStorage != 'undefined' &&localStorage.getItem(key)
78
+ }
79
+
80
+ export const removeLocalStorage = (key) => {
81
+ return typeof localStorage != 'undefined' &&localStorage.removeItem(key)
82
+ }
83
+
84
+ export const clearLocalStorage = () => {
85
+ return typeof localStorage != 'undefined' &&localStorage.clear()
86
+ }
87
+
88
+ export const hasChild = (item) => {
89
+ return item.children && item.children.length !== 0
90
+ }
91
+
92
+ const showThisMenuEle = (item, access) => {
93
+ if (item.meta && item.meta.access && item.meta.access.length) {
94
+ if (hasOneOf(item.meta.access, access)) return true
95
+ else return false
96
+ } else return true
97
+ }
98
+ /**
99
+ * @param {Array} list 通过路由列表得到菜单列表
100
+ * @returns {Array}
101
+ */
102
+ export const getMenuByRouter = (list, access) => {
103
+ let res = []
104
+ forEach(list, item => {
105
+ if (!item.meta || (item.meta && !item.meta.hideInMenu)) {
106
+ let obj = {
107
+ icon: (item.meta && item.meta.icon) || '',
108
+ name: item.name,
109
+ meta: item.meta
110
+ }
111
+ if ((hasChild(item) || (item.meta && item.meta.showAlways)) && showThisMenuEle(item, access)) {
112
+ obj.children = getMenuByRouter(item.children, access)
113
+ }
114
+ if (item.meta && item.meta.href) obj.href = item.meta.href
115
+ if (showThisMenuEle(item, access)) res.push(obj)
116
+ }
117
+ })
118
+ return res
119
+ }
120
+
121
+ /**
122
+ * @param {Array} routeMetched 当前路由metched
123
+ * @returns {Array}
124
+ */
125
+ export const getBreadCrumbList = (route, homeRoute) => {
126
+ let homeItem = {...homeRoute, icon: homeRoute.meta.icon}
127
+ const {crumbs} = route.meta
128
+ if (crumbs && crumbs.length > 0) {
129
+ crumbs.forEach(item => {
130
+ item.meta = {
131
+ title: item.title
132
+ }
133
+ if (item.type === 2) {
134
+ item.to = item.name
135
+ }
136
+ })
137
+ }
138
+ let breadCrumbList = [{...homeItem, to: homeRoute.name}]
139
+ if (crumbs && crumbs.length > 0) {
140
+ breadCrumbList = breadCrumbList.concat(crumbs)
141
+ }
142
+ return breadCrumbList
143
+ }
144
+
145
+ export const getRouteTitleHandled = (route) => {
146
+ let router = {...route}
147
+ let meta = {...route.meta}
148
+ let title = ''
149
+ if (meta.title) {
150
+ if (typeof meta.title === 'function') {
151
+ meta.__titleIsFunction__ = true
152
+ title = meta.title(router)
153
+ } else title = meta.title
154
+ }
155
+ meta.title = title
156
+ router.meta = meta
157
+ return router
158
+ }
159
+
160
+ export const showTitle = (item, vm) => {
161
+ return item.meta.title
162
+ }
163
+
164
+ /**
165
+ * @description 本地存储和获取标签导航列表
166
+ */
167
+ export const setTagNavListInLocalstorage = (list , key) => {
168
+ if (!key) {
169
+ key = 'LD-tagNavList';
170
+ }
171
+ localStorage[key] = JSON.stringify(list)
172
+ }
173
+ /**
174
+ * @returns {Array} 其中的每个元素只包含路由原信息中的name, path, meta三项
175
+ */
176
+ export const getTagNavListFromLocalstorage = (key) => {
177
+ if (!key) {
178
+ key = 'LD-tagNavList';
179
+ }
180
+ const list = localStorage[key]
181
+ return list ? JSON.parse(list) : []
182
+ }
183
+
184
+ /**
185
+ * @param {Array} routers 路由列表数组
186
+ * @description 用于找到路由列表中name为home的对象
187
+ */
188
+ export const getHomeRoute = (routers, homeName = 'home') => {
189
+ let i = -1
190
+ let len = routers.length
191
+ let homeRoute = {}
192
+ while (++i < len) {
193
+ let item = routers[i]
194
+ if (item.children && item.children.length) {
195
+ let res = getHomeRoute(item.children, homeName)
196
+ if (res.name) return res
197
+ } else {
198
+ if (item.name === homeName) homeRoute = item
199
+ }
200
+ }
201
+ return homeRoute
202
+ }
203
+
204
+ /**
205
+ * @param {*} list 现有标签导航列表
206
+ * @param {*} newRoute 新添加的路由原信息对象
207
+ * @description 如果该newRoute已经存在则不再添加
208
+ */
209
+ export const getNewTagList = (list, newRoute) => {
210
+ const {name, path, meta} = newRoute
211
+ let newList = [...list]
212
+ if (newList.findIndex(item => item.name === name) >= 0) return newList
213
+ else newList.push({name, path, meta})
214
+ return newList
215
+ }
216
+
217
+ /**
218
+ * @param {*} access 用户权限数组,如 ['super_admin', 'admin']
219
+ * @param {*} route 路由列表
220
+ */
221
+ const hasAccess = (access, route) => {
222
+ if (route.meta && route.meta.access) return hasOneOf(access, route.meta.access)
223
+ else return true
224
+ }
225
+
226
+ /**
227
+ * 权鉴
228
+ * @param {*} name 即将跳转的路由name
229
+ * @param {*} access 用户权限数组
230
+ * @param {*} routes 路由列表
231
+ * @description 用户是否可跳转到该页
232
+ */
233
+ export const canTurnTo = (name, access, routes) => {
234
+ const routePermissionJudge = (list) => {
235
+ return list.some(item => {
236
+ if (item.children && item.children.length) {
237
+ return routePermissionJudge(item.children)
238
+ } else if (item.name === name) {
239
+ return hasAccess(access, item)
240
+ }
241
+ })
242
+ }
243
+
244
+ return routePermissionJudge(routes)
245
+ }
246
+
247
+ /**
248
+ * @param {String} url
249
+ * @description 从URL中解析参数
250
+ */
251
+ export const getParams = url => {
252
+ const keyValueArr = url.split('?')[1].split('&')
253
+ let paramObj = {}
254
+ keyValueArr.forEach(item => {
255
+ const keyValue = item.split('=')
256
+ paramObj[keyValue[0]] = keyValue[1]
257
+ })
258
+ return paramObj
259
+ }
260
+
261
+
262
+ /**
263
+ * @param {Number} times 回调函数需要执行的次数
264
+ * @param {Function} callback 回调函数
265
+ */
266
+ export const doCustomTimes = (times, callback) => {
267
+ let i = -1
268
+ while (++i < times) {
269
+ callback(i)
270
+ }
271
+ }
272
+
273
+ /**
274
+ * @param {Object} file 从上传组件得到的文件对象
275
+ * @returns {Promise} resolve参数是解析后的二维数组
276
+ * @description 从Csv文件中解析出表格,解析成二维数组
277
+ */
278
+ export const getArrayFromFile = (file) => {
279
+ let nameSplit = file.name.split('.')
280
+ let format = nameSplit[nameSplit.length - 1]
281
+ return new Promise((resolve, reject) => {
282
+ let reader = new FileReader()
283
+ reader.readAsText(file) // 以文本格式读取
284
+ let arr = []
285
+ reader.onload = function (evt) {
286
+ let data = evt.target.card // 读到的数据
287
+ let pasteData = data.trim()
288
+ arr = pasteData.split((/[\n\u0085\u2028\u2029]|\r\n?/g)).map(row => {
289
+ return row.split('\t')
290
+ }).map(item => {
291
+ return item[0].split(',')
292
+ })
293
+ if (format === 'csv') resolve(arr)
294
+ else reject(new Error('[Format Error]:你上传的不是Csv文件'))
295
+ }
296
+ })
297
+ }
298
+
299
+ /**
300
+ * @param {Array} array 表格数据二维数组
301
+ * @returns {Object} { columns, tableData }
302
+ * @description 从二维数组中获取表头和表格数据,将第一行作为表头,用于在iView的表格中展示数据
303
+ */
304
+ export const getTableDataFromArray = (array) => {
305
+ let columns = []
306
+ let tableData = []
307
+ if (array.length > 1) {
308
+ let titles = array.shift()
309
+ columns = titles.map(item => {
310
+ return {
311
+ title: item,
312
+ key: item
313
+ }
314
+ })
315
+ tableData = array.map(item => {
316
+ let res = {}
317
+ item.forEach((col, i) => {
318
+ res[titles[i]] = col
319
+ })
320
+ return res
321
+ })
322
+ }
323
+ return {
324
+ columns,
325
+ tableData
326
+ }
327
+ }
328
+
329
+ /**
330
+ * 寻找上级节点
331
+ * @param ele
332
+ * @param tag
333
+ * @returns {*}
334
+ */
335
+ export const findNodeUpper = (ele, tag) => {
336
+ if (ele.parentNode) {
337
+ if (ele.parentNode.tagName === tag.toUpperCase()) {
338
+ return ele.parentNode
339
+ } else {
340
+ return findNodeUpper(ele.parentNode, tag)
341
+ }
342
+ }
343
+ }
344
+
345
+ /**
346
+ * 根据class寻找上级节点
347
+ * @param ele
348
+ * @param classes
349
+ * @returns {*}
350
+ */
351
+ export const findNodeUpperByClasses = (ele, classes) => {
352
+ let parentNode = ele.parentNode
353
+ if (parentNode) {
354
+ let classList = parentNode.classList
355
+ if (classList && classes.every(className => classList.contains(className))) {
356
+ return parentNode
357
+ } else {
358
+ return findNodeUpperByClasses(parentNode, classes)
359
+ }
360
+ }
361
+ }
362
+
363
+ /**
364
+ * 根据ele寻找下级节点
365
+ * @param ele
366
+ * @param tag
367
+ * @returns {*}
368
+ */
369
+ export const findNodeDownward = (ele, tag) => {
370
+ const tagName = tag.toUpperCase()
371
+ if (ele.childNodes.length) {
372
+ let i = -1
373
+ let len = ele.childNodes.length
374
+ while (++i < len) {
375
+ let child = ele.childNodes[i]
376
+ if (child.tagName === tagName) return child
377
+ else return findNodeDownward(child, tag)
378
+ }
379
+ }
380
+ }
381
+
382
+ /**
383
+ * @description 判断要查询的数组是否至少有一个元素包含在目标数组中
384
+ * @param access 需要查询的数组
385
+ * @param canViewAccess 目标数组
386
+ * @returns {*}
387
+ */
388
+ export const showByAccess = (access, canViewAccess) => {
389
+ return hasOneOf(canViewAccess, access)
390
+ }
391
+
392
+ /**
393
+ * @description 根据name/params/query判断两个路由对象是否相等
394
+ * @param {*} route1 路由对象
395
+ * @param {*} route2 路由对象
396
+ */
397
+ export const routeEqual = (route1, route2) => {
398
+ const params1 = route1.params || {}
399
+ const params2 = route2.params || {}
400
+ const query1 = route1.query || {}
401
+ const query2 = route2.query || {}
402
+ return (route1.name === route2.name) && objEqual(params1, params2) && objEqual(query1, query2)
403
+ }
404
+
405
+ /**
406
+ * 判断打开的标签列表里是否已存在这个新添加的路由对象
407
+ */
408
+ export const routeHasExist = (tagNavList, routeItem) => {
409
+ let len = tagNavList.length
410
+ let res = false
411
+ doCustomTimes(len, (index) => {
412
+ if (routeEqual(tagNavList[index], routeItem)) res = true
413
+ })
414
+ return res
415
+ }
416
+
417
+ /**
418
+ * scrollTop animation
419
+ * @param el
420
+ * @param from
421
+ * @param to
422
+ * @param duration
423
+ * @param endCallback
424
+ */
425
+ export const scrollTop = (el, from = 0, to, duration = 500, endCallback) => {
426
+ if (!window.requestAnimationFrame) {
427
+ window.requestAnimationFrame = (
428
+ window.webkitRequestAnimationFrame ||
429
+ window.mozRequestAnimationFrame ||
430
+ window.msRequestAnimationFrame ||
431
+ function (callback) {
432
+ return window.setTimeout(callback, 1000 / 60)
433
+ }
434
+ )
435
+ }
436
+ const difference = Math.abs(from - to)
437
+ const step = Math.ceil(difference / duration * 50)
438
+
439
+ const scroll = (start, end, step) => {
440
+ if (start === end) {
441
+ endCallback && endCallback()
442
+ return
443
+ }
444
+
445
+ let d = (start + step > end) ? end : start + step
446
+ if (start > end) {
447
+ d = (start - step < end) ? end : start - step
448
+ }
449
+
450
+ if (el === window) {
451
+ window.scrollTo(d, d)
452
+ } else {
453
+ el.scrollTop = d
454
+ }
455
+ window.requestAnimationFrame(() => scroll(d, end, step))
456
+ }
457
+ scroll(from, to, step)
458
+ }
459
+
460
+ /**
461
+ * @description 根据当前跳转的路由设置显示在浏览器标签的title
462
+ * @param {String} configTitle 配置标题
463
+ * @param {Object} routeItem 路由对象
464
+ * @param {Object} vm Vue实例
465
+ */
466
+ export const setTitle = (configTitle,routeItem, vm) => {
467
+ const handledRoute = getRouteTitleHandled(routeItem)
468
+ const pageTitle = showTitle(handledRoute, vm)
469
+ const resTitle = pageTitle ? `${configTitle} - ${pageTitle}` : configTitle
470
+ window.document.title = resTitle
471
+ }
472
+
473
+ /**
474
+ * 获取浏览器地址url中的参数
475
+ * @param url
476
+ * @returns {Object}
477
+ */
478
+ export const getUrlParams = (url) => {
479
+ if (!url){
480
+ url = location.search;
481
+ }
482
+ //const url = location.search; //获取url中"?"符后的字串
483
+ const theRequest = new Object();
484
+ if (url.indexOf("?") != -1) {
485
+ const str = url.substr(1);
486
+ let strs = str.split("&");
487
+ for (let i = 0; i < strs.length; i++) {
488
+ theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
489
+ }
490
+ }
491
+ return theRequest;
492
+ }
493
+
494
+
495
+ export const getChangeTableDatas = (oldData, newData) => {
496
+ let list = []
497
+ for (let i = 0; i < newData.length; i++) {
498
+ if (oldData[i].checked != newData[i].checked) {
499
+ let tmpData = {
500
+ "id": newData[i].id,
501
+ "checked": newData[i].checked
502
+ }
503
+ if (newData[i].dpType) {
504
+ tmpData.dpType = newData[i].dpType
505
+ }
506
+ if (newData[i].employeeJobIdentityId) {
507
+ tmpData.employeeJobIdentityId = newData[i].employeeJobIdentityId
508
+ }
509
+ if (newData[i].userId) {
510
+ tmpData.userId = newData[i].userId
511
+ }
512
+ list.push(tmpData);
513
+ }
514
+ if (newData[i].children) {
515
+ list = list.concat(getChangeTableDatas(oldData[i].children, newData[i].children))
516
+ }
517
+ }
518
+ return list
519
+ }
520
+
521
+ /**
522
+ * 合并数组并去重
523
+ * @param oldRow
524
+ * @param newRow
525
+ * @param key
526
+ * @returns {*[]}
527
+ */
528
+ export const removeDup = (oldRow,newRow,key) => {
529
+ let resultMap = {};
530
+ for(let o of oldRow){
531
+ resultMap[o[key]] = o;
532
+ }
533
+ for (let n of newRow) {
534
+ resultMap[n[key]] = n;
535
+ }
536
+ let result = []
537
+ for (let row in resultMap) {
538
+ result.push(resultMap[row])
539
+ }
540
+ return result;
541
+ }
542
+ /**
543
+ * 获取数组修改的数据
544
+ * @param oldRow
545
+ * @param newRow
546
+ * @param key
547
+ * @returns {{delList: *[], addList: *[]}}
548
+ */
549
+ export const getChangeData = (oldRow,newRow,key) =>{
550
+ let oldMap = {};
551
+ for(let o of oldRow){
552
+ if (key){
553
+ oldMap[o[key]] = o;
554
+ } else {
555
+ oldMap[o] = o;
556
+ }
557
+ }
558
+ let newMap = {}
559
+ for(let n of newRow){
560
+ if (key){
561
+ newMap[n[key]] = n;
562
+ } else {
563
+ newMap[n] = n;
564
+ }
565
+ }
566
+ let addList = []
567
+ for (let n of newRow) {
568
+ if (key){
569
+ if (!oldMap[n[key]]) {
570
+ addList.push(n);
571
+ }
572
+ } else {
573
+ if (!oldMap[n]) {
574
+ addList.push(n);
575
+ }
576
+ }
577
+ }
578
+ let delList = []
579
+ for (let o of oldRow) {
580
+ if (key){
581
+ if (!newMap[o[key]]) {
582
+ delList.push(o);
583
+ }
584
+ } else {
585
+ if (!newMap[o]) {
586
+ delList.push(o);
587
+ }
588
+ }
589
+ }
590
+ return {
591
+ addList,delList
592
+ }
593
+ }
594
+
595
+ /**
596
+ * @param {Array} arr1
597
+ * @param {Array} arr2
598
+ * @description 得到两个数组的交集, 两个数组的元素为数值或字符串
599
+ */
600
+ export const getIntersection = (arr1, arr2) => {
601
+ let len = Math.min(arr1.length, arr2.length)
602
+ let i = -1
603
+ let res = []
604
+ while (++i < len) {
605
+ const item = arr2[i]
606
+ if (arr1.indexOf(item) > -1) res.push(item)
607
+ }
608
+ return res
609
+ }
610
+
611
+ /**
612
+ * @param {Array} arr1
613
+ * @param {Array} arr2
614
+ * @description 得到两个数组的并集, 两个数组的元素为数值或字符串
615
+ */
616
+ export const getUnion = (arr1, arr2) => {
617
+ return Array.from(new Set([...arr1, ...arr2]))
618
+ }
619
+
620
+ /**
621
+ * @param {Array} target 目标数组
622
+ * @param {Array} arr 需要查询的数组
623
+ * @description 判断要查询的数组是否至少有一个元素包含在目标数组中
624
+ */
625
+ const hasOneOf = (targetarr, arr) => {
626
+ return targetarr.some(_ => arr.indexOf(_) > -1)
627
+ }
628
+
629
+ /**
630
+ * foreach
631
+ * @param arr
632
+ * @param fn 回调函数,参数接收arr的元素,索引,arr本身
633
+ */
634
+ const forEach = (arr, fn) => {
635
+ if (!arr.length || !fn) return
636
+ let i = -1
637
+ let len = arr.length
638
+ while (++i < len) {
639
+ let item = arr[i]
640
+ fn(item, i, arr)
641
+ }
642
+ }
643
+
644
+ /**
645
+ * @param {String|Number} value 要验证的字符串或数值
646
+ * @param {*} validList 用来验证的列表
647
+ */
648
+ export function oneOf (value, validList) {
649
+ for (let i = 0; i < validList.length; i++) {
650
+ if (value === validList[i]) {
651
+ return true
652
+ }
653
+ }
654
+ return false
655
+ }
656
+
657
+ /**
658
+ * recursionKeyFindItem
659
+ * @param arr
660
+ * @param filterKey
661
+ * @param filterValue
662
+ * @param recursionKey
663
+ * @returns {*|null}
664
+ */
665
+ export const recursionKeyFindItem = (arr, filterKey, filterValue, recursionKey) => {
666
+ for (const item of arr) {
667
+ if (item[filterKey] && item[filterKey] == filterValue && item['type'] == 2) {
668
+ return item;
669
+ }
670
+ let result = null;
671
+ if (item[recursionKey]) {
672
+ result = recursionKeyFindItem(item[recursionKey], filterKey, filterValue, recursionKey);
673
+ if (result) {
674
+ return result;
675
+ }
676
+ }
677
+ }
678
+ return null;
679
+ };
680
+
681
+ /**
682
+ * filterMenuName
683
+ * @param menuList
684
+ * @param name
685
+ * @returns {*|null}
686
+ */
687
+ export const filterMenuName = (menuList, name) => {
688
+ return recursionKeyFindItem(menuList, 'name', name, 'children')
689
+ };
690
+
691
+ /**
692
+ * filterMenuUri
693
+ * @param menuList
694
+ * @param name
695
+ * @returns {*|null}
696
+ */
697
+ export const filterMenuUri = (menuList, name) => {
698
+ return recursionKeyFindItem(menuList, 'uri', name, 'children')
699
+ };
700
+
701
+ /**
702
+ * tagExists
703
+ * @param taglist
704
+ * @param name
705
+ * @returns {boolean}
706
+ */
707
+ export const tagExists = (taglist, name) => {
708
+ return taglist && taglist.filter(item => item.name === name).length > 0;
709
+ };
710
+
711
+ /**
712
+ * 判断菜单是否为新窗口打开
713
+ * @param menu
714
+ */
715
+ export const isOpenBlank = (menu) => {
716
+ let extendProps = {}
717
+ if (menu && menu.meta && menu.meta.data && menu.meta.data.extension) {
718
+ extendProps = JSON.parse(menu.meta.data.extension)
719
+ }
720
+ if (menu && menu.extension) {
721
+ extendProps = JSON.parse(menu.extension)
722
+ }
723
+ if (extendProps && extendProps.target_type && extendProps.target_type == 'blank') {
724
+ return true;
725
+ }
726
+ if (extendProps && extendProps.targetType && extendProps.targetType == 'blank') {
727
+ return true;
728
+ }
729
+ return false;
730
+ }
731
+
732
+ /**
733
+ * 判断应用是否为移动应用
734
+ * @param menu
735
+ */
736
+ export const isMobileApp = (app) => {
737
+ try{
738
+ let extendProps = {};
739
+ if (app.extendProps) {
740
+ if (typeof app.extendProps == 'string') {
741
+ extendProps = JSON.parse(app.extendProps);
742
+ } else {
743
+ extendProps = app.extendProps;
744
+ }
745
+ }
746
+ if (app.setting) {
747
+ if (typeof app.setting == 'string') {
748
+ extendProps = JSON.parse(app.setting);
749
+ } else {
750
+ extendProps = app.setting;
751
+ }
752
+ }
753
+ if (extendProps && extendProps.is_mobile_app && extendProps.is_mobile_app == '1') {
754
+ return true;
755
+ }
756
+ }catch (e) {
757
+ console.error(e)
758
+ }
759
+ return false;
760
+ }
761
+
762
+ /**
763
+ * 获取pc应用列表
764
+ * @param appList
765
+ * @returns {*[]}
766
+ */
767
+ export const getPCAppList = (appList,filterCenter = false) => {
768
+ let finalList = []
769
+ if(appList) {
770
+ for (let app of appList) {
771
+ if ((!isMobileApp(app) && filterCenter && isCenterApp(app))
772
+ || (!isMobileApp(app) && !filterCenter)) {
773
+ finalList.push(app);
774
+ }
775
+ }
776
+ }
777
+ return finalList;
778
+ }
779
+
780
+ /**
781
+ * 获取移动应用列表
782
+ * @param appList
783
+ * @returns {*[]}
784
+ */
785
+ export const getMobileAppList = (appList,filterCenter= false) => {
786
+ let finalList = []
787
+ if(appList) {
788
+ for (let app of appList) {
789
+ if ((isMobileApp(app) && filterCenter && isCenterApp(app))
790
+ || (isMobileApp(app) && !filterCenter)) {
791
+ finalList.push(app);
792
+ }
793
+ }
794
+ }
795
+ return finalList;
796
+ }
797
+ /**
798
+ * 判断应用是否门户应用
799
+ * @param menu
800
+ */
801
+ export const isCenterApp = (app) => {
802
+ try{
803
+ let extendProps = {};
804
+ if (app.extendProps) {
805
+ if (typeof app.extendProps == 'string') {
806
+ extendProps = JSON.parse(app.extendProps);
807
+ } else {
808
+ extendProps = app.extendProps;
809
+ }
810
+ }
811
+ if (app.setting) {
812
+ if (typeof app.setting == 'string') {
813
+ extendProps = JSON.parse(app.setting);
814
+ } else {
815
+ extendProps = app.setting;
816
+ }
817
+ }
818
+ if (extendProps && extendProps.is_center_app && extendProps.is_center_app == '1') {
819
+ return true;
820
+ }
821
+ }catch (e) {
822
+ console.error(e);
823
+ }
824
+ return false;
825
+ }
826
+
827
+ /**
828
+ * 获取一级菜单作为顶级导航
829
+ * @param permissionList
830
+ * @param appType
831
+ * @returns {*[]}
832
+ */
833
+ export const buildNavListByMenu = (permissionList,appInfo,appType,defaultHideName = '') => {
834
+ let navList = []
835
+ if (permissionList && appInfo && appInfo.appId) {
836
+ let permissions = permissionList.filter(item => item.hasOwnProperty('pid')
837
+ && item.pid == '0' && item.appId == appInfo.appId && item.name != defaultHideName)
838
+ for (let per of permissions) {
839
+ if (appType && appType == 'sc') {
840
+ let nav = {
841
+ "data" : deepCopy(per),
842
+ "appInfo" : deepCopy(appInfo),
843
+ "orderNo": per.orders,
844
+ "application": {
845
+ "extendProps": per.extension ? JSON.parse(per.extension) : "",
846
+ "appId": per.permissionId,
847
+ "appBizCode": per.permissionValue,
848
+ "appName": per.title,
849
+ "appDesc": per.description,
850
+ "appUrl": appInfo.basepath,
851
+ "icon": per.icon,
852
+ "appStatus": 1,
853
+ "manageUnitId": "",
854
+ "protocolType": null,
855
+ "grantTypes": null,
856
+ "logoutUrl": null,
857
+ "redirectUrls": null,
858
+ "codeExpiresIn": null,
859
+ "idTokenExpiresIn": null,
860
+ "accessTokenExpiresIn": null,
861
+ "clientId": "",
862
+ "clientSecret": "",
863
+ "isEnableSso": false,
864
+ "isShare": false,
865
+ "referAppId": null,
866
+ "externalId": null,
867
+ "callerAppId": null,
868
+ "orderNo": 1,
869
+ "parentId": null,
870
+ "appType": null,
871
+ "relativeName": null,
872
+ "shortName": null,
873
+ "authType": "1",
874
+ "isLower": null
875
+ },
876
+ "basepath": appInfo.basepath,
877
+ "appId": per.permissionId,
878
+ "icon": per.icon,
879
+ "name": per.name,
880
+ "extendProps": per.extension ? JSON.parse(per.extension) : "",
881
+ "title": per.title,
882
+ "type": "00",
883
+ "status": 1
884
+ }
885
+ navList.push(nav)
886
+ } else {
887
+ let nav = {
888
+ "data" : deepCopy(per),
889
+ "appInfo" : deepCopy(appInfo),
890
+ "id": per.id,
891
+ "appId": per.permissionId,
892
+ "systemId": per.systemId,
893
+ "icon": per.icon,
894
+ "banner": null,
895
+ "theme": null,
896
+ "basepath": appInfo.basepath,
897
+ "status": 1,
898
+ "name": per.name,
899
+ "title": per.title,
900
+ "type": "00",
901
+ "setting": "",
902
+ "description": per.description,
903
+ "orders": per.orders,
904
+ "createTime": 1710772466000,
905
+ "updateTime": 1710772466000
906
+ }
907
+ navList.push(nav)
908
+ }
909
+ }
910
+ }
911
+ return navList;
912
+ }
913
+
914
+ /**
915
+ * 判断是否为子菜单
916
+ * @param permissionList
917
+ * @param pid
918
+ * @param per
919
+ * @returns {boolean|boolean|*}
920
+ */
921
+ export const isChildPermission = (permissionList, pid, per) => {
922
+ if (permissionList && pid && per && per.pid) {
923
+ let res = permissionList.find(item => item.hasOwnProperty('permissionId') && item.permissionId == per.pid)
924
+ if (res && res.permissionId && res.permissionId == pid) {
925
+ return true;
926
+ } else {
927
+ return isChildPermission(permissionList, pid, res)
928
+ }
929
+ }
930
+ return false;
931
+ }
932
+ /**
933
+ * 获取所有子菜单
934
+ * @param permissionList
935
+ * @param pid
936
+ */
937
+ export const getChildPermissions = (permissionList, pid, appInfo) => {
938
+ let res = []
939
+ if (permissionList && pid) {
940
+ for (let permission of permissionList) {
941
+ if (isChildPermission(permissionList, pid, permission)) {
942
+ let per2 = deepCopy(permission);
943
+ per2.appId = pid;
944
+ if (per2.pid == pid) {
945
+ per2.pid = "0";
946
+ }
947
+ per2.appInfo = deepCopy(appInfo)
948
+ res.push(per2);
949
+ }
950
+ }
951
+ }
952
+ return res;
953
+ }
954
+ /**
955
+ * 恢复权限的原始信息
956
+ * @param permission
957
+ */
958
+ export const getOriginalPermission = (permission) => {
959
+ if (permission && permission.meta && permission.meta.data && permission.meta.data.appInfo) {
960
+ let per2 = deepCopy(permission);
961
+ if (per2.hasOwnProperty('pid') && per2.pid == '0') {
962
+ per2.pid = per2.meta.data.appId;
963
+ per2.meta.data.pid = per2.meta.data.appId;
964
+ }
965
+ per2.meta.appId = permission.meta.data.appInfo.appId;
966
+ per2.meta.data.appId = permission.meta.data.appInfo.appId;
967
+ return per2;
968
+ }
969
+ return permission
970
+ }
971
+
972
+ /**
973
+ * 单应用时修改源权限信息
974
+ * @param permissionList
975
+ * @param menu
976
+ * @param appInfo
977
+ * @returns {*}
978
+ */
979
+ export const buildSinglePermission = (permissionList, menu) => {
980
+ let permission = permissionList.find(item => item.permissionId == menu.permissionId && item.appId == menu.appId)
981
+ let rootPermission = getRootPermission(permissionList, permission)
982
+ if (rootPermission && rootPermission.permissionId) {
983
+ menu.appInfo = {
984
+ appId: menu.appId
985
+ }
986
+ menu.appId = rootPermission.permissionId;
987
+ }
988
+ return menu;
989
+ }
990
+ /**
991
+ * 获取菜单根节点
992
+ * @param permissionList
993
+ * @param permission
994
+ * @returns {*|{pid}|{}}
995
+ */
996
+ export const getRootPermission = (permissionList, permission) => {
997
+ if (permissionList, permission) {
998
+ if (!permission.hasOwnProperty('pid')) {
999
+ return permission
1000
+ } else if (permission.pid == '0') {
1001
+ return permission
1002
+ } else {
1003
+ let parentPermission = permissionList.find(item => item.permissionId == permission.pid && item.appId == permission.appId)
1004
+ return getRootPermission(permissionList, parentPermission);
1005
+ }
1006
+ }
1007
+ return permission;
1008
+ }
1009
+ /**
1010
+ * getPreviousTagIndex
1011
+ * @param tagList
1012
+ * @param name
1013
+ * @returns {number}
1014
+ */
1015
+ export const getPreviousTagIndex = (tagList, name) => {
1016
+ let count = 0;
1017
+ if (tagList && name) {
1018
+ for (let i = 0 ;i < tagList.length; i++) {
1019
+ let item = tagList[i];
1020
+ if (item.name == name) {
1021
+ count = i - 1;
1022
+ if (count < 0) {
1023
+ count = 0;
1024
+ }
1025
+ return count;
1026
+ }
1027
+ }
1028
+ }
1029
+ return count;
1030
+ };
1031
+
1032
+ /**
1033
+ * getDelTagIndex
1034
+ * @param tagList
1035
+ * @param name
1036
+ * @returns {number}
1037
+ */
1038
+ export const getDelTagIndex = (tagList, name) => {
1039
+ let count = 1;
1040
+ if (tagList && name) {
1041
+ for (let i = 1 ;i < tagList.length; i++) {
1042
+ let item = tagList[i];
1043
+ if (item.name !== name) {
1044
+ return count;
1045
+ }
1046
+ }
1047
+ }
1048
+ return count;
1049
+ }
1050
+
1051
+ /**
1052
+ * turnToPage
1053
+ * @param vm
1054
+ * @param name
1055
+ * @param url
1056
+ */
1057
+ export const turnToPage = (vm, name ,url, forceLocation = false) =>{
1058
+ if (window.top && window.top.location.href != window.location.href) {
1059
+ typeof sessionStorage != 'undefined' && sessionStorage.removeItem('activeName')
1060
+ window.top.location.href = url;
1061
+ } else if (forceLocation){
1062
+ typeof sessionStorage != 'undefined' && sessionStorage.removeItem('activeName')
1063
+ if (window.top){
1064
+ window.top.location.href = url;
1065
+ } else {
1066
+ window.location.href = url;
1067
+ }
1068
+ } else if (vm && vm.$router){
1069
+ vm.$router.push({
1070
+ name: name
1071
+ })
1072
+ } else {
1073
+ window.location.href = url;
1074
+ }
1075
+ }
1076
+
1077
+
1078
+ /**
1079
+ * 获取上级节点的方法
1080
+ * @param vm
1081
+ * @param methodName
1082
+ * @returns {*}
1083
+ */
1084
+ export const getParentMethod = (vm,methodName) => {
1085
+ if (vm.$parent) {
1086
+ if (vm.$parent[methodName]) {
1087
+ return vm.$parent[methodName];
1088
+ } else {
1089
+ return getParentMethod(vm.$parent,methodName)
1090
+ }
1091
+ }
1092
+ return undefined;
1093
+ }
1094
+
1095
+ /**
1096
+ * 执行全屏操作
1097
+ * @param vm
1098
+ */
1099
+ export const doParentMethod = (vm,methodName) => {
1100
+ let action = getParentMethod(vm,methodName)
1101
+ if (action) {
1102
+ action()
1103
+ }
1104
+ }
1105
+ /**
1106
+ * 替换url中的指定参数
1107
+ * @param url
1108
+ * @param paramName
1109
+ * @param paramValue
1110
+ * @returns {string}
1111
+ */
1112
+ export const replaceUrlParam = (url, paramName, paramValue) => {
1113
+ let pattern = new RegExp('(' + paramName + '=)([^&]+)', 'i');
1114
+ let queryString = url.split('?')[1];
1115
+ if (queryString) {
1116
+ let newParam = paramName + '=' + encodeURIComponent(paramValue);
1117
+ let newQueryString = queryString.replace(pattern, newParam);
1118
+ return url.split('?')[0] + '?' + newQueryString;
1119
+ } else {
1120
+ return url + '?' + paramName + '=' + encodeURIComponent(paramValue);
1121
+ }
1122
+ }
1123
+ /**
1124
+ * 拼接url
1125
+ * @param href
1126
+ * @param key
1127
+ * @param value
1128
+ * @returns {string}
1129
+ */
1130
+ export const buildParams = (href, key, value) =>{
1131
+ if (href && key && value) {
1132
+ if (!href.includes(key + '=')) {
1133
+ if (href.includes('?')) {
1134
+ href += '&' + key + '=' + value
1135
+ } else {
1136
+ href += '?' + key + '=' + value
1137
+ }
1138
+ } else {
1139
+ href = this.replaceUrlParam(href,key,value)
1140
+ }
1141
+ return href;
1142
+ }
1143
+ return '';
1144
+ }
1145
+ /**
1146
+ * 组装菜单url
1147
+ * @param item
1148
+ * @param ssoToken
1149
+ * @param ssoid
1150
+ * @returns {string}
1151
+ */
1152
+ export const buildMenuUri = (item,ssoToken,ssoid) => {
1153
+ if (!item.uri) {
1154
+ return ''
1155
+ }
1156
+ let href = ''
1157
+ let uri = item.uri
1158
+ if (uri.startsWith('http')) {
1159
+ href = uri
1160
+ } else {
1161
+ let basepath = ''
1162
+ if (item.navList) {
1163
+ let navList = deepCopy(item.navList);
1164
+ let appId = '';
1165
+ if (item.appId) {
1166
+ appId = item.appId;
1167
+ } else if (item.meta && item.meta.appId) {
1168
+ appId = item.meta.appId;
1169
+ }
1170
+ let appInfo = navList.find(app => app.appId === appId)
1171
+ if (appInfo && appInfo.basepath) {
1172
+ basepath = appInfo.basepath
1173
+ }
1174
+ }
1175
+ if (!basepath.startsWith('/') && !basepath.startsWith('http')) {
1176
+ basepath = '/' + basepath
1177
+ }
1178
+ if (basepath.endsWith('/')) {
1179
+ basepath = basepath.substring(0, basepath.length - 1)
1180
+ }
1181
+ if (!uri.startsWith('/')) {
1182
+ uri = '/' + uri
1183
+ }
1184
+ href = basepath + uri
1185
+ }
1186
+ href = buildParams(href,"layout","screen");
1187
+ if (ssoToken) {
1188
+ href = buildParams(href,"token",ssoToken);
1189
+ }
1190
+ if (ssoid) {
1191
+ href = buildParams(href,"ssoid",ssoid);
1192
+ }
1193
+ if (item.cts) {
1194
+ href = buildParams(href,"cts",item.cts);
1195
+ }
1196
+ return href
1197
+ }
1198
+ /**
1199
+ * 给query添加时间戳
1200
+ */
1201
+ export const addTimestamp = ($route) => {
1202
+ let query = {};
1203
+ if ($route.query) {
1204
+ query = $route.query;
1205
+ }
1206
+ query = Object.assign({},query,{cts:new Date().getTime()})
1207
+ $route.query = query;
1208
+ return $route;
1209
+ }
1210
+ /**
1211
+ * 根据配置信息修改系统信息
1212
+ * @param systemInfo
1213
+ */
1214
+ export const changeSystemInfo = async (systemInfo) => {
1215
+ let defaultSystemInfo = {
1216
+ layoutSize: 'small',
1217
+ systemLogo: systemLogo,
1218
+ logoWidth: '150px',
1219
+ systemName: sessionStorage.getItem('systemName') ? sessionStorage.getItem('systemName') : config.title,
1220
+ nameSize: 1,
1221
+ navType: 'dropdown',
1222
+ rightTopOptButtonList: ['collect', 'fullScreen'],
1223
+ rightTopShowFunList: ['theme', 'personalCenter', 'noticeList', 'logout'],
1224
+ menuLogo: '1',
1225
+ titleShow: 'wrap',
1226
+ menuScaling: '1',
1227
+ footerInfo: 'Copyright © 2021 浪潮数字商业科技有限公司 版权所有<br> 辽ICP备11001865号-3',
1228
+ showTheme: '',
1229
+ theme: 'default',
1230
+ tabNum: 5,
1231
+ topMenu: 4,
1232
+ };
1233
+ if (systemInfo) {
1234
+ systemInfo = Object.assign(defaultSystemInfo, systemInfo);
1235
+ } else {
1236
+ systemInfo = defaultSystemInfo;
1237
+ }
1238
+ if (systemInfo.logo) {
1239
+ systemInfo.systemLogo = config.ossServerContext + '/anon/system/file/get/' + systemInfo.logo
1240
+ } else {
1241
+ systemInfo.systemLogo = ''
1242
+ }
1243
+ sessionStorage.setItem('systemLogo', systemInfo.systemLogo)
1244
+ if (systemInfo.systemLogo) {
1245
+ let link = document.querySelector("link[rel*='icon']") || document.createElement('link');
1246
+ link.setAttribute('href', systemInfo.systemLogo);
1247
+ if (!link.getAttribute('rel')) {
1248
+ link.setAttribute('rel', 'icon');
1249
+ }
1250
+ if (!link.getAttribute('type')) {
1251
+ link.setAttribute('type', 'image/png');
1252
+ }
1253
+ }
1254
+ if (systemInfo.logoWidth) {
1255
+ systemInfo.logoWidth = systemInfo.logoWidth + ''
1256
+ }
1257
+ if (systemInfo.systemName) {
1258
+ document.title = systemInfo.systemName
1259
+ sessionStorage.setItem('systemName', systemInfo.systemName)
1260
+ }
1261
+ if (localStorage.getItem('theme')) {
1262
+ systemInfo.theme = localStorage.getItem('theme')
1263
+ }
1264
+ changeByThemeKey(systemInfo.theme)
1265
+ if (localStorage.getItem('themeIdCurrent')) {
1266
+ systemInfo.showTheme = localStorage.getItem('themeIdCurrent')
1267
+ }
1268
+ if (systemInfo.showTheme) {
1269
+ let showTheme = systemInfo.showTheme
1270
+ let split = showTheme.split('-')
1271
+ let systemForm = null
1272
+ let themeId = split[0];
1273
+ let status = split[1];
1274
+ let filterStatus = split[2];
1275
+ if (themeId) {
1276
+ let res = await ajax.get(config.upmsServerContext + '/anon/system/themeInfo?themeId=' + split[0])
1277
+ if (res.data.code == 1) {
1278
+ systemForm = res.data.data[0]
1279
+ if (!status && systemForm.status) {
1280
+ status = systemForm.status;
1281
+ }
1282
+ if (!filterStatus && systemForm.filterStatus) {
1283
+ filterStatus = systemForm.filterStatus;
1284
+ }
1285
+ }
1286
+ }
1287
+ if (systemForm) {
1288
+ changeThemeByThemeId(themeId, status, filterStatus, systemForm)
1289
+ }
1290
+ }
1291
+ if (!systemInfo.rightTopOptButtonList || systemInfo.rightTopOptButtonList.length <= 0) {
1292
+ systemInfo.rightTopOptButtonList = ['collect', 'fullScreen'];
1293
+ }
1294
+ if (!systemInfo.rightTopShowFunList || systemInfo.rightTopShowFunList.length <= 0) {
1295
+ systemInfo.rightTopShowFunList = ['theme', 'personalCenter', 'noticeList', 'logout']
1296
+ }
1297
+ return systemInfo;
1298
+ }
1299
+
1300
+ export const buildHomeConfigs = (settings) => {
1301
+ let result = [];
1302
+ if (settings && settings.length > 0) {
1303
+ let settingMap = {}
1304
+ for (let st of settings) {
1305
+ let key = st.categoryCode;
1306
+ if (!key) {
1307
+ key = "otherCategory";
1308
+ }
1309
+ if (settingMap[key]) {
1310
+ let oldSt = settingMap[key];
1311
+ if (st.permit && oldSt.permit
1312
+ && (st.permit.permissionType > oldSt.permit.permissionType
1313
+ || (st.permit.permissionType == oldSt.permit.permissionType
1314
+ && st.permit.createTime > oldSt.permit.createTime))) {
1315
+ settingMap[key] = st;
1316
+ }
1317
+ } else {
1318
+ settingMap[key] = st;
1319
+ }
1320
+ }
1321
+ if (settingMap['default']) {
1322
+ result.push(settingMap['default']);
1323
+ }
1324
+ for(let key in settingMap) {
1325
+ if (key != 'default') {
1326
+ result.push(settingMap[key])
1327
+ }
1328
+ }
1329
+ }
1330
+ return result;
1331
+ }
1332
+
1333
+ export const getAllElements = ( plist = [], result = []) => {
1334
+ for (let obj of plist) {
1335
+ if (obj.permissionId) {
1336
+ result.push(obj.permissionId);
1337
+ }
1338
+ if (obj.children && obj.children.length > 0) {
1339
+ getAllElements(obj.children, result);
1340
+ }
1341
+ }
1342
+ return result;
1343
+ }