-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Template.vue
160 lines (155 loc) · 4.27 KB
/
Template.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<template>
<div>
<p class="tip">使用自定义模板渲染</p>
<vxe-virtual-tree
border
resizable
toolbar
row-key
:tree-config="{children: 'children'}"
:data="tableData"
:columns="tableColumn">
<template v-slot:buttons>
<vxe-input size="small" placeholder="搜索"></vxe-input>
</template>
<template v-slot:tools>
<vxe-button status="primary">操作1</vxe-button>
<vxe-button status="primary">操作2</vxe-button>
<vxe-button status="primary">操作3</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: 'seq', title: '序号', width: 80 },
{ field: 'name', title: 'app.body.label.name' },
{ field: 'size', title: 'Size' },
{
field: 'type',
title: 'Type',
slots: {
default: ({ row }) => {
return [
<span>{ `类型:${row.type || '无'}` }</span>
]
}
}
},
{
title: 'Image',
treeNode: true,
slots: {
default: ({ row }) => {
return [
<img src="static/other/img1.gif" height="50"/>
]
}
}
},
{
field: 'date',
title: 'Date',
slots: {
default: ({ row }) => {
return [
<span>{ XEUtils.toDateString(row.date, 'yyyy-MM-dd HH:mm:ss.S') }</span>
]
}
}
}
],
demoCodes: [
`
<vxe-virtual-tree
border
resizable
toolbar
row-key
:tree-config="{children: 'children'}"
:data="tableData"
:columns="tableColumn">
<template v-slot:buttons>
<vxe-input size="small" placeholder="搜索"></vxe-input>
</template>
<template v-slot:tools>
<vxe-button status="primary">操作1</vxe-button>
<vxe-button status="primary">操作2</vxe-button>
<vxe-button status="primary">操作3</vxe-button>
</template>
</vxe-virtual-tree>
`,
`
export default {
data () {
return {
tableData: [],
tableColumn: [
{ type: 'seq', title: '序号', width: 80 },
{ field: 'name', title: 'app.body.label.name' },
{ field: 'size', title: 'Size' },
{
field: 'type',
title: 'Type',
slots: {
default: ({ row }) => {
return [
<span>{ \`类型:\${row.type || '无'}\` }</span>
]
}
}
},
{
title: 'Image',
treeNode: true,
slots: {
default: ({ row }) => {
return [
<img src="static/other/img1.gif" height="50"/>
]
}
}
},
{
field: 'date',
title: 'Date',
slots: {
default: ({ row }) => {
return [
<span>{ XEUtils.toDateString(row.date, 'yyyy-MM-dd HH:mm:ss.S') }</span>
]
}
}
}
]
}
},
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>