1.12.1 • Published 3 years ago

multi-function-table v1.12.1

Weekly downloads
51
License
MIT
Repository
github
Last release
3 years ago

multi-function-table

基于ElementUI进行二次开发的多功能表格组件


安装

使用npm进行安装

npm i multi-function-table

使用yarn进行安装

yarn add multi-function-table

引入

全局引入

import Vue from 'vue'
import App from './App.vue'
import MultiFunctionTable from 'multi-function-table'

Vue.use(MultiFunctionTable)

new Vue({
  el: '#app',
  render: h => h(App)
})

组件中引入

<template>
  <multi-function-table></multi-function-table>
</template>
<script>
  import MultiFunctionTable from 'multi-function-table'

  export default {
    components: { MultiFunctionTable }
  }
</script>

参数说明

基础参数说明

参数说明类型可选值默认值
table-headers表头以及带有多操作选项的配置。多选操作包含提示文字、排序。Arrayprop / label / options[]
table-height是否启用表格高度以固定表头。String'200px''false'
table-max-height是否启用表格最大高度以固定表头。String'200px''false'
table-data表格中的数据。Array-[]
table-header-height表头的高度。String / Number-50
header-background表头背景颜色。String-'#f2f5fa'
header-font-color表头文字颜色。String-'#909399'
is-stripe是否启用斑马纹表格。Booleanfalse / truetrue
stripe-background斑马纹背景颜色。String-'#f7f8fa'
body-color表格中数据展示区域的字体颜色。String-'#001741'
is-checkbox是否启用表格多选操作。Booleanfalse / truefalse
is-page是否启用分页器。Booleanfalse / truefalse
page当前选中的页面。Number-1
total表格数据总条数。Number-0
page-size分页大小,决定一页显示多少条数据。Number-10
page-sizes快捷选择分页大小,可以通过选择分页器中的选项决定分页大小。Array-5, 10, 25, 50, 100
page-position分页器位置。String'left' / 'center' / 'right''center'
page-layout分页器功能布局配置,可任意选择可选值,进行顺序的调整。String'prev' / 'pager' / 'next' / 'sizes' / 'jumper''prev, pager, next, sizes, jumper'
page-background是否启用带有选中背景的分页器。Booleanfalse / truetrue
hide-on-single-page是否在只有一页数据时候隐藏分页器。Booleanfalse / truetrue

表头多选参数说明

参数说明类型可选值默认值
prop对应table-data中需要显示的字段。String--
label字段需要在表头中展示的名称。String--
width列宽度。Number--
minWidth最小列宽度。Number--
options表头是否支持操作选项。目前多功能表头只支持信息提示'popover'、排序'sort'Array'popover' / 'sort'-

方法说明

事件名称说明回调参数参数说明
rowClick当某一行被点击时会触发该事件。row, column, eventrow: 当前行数据。column: 当前列数据。event: 事件信息。
currentPage当分页器的当前页发生变化时会触发该事件。pagepage: 当前选中的页码。
selectionChange当多选框选中项发生变化时会触发该事件。selectionselection: 勾选的下标数组。
sizeChange当分页器中分页大小发生改变时会触发该事件。sizesize: 选中的分页大小。

多功能表格使用示例

基础表格

基础表格展示

<template>
  <multi-function-table
    :table-data="tableData"
    :table-headers="tableHeaders" />
</template>

<script>
export default {
  data() {
    return {
      tableData: [
        { name: '小明', mobile: '133xxxx8976', sex: '男'},
        { name: '小红', mobile: '173xxxx8976', sex: '女'}
      ],
      tableHeaders: [
        { prop: 'name', label: '姓名' },
        { prop: 'mobile', label: '手机号' },
        { prop: 'sex', label: '性别' }
      ]
    }
  }
}
</script>

多功能表头

多功能表头允许使用提示信息和排序功能。多功能表头只需要在table-header参数中进行配置即可。

<template>
  <multi-function-table
    :table-data="tableData"
    :table-headers="tableHeaders" />
</template>

<script>
export default {
  data() {
    return {
      tableData: [
        { name: '小明', mobile: '133xxxx8976', sex: '男'},
        { name: '小红', mobile: '173xxxx8976', sex: '女'}
      ],
      tableHeaders: [
        { prop: 'name', label: '姓名' },
        { prop: 'mobile', label: '手机号' },
        {
          prop: 'sex',
          label: '性别',
          options: [
            {
              type: 'popover',
              props: {
                icon: 'el-icon-edit',
                content: '提示内容'
              }
            },
            {
              type: 'sort'
            }
          ]
        }
      ]
    }
  }
}
</script>

自定义模板

自定义列的显示内容,可以搭配其他ElementUI组件一起使用。通常自定义列需要使用插槽进行实现。

<template>
  <multi-function-table
    :table-data="tableData"
    :table-headers="tableHeaders">
    <template slot="options" slot-scope="scope">
      <el-button>按钮</el-button>
    </template>
  </multi-function-table>
</template>

<script>
export default {
  data() {
    return {
      tableData: [
        { name: '小明', mobile: '133xxxx8976', sex: '男'},
        { name: '小红', mobile: '173xxxx8976', sex: '女'}
      ],
      tableHeaders: [
        { prop: 'name', label: '姓名' },
        { prop: 'mobile', label: '手机号' },
        { prop: 'sex', label: '性别' },
        { prop: 'options', label: '操作' }
      ]
    }
  }
}
</script>
1.12.1

3 years ago

1.12.0

3 years ago

1.11.0

3 years ago

1.10.0

3 years ago

1.9.1

3 years ago

1.9.0

3 years ago

1.8.4

3 years ago

1.8.2

3 years ago

1.8.3

3 years ago

1.8.1

3 years ago

1.8.0

3 years ago

1.7.1

3 years ago

1.7.0

3 years ago

1.6.1

3 years ago

1.6.0

3 years ago

1.5.0

3 years ago

1.4.0

3 years ago

1.2.0

3 years ago

1.1.0

4 years ago

1.0.33

4 years ago

1.0.32

4 years ago

1.0.31

4 years ago

1.0.30

4 years ago

1.0.29

4 years ago

1.0.28

4 years ago

1.0.27

4 years ago

1.0.19

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.22

4 years ago

1.0.20

4 years ago

1.0.25

4 years ago

1.0.24

4 years ago

1.0.23

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.9

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago