Coder Social home page Coder Social logo

zouzhibin / zb-table Goto Github PK

View Code? Open in Web Editor NEW
33.0 3.0 10.0 3.61 MB

表格组件 支持固定表头和首列、上拉加载更多、及固定多列,表格自适应内容,排序,多选checkbox、可点击删除,编辑、合计功能,完美兼容多端

Home Page: https://zouzhibin.github.io/zb-table/#/

Vue 56.18% HTML 0.50% JavaScript 24.37% SCSS 12.83% CSS 6.12%
uniapp table fixed-header-first-column edit delete sorter fixed

zb-table's Introduction

介绍

基于uni-app开发的一个普通的表格组件,功能有固定首列和表头、排序、操作按钮、数据格式化、 table 表格 固定表头、固定首列、多列 上拉加载更多、 排序、自适应列宽、多选checkbox、编辑、删除、按钮、表尾合计 已用于生产环境

微信=》 19550102670 拉进群

-- github 第一时间会更新到github,永远保持最新,有啥想法的可以提PR,共同开发 地址

友情链接

table 属性

参数 说明 类型 可选值 默认值 是否必须
data 显示的数据 array -- -- 必须
column 显示的列数据 array -- -- 必须
stripe 是否为斑马纹 table boolean - false
isLoading 是否显示loading,动态控制 boolean - false
fit 列的宽度是否自撑开 boolean true,false false
show-header 是否显示表头 boolean true,false true
cell-style 单元格的 style 的回调方法,也可以使用一个固定的 Object 为所有单元格设置一样的 Style。 Function({row, column, rowIndex, columnIndex})/Object -- --
cell-header-style 头部单元格的 style 的回调方法,也可以使用一个固定的 Object 为所有单元格设置一样的 Style。 Function({ column, columnIndex})/Object -- --
formatter colomn =》formatter 必须设置为true,才有作用,进行格式化数据,进行数据的转换 Function({row, column, rowIndex, columnIndex})/Object -- --
border 是否带有纵向边框 boolean true,false true
highlight 是否要高亮当前行 boolean true,false false
show-summary 是否在表尾显示合计行 boolean true,false false
sum-text 合计行第一列的文本 String - 合计
summary-method 自定义的合计计算方法 Function({ columns, data }) - -
permissionBtn 是否动态控制按钮的显示隐藏 Function({ row, renders,index }) - -
isShowLoadMore 是否开启上拉加载 boolean true,false false
pullUpLoading 开启上拉加载后的返回函数,接收参数done是函数,done(type),type为空代表还有数据,继续开启上拉加载,type='ok',代表结束上拉加载 Function(done) -- --
关闭上拉加载的方式1:pullUpLoading((done)=>{
	done(type)
})
done 接收参数为 type ,type为空代表还有数据,可以继续加载,无数据的时候传入 'ok'代表结束

table 事件

参数 说明 类型 可选值 默认值 是否必须
事件名自定义 取决于type类型为operation的 renders参数里面 func 的参数名 Function (row,index)=>{} --
sort-change 取决于type类型为operation的 renders参数里面 func 的参数名 Function (column,model,index)=>{} --
currentChange 当表格的当前行发生变化的时候会触发该事件,如果要高亮当前行,请打开表格的 highlight属性,this.$refs.table.resetHighlight()清除选中 Function (row,index)=>{} --
toggleRowSelection 用于多选表格,切换某一行的选中状态,第一个参数代表选中状态,参数二代表选中的对象 Function (selected ,array)=>{} --
toggleAllSelection 用于多选表格,切换所有行的选中状态 ,第一个参数代表选中状态,参数二代表选中的对象 Function (selected ,array)=>{} --
rowClick 单击某行 ,第一个参数代表选中对象,参数二代表选中的index Function (row ,index)=>{} --
pullUpLoading 开启上拉加载后的返回函数,无参数 Function -- --
关闭上拉加载的方式2:this.$refs.zbTable.pullUpCompleteLoading('ok')
接收参数为 type ,type为空代表还有数据,可以继续加载,无数据的时候传入 'ok'代表结束

data 属性

参数 说明 类型 可选值 默认值
checked 是否被勾选 boolean true,false

column 属性

