|
|
@@ -12,15 +12,15 @@ export function getNowDateTime() {
|
|
12
|
12
|
myDate.getYear() // 获取当前年份(2位)
|
|
13
|
13
|
const YY = myDate.getFullYear() // 获取完整的年份(4位,1970-????)
|
|
14
|
14
|
let MM = myDate.getMonth() + 1 // 获取当前月份(0-11,0代表1月)
|
|
15
|
|
- MM = MM > 9 ? MM : ('0' + MM)
|
|
|
15
|
+ MM = MM > 9 ? MM : '0' + MM
|
|
16
|
16
|
let DD = myDate.getDate() // 获取当前日(1-31)
|
|
17
|
|
- DD = DD > 9 ? DD : ('0' + DD)
|
|
|
17
|
+ DD = DD > 9 ? DD : '0' + DD
|
|
18
|
18
|
let hh = myDate.getHours()
|
|
19
|
|
- hh = hh > 9 ? hh : ('0' + hh)
|
|
|
19
|
+ hh = hh > 9 ? hh : '0' + hh
|
|
20
|
20
|
let mm = myDate.getMinutes()
|
|
21
|
|
- mm = mm > 9 ? mm : ('0' + mm)
|
|
|
21
|
+ mm = mm > 9 ? mm : '0' + mm
|
|
22
|
22
|
let ss = myDate.getSeconds()
|
|
23
|
|
- ss = ss > 9 ? ss : ('0' + ss)
|
|
|
23
|
+ ss = ss > 9 ? ss : '0' + ss
|
|
24
|
24
|
return YY + '-' + MM + '-' + DD + ' ' + hh + ':' + mm + ':' + ss
|
|
25
|
25
|
}
|
|
26
|
26
|
|
|
|
@@ -32,9 +32,9 @@ export function getNowDate() {
|
|
32
|
32
|
myDate.getYear() // 获取当前年份(2位)
|
|
33
|
33
|
const YY = myDate.getFullYear() // 获取完整的年份(4位,1970-????)
|
|
34
|
34
|
let MM = myDate.getMonth() + 1 // 获取当前月份(0-11,0代表1月)
|
|
35
|
|
- MM = MM > 9 ? MM : ('0' + MM)
|
|
|
35
|
+ MM = MM > 9 ? MM : '0' + MM
|
|
36
|
36
|
let DD = myDate.getDate() // 获取当前日(1-31)
|
|
37
|
|
- DD = DD > 9 ? DD : ('0' + DD)
|
|
|
37
|
+ DD = DD > 9 ? DD : '0' + DD
|
|
38
|
38
|
return YY + '-' + MM + '-' + DD
|
|
39
|
39
|
}
|
|
40
|
40
|
|
|
|
@@ -48,9 +48,9 @@ export function getPreDate(pdate = 3600 * 1000 * 24 * 30) {
|
|
48
|
48
|
start.getYear() // 获取当前年份(2位)
|
|
49
|
49
|
const YY = start.getFullYear() // 获取完整的年份(4位,1970-????)
|
|
50
|
50
|
let MM = start.getMonth() + 1 // 获取当前月份(0-11,0代表1月)
|
|
51
|
|
- MM = MM > 9 ? MM : ('0' + MM)
|
|
|
51
|
+ MM = MM > 9 ? MM : '0' + MM
|
|
52
|
52
|
let DD = start.getDate() // 获取当前日(1-31)
|
|
53
|
|
- DD = DD > 9 ? DD : ('0' + DD)
|
|
|
53
|
+ DD = DD > 9 ? DD : '0' + DD
|
|
54
|
54
|
return YY + '-' + MM + '-' + DD
|
|
55
|
55
|
}
|
|
56
|
56
|
|
|
|
@@ -62,9 +62,9 @@ export function getFirstDayInCurrentMonth() {
|
|
62
|
62
|
myDate.getYear() // 获取当前年份(2位)
|
|
63
|
63
|
const YY = myDate.getFullYear() // 获取完整的年份(4位,1970-????)
|
|
64
|
64
|
let MM = myDate.getMonth() + 1 // 获取当前月份(0-11,0代表1月)
|
|
65
|
|
- MM = MM > 9 ? MM : ('0' + MM)
|
|
|
65
|
+ MM = MM > 9 ? MM : '0' + MM
|
|
66
|
66
|
let DD = myDate.getDate() // 获取当前日(1-31)
|
|
67
|
|
- DD = DD > 9 ? DD : ('0' + DD)
|
|
|
67
|
+ DD = DD > 9 ? DD : '0' + DD
|
|
68
|
68
|
return YY + '-' + MM + '-01'
|
|
69
|
69
|
}
|
|
70
|
70
|
/**
|
|
|
@@ -73,14 +73,20 @@ export function getFirstDayInCurrentMonth() {
|
|
73
|
73
|
export function getLastDay(year, month) {
|
|
74
|
74
|
var order_month = month
|
|
75
|
75
|
var new_year = year // 取当前的年份
|
|
76
|
|
- var new_month = month++// 取下一个月的第一天,方便计算(最后一天不固定)
|
|
|
76
|
+ var new_month = month++ // 取下一个月的第一天,方便计算(最后一天不固定)
|
|
77
|
77
|
if (month > 12) {
|
|
78
|
78
|
new_month -= 12 // 月份减
|
|
79
|
79
|
new_year++ // 年份增
|
|
80
|
80
|
}
|
|
81
|
81
|
var new_date = new Date(new_year, new_month, 1) // 取当年当月中的第一天
|
|
82
|
82
|
console.log(month)
|
|
83
|
|
- return year + '-' + order_month + '-' + (new Date(new_date.getTime() - 1000 * 60 * 60 * 24)).getDate()// 获取当月最后一天日期
|
|
|
83
|
+ return (
|
|
|
84
|
+ year +
|
|
|
85
|
+ '-' +
|
|
|
86
|
+ order_month +
|
|
|
87
|
+ '-' +
|
|
|
88
|
+ new Date(new_date.getTime() - 1000 * 60 * 60 * 24).getDate()
|
|
|
89
|
+ ) // 获取当月最后一天日期
|
|
84
|
90
|
}
|
|
85
|
91
|
/**
|
|
86
|
92
|
* 超期变红
|
|
|
@@ -89,7 +95,12 @@ export function getLastDay(year, month) {
|
|
89
|
95
|
*/
|
|
90
|
96
|
export function endtimeFilter(status) {
|
|
91
|
97
|
const d = status.replace(/-/g, '/')
|
|
92
|
|
- let curDate = new Date().getFullYear() + '-' + (new Date().getMonth() + 1) + '-' + new Date().getDate()
|
|
|
98
|
+ let curDate =
|
|
|
99
|
+ new Date().getFullYear() +
|
|
|
100
|
+ '-' +
|
|
|
101
|
+ (new Date().getMonth() + 1) +
|
|
|
102
|
+ '-' +
|
|
|
103
|
+ new Date().getDate()
|
|
93
|
104
|
curDate = curDate.replace(/-/g, '/')
|
|
94
|
105
|
let str = ''
|
|
95
|
106
|
if (Date.parse(d) >= Date.parse(curDate)) {
|
|
|
@@ -114,11 +125,16 @@ export function timestampToTime0(timestamp) {
|
|
114
|
125
|
}
|
|
115
|
126
|
const date = new Date(timestamp)
|
|
116
|
127
|
const Y = date.getFullYear() + '-'
|
|
117
|
|
- const M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'
|
|
118
|
|
- const D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()) + ' '
|
|
119
|
|
- const h = (date.getHours() < 10 ? '0' + (date.getHours()) : date.getHours()) + ':'
|
|
120
|
|
- const m = (date.getMinutes() < 10 ? '0' + (date.getMinutes()) : date.getMinutes()) + ':'
|
|
121
|
|
- const s = (date.getSeconds() < 10 ? '0' + (date.getSeconds()) : date.getSeconds())
|
|
|
128
|
+ const M =
|
|
|
129
|
+ (date.getMonth() + 1 < 10
|
|
|
130
|
+ ? '0' + (date.getMonth() + 1)
|
|
|
131
|
+ : date.getMonth() + 1) + '-'
|
|
|
132
|
+ const D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' '
|
|
|
133
|
+ const h =
|
|
|
134
|
+ (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':'
|
|
|
135
|
+ const m =
|
|
|
136
|
+ (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':'
|
|
|
137
|
+ const s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
|
|
122
|
138
|
return Y + M + D + h + m + s
|
|
123
|
139
|
}
|
|
124
|
140
|
|
|
|
@@ -149,7 +165,16 @@ export function timestampToTime(time, cFormat) {
|
|
149
|
165
|
}
|
|
150
|
166
|
const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
|
|
151
|
167
|
let value = formatObj[key]
|
|
152
|
|
- if (key === 'a') return ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期日'][value - 1]
|
|
|
168
|
+ if (key === 'a')
|
|
|
169
|
+ return [
|
|
|
170
|
+ '星期一',
|
|
|
171
|
+ '星期二',
|
|
|
172
|
+ '星期三',
|
|
|
173
|
+ '星期四',
|
|
|
174
|
+ '星期五',
|
|
|
175
|
+ '星期六',
|
|
|
176
|
+ '星期日'
|
|
|
177
|
+ ][value - 1]
|
|
153
|
178
|
if (result.length > 0 && value < 10) {
|
|
154
|
179
|
value = '0' + value
|
|
155
|
180
|
}
|
|
|
@@ -164,12 +189,12 @@ export function timestampToTime(time, cFormat) {
|
|
164
|
189
|
export function secondToDuring(ss) {
|
|
165
|
190
|
let days = parseInt(ss / (60 * 60 * 24))
|
|
166
|
191
|
let hours = parseInt((ss % (60 * 60 * 24)) / (60 * 60))
|
|
167
|
|
- let minutes = parseInt((ss % (60 * 60)) / (60))
|
|
|
192
|
+ let minutes = parseInt((ss % (60 * 60)) / 60)
|
|
168
|
193
|
let seconds = ss % 60
|
|
169
|
|
- days = days > 0 ? (days + '天') : ''
|
|
170
|
|
- hours = hours > 0 ? (hours + '小时') : ''
|
|
171
|
|
- minutes = minutes > 0 ? (minutes + '分') : ''
|
|
172
|
|
- seconds = seconds >= 0 ? (seconds + '秒') : ''
|
|
|
194
|
+ days = days > 0 ? days + '天' : ''
|
|
|
195
|
+ hours = hours > 0 ? hours + '小时' : ''
|
|
|
196
|
+ minutes = minutes > 0 ? minutes + '分' : ''
|
|
|
197
|
+ seconds = seconds >= 0 ? seconds + '秒' : ''
|
|
173
|
198
|
return days + hours + minutes + seconds
|
|
174
|
199
|
}
|
|
175
|
200
|
|
|
|
@@ -197,7 +222,8 @@ export function formatTime(time, option) {
|
|
197
|
222
|
|
|
198
|
223
|
if (diff < 30) {
|
|
199
|
224
|
return '刚刚'
|
|
200
|
|
- } else if (diff < 3600) { // less 1 hour
|
|
|
225
|
+ } else if (diff < 3600) {
|
|
|
226
|
+ // less 1 hour
|
|
201
|
227
|
return Math.ceil(diff / 60) + '分钟前'
|
|
202
|
228
|
} else if (diff < 3600 * 24) {
|
|
203
|
229
|
return Math.ceil(diff / 3600) + '小时前'
|
|
|
@@ -207,39 +233,50 @@ export function formatTime(time, option) {
|
|
207
|
233
|
if (option) {
|
|
208
|
234
|
return formatTime(time, option)
|
|
209
|
235
|
} else {
|
|
210
|
|
- return d.getMonth() + 1 + '月' + d.getDate() + '日' + d.getHours() + '时' + d.getMinutes() + '分'
|
|
|
236
|
+ return (
|
|
|
237
|
+ d.getMonth() +
|
|
|
238
|
+ 1 +
|
|
|
239
|
+ '月' +
|
|
|
240
|
+ d.getDate() +
|
|
|
241
|
+ '日' +
|
|
|
242
|
+ d.getHours() +
|
|
|
243
|
+ '时' +
|
|
|
244
|
+ d.getMinutes() +
|
|
|
245
|
+ '分'
|
|
|
246
|
+ )
|
|
211
|
247
|
}
|
|
212
|
248
|
}
|
|
213
|
249
|
|
|
214
|
250
|
// 格式化 日期选择器的 带快捷选项
|
|
215
|
251
|
export const pickerOptions = {
|
|
216
|
|
- shortcuts: [{
|
|
217
|
|
- text: '最近一周',
|
|
218
|
|
- onClick(picker) {
|
|
219
|
|
- const end = new Date()
|
|
220
|
|
- const start = new Date()
|
|
221
|
|
- start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
|
|
222
|
|
- picker.$emit('pick', [start, end])
|
|
223
|
|
- }
|
|
224
|
|
- },
|
|
225
|
|
- {
|
|
226
|
|
- text: '最近一个月',
|
|
227
|
|
- onClick(picker) {
|
|
228
|
|
- const start = new Date()
|
|
229
|
|
- const end = new Date()
|
|
230
|
|
- start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
|
|
231
|
|
- picker.$emit('pick', [start, end])
|
|
232
|
|
- }
|
|
233
|
|
- },
|
|
234
|
|
- {
|
|
235
|
|
- text: '最近三个月',
|
|
236
|
|
- onClick(picker) {
|
|
237
|
|
- const start = new Date()
|
|
238
|
|
- const end = new Date()
|
|
239
|
|
- start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
|
|
240
|
|
- picker.$emit('pick', [start, end])
|
|
|
252
|
+ shortcuts: [
|
|
|
253
|
+ {
|
|
|
254
|
+ text: '最近一周',
|
|
|
255
|
+ onClick(picker) {
|
|
|
256
|
+ const end = new Date()
|
|
|
257
|
+ const start = new Date()
|
|
|
258
|
+ start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
|
|
|
259
|
+ picker.$emit('pick', [start, end])
|
|
|
260
|
+ }
|
|
|
261
|
+ },
|
|
|
262
|
+ {
|
|
|
263
|
+ text: '最近一个月',
|
|
|
264
|
+ onClick(picker) {
|
|
|
265
|
+ const start = new Date()
|
|
|
266
|
+ const end = new Date()
|
|
|
267
|
+ start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
|
|
|
268
|
+ picker.$emit('pick', [start, end])
|
|
|
269
|
+ }
|
|
|
270
|
+ },
|
|
|
271
|
+ {
|
|
|
272
|
+ text: '最近三个月',
|
|
|
273
|
+ onClick(picker) {
|
|
|
274
|
+ const start = new Date()
|
|
|
275
|
+ const end = new Date()
|
|
|
276
|
+ start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
|
|
|
277
|
+ picker.$emit('pick', [start, end])
|
|
|
278
|
+ }
|
|
241
|
279
|
}
|
|
242
|
|
- }
|
|
243
|
280
|
]
|
|
244
|
281
|
}
|
|
245
|
282
|
|
|
|
@@ -274,10 +311,20 @@ export const filterContent = {
|
|
274
|
311
|
},
|
|
275
|
312
|
// 原样式输出内容
|
|
276
|
313
|
content(con) {
|
|
277
|
|
- if (con === 'null' || con === 'undefined' || con === null || con === undefined || con === '') {
|
|
|
314
|
+ if (
|
|
|
315
|
+ con === 'null' ||
|
|
|
316
|
+ con === 'undefined' ||
|
|
|
317
|
+ con === null ||
|
|
|
318
|
+ con === undefined ||
|
|
|
319
|
+ con === ''
|
|
|
320
|
+ ) {
|
|
278
|
321
|
con = '暂无内容'
|
|
279
|
322
|
} else {
|
|
280
|
|
- con = con.replace(/[ ]/g, ' ').replace(/\ +/g, ' ').replace(/\r\n/g, '<br />').replace(/\n/g, '<br />')
|
|
|
323
|
+ con = con
|
|
|
324
|
+ .replace(/[ ]/g, ' ')
|
|
|
325
|
+ .replace(/\ +/g, ' ')
|
|
|
326
|
+ .replace(/\r\n/g, '<br />')
|
|
|
327
|
+ .replace(/\n/g, '<br />')
|
|
281
|
328
|
}
|
|
282
|
329
|
return con
|
|
283
|
330
|
}
|
|
|
@@ -295,8 +342,8 @@ export function formatterContent(strVal) {
|
|
295
|
342
|
// GUID 的格式为“xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”,其中的 x 是 0-9 或 a-f 范围内的一个32位十六进制数
|
|
296
|
343
|
export function guid() {
|
|
297
|
344
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
|
298
|
|
- const r = Math.random() * 16 | 0
|
|
299
|
|
- const v = c === 'x' ? r : (r & 0x3 | 0x8)
|
|
|
345
|
+ const r = (Math.random() * 16) | 0
|
|
|
346
|
+ const v = c === 'x' ? r : (r & 0x3) | 0x8
|
|
300
|
347
|
return v.toString(16)
|
|
301
|
348
|
})
|
|
302
|
349
|
}
|
|
|
@@ -326,58 +373,70 @@ export function uniqueObjArray(oldArr, attr) {
|
|
326
|
373
|
/**
|
|
327
|
374
|
* 防抖动 节流
|
|
328
|
375
|
*/
|
|
329
|
|
-// scroll 事件本身会触发页面的重新渲染,同时 scroll 事件的 handler 又会被高频度的触发,
|
|
330
|
|
-// 因此事件的 handler 内部不应该有复杂操作,例如 DOM 操作就不应该放在事件处理中。
|
|
331
|
|
-// 针对此类高频度触发事件问题(例如页面 scroll ,屏幕 resize,监听用户输入等),有两种常用的解决方法,防抖和节流。
|
|
332
|
|
-export function debounce(func, wait, immediate) {
|
|
333
|
|
- let timeout, args, context, timestamp, result
|
|
334
|
|
- const later = function() {
|
|
335
|
|
- // 据上一次触发时间间隔
|
|
336
|
|
- const last = +new Date() - timestamp
|
|
|
376
|
+// 例子 debounceList = debounce(getList, 5000)先声明
|
|
|
377
|
+// 后debounceList()调用,每个页面声明一次即可,调用可多次
|
|
|
378
|
+export function debounce(fn, delay, immediate = false, resultCallback) {
|
|
|
379
|
+ // 1.定义一个定时器, 保存上一次的定时器
|
|
|
380
|
+ let timer = null
|
|
|
381
|
+ let isInvoke = false
|
|
337
|
382
|
|
|
338
|
|
- // 上次被包装函数被调用时间间隔last小于设定时间间隔wait
|
|
339
|
|
- if (last < wait && last > 0) {
|
|
340
|
|
- timeout = setTimeout(later, wait - last)
|
|
341
|
|
- } else {
|
|
342
|
|
- timeout = null
|
|
343
|
|
- // 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
|
|
344
|
|
- if (!immediate) {
|
|
345
|
|
- result = func.apply(context, args)
|
|
346
|
|
- if (!timeout) context = args = null
|
|
|
383
|
+ // 2.真正执行的函数
|
|
|
384
|
+ const _debounce = function(...args) {
|
|
|
385
|
+ return new Promise((resolve, reject) => {
|
|
|
386
|
+ // 取消上一次的定时器
|
|
|
387
|
+ if (timer) clearTimeout(timer)
|
|
|
388
|
+
|
|
|
389
|
+ // 判断是否需要立即执行
|
|
|
390
|
+ if (immediate && !isInvoke) {
|
|
|
391
|
+ const result = fn.apply(this, args)
|
|
|
392
|
+ if (resultCallback) resultCallback(result)
|
|
|
393
|
+ resolve(result)
|
|
|
394
|
+ isInvoke = true
|
|
|
395
|
+ } else {
|
|
|
396
|
+ // 延迟执行
|
|
|
397
|
+ timer = setTimeout(() => {
|
|
|
398
|
+ // 外部传入的真正要执行的函数
|
|
|
399
|
+ const result = fn.apply(this, args)
|
|
|
400
|
+ if (resultCallback) resultCallback(result)
|
|
|
401
|
+ resolve(result)
|
|
|
402
|
+ isInvoke = false
|
|
|
403
|
+ timer = null
|
|
|
404
|
+ }, delay)
|
|
347
|
405
|
}
|
|
348
|
|
- }
|
|
|
406
|
+ })
|
|
349
|
407
|
}
|
|
350
|
|
- return function(...args) {
|
|
351
|
|
- context = this
|
|
352
|
|
- timestamp = +new Date()
|
|
353
|
|
- const callNow = immediate && !timeout
|
|
354
|
|
- // 如果延时不存在,重新设定延时
|
|
355
|
|
- if (!timeout) timeout = setTimeout(later, wait)
|
|
356
|
|
- if (callNow) {
|
|
357
|
|
- result = func.apply(context, args)
|
|
358
|
|
- context = args = null
|
|
359
|
|
- }
|
|
360
|
|
- return result
|
|
|
408
|
+
|
|
|
409
|
+ // 封装取消功能
|
|
|
410
|
+ _debounce.cancel = function() {
|
|
|
411
|
+ if (timer) clearTimeout(timer)
|
|
|
412
|
+ timer = null
|
|
|
413
|
+ isInvoke = false
|
|
361
|
414
|
}
|
|
|
415
|
+
|
|
|
416
|
+ return _debounce
|
|
362
|
417
|
}
|
|
363
|
418
|
|
|
364
|
419
|
// 首字母转大写
|
|
365
|
420
|
export function firstToUpper(str) {
|
|
366
|
|
- return str.replace(/( |^)[a-z]/g, (L) => L.toUpperCase())
|
|
|
421
|
+ return str.replace(/( |^)[a-z]/g, L => L.toUpperCase())
|
|
367
|
422
|
}
|
|
368
|
423
|
|
|
369
|
424
|
// 导出
|
|
370
|
425
|
export function exportExcel(exporParams, getListExpt) {
|
|
371
|
426
|
return new Promise(resolve => {
|
|
372
|
427
|
getListExpt(exporParams).then(response => {
|
|
373
|
|
- const headerDispostion = response.headers['content-disposition'] || response.headers['Content-Disposition'] || ''
|
|
|
428
|
+ const headerDispostion =
|
|
|
429
|
+ response.headers['content-disposition'] ||
|
|
|
430
|
+ response.headers['Content-Disposition'] ||
|
|
|
431
|
+ ''
|
|
374
|
432
|
if (headerDispostion) {
|
|
375
|
433
|
const content = response.data
|
|
376
|
434
|
const blob = new Blob([content])
|
|
377
|
435
|
// let fileName = '报表数据.xls'
|
|
378
|
436
|
let fileName = headerDispostion.split(';')[1].split('=')[1]
|
|
379
|
437
|
var explorer = navigator.userAgent
|
|
380
|
|
- if (explorer.indexOf('MSIE') >= 0 || explorer.indexOf('Chrome') >= 0) { // IE和google浏览器
|
|
|
438
|
+ if (explorer.indexOf('MSIE') >= 0 || explorer.indexOf('Chrome') >= 0) {
|
|
|
439
|
+ // IE和google浏览器
|
|
381
|
440
|
fileName = decodeURIComponent(fileName)
|
|
382
|
441
|
} else {
|
|
383
|
442
|
fileName = decodeURI(escape(fileName))
|
|
|
@@ -405,10 +464,10 @@ export function exportExcel(exporParams, getListExpt) {
|
|
405
|
464
|
}
|
|
406
|
465
|
|
|
407
|
466
|
/**
|
|
408
|
|
- * 将一维的扁平数组转换为多层级对象
|
|
409
|
|
- * @param {[type]} list 一维数组,数组中每一个元素需包含id和pid两个属性
|
|
410
|
|
- * @return {[type]} tree 多层级树状结构
|
|
411
|
|
- */
|
|
|
467
|
+ * 将一维的扁平数组转换为多层级对象
|
|
|
468
|
+ * @param {[type]} list 一维数组,数组中每一个元素需包含id和pid两个属性
|
|
|
469
|
+ * @return {[type]} tree 多层级树状结构
|
|
|
470
|
+ */
|
|
412
|
471
|
export function buildTree(list) {
|
|
413
|
472
|
const temp = {}
|
|
414
|
473
|
const tree = {}
|
|
|
@@ -492,4 +551,3 @@ export function filterMenuDatas(menudatas) {
|
|
492
|
551
|
})
|
|
493
|
552
|
return accessedRouters
|
|
494
|
553
|
}
|
|
495
|
|
-
|