Skip to content

Commit

Permalink
新增树状表格组件
Browse files Browse the repository at this point in the history
  • Loading branch information
zhigang.li committed Nov 16, 2018
1 parent 56742b7 commit e33acdc
Show file tree
Hide file tree
Showing 8 changed files with 227 additions and 3 deletions.
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"js-cookie": "^2.2.0",
"simplemde": "^1.11.2",
"sortablejs": "^1.7.0",
"tree-table-vue": "^1.0.5",
"vue": "^2.5.10",
"vue-i18n": "^7.8.0",
"vue-router": "^3.0.1",
Expand Down
3 changes: 2 additions & 1 deletion src/locale/lang/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ export default {
query: 'Query',
params: 'Params',
cropper_page: 'Cropper',
message_page: 'Message Center'
message_page: 'Message Center',
tree_table_page: 'Tree Table'
}
3 changes: 2 additions & 1 deletion src/locale/lang/zh-CN.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ export default {
query: '带参路由',
params: '动态路由',
cropper_page: '图片裁剪',
message_page: '消息中心'
message_page: '消息中心',
tree_table_page: '树状表格'
}
3 changes: 2 additions & 1 deletion src/locale/lang/zh-TW.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ export default {
query: '帶參路由',
params: '動態路由',
cropper_page: '圖片裁剪',
message_page: '消息中心'
message_page: '消息中心',
tree_table_page: '樹狀表格'
}
2 changes: 2 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ import importDirective from '@/directive'
import installPlugin from '@/plugin'
import './index.less'
import '@/assets/icons/iconfont.css'
import TreeTable from 'tree-table-vue'
// 实际打包时应该不引入mock
/* eslint-disable */
if (process.env.NODE_ENV !== 'production') require('@/mock')

Vue.use(iView, {
i18n: (key, value) => i18n.t(key, value)
})
Vue.use(TreeTable)
/**
* @description 注册admin内置插件
*/
Expand Down
9 changes: 9 additions & 0 deletions src/router/routers.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ export default [
},
component: () => import('@/view/components/drag-list/drag-list.vue')
},
{
path: 'tree_table_page',
name: 'tree_table_page',
meta: {
icon: 'md-git-branch',
title: '树状表格'
},
component: () => import('@/view/components/tree-table/index.vue')
},
{
path: 'cropper_page',
name: 'cropper_page',
Expand Down
194 changes: 194 additions & 0 deletions src/view/components/tree-table/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
<template>
<div>
<Card shadow>
树状表格组件tree-table-vue,基于<a href="https://github.com/MisterTaki/vue-table-with-tree-grid">vue-table-with-tree-grid</a>进行开发,修复了一些bug,添加了一些新属性
<p><b>支持使用slot-scope进行自定义列渲染内容</b></p>
<p>文档请看<a href="https://github.com/lison16/tree-table-vue">https://github.com/lison16/tree-table-vue</a></p>
<tree-table expand-key="sex" :expand-type="false" :selection-type="false" :columns="columns" :data="data" >
<template slot="likes" slot-scope="scope">
<Button @click="handle(scope)">123</Button>
</template>
</tree-table>
</Card>
</div>
</template>

<script>
export default {
name: 'tree_table_page',
data () {
return {
columns: [
{
label: 'name',
prop: 'name',
width: '400px'
},
{
label: 'sex',
prop: 'sex',
minWidth: '50px'
},
{
label: 'score',
prop: 'score'
},
{
label: 'likes',
prop: 'likes',
minWidth: '200px',
type: 'template',
template: 'likes'
}
],
data: [
{
name: 'Jack',
sex: 'male',
likes: ['football', 'basketball'],
score: 10,
children: [
{
name: 'Ashley',
sex: 'female',
likes: ['football', 'basketball'],
score: 20,
children: [
{
name: 'Ashley',
sex: 'female',
likes: ['football', 'basketball'],
score: 20
},
{
name: 'Taki',
sex: 'male',
likes: ['football', 'basketball'],
score: 10,
children: [
{
name: 'Ashley',
sex: 'female',
likes: ['football', 'basketball'],
score: 20
},
{
name: 'Taki',
sex: 'male',
likes: ['football', 'basketball'],
score: 10,
children: [
{
name: 'Ashley',
sex: 'female',
likes: ['football', 'basketball'],
score: 20
},
{
name: 'Taki',
sex: 'male',
likes: ['football', 'basketball'],
score: 10
}
]
}
]
}
]
},
{
name: 'Taki',
sex: 'male',
likes: ['football', 'basketball'],
score: 10
}
]
},
{
name: 'Tom',
sex: 'male',
likes: ['football', 'basketball'],
score: 20,
children: [
{
name: 'Ashley',
sex: 'female',
likes: ['football', 'basketball'],
score: 20,
children: [
{
name: 'Ashley',
sex: 'female',
likes: ['football', 'basketball'],
score: 20
},
{
name: 'Taki',
sex: 'male',
likes: ['football', 'basketball'],
score: 10
}
]
},
{
name: 'Taki',
sex: 'male',
likes: ['football', 'basketball'],
score: 10,
children: [
{
name: 'Ashley',
sex: 'female',
likes: ['football', 'basketball'],
score: 20
},
{
name: 'Taki',
sex: 'male',
likes: ['football', 'basketball'],
score: 10
}
]
}
]
},
{
name: 'Tom',
sex: 'male',
likes: ['football', 'basketball'],
score: 20
},
{
name: 'Tom',
sex: 'male',
likes: ['football', 'basketball'],
score: 20,
children: [
{
name: 'Ashley',
sex: 'female',
likes: ['football', 'basketball'],
score: 20
},
{
name: 'Taki',
sex: 'male',
likes: ['football', 'basketball'],
score: 10
}
]
}
]
}
},
methods: {
handle (scope) {
console.log(scope)
}
}
}
</script>

<style>
</style>

0 comments on commit e33acdc

Please sign in to comment.