-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Edit.vue
100 lines (95 loc) · 3.34 KB
/
Edit.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<template>
<div>
<p class="tip">可编辑树表格,还可以通过手动调用展开收起</p>
<vxe-virtual-tree
resizable
row-key
toolbar
ref="xVTree"
row-id="id"
:tree-config="{children: 'children'}"
:edit-config="{trigger: 'click', mode: 'row'}"
:checkbox-config="{labelField: 'id'}"
:columns="tableColumn"
:data="tableData">
<template v-slot:buttons>
<vxe-button @click="$refs.xTree.toggleTreeExpansion(tableData[0], true)">切换第一个</vxe-button>
<vxe-button @click="$refs.xTree.setTreeExpansion(tableData[2], true)">展开第三个</vxe-button>
<vxe-button @click="$refs.xTree.setAllTreeExpansion(true)">展开所有</vxe-button>
<vxe-button @click="$refs.xTree.clearTreeExpand()">关闭所有</vxe-button>
</template>
</vxe-virtual-tree>
<p class="demo-code">{{ $t('app.body.button.showCode') }}</p>
<pre>
<code class="xml">{{ demoCodes[0] }}</code>
<code class="javascript">{{ demoCodes[1] }}</code>
</pre>
</div>
</template>
<script>
import XEUtils from 'xe-utils'
import hljs from 'highlight.js'
export default {
data () {
return {
tableData: [],
tableColumn: [
{ type: 'checkbox', title: 'ID', treeNode: true },
{ field: 'name', title: 'Name', editRender: { name: 'input' } },
{ field: 'size', title: 'Size', editRender: { name: 'input' } },
{ field: 'type', title: 'Type', editRender: { name: 'input' } },
{ field: 'date', title: 'Date', editRender: { name: 'input' } }
],
demoCodes: [
`
<vxe-virtual-tree
resizable
row-key
toolbar
ref="xVTree"
row-id="id"
:tree-config="{children: 'children'}"
:edit-config="{trigger: 'click', mode: 'row'}"
:checkbox-config="{labelField: 'id'}"
:columns="tableColumn"
:data="tableData">
<template v-slot:buttons>
<vxe-button @click="$refs.xTree.toggleTreeExpansion(tableData[0], true)">切换第一个</vxe-button>
<vxe-button @click="$refs.xTree.setTreeExpansion(tableData[2], true)">展开第三个</vxe-button>
<vxe-button @click="$refs.xTree.setAllTreeExpansion(true)">展开所有</vxe-button>
<vxe-button @click="$refs.xTree.clearTreeExpand()">关闭所有</vxe-button>
</template>
</vxe-virtual-tree>
`,
`
export default {
data () {
return {
tableData: [],
tableColumn: [
{ type: 'checkbox', title: 'ID', treeNode: true },
{ field: 'name', title: 'Name', editRender: { name: 'input' } },
{ field: 'size', title: 'Size', editRender: { name: 'input' } },
{ field: 'type', title: 'Type', editRender: { name: 'input' } },
{ field: 'date', title: 'Date', editRender: { name: 'input' } }
]
}
},
created () {
this.tableData = window.MOCK_TREE_DATA_LIST.slice(0)
}
}
`
]
}
},
created () {
this.tableData = XEUtils.clone(window.MOCK_TREE_DATA_LIST, true)
},
mounted () {
Array.from(this.$el.querySelectorAll('pre code')).forEach((block) => {
hljs.highlightBlock(block)
})
}
}
</script>