* 1.增加treeTable 2.增加两个treeTable的demo * 1.增加treeTable的使用功能说明 * 优化代码,去除console * 修复bug * 修复marLTemp变量未清空的bug * 修复marLTemp变量未清空的bug * 修复marLTemp变量未清空的bug * 修改customTree,使其展示无columns时的功能
This commit is contained in:
29
src/components/TreeTable/eval.js
Normal file
29
src/components/TreeTable/eval.js
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @Author: jianglei
|
||||
* @Date: 2017-10-12 12:06:49
|
||||
*/
|
||||
'use strict'
|
||||
import Vue from 'vue'
|
||||
export default function treeToArray(data, expandedAll, parent, level) {
|
||||
let tmp = []
|
||||
Array.from(data).forEach(function(record) {
|
||||
if (record._expanded === undefined) {
|
||||
Vue.set(record, '_expanded', expandedAll)
|
||||
}
|
||||
let _level = 1
|
||||
if (level !== undefined && level !== null) {
|
||||
_level = level + 1
|
||||
}
|
||||
Vue.set(record, '_level', _level)
|
||||
// 如果有父元素
|
||||
if (parent) {
|
||||
Vue.set(record, 'parent', parent)
|
||||
}
|
||||
tmp.push(record)
|
||||
if (record.children && record.children.length > 0) {
|
||||
const children = treeToArray(record.children, expandedAll, record, _level)
|
||||
tmp = tmp.concat(children)
|
||||
}
|
||||
})
|
||||
return tmp
|
||||
}
|
Reference in New Issue
Block a user