Search搜索 + Table 表格 + Pagination分页

简介

本组件是有搜索、表格、分页组成,我们可以通过ZtTable Attributes来对此组件的功能进行配置,同时也可以单独使用其中某个或者组合使用,相关属性设置,请参考下面的表格

安装zt-ui依赖的包

npm install vue -S
npm install vue-router -S
npm install element-ui -S
或
cnpm install vue -S
cnpm install vue-router -S
cnpm install element-ui -S

安装zt-ui

npm install zt-ui -S
或者
cnpm install zt-ui -S 

引用引zt-ui包

// 引zt-ui包
// 我们的zt-ui也提供了按需引包
import { ZtTable } from 'zt-ui';
Vue.use(ZtTable);

案例一:精确搜索+基本表格+分页

精确搜索+基本表格+分页
<template>
    <div id="tsp">
        <zt-table
                :theadData="theadData"
                :tbodyData="tbodyData"
                :isShowGroupSearch="false"
                @table-precise-search="tablePreciseSearch"
                @current-pag-change="currentPagChange"
        ></zt-table>
    </div>
</template>
<script>
    export default{
        data(){
            return {
//                下面每个{}代表一列的表头数据
                theadData: [
//                    一下是每列表头对应的数据,
//                   具体的配置请参考对应的文档配置
                    {
                        prop: 'col1',
                        label: '年龄',
                        width: '180',
//                        内容查处格子,查处部分"..."代替
                        showOverflowTooltip: true,
                        align: 'center',
                    },
                    {
                        prop: 'col2',
                        label: '姓名',
                        width: '180',
                        showOverflowTooltip: true,
                        align: 'center',
                    },
                    {
                        prop: 'col3',
                        label: '地址',
                        showOverflowTooltip: true,
                        align: 'center',
                    }
                ],
                tbodyData: [
//                    {}是每一行数据,这里的每个字段就代表对应表都的字段,也就是prop的值
                    {
                        col1: '2016-05-02',
                        col2: '小虎',
                        col3: '上海市普陀区金沙江路 1518 弄'
                    }, {
                        col1: '2016-05-04',
                        col2: '王小虎',
                        col3: '上海市普陀区金沙江路 1517 弄'
                    }, {
                        col1: '2016-05-01',
                        col2: '王小虎',
                        col3: '上海市普陀区金沙江路 1519 弄'
                    }, {
                        col1: '2016-05-03',
                        col2: '王小虎',
                        col3: '上海市普陀区金沙江路 1516 弄'
                    }, {
                        col1: '2016-05-03',
                        col2: '王小虎',
                        col3: '上海市普陀区金沙江路 1516 弄'
                    }, {
                        col1: '2016-05-03',
                        col2: '王小虎',
                        col3: '上海市普陀区金沙江路 1516 弄'
                    }
                ],
//                储存精确搜索内的值
                selectValue:'',
//                储存分页页码
                currentPage:''
            }
        },
        methods:{
//            精确搜索时候,点击搜索按钮或者回车键(搜索框处于focus)会触发事件
            tablePreciseSearch(selectValue){
//            将搜索框的数据保留
                this.selectValue = selectValue;
            },
//            分页页码改变时候会触发
            currentPagChange(currentPage){
//            将储存分页页码保留
                this.currentPage = currentPage;
            }
        }
    }
</script>

案例二:精确搜索+表格(含有操作)+分页

精确搜索+表格(含有操作)+分页
<template>
    <div id="tsp">
        <zt-table
                :theadData="theadData"
                :tbodyData="tbodyData"
                :isShowGroupSearch="false"
                :tOperateData="tOperateData"
                @table-precise-search="tablePreciseSearch"
                @current-pag-change="currentPagChange"
                @table-operate-btn="tOperateBtn"
        >
        </zt-table>
    </div>
