Skip to content

element-push el-table span-method 行合并的通用方法

Notifications You must be signed in to change notification settings

xz551/ele-span-method

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

element-push 行合并通用方法

依赖 element-ui typescript

使用方法

npm i ele-span-method
import { eleSpanMethod } from 'ele-span-method'
<el-table :data="data" :span-method="eleSpanMethod(data,['id','name'],['name'])">
</el-table>

参数说明

<T extends object,K extends keyof T>(list:T[],primaryKey:K[],mergeKey?:K[]) => {}

list: 数据集合

primaryKey 参考的数据属性,只要这几个数据属性相同,则合并

mergeKey 要合并的字段,不填写则按照 primaryKey 的字段合并

list可以是不需要经过排序,任意顺序的,指定了 primaryKey 的字段,会经过分组排序 例如

[
    {id:'1',name:'A1',age:10},
    {id:'2',name:'A2',age:20},
    {id:'1',name:'A3',age:30},
    {id:'4',name:'A4',age:40},
    {id:'1',name:'A1',age:50},
]

primaryKey 参数为 ['id','name'] 数据会经过整理,整理后变为

 [
    {id:'1',name:'A1',age:10},
    {id:'1',name:'A1',age:50},
    {id:'1',name:'A3',age:30},
    {id:'2',name:'A2',age:20},
    {id:'4',name:'A4',age:40},
]

mergeKey,可以设置数据对应的列,不填写则按照 primaryKey 的字段合并

About

element-push el-table span-method 行合并的通用方法

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published