a ant-desgin-vue table component

Overview

整体介绍

TablePage 是在ant-desgin-vue组件的基础上封装

适用场景是表格页面布局,支持,查询,分页,过滤等功能

效果呈现

使用

yarn install
yarn dev

文件说明

如果需要使用移植

  • filter.js //过滤功能
  • index.js //入口文件
  • search.js //查询功能
  • store.js //数据管理
  • Table.vue //主文件

其他文件说明

  • /test 组件demo

功能

  1. 查询 []
  2. 表格二次筛选 []
  3. 自适应列宽(根据内容自适应宽度而不用每个列配置width) []
  4. 分页参数自动携带(分页与请求解耦,妈妈再也不用担心Page小九九了) []
  5. 数据默认值配置(可配置默认参数_defaultTable,让表格组件整体统一) []
  6. 查询,二次筛选,几乎支持ant-desgin全表单控件21个表单控件的支持,组件配置共享(a-transfer和a-upload不支持) []
  7. 几乎全部支持原本ant-table所有配置 []

使用

默认配置

//store.js  可以在Table.vue中导出更改也是OK的  一次配置  多次生效
export const _defaultTable = {
  //自动配置唯一key
  rowKey: () => {
    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
      var r = (Math.random() * 16) | 0,
        v = c == 'x' ? r : (r & 0x3) | 0x8
      return v.toString(16)
    })
  },
  //表格边框
  bordered: true,
  //分页参数
  pagination: {
    pageSize: 10,
    current: 1,
    total: 0,
    showTotal: (total, range) => `${range[0]}-${range[1]} 共${total}条`
  },
  //自定义分页传参的key  如果你的list列表传入的值不一样请修改这个配置
  pageKey: {
    current: 'pageNo',
    pageSize: 'page_size'
  },
  //高度自动计算,为了达到横向滚动条始终在页面可视范围内,方便横向滚动条拖拽
  height: 'auto'
}

props

只写改装的属性,其他与a-table一致 https://2x.antdv.com/components/table-cn

  • dataSource [Function, Array]
    • Function (params:object):[list:string, total:number]
      • params 查询参数的回调
      • list 返回数组第一个是数组
      • total 分页需要用的总数量
    • Array [obj] 表格需要的数据
this.tablePageConfig.dataSource = async (params) => {
    console.log('params', params)
    let { data } = await api.get('/list', params)
    return [data.list, data.total]
}
  • formItem:Object 按照下面例子讲解
    • 整体a的外层除了 component value props filter 其他配置加上外层的key会作为AFormItem的v-bind绑定,里层props会作为子组件的属性绑定
    • Key(a):作为key 意义与columns的dataIndex对应 查询的query会携带a:XX 也会作为AFormItem的name属性绑定,如果含有:会以冒号后面userId作为query携带,如果search:"userInfo"会以这个优先级有限,query的优先级,里层的serarch:"key" > "a:userId"的userId > "a:userId"的a
    • component:表单控件用什么组件渲染,内部用vue提供的component组件去实现的 支持全ant表单控件(21个)"AInput"或"a-input"都支持
    • value:初始值 不同的控件初始值需要注意下
    • props: 表单控件的属性直接v-bind绑定 也就是说事件也是支持的 eg:onClick
    • search true|false 是否查询表格,如果有写key则默认查询true
    • filter true|false 是否过滤 与查询互斥
a:userId: {
    label: 'AInput',
    component: 'AInput',
    value: '',//默认值
    props: {
        placeholder: '请输入字典名称'//不加默认会加上 请输入 + label
    },
    search:true
    filter:true
}
  • height:String "auto"
    • 高度自动计算,为了达到横向滚动条始终在页面可视范围内,方便横向滚动条拖拽

slots

  • search 自定义查询 {query} 查询query拓展 需要在formItem上加上初始化值 key:{value:""}
  • search-after 自定义查询后面的表单控件 {query} 查询query拓展 需要在formItem上加上初始化值 key:{value:""} 并手动调用实例的searchQuery方法 详情看search-after "只看我"
  • toolbar 自定义查询 {query} 查询query拓展 表格按钮操作栏 方便做导出

方法

  • reflush 刷新(不会重置分页)
  • search 重新调用查询方法(会重置分页)
  • searchReset 重置
  • pagingChange({curremt}) 跳转到指定页

调用事例

">

  