</template>
<script>
    export default{
        data(){
            return {
//                下面每个{}代表一列的表头数据
                theadData: [
//                    一下是每列表头对应的数据,
//                   具体的配置请参考对应的文档配置
                    {
                        prop: 'col1',
                        label: '年龄',
                        width: '180',
//                        内容查处格子,查处部分"..."代替
                        showOverflowTooltip: true,
                        align: 'center',
                    },
                    {
                        prop: 'col2',
                        label: '姓名',
                        width: '180',
                        showOverflowTooltip: true,
                        align: 'center',
                    },
                    {
                        prop: 'col3',
                        label: '地址',
                        showOverflowTooltip: true,
                        align: 'center',
                    }
                ],
                tOperateData: {
                    label: '操作',
                    align: 'center',
                    width:'100',
                    btn: [
                        {
                            id: 'btn1',
                            type:'text',
                            size:'small',
                        },
                        {
                            id: 'btn2',
                            type:'text',
                            size:'small',
                        },
                    ]
                },
                tbodyData: [
//                    {}是每一行数据,这里的每个字段就代表对应表都的字段,也就是prop的值
                    {
                        col1: '2016-05-02',
                        col2: '小虎',
                        col3: '上海市普陀区金沙江路 1518 弄'
                    }, {
                        col1: '2016-05-04',
                        col2: '王小虎',
                        col3: '上海市普陀区金沙江路 1517 弄'
                    }, {
                        col1: '2016-05-01',
                        col2: '王小虎',
                        col3: '上海市普陀区金沙江路 1519 弄'
                    }, {
                        col1: '2016-05-03',
                        col2: '王小虎',
                        col3: '上海市普陀区金沙江路 1516 弄'
                    }, {
                        col1: '2016-05-03',
                        col2: '王小虎',
                        col3: '上海市普陀区金沙江路 1516 弄'
                    }, {
                        col1: '2016-05-03',
                        col2: '王小虎',
                        col3: '上海市普陀区金沙江路 1516 弄'
                    }
                ],
//                储存精确搜索内的值
                selectValue: '',
//                储存分页页码
                currentPage: ''
            }
        },
        methods: {
//            精确搜索时候,点击搜索按钮或者回车键(搜索框处于focus)会触发事件
            tablePreciseSearch(selectValue){
//            将搜索框的数据保留
                this.selectValue = selectValue;
            },
//            分页页码改变时候会触发
            currentPagChange(currentPage){
//            将储存分页页码保留
                this.currentPage = currentPage;
            },
            tOperateBtn(scope, btnId){
//                scope是被点击的按钮所在行的相关信息,btnId对应的按钮按钮id
                console.log(scope, btnId);
            }
        }
    }
</script>

案例三:精确搜索+表格(含有操作、多选功能)+分页

精确搜索+表格(含有操作、多选功能)+分页
<template>
    <div id="tsp">
        <zt-table
                :theadData="theadData"
                :tbodyData="tbodyData"
                :isShowGroupSearch="false"
                :tOperateData="tOperateData"
                @table-precise-search="tablePreciseSearch"
                @current-pag-change="currentPagChange"
                @table-operate-btn="tOperateBtn"
                @selection-change="selectionChange"
        >
        </zt-table>
    </div>
</template>
<script>
    export default{
        data(){
            return {
//                下面每个{}代表一列的表头数据
                theadData: [
//                    这个代表第一列显示checkBox(本列根据业务需求选择性使用)
                    {
                        type: 'selection',
                        width: '55',
                    },
//                    一下是每列表头对应的数据,
//                   具体的配置请参考对应的文档配置
                    {
                        prop: 'col1',
                        label: '年龄',
                        width: '180',
//                        内容查处格子,查处部分"..."代替
                        showOverflowTooltip: true,
                        align: 'center',
                    },
                    {
                        prop: 'col2',
                        label: '姓名',
                        width: '180',
                        showOverflowTooltip: true,
                        align: 'center',
                    },
                    {
                        prop: 'col3',
                        label: '地址',
                        showOverflowTooltip: true,
                        align: 'center',
                    }
                ],
                tOperateData: {
                    label: '操作',
                    align: 'center',
                    width: '100',
                    btn: [
                        {
                            id: 'btn1',
                            type: 'text',
                            size: 'small',
                        },
                        {
                            id: 'btn2',
                            type: 'text',
                            size: 'small',
                        },
                    ]
                },
                tbodyData: [
//                    {}是每一行数据,这里的每个字段就代表对应表都的字段,也就是prop的值
                    {
                        col1: '2016-05-02',
                        col2: '小虎',
                        col3: '上海市普陀区金沙江路 1518 弄'
                    }, {
                        col1: '2016-05-04',
                        col2: '王小虎',
                        col3: '上海市普陀区金沙江路 1517 弄'
                    }, {
                        col1: '2016-05-01',
                        col2: '王小虎',
                        col3: '上海市普陀区金沙江路 1519 弄'
                    }, {
                        col1: '2016-05-03',
                        col2: '王小虎',
                        col3: '上海市普陀区金沙江路 1516 弄'
                    }, {
                        col1: '2016-05-03',
                        col2: '王小虎',
                        col3: '上海市普陀区金沙江路 1516 弄'
                    }, {
                        col1: '2016-05-03',
                        col2: '王小虎',
                        col3: '上海市普陀区金沙江路 1516 弄'
                    }
                ],
//                储存精确搜索内的值
                selectValue: '',
//                储存分页页码
                currentPage: '',
//                获取的checkBox被选择中的相关数据
                tableSelectionValue: [],
            }
        },
        methods: {
//            精确搜索时候,点击搜索按钮或者回车键(搜索框处于focus)会触发事件
            tablePreciseSearch(selectValue){
//            将搜索框的数据保留
                this.selectValue = selectValue;
            },
//            分页页码改变时候会触发
            currentPagChange(currentPage){
//            将储存分页页码保留
                this.currentPage = currentPage;
            },
            tOperateBtn(scope, btnId){
//                scope是被点击的按钮所在行的相关信息,btnId对应的按钮按钮id
                console.log(scope, btnId);
            },
//            当选择项发生变化时会触发该事件
            selectionChange(selection){
//                获取的checkBox被选择中的相关数据,将数据保存下来
                this.tableSelectionValue = selection
            }
        }
    }
