正常的表格展示
树形结构的表格展示
表格进行拖拽排序
自定义表格内容
拖拽表格数据
多级表头展示
npm install
npm run dev
npm install complex-grid
在main.js里引用组件
import ComplexGrid from "complex-grid"
Vue.use(ComplexGrid)
<complex-grid
ref="treeGrid1"
:fields="treeGridJson.fields"
:data.sync="treeGridJson.data"
:checkable="true"
:isTree="true"
:empty="empty"
style="height: 300px"
@clickFirst="testClick"
@dragStart="dragstart"
@dragEnd="dragendTree"
@checkboxClick="checkboxClick"
@checkAllClick="checkAllClick"
:loadState="loadState"
:isDrag="true"
:isExpandAll="true"
>
</complex-grid>
如果可以拖拽,调用组件里的isQueryDrag方法,即可拿到拖拽后重新排列的数据
dragend (startval, endval, whereInsert) {
let newData = this.$refs.treeGrid1.isQueryDrag(startval, endval, whereInsert)
this.treeGrid1.data = [...newData]
},
this.$refs[ref].makeTreeExpand(id, isExpand) 展开或收起某一行数据(id为树的节点id,isExpand为Boolean值,true为展开,false为收起)。
{
id: 'JGQC',
title: '测试',
linkable: true,
width: 300
},
{
id: 'JGJC',
title: '测试',
sortable: true,
width: 190
},
{
id: 'JGFZR',
title: '测试',
width: 150
},
],
每行数据需要有id, children代表子节点数据
data: [
{
id: 11111,
JGQC: '二级2222222',
JGJC: 'true',
JGFZR: 'test',
ZGJG: '总本部',
JGLB: 'test',
JGZT: 'test',
JGSX: 'test',
JGCJ: 'test',
BZRS: '40',
SYRS: '39',
children: [
{
id: 22222,
JGQC: '二级2222222',
JGJC: 'true',
JGFZR: 'test',
ZGJG: '总本部',
JGLB: 'test',
JGZT: 'test',
JGSX: 'test',
JGCJ: 'test',
BZRS: '40',
SYRS: '39',
children: [
{
id: 33333,
JGQC: '二级2222222',
JGJC: 'true',
JGFZR: 'test',
ZGJG: '总本部',
JGLB: 'test',
JGZT: 'test',
JGSX: 'test',
JGCJ: 'test',
BZRS: '40',
SYRS: '39'
}
]
},
{
id: 44444,
JGQC: '二级2222222',
JGJC: 'true',
JGFZR: 'test',
ZGJG: '总本部',
JGLB: 'test',
JGZT: 'test',
JGSX: 'test',
JGCJ: 'test',
BZRS: '40',
SYRS: '39'
}
]
},
{
id: 55555,
JGQC: '翻页后的数据',
JGJC: 'true',
JGFZR: 'test',
ZGJG: '总本部',
JGLB: 'test',
JGZT: 'test',
JGSX: 'test',
JGCJ: 'test',
BZRS: '40',
SYRS: '39'
},
{
id: 66666,
JGQC: '翻页后的数据',
JGJC: 'true',
JGFZR: 'test',
ZGJG: '总本部',
JGLB: 'test',
JGZT: 'test',
JGSX: 'test',
JGCJ: 'test',
BZRS: '40',
SYRS: '39'
},
],