d2-crud 筛选
Former-commit-id: ce54da6a3adb33c4f5670059c1a0e2cb923d9a00 [formerly ce54da6a3adb33c4f5670059c1a0e2cb923d9a00 [formerly ce54da6a3adb33c4f5670059c1a0e2cb923d9a00 [formerly ce54da6a3adb33c4f5670059c1a0e2cb923d9a00 [formerly 3c44916360da76b49d117befe0f81a641f6315fa [formerly 592148a1be6334389df735529f273d2b937d0427]]]]] Former-commit-id: 22ed44ade276867f0c6e32b537e1227420cf6912 Former-commit-id: 9d8372d8997449efe2b9f74538738f20dd3dfe1b Former-commit-id: 02b17360c6232b1d58f174341d66e59b2d533815 [formerly 70a2be5169086d45ffa196c37019d4c012bc9ba7] Former-commit-id: aaa99cb71780eb2620fb27ff23687d7717766b7a Former-commit-id: 696d6f3c55166babfc3fb7c96b461f94540e7ddd Former-commit-id: bc0a27c60ed1ef06eeb23e163a6126677897636e Former-commit-id: 916f86bb74dc6d6fb85a80f5e755fb1b3b057352 Former-commit-id: 74007628b8fd0aa661e86df4293c72431e5478a8
This commit is contained in:
parent
cf85416cce
commit
617bd67c65
|
|
@ -12,3 +12,4 @@
|
|||
| 多级表头 | [点我查看](https://fairyever.gitee.io/d2-admin-preview/#/demo/d2-crud/demo8) |
|
||||
| 单选 | [点我查看](https://fairyever.gitee.io/d2-admin-preview/#/demo/d2-crud/demo9) |
|
||||
| 多选 | [点我查看](https://fairyever.gitee.io/d2-admin-preview/#/demo/d2-crud/demo10) |
|
||||
| 排序 | [点我查看](https://fairyever.gitee.io/d2-admin-preview/#/demo/d2-crud/demo11) |
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ export default {
|
|||
{ path: `${pre}demo8`, title: '多级表头' },
|
||||
{ path: `${pre}demo9`, title: '单选' },
|
||||
{ path: `${pre}demo10`, title: '多选' },
|
||||
{ path: `${pre}demo11`, title: '排序' }
|
||||
{ path: `${pre}demo11`, title: '排序' },
|
||||
{ path: `${pre}demo12`, title: '筛选' }
|
||||
])('/demo/d2-crud/')
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,68 @@
|
|||
export default `<template>
|
||||
<div>
|
||||
<d2-crud
|
||||
:columns="columns"
|
||||
:data="data"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
columns: [
|
||||
{
|
||||
title: '日期',
|
||||
key: 'date'
|
||||
},
|
||||
{
|
||||
title: '姓名',
|
||||
key: 'name'
|
||||
},
|
||||
{
|
||||
title: '地址',
|
||||
key: 'address'
|
||||
},
|
||||
{
|
||||
title: '标签',
|
||||
key: 'tag',
|
||||
filters: [
|
||||
{ text: '家', value: '家' },
|
||||
{ text: '公司', value: '公司' }
|
||||
],
|
||||
filterMethod (value, row) {
|
||||
return row.tag === value
|
||||
},
|
||||
filterPlacement: 'bottom-end'
|
||||
}
|
||||
],
|
||||
data: [
|
||||
{
|
||||
date: '2016-05-02',
|
||||
name: '王小虎',
|
||||
address: '上海市普陀区金沙江路 1518 弄',
|
||||
tag: '家'
|
||||
},
|
||||
{
|
||||
date: '2016-05-04',
|
||||
name: '王小虎',
|
||||
address: '上海市普陀区金沙江路 1517 弄',
|
||||
tag: '公司'
|
||||
},
|
||||
{
|
||||
date: '2016-05-01',
|
||||
name: '王小虎',
|
||||
address: '上海市普陀区金沙江路 1519 弄',
|
||||
tag: '家'
|
||||
},
|
||||
{
|
||||
date: '2016-05-03',
|
||||
name: '王小虎',
|
||||
address: '上海市普陀区金沙江路 1516 弄',
|
||||
tag: '公司'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>`
|
||||
|
|
@ -0,0 +1 @@
|
|||
在 `columns` 中设置 `filters` `filterMethod` 属性即可开启该列的筛选,`filters` 是一个数组, `filterMethod` 是一个方法,它用于决定某些数据是否显示,会传入三个参数:`value`, `row` 和 `column`。代码如下:
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
<template>
|
||||
<d2-container>
|
||||
<template slot="header">筛选</template>
|
||||
<d2-crud
|
||||
:columns="columns"
|
||||
:data="data">
|
||||
</d2-crud>
|
||||
<el-card shadow="never" class="d2-mb">
|
||||
<d2-markdown :source="doc"/>
|
||||
</el-card>
|
||||
<el-card shadow="never" class="d2-mb">
|
||||
<d2-highlight :code="code"/>
|
||||
</el-card>
|
||||
<template slot="footer">
|
||||
<d2-link-btn title="D2 CRUD" link="https://github.com/d2-projects/d2-crud"/>
|
||||
</template>
|
||||
</d2-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import doc from './doc.md'
|
||||
import code from './code.js'
|
||||
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
doc,
|
||||
code,
|
||||
columns: [
|
||||
{
|
||||
title: '日期',
|
||||
key: 'date'
|
||||
},
|
||||
{
|
||||
title: '姓名',
|
||||
key: 'name'
|
||||
},
|
||||
{
|
||||
title: '地址',
|
||||
key: 'address'
|
||||
},
|
||||
{
|
||||
title: '标签',
|
||||
key: 'tag',
|
||||
filters: [
|
||||
{ text: '家', value: '家' },
|
||||
{ text: '公司', value: '公司' }
|
||||
],
|
||||
filterMethod (value, row) {
|
||||
return row.tag === value
|
||||
},
|
||||
filterPlacement: 'bottom-end'
|
||||
}
|
||||
],
|
||||
data: [
|
||||
{
|
||||
date: '2016-05-02',
|
||||
name: '王小虎',
|
||||
address: '上海市普陀区金沙江路 1518 弄',
|
||||
tag: '家'
|
||||
},
|
||||
{
|
||||
date: '2016-05-04',
|
||||
name: '王小虎',
|
||||
address: '上海市普陀区金沙江路 1517 弄',
|
||||
tag: '公司'
|
||||
},
|
||||
{
|
||||
date: '2016-05-01',
|
||||
name: '王小虎',
|
||||
address: '上海市普陀区金沙江路 1519 弄',
|
||||
tag: '家'
|
||||
},
|
||||
{
|
||||
date: '2016-05-03',
|
||||
name: '王小虎',
|
||||
address: '上海市普陀区金沙江路 1516 弄',
|
||||
tag: '公司'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.el-table .warning-row {
|
||||
background: oldlace;
|
||||
}
|
||||
|
||||
.el-table .success-row {
|
||||
background: #f0f9eb;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -1 +1 @@
|
|||
f97628e615568020c3de348bdc064cb2a7dc3061
|
||||
d4bcc9f74429353eb00fc5a9e835c0e86842cdfa
|
||||
Loading…
Reference in New Issue