</script>

案例四:精确搜索+组合搜索(下拉选择器搜索)+表格(含有操作、多选功能)+分页

精确搜索+组合搜索(下拉选择器搜索)+表格(含有操作、多选功能)+分页
<template>
    <div id="tsp">
        <zt-table
                :theadData="theadData"
                :tbodyData="tbodyData"
                :isShowGroupSearch="true"
                :tOperateData="tOperateData"
                :selectData="selectData"
                @table-precise-search="tablePreciseSearch"
                @current-pag-change="currentPagChange"
                @table-operate-btn="tOperateBtn"
                @table-select-change="tableSelectChange"
        >
        </zt-table>
    </div>
</template>
<script>
    export default{
        data(){
            return {
//                下面每个{}代表一列的表头数据
                theadData: [
//                    一下是每列表头对应的数据,
//                   具体的配置请参考对应的文档配置
                    {
                        prop: 'col1',
                        label: '年龄',
                        width: '180',
//                        内容查处格子,查处部分"..."代替
                        showOverflowTooltip: true,
                        align: 'center',
                    },
                    {
                        prop: 'col2',
                        label: '姓名',
                        width: '180',
                        showOverflowTooltip: true,
                        align: 'center',
                    },
                    {
                        prop: 'col3',
                        label: '地址',
                        showOverflowTooltip: true,
                        align: 'center',
                    }
                ],
                tOperateData: {
                    label: '操作',
                    align: 'center',
                    width: '100',
                    btn: [
                        {
                            id: 'btn1',
                            type: 'text',
                            size: 'small',
                        },
                        {
                            id: 'btn2',
                            type: 'text',
                            size: 'small',
                        },
                    ]
                },
                tbodyData: [
//                    {}是每一行数据,这里的每个字段就代表对应表都的字段,也就是prop的值
                    {
                        col1: '2016-05-02',
                        col2: '小虎',
                        col3: '上海市普陀区金沙江路 1518 弄'
                    }, {
                        col1: '2016-05-04',
                        col2: '王小虎',
                        col3: '上海市普陀区金沙江路 1517 弄'
                    }, {
                        col1: '2016-05-01',
                        col2: '王小虎',
                        col3: '上海市普陀区金沙江路 1519 弄'
                    }, {
                        col1: '2016-05-03',
                        col2: '王小虎',
                        col3: '上海市普陀区金沙江路 1516 弄'
                    }, {
                        col1: '2016-05-03',
                        col2: '王小虎',
                        col3: '上海市普陀区金沙江路 1516 弄'
                    }, {
                        col1: '2016-05-03',
                        col2: '王小虎',
                        col3: '上海市普陀区金沙江路 1516 弄'
                    }
                ],
                selectData:[
//                    {}代表一个下拉选择器
                    {
//                        selectOptions:的值就是这个下拉选择器的值,{}代表下拉选择器中的每个下拉内容
                        selectOptions: [
                            {
//                                此项被选中之后,获取到的值
                                value: '选项1',
//                                下拉框内显示在页面上的选项
                                label: '黄糕'
                            }, {
                                value: '选项2',
                                label: '双皮奶'
                            }, {
                                value: '选项3',
                                label: '蚵仔煎'
                            }, {
                                value: '选项4',
                                label: '龙须面'
                            }, {
                                value: '选项5',
                                label: '北京烤鸭'
                            }
                        ],
//                        初始化输入框的值
                        selectValue: '',
//                        占位符
                        placeholder: '请选择',
//                        栅格占据的列数(总列数24)
                        span: 4,
//                        对应的select的id
                        id:'Select1'
                    },
                    {
                        selectOptions: [
                            {
                                value: '选项1',
                                label: '黄糕'
                            }, {
                                value: '选项2',
                                label: '双皮奶'
                            }, {
                                value: '选项3',
                                label: '蚵仔煎'
                            }, {
                                value: '选项4',
                                label: '龙须面'
                            }, {
                                value: '选项5',
                                label: '北京烤鸭'
                            }
                        ],
                        selectValue: '',
                        placeholder: '请选择',
                        span: 4,
                        id:'Select2'
                    },
                ],
//                储存精确搜索内的值
                selectValue: '',
//                储存分页页码
                currentPage: '',
            }
        },
        methods: {
//            精确搜索时候,点击搜索按钮或者回车键(搜索框处于focus)会触发事件
            tablePreciseSearch(selectValue){
//            将搜索框的数据保留
                this.selectValue = selectValue;
            },
//            分页页码改变时候会触发
            currentPagChange(currentPage){
//            将储存分页页码保留
                this.currentPage = currentPage;
            },
            tOperateBtn(scope, btnId){
//                scope是被点击的按钮所在行的相关信息,btnId对应的按钮按钮id
                console.log(scope, btnId);
            },
//            组合select选择器值改变会触发该事件
            tableSelectChange(selectValue,selectId){
//                select值改变返回该select的值selectValue,以及对应的selectId
                console.log(selectValue,selectId);
            },
        }
    }