写在最后

原本计划是准备加上编辑和导出功能的,卡在编辑的回显,多表格需要做兼容回显过于繁琐,考虑到投入产出比,决定只做这两个功能,编辑功能完成70%感兴趣可以看下edit分支。

You might also like...
Customizable Vue Table Component

prot-table Description A customizable table component in vue. Intended to be used as a web-component or as a component in vue projects. demo jsfiddle

vue table component of vue2

vue-virtual-table Vue table component with virtual dom and easy api. Keep smooth when the data reachs thousands of rows or even more. Easy to use with

Data table component for Vue 1.x
Data table component for Vue 1.x

Vue Date Table Component Attention: new repo for Vue 2.x: https://github.com/OneWayTech/vue2-datatable Intellectual property of Oneway.mobi Notice Thi

The best Data table component for Vue.js
The best Data table component for Vue.js

Vue Date Table Component Attention: new repo for Vue 2.x: https://github.com/OneWayTech/vue2-datatable Intellectual property of Oneway.mobi Notice Thi

Lightweight and flexible table component for the web :zap:

Teible Lightweight and flexible table component for the web. No more hassle writing columns outside the template or customizing render template. Packa

A very simple table component for vue3
A very simple table component for vue3

A very simple table component for vue3

Simter table component

Vue Component simter-vue-table A Vue component used to generate HTML table element. Demo. Options: Name___________ Require ValueType Description col

Lightweight and flexible table component for the web.

Teible Lightweight and flexible table component for the web. No more hassle writing columns outside the template or customizing render template. Packa

Fully functional table component headless or not, you shoose!. (Just for fun)

Vue 3 + TypeScript + Vite This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 script setu

Owner
null
A simple table component based Vue 2.x: https://dwqs.github.io/v2-table/

中文 README v2-table A simple table component based Vue 2.x. Installation Install the pkg with npm: npm i --save v2-table beautify-scrollbar or yarn ya

Pomy 98 Feb 7, 2022
A fully functional Vue Table, to meet most of the Table all requirements, and perfect compatibility with any component library

s-table A fully functional Vue Table, to meet most of the Table all requirements, and perfect compatibility with any component library.

杨玉杰(Chris Yang) 0 Jun 26, 2020
vue3-easy-data-table is a simple and easy-to-use data table component made with Vue.js 3.x

Introduction vue3-easy-data-table is a simple and easy-to-use data table component made with Vue.js 3.x. The data table component in Vuetify 3 hasn't

HC 222 Dec 30, 2022
🍉 Table Component/ Data Grid / Data Table.Support Virtual Scroll,Column Fixed,Header Fixed,Header Grouping,Filter,Sort,Cell Ellipsis,Row Expand,Row Checkbox ...

vue-easytable English | 中文 Introduction Based on vue2.x flexible table components. v2.0 New Version Complete rewriting of version 1.0. Based on JSX sy

null 3.1k Jan 3, 2023
data table simplify! -- datatable component for Vue 2.x. See documentation at

Vuetable-2 - data table simplify! Vuetable-2 v2.0-beta is available now! See the next branch. Vuetable-2 works with Vue 2.x, vuetable is for Vue 1.x I

Rati Wannapanop 2.2k Jan 4, 2023
Yeap, another Vue table component.

Vue Data Tablee Yeap, another Vue table component. This one is based on vue-good-table, a simple and pretty table component. Install Install from npm.

Vitor Luiz Cavalcanti 40 Mar 2, 2021
A vue component for pivot table

vue-pivot-table A vue component for pivot table Live demo (jsfiddle) Install npm install --save @marketconnect/vue-pivot-table Components This project

Click2Buy 213 Dec 19, 2022
BeeGridTable , is a Highly Customizable Table UI component library based on Vue.js. Rich functions、More efficient、Easy to use!

BeeGridTable (中文) Description BeeGridTable , is a Highly Customizable Table UI component library based on Vue.js. Rich functions、More efficient、Easy t

刘佳恒 45 Oct 31, 2022
Vue table component with virtual dom and easy api.

Vue table component with virtual dom and easy api.

Jack Woods 94 Dec 2, 2022
A table (with tree-grid) component for Vue.js 2.0. (Its style extends @iView)

A table (with tree-grid) component for Vue.js 2.0. (Its style extends @iView)

Gao Qi(高琦) 861 Dec 19, 2022