参数 说明 类型 可选值 默认值
name 属性值 string --
label 显示的标题 string --
width 列的宽度 number -- 100
fixed 列是否固定在左侧,true 表示固定在左侧 boolean true,false true
formatter 是否进行格式化转换数据 boolean true,false false
sorter 排序,当设置为custom的时候代表自定义排序,不会再触发默认排序,会触发table事件@sort-change,可以通过接口来进行排序 boolean true,false,'custom' false
emptyString 当值为空的时候默认显示的值 string --
filters 对象过滤的选项,对象格式,对象中的元素需要有 key 和 value 属性。 Object {key:value} --
align 对齐方式 String left/center/right left
type 为 operation 的时候代表为操作按钮,img的时候代表图片地址,index代表序列号 string operation,img,index --
renders type 为operation的时候 必传 Array {name:'名字',func:"父元素接收事件名",type:"按钮的类型",size:"大小"} --
type 为 operation 的时候代表为操作按钮
renders 代表传入的按钮  Array  =>[
    {
        name:'编辑',
        class:"", // 添加class
        type:'primary',代表按钮的类型  type 为custom的时候自定义按钮 其他类型取决于uniapp buttom组件按钮
        size:'mini',代表按钮的大小
        func:'edit' // func 代表操作按钮点击的事件名字 父元素接收的事件 父元素 @edit
        例如:// <zb-table @edit=""/> 
        
    }
]

示例

<zb-table
            :show-header="true"
            :columns="column"
            :stripe="true"
            :fit="false"
            show-summary
            sum-text="合计"
            @rowClick="rowClick"
            :summary-method="getSummaries"
            @toggleRowSelection="toggleRowSelection"
            @toggleAllSelection="toggleAllSelection"
            :border="true"
            @edit="buttonEdit"
            @dele="dele"
            :data="data"></zb-table>

数据格式

column:[
          { type:'selection', fixed:true,width:50 },
          { name: 'name', label: '姓名',fixed:false,width:80,emptyString:'--' },
          { name: 'age', label: '年纪',sorter:false,align:'right', },
          { name: 'sex', label: '性别',filters:{0:'男',1:'女'}},
		  { name: 'img', label: '图片',type:"img" },
          { name: 'address', label: '地址' },
          { name: 'date', label: '日期',sorter:true },
          { name: 'province', label: '省份' },
          { name: 'city', label: '城市' },
          { name: 'zip', label: '邮编' },
          { name: 'operation', type:'operation',label: '操作',renders:[
              {
                name:'编辑',
                func:'edit' // func 代表子元素点击的事件 父元素接收的事件 父元素 @edit
              },
              {
                name:'自定义按钮',
                type:'custom', // type 为custom的时候自定义按钮 其他类型取决于uniapp buttom组件按钮
                class:"custom",
                func:'custom'
              },
              {
                name:'删除',
                type:'warn',
                func:"dele"
              },
            ]},
        ],
 data:[
          {
            date: '2016-05-02',
            name: '王小虎1',
            province: '上海',
            sex:'男',
            age:'18',
			img:"https://img1.baidu.com/it/u=300787145,1214060415&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500",
            city: '普陀区',
            address: '上海市普',
            zip: 200333
          },
          {
            date: '2016-05-02',
            name: '王小虎2',
            province: '上海',
            sex:'男',
            age:'18',
            city: '普陀区',
            address: '上海市普',
            zip: 200333
          },
          {
            date: '2016-05-02',
            name: '王小虎3',
            province: '上海',
            sex:'男',
            age:'18',
            city: '普陀区',
            address: '上海市普',
            zip: 200333
          },
          {
            date: '2016-05-02',
            name: '王小虎4',
            province: '上海',
            sex:'男',
            age:'18',
            city: '普陀区',
            address: '上海市普',
            zip: 200333
          },
          {
            date: '2016-05-02',
            name: '王小虎5',
            province: '上海',
            sex:'男',
            age:'18',
            city: '普陀区',
            address: '上海市普',
            zip: 200333
          }
        ]       

zb-table's People

Contributors

zouzhibin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

zb-table's Issues

功能建议

加入列表虚拟滚动

在手机app中,上拉加载,当数据条数大于500条时,卡顿特别严重,基本无法正常滚动

关于单元格文字超长的处理

目前单元格文字超长的时候会出现【...】,希望可以加入单击出现气泡提示显示全部内容的属性。或者加入单元格的插槽

功能建议

1、新增、编辑、删除操作建议放在表格头部,以tools插槽的方式自定义样式等。
2、希望支持数据格式化方法,类似formatter(value,index,row){}方式格式化数据展示。

在苹果手机的微信上显示列表在向左拖动时表格会上下晃动

我使用zb-table组件开发我的微信小程序表格功能,我锁定了第一列和表头行,由于列的数量多,数据也多所以会有横向滚动条和纵向滚动,当我向左拖动表格以显示其他列的时候,表格的纵向滚动条在晃动,效果就好像我向下拖动了滚动条一样,实际我只是在横向拖动。虽然没有出现错行的现象,但是这种效果让我的客户不满意,是否有办法可以禁止这种行为?

只出现在苹果手机,安卓手机没有问题!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.