</script>

案例五:精确搜索+组合搜索(下拉选择器搜索、时间范围搜索)+表格(含有操作、多选功能)+分页

精确搜索+组合搜索(下拉选择器搜索、时间范围搜索)+表格(含有操作、多选功能)+分页
精确搜索+组合搜索(下拉选择器搜索、时间范围搜索)+表格(含有操作、多选功能
<template>
    <div id="tsp">
        <zt-table
                :theadData="theadData"
                :tbodyData="tbodyData"
                :isShowGroupSearch="true"
                :tOperateData="tOperateData"
                :selectData="selectData"
                :datePicker="datePicker"
                @table-precise-search="tablePreciseSearch"
                @current-pag-change="currentPagChange"
                @table-operate-btn="tOperateBtn"
                @table-select-change="tableSelectChange"
                @date-picker-change="datePickerChange"
        >
        </zt-table>
    </div>
</template>
<script>
    export default{
        data(){
            return {
//                下面每个{}代表一列的表头数据
                theadData: [
//                    一下是每列表头对应的数据,
//                   具体的配置请参考对应的文档配置
                    {
                        prop: 'col1',
                        label: '年龄',
                        width: '180',
//                        内容查处格子,查处部分"..."代替
                        showOverflowTooltip: true,
                        align: 'center',
                    },
                    {
                        prop: 'col2',
                        label: '姓名',
                        width: '180',
                        showOverflowTooltip: true,
                        align: 'center',
                    },
                    {
                        prop: 'col3',
                        label: '地址',
                        showOverflowTooltip: true,
                        align: 'center',
                    }
                ],
                tOperateData: {
                    label: '操作',
                    align: 'center',
                    width: '100',
                    btn: [
                        {
                            id: 'btn1',
                            type: 'text',
                            size: 'small',
                        },
                        {
                            id: 'btn2',
                            type: 'text',
                            size: 'small',
                        },
                    ]
                },
                tbodyData: [
//                    {}是每一行数据,这里的每个字段就代表对应表都的字段,也就是prop的值
                    {
                        col1: '2016-05-02',
                        col2: '小虎',
                        col3: '上海市普陀区金沙江路 1518 弄'
                    }, {
                        col1: '2016-05-04',
                        col2: '王小虎',
                        col3: '上海市普陀区金沙江路 1517 弄'
                    }, {
                        col1: '2016-05-01',
                        col2: '王小虎',
                        col3: '上海市普陀区金沙江路 1519 弄'
                    }, {
                        col1: '2016-05-03',
                        col2: '王小虎',
                        col3: '上海市普陀区金沙江路 1516 弄'
                    }, {
                        col1: '2016-05-03',
                        col2: '王小虎',
                        col3: '上海市普陀区金沙江路 1516 弄'
                    }, {
                        col1: '2016-05-03',
                        col2: '王小虎',
                        col3: '上海市普陀区金沙江路 1516 弄'
                    }
                ],
                selectData: [
//                    {}代表一个下拉选择器
                    {
//                        selectOptions:的值就是这个下拉选择器的值,{}代表下拉选择器中的每个下拉内容
                        selectOptions: [
                            {
//                                此项被选中之后,获取到的值
                                value: '选项1',
//                                下拉框内显示在页面上的选项
                                label: '黄糕'
                            }, {
                                value: '选项2',
                                label: '双皮奶'
                            }, {
                                value: '选项3',
                                label: '蚵仔煎'
                            }, {
                                value: '选项4',
                                label: '龙须面'
                            }, {
                                value: '选项5',
                                label: '北京烤鸭'
                            }
                        ],
//                        初始化输入框的值
                        selectValue: '',
//                        占位符
                        placeholder: '请选择',
//                        栅格占据的列数(总列数24)
                        span: 4,
//                        对应的select的id
                        id: 'Select1'
                    }
                ],

                datePicker: {
//                        栅格占据的列数(总列数24)
                    span: 4,
//                    显示快捷选择
                    isShowPickerOptions: true,
                },
//                储存精确搜索内的值
                selectValue: '',
//                储存分页页码
                currentPage: '',
            }
        },
        methods: {
//            精确搜索时候,点击搜索按钮或者回车键(搜索框处于focus)会触发事件
            tablePreciseSearch(selectValue){
//            将搜索框的数据保留
                this.selectValue = selectValue;
            },
//            分页页码改变时候会触发
            currentPagChange(currentPage){
//            将储存分页页码保留
                this.currentPage = currentPage;
            },
            tOperateBtn(scope, btnId){
//                scope是被点击的按钮所在行的相关信息,btnId对应的按钮按钮id
                console.log(scope, btnId);
            },
//            组合select选择器值改变会触发该事件
            tableSelectChange(selectValue, selectId){
//                select值改变返回该select的值selectValue,以及对应的selectId
                console.log(selectValue, selectId);
            },
            datePickerChange(date){
//                组合搜索时间选择器值变化时触发事件,返回格式化后的date,
                console.log(date);
            },
        }
    }
</script>

案例六:精确搜索+组合搜索(下拉选择器搜索、时间范围搜索)+表格(含有操作、多选功能)+表格排序+分页

精确搜索+组合搜索(下拉选择器搜索、时间范围搜索)+表格(含有操作、多选功能)+表格排序+分页
<template>
    <div id="tsp">
        <zt-table
                :theadData="theadData"
                :tbodyData="tbodyData"
                :isShowGroupSearch="true"
                :tOperateData="tOperateData"
                :selectData="selectData"
                :datePicker="datePicker"
                @table-precise-search="tablePreciseSearch"
                @current-pag-change="currentPagChange"
                @table-operate-btn="tOperateBtn"
                @table-select-change="tableSelectChange"
                @date-picker-change="datePickerChange"
                @sort-change="sortChange"
        >
        </zt-table>
    </div>
</template>
<script>
    export default{
        data(){
            return {
//                下面每个{}代表一列的表头数据
                theadData: [
//                    一下是每列表头对应的数据,
//                   具体的配置请参考对应的文档配置
                    {
                        prop: 'col1',
                        label: '日期',
                        width: '180',
//                        内容查处格子,查处部分"..."代替
                        showOverflowTooltip: true,
                        align: 'center',
                        sortable:'custom'
                    },
                    {
                        prop: 'col2',
                        label: '姓名',
                        width: '180',
                        showOverflowTooltip: true,
                        align: 'center',
                    },
                    {
                        prop: 'col3',
                        label: '地址',
                        showOverflowTooltip: true,
                        align: 'center',
                    }
                ],
                tOperateData: {
                    label: '操作',
                    align: 'center',
                    width: '100',
                    btn: [
                        {
                            id: 'btn1',
                            type: 'text',
                            size: 'small',
                        },
                        {
                            id: 'btn2',
                            type: 'text',
                            size: 'small',
                        },
                    ]
                },
                tbodyData: [
//                    {}是每一行数据,这里的每个字段就代表对应表都的字段,也就是prop的值
                    {
                        col1: '2016-05-02',
                        col2: '小虎',
                        col3: '上海市普陀区金沙江路 1518 弄'
                    }, {
                        col1: '2016-05-04',
                        col2: '王小虎',
                        col3: '上海市普陀区金沙江路 1517 弄'
                    }, {
                        col1: '2016-05-01',
                        col2: '王小虎',
                        col3: '上海市普陀区金沙江路 1519 弄'
                    }, {
                        col1: '2016-05-03',
                        col2: '王小虎',
                        col3: '上海市普陀区金沙江路 1516 弄'
                    }, {
                        col1: '2016-05-03',
                        col2: '王小虎',
                        col3: '上海市普陀区金沙江路 1516 弄'
                    }, {
                        col1: '2016-05-03',
                        col2: '王小虎',
                        col3: '上海市普陀区金沙江路 1516 弄'
                    }
                ],
                selectData: [
//                    {}代表一个下拉选择器
                    {
//                        selectOptions:的值就是这个下拉选择器的值,{}代表下拉选择器中的每个下拉内容
                        selectOptions: [
                            {
//                                此项被选中之后,获取到的值
                                value: '选项1',
//                                下拉框内显示在页面上的选项
                                label: '黄糕'
                            }, {
                                value: '选项2',
                                label: '双皮奶'
                            }, {
                                value: '选项3',
                                label: '蚵仔煎'
                            }, {
                                value: '选项4',
                                label: '龙须面'
                            }, {
                                value: '选项5',
                                label: '北京烤鸭'
                            }
                        ],
//                        初始化输入框的值
                        selectValue: '',
//                        占位符
                        placeholder: '请选择',
//                        栅格占据的列数(总列数24)
                        span: 4,
//                        对应的select的id
                        id: 'Select1'
                    }
                ],

                datePicker: {
//                        栅格占据的列数(总列数24)
                    span: 4,
//                    显示快捷选择
                    isShowPickerOptions: true,
                },
//                储存精确搜索内的值
                selectValue: '',
//                储存分页页码
                currentPage: '',
            }
        },
        methods: {
//            精确搜索时候,点击搜索按钮或者回车键(搜索框处于focus)会触发事件
            tablePreciseSearch(selectValue){
//            将搜索框的数据保留
                this.selectValue = selectValue;
            },
//            分页页码改变时候会触发
            currentPagChange(currentPage){
//            将储存分页页码保留
                this.currentPage = currentPage;
            },
            tOperateBtn(scope, btnId){
//                scope是被点击的按钮所在行的相关信息,btnId对应的按钮按钮id
                console.log(scope, btnId);
            },
//            组合select选择器值改变会触发该事件
            tableSelectChange(selectValue, selectId){
//                select值改变返回该select的值selectValue,以及对应的selectId
                console.log(selectValue, selectId);
            },
            datePickerChange(date){
//                组合搜索时间选择器值变化时触发事件,返回格式化后的date,
                console.log(date);
            },
//            当表格的排序条件发生变化的时候会触发该事件
            sortChange(column, prop, order){
                console.log(column, prop, order);
            }
        }
    }
</script>

ZtTable Attributes 组件的属性

参数 说明 类型 可选值 默认值
isShowPreciseSearch 是否显示精确搜索功能 Boolean true/false true
isShowGroupSearch 是否显示组合搜索功能 Boolean true/false true
theadData 表头数据 Array —— ——
tbodyData 表身数据 Array —— ——
border 是否带有纵向边框 Boolean —— false
stripe 是否为斑马纹 table Boolean —— false
show-header 是否显示表头 Boolean —— true
highlight-current-row 是否要高亮当前行 Boolean —— false
empty-text 空数据时显示的文本内容,也可以通过 slot="empty" 设置 String —— 暂无数据
default-sort 默认的排序列的prop和顺序。它的prop属性指定默认的排序的列,order指定默认排序的顺序 Object order: ascending, descending 如果只指定了prop, 没有指定order, 则默认顺序是ascending
selectData 组合搜索下拉框搜索数据 Array —— ——
tOperateData 表格右侧是操作数据 Object —— ——
isShowPagination 是否显示分页功能 Boolean true/false true
datePicker 时间选择器 Object —— ——
layout 组件布局,子组件名用逗号分隔 String sizes, prev, pager, next, jumper, ->, total, slot 'prev, pager, next, jumper, ->, total'
page-size 每页显示个数选择器的选项设置 Number —— [10, 20, 30, 40, 50, 100]
isShowPagination 是否显示分页功能 Boolean true/false true
isShowOperate 是否显示表格右侧的按钮功能 Boolean true/false false

TheadData Attributes 表格头部属性

参数 说明 类型 可选值 默认值
type 对应列的类型。如果设置了 selection 则显示多选框;如果设置了 index 则显示该行的索引(从 1 开始计算 );如果设置了 expand 则显示为一个可展开的按钮 String selection/index/expand ——
label 显示的标题 String —— ——
prop 对应列内容的字段名,也可以使用 property 属性 String —— ——
width 对应列的宽度 String —— ——
minWidth 对应列的最小宽度,与 width 的区别是 width 是固定的,minWidth会把剩余宽度按比例分配给设置了 minWidth 的列 String —— ——
fixed 列是否固定在左侧或者右侧,true 表示固定在左侧 String, Boolean true/left/right ——
sortable 对应列是否可以排序,如果设置为 'custom',则代表用户希望远程排序,需要监听 Table 的 sort-change 事件 String, Boolean true/false/'custom' false
showOverflowTooltip 当内容过长被隐藏时显示 tooltip Boolean —— false
align 对齐方式 String left/center/right left
headerAlign 表头对齐方式,若不设置该项,则使用表格的对齐方式 String left/center/right ——
className 列的 className String —— ——
labelClassName 当前列标题的自定义类名 String —— ——
selectable 仅对 type=selection 的列有效,类型为 Function,Function 的返回值用来决定这一行的 CheckBox 是否可以勾选 Function(row, index) —— ——
// 下面每个{}代表一列的表头数据
theadData: [
//  这个代表第一列显示checkBox(本列根据业务需求选择性使用)
    {
        type: 'selection',
        width: '55',
    },
//  一下是每列表头对应的数据,
//   具体的配置请参考对应的文档配置
    {
        prop: 'col1',
        label: '年龄',
        width: '180',
        align: 'center',
        sortable: true
    },
    {
        prop: 'col2',
        label: '姓名',
        width: '180',
    },
    {
        prop: 'col3',
        label: '地址',
        showOverflowTooltip: true,
        headerAlign: 'center',
        align:'center',
        className: 'hhh'
    }
],

TbodyData Attributes 表格身体属性

表格数据,是Array,里面是每个Object是表格中每行的数据,每个Object的属性是TheadData每列对应的prop值

                
tbodyData: [
// {}是每一行数据,这里的每个字段就代表对应表都的字段,也就是prop的值
    {
        col1: '2016-05-02',
        col2: '小虎',
        col3: '上海市普陀区金沙江路 1518 弄'
    }, {
        col1: '2016-05-04',
        col2: '王小虎',
        col3: '上海市普陀区金沙江路 1517 弄'
    }, {
        col1: '2016-05-01',
        col2: '王小虎',
        col3: '上海市普陀区金沙江路 1519 弄'
    }, {
        col1: '2016-05-03',
        col2: '王小虎',
        col3: '上海市普陀区金沙江路 1516 弄'
    }, {
        col1: '2016-05-03',
        col2: '王小虎',
        col3: '上海市普陀区金沙江路 1516 弄'
    }, {
        col1: '2016-05-03',
        col2: '王小虎',
        col3: '上海市普陀区金沙江路 1516 弄'
    }
],

SelectData Attributes 组合搜索的属性

参数 说明 类型 可选值 默认值
selectOptions 下拉框内的数据 Array —— ——
value 选项的值 String/Number/Object —— ——
label 选项的标签,若不设置则默认与 value 相同 String/Number —— ——
selectValue select的默认值 String —— ——
placeholder 占位符 String —— ——
span 栅格占据的列数(总列数24) Number —— ——

selectData:[
//    {}代表一个下拉选择器
    {
//  selectOptions:的值就是这个下拉选择器的值,{}代表下拉选择器中的每个下拉内容
        selectOptions: [
            {
//   此项被选中之后,获取到的值
                value: '选项1',
//     下拉框内显示在页面上的选项
                label: '黄糕'
            }, {
                value: '选项2',
                label: '双皮奶'
            }, {
                value: '选项3',
                label: '蚵仔煎'
            }, {
                value: '选项4',
                label: '龙须面'
            }, {
                value: '选项5',
                label: '北京烤鸭'
            }
        ],
//    初始化输入框的值
        selectValue: '',
//    占位符
        placeholder: '请选择',
//   栅格占据的列数(总列数24)
        span: 4,
//   对应的select的id
        id:'Select1'
    },
    {
        selectOptions: [
            {
                value: '选项1',
                label: '黄糕'
            }, {
                value: '选项2',
                label: '双皮奶'
            }, {
                value: '选项3',
                label: '蚵仔煎'
            }, {
                value: '选项4',
                label: '龙须面'
            }, {
                value: '选项5',
                label: '北京烤鸭'
            }
        ],
        selectValue: '',
        placeholder: '请选择',
        span: 4,
        id:'Select2'
    },
]

TOperateData Attributes 表格操作属性

参数 说明 类型 可选值 默认值
type 对应列的类型。如果设置了 selection 则显示多选框;如果设置了 index 则显示该行的索引(从 1 开始计算 );如果设置了 expand 则显示为一个可展开的按钮 String selection/index/expand ——
label 显示的标题 String —— ——
prop 对应列内容的字段名,也可以使用 property 属性 String —— ——
width 对应列的宽度 String —— ——
minWidth 对应列的最小宽度,与 width 的区别是 width 是固定的,minWidth会把剩余宽度按比例分配给设置了 minWidth 的列 String —— ——
fixed 列是否固定在左侧或者右侧,true 表示固定在左侧 String, Boolean true/left/right ——
sortable 对应列是否可以排序,如果设置为 'custom',则代表用户希望远程排序,需要监听 Table 的 sort-change 事件 String, Boolean true/false/'custom' false
showOverflowTooltip 当内容过长被隐藏时显示 tooltip Boolean —— false
align 对齐方式 String left/center/right left
headerAlign 表头对齐方式,若不设置该项,则使用表格的对齐方式 String left/center/right ——
className 列的 className String —— ——
labelClassName 当前列标题的自定义类名 String —— ——
selectable 仅对 type=selection 的列有效,类型为 Function,Function 的返回值用来决定这一行的 CheckBox 是否可以勾选 Function(row, index) —— ——
btn 按钮数据 Arrary 请参考下面的Btn Attributes ——

Btn Attributes 组合搜索时间选择器属性

参数 说明 类型 可选值 默认值
size 类型 String primary,success,warning,danger,info,text ——
type 尺寸 String large,small,mini ——
plain 是否朴素按钮 Boolean —— false
disabled 是否禁用状态 Boolean —— false
icon 图标,element-ui的图标库中的图标名 String —— ——
autofocus 是否默认聚焦 Boolean —— false

DatePicker Attributes 组合搜索时间选择器属性

参数 说明 类型 可选值 默认值
isShowDataPicker 是否显示时间选择器 Boolean true/false false
span 栅格占据的列数(总列数24) Number —— ——
isShowPickerOptions 当前时间日期选择器特有的选项参考下表 Boolean/Object true/false/Object false
datePicker: {
//  栅格占据的列数(总列数24)
    span: 4,
//  显示快捷选择
    isShowPickerOptions: true,
}

Picker Options 组合搜索时间选择器快捷的属性

参数 说明 类型 可选值 默认值
shortcuts 设置快捷选项,需要传入 { text, onClick } 对象用法参考 demo 或下表 Object[] —— ——
disabledDate 设置禁用状态,参数为当前日期,要求返回 Boolean Function —— ——
firstDayOfWeek 周起始日 Number 1 到 7 7
onPick 选中日期后会执行的回调,只有当 daterange 或 datetimerange 才生效 Function({ maxDate, minDate }) —— ——

Shortcuts 设置快捷选项属性

参数 说明 类型 可选值 默认值
text 标题文本 string —— ——
onClick 选中后的回调函数,参数是 vm,可通过触发 'pick' 事件设置选择器的值。例如 vm.$emit('pick', new Date()) function —— ——
datePicker: {
// 栅格占据的列数(总列数24)
    span: 4,
// 自定义快捷选择
    isShowPickerOptions: {
        shortcuts: [{
            text: '最近一周',
            onClick(picker) {
                const end = new Date();
                const start = new Date();
                start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
                picker.$emit('pick', [start, end]);
            }
        }, {
            text: '最近一个月',
            onClick(picker) {
                const end = new Date();
                const start = new Date();
                start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
                picker.$emit('pick', [start, end]);
            }
        }, {
            text: '最近三个月',
            onClick(picker) {
                const end = new Date();
                const start = new Date();
                start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
                picker.$emit('pick', [start, end]);
            }
        }]
    },
}

ZtTable Events 组件事件

事件名 说明 参数
table-reset-value 组合查询或者精确查询的搜索框存在值时才会触发重置事件 ——
date-picker-change 组合搜索时间选择器值变化时触发事件 格式化后的date
table-select-change 组合select选择器值改变会触发该事件 select值改变返回该select的值selectValue
table-switch-search-way 切换精确搜索和组合搜索会触发该事件 ——
on-icon-click 点击精确搜索右侧的X 按钮会触发该事件 ——
table-precise-search 精确搜索时候,点击搜索按钮或者回车键(input处于focus)会触发事件 当前精确搜索框内的值 preciseValue
current-change 当表格的当前行发生变化的时候会触发该事件,如果要高亮当前行,请打开表格的 highlight-current-row 属性 currentRow, oldCurrentRow
sort-change 当表格的排序条件发生变化的时候会触发该事件 { column, prop, order }
select 当用户手动勾选数据行的 Checkbox 时触发的事件 selection, row
select-all 当用户手动勾选全选 Checkbox 时触发的事件 selection
selection-change 当选择项发生变化时会触发该事件 selection
cell-mouse-enter 当单元格 hover 进入时会触发该事件 row, column, cell, event
cell-mouse-leave 当单元格 hover 退出时会触发该事件 row, column, cell, event
cell-click 当某个单元格被点击时会触发该事件 row, column, cell, event
cell-dblclick 当某个单元格被双击击时会触发该事件 row, column, cell, event
row-click 当某一行被点击时会触发该事件 row, event, column
row-contextmenu 当某一行被鼠标右键点击时会触发该事件 row, event
row-dblclick 当某一行被双击时会触发该事件 row, event
header-click 当某一列的表头被点击时会触发该事件 column, event
current-table-change 当表格的当前行发生变化的时候会触发该事件,如果要高亮当前行,请打开表格的 highlight-current-row 属性 currentRow, oldCurrentRow
size-change pageSize 改变时会触发 每页条数size
current-pag-change 分页页码改变时候会触发 当前页数
table-operate-btn 表格右侧操作按钮 {scop,btnId}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 194,457评论 5 459
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 81,837评论 2 371
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 141,696评论 0 319
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 52,183评论 1 263
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 61,057评论 4 355
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 46,105评论 1 272
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 36,520评论 3 381
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 35,211评论 0 253
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 39,482评论 1 290
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 34,574评论 2 309
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 36,353评论 1 326
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 32,213评论 3 312
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 37,576评论 3 298
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 28,897评论 0 17
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,174评论 1 250
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 41,489评论 2 341
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 40,683评论 2 335

推荐阅读更多精彩内容