Skip to content

Commit ae2ec1f

Browse files
author
黄书伟
committed
实例优化
1 parent 1bdda66 commit ae2ec1f

File tree

2 files changed

+40
-23
lines changed

2 files changed

+40
-23
lines changed

examples/doc/table/api.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@
2828
| row-click-color | 表格体行点击后的背景色(行高亮) | string |||
2929
| show-vertical-border | 是否显示垂直border,false 时列拖动失效 | boolean || true |
3030
| show-horizontal-border | 是否显示横向border | boolean || true |
31+
| on-row-click | 行点击回调 | Function({rowIndex, rowData, field}) |||
32+
| row-mouse-enter| 鼠标进入表体行的回调| Function({rowIndex}) |||
33+
| row-mouse-leave| 鼠标离开表体行的回调| Function({rowIndex}) |||
34+
| sort-change| 点击排序回调| Function({sortColumns}) 参数说明: 参数为排序的列对象信息 |||
35+
| ~~cell-edit-formatter~~ [1.3.5](https://github.com/huangshuwei/vue-easytable/releases/tag/1.3.5) 版本废除| ~~单元格编辑格式化回调(可以对编辑的结果设置样式等)~~| ~~Function({newValue,oldValue,rowIndex,rowData,field})~~|||
36+
| cell-edit-done| 单元格编辑完成回调| Function({newValue,oldValue,rowIndex,rowData,field})|||
37+
| cell-merge| 单元格合并,支持rowSpan、colSpan,返回值`{colSpan: 1,rowSpan: 1,content: '',componentName: ''}`;合并后单元格的内容可以通过`content`(html)设置也可以通过,`componentName`(自定义组件)设置| Function({rowIndex,rowData,field})|||
38+
| select-all| 全选时触发 | Function({selection}) 参数说明: selection 当前选中的项集合 |||
39+
| select-change| 某一项 checkbox 触发 | Function({selection,rowData}) 参数说明:selection为当前选中的项集合,rowData为当前选中的项|||
40+
| select-group-change| 选中项发生变化触发 |Function({selection}) 参数说明: selection为当前选中的项集合 |||
41+
| column-cell-class-name| 表体单元格设置className | Function({rowIndex,columnName,rowData}) |||
3142

3243

3344

@@ -77,22 +88,11 @@ table 表格数据,通过设置一些特殊属性实现某些功能,如 chec
7788
| _disabled | 是否禁用选中\未选中(当开启多选时有效) | boolean || false |
7889

7990

80-
### Table Event
91+
### Table Event(注意传入的‘事件名称’必须和api保持一致)
92+
8193
| 事件名称 | 说明 | 回调参数 |
8294
|---------- |-------- |---------- |
83-
| on-row-click | 行点击回调 | rowIndex, rowData, field |
84-
| row-mouse-enter| 鼠标进入表体行的回调| rowIndex |
85-
| row-mouse-leave| 鼠标离开表体行的回调| rowIndex |
86-
| sort-change| 点击排序回调| sortColumns(排序的列对象信息) |
87-
| ~~cell-edit-formatter~~ [1.3.5](https://github.com/huangshuwei/vue-easytable/releases/tag/1.3.5) 版本废除| ~~单元格编辑格式化回调(可以对编辑的结果设置样式等)~~| ~~newValue,oldValue,rowIndex,rowData,field~~|
88-
| cell-edit-done| 单元格编辑完成回调| newValue,oldValue,rowIndex,rowData,field|
89-
| cell-merge| 单元格合并,支持rowSpan、colSpan,返回值`{colSpan: 1,rowSpan: 1,content: '',componentName: ''}`;合并后单元格的内容可以通过`content`(html)设置也可以通过,`componentName`(自定义组件)设置| rowIndex,rowData,field|
90-
| select-all| 全选时触发 | selection 当前选中的项集合 |
91-
| select-change| 某一项 checkbox 触发 | selection(当前选中的项集合),rowData(当前选中的项)|
92-
| select-group-change| 选中项发生变化触发 | selection(当前选中的项集合) |
93-
| column-cell-class-name| 表体单元格设置className | rowIndex,columnName,rowData |
94-
95-
95+
| on-custom-comp | 自定义列为组件时,子组件与父组件通讯的方法 | params (参数为任意类型,根据业务场景随意构造) |
9696

9797

9898
### Table Methods

examples/doc/table/custom-columns.md

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
:::demo **自定义列普通用法**:通过 `formatter`函数对当前数据进行简单的加工处理,这个方法接收`rowData``rowIndex`,`pagingIndex`,`field`作为回调数据;<br>**自定义列高级用法**:通过`componentName`传递一个vue组件,这个自定义组件会接收到`rowData``field``index`作为回调数据;
1+
:::demo **自定义列普通用法**<br>通过 `formatter`函数对当前数据进行简单的加工处理,这个方法接收`rowData``rowIndex`,`pagingIndex`,`field`作为回调数据;<br>**自定义列高级用法**<br>通过`componentName`传递一个vue组件,这个自定义组件会接收到`rowData``field``index`作为回调数据;<br>通过传入事件`on-custom-comp`实现子组件与父组件通讯的目的
22
```html
33
<template>
44
<v-table
@@ -8,6 +8,7 @@
88
:table-data="tableData"
99
row-hover-color="#eee"
1010
row-click-color="#edf7ff"
11+
@on-custom-comp="customCompFunc"
1112
></v-table>
1213
</template>
1314

@@ -38,6 +39,23 @@
3839
{field: 'address', title: '地址', width: 230, titleAlign: 'center',columnAlign:'left',isResize:true},
3940
{field: 'custome-adv', title: '操作',width: 200, titleAlign: 'center',columnAlign:'center',componentName:'table-operation',isResize:true}
4041
]
42+
43+
}
44+
},
45+
methods:{
46+
customCompFunc(params){
47+
48+
console.log(params);
49+
50+
if (params.type === 'delete'){ // do delete operation
51+
52+
this.$delete(this.tableData,params.index);
53+
54+
}else if (params.type === 'edit'){ // do edit operation
55+
56+
alert(`行号:${params.index} 姓名:${params.rowData['name']}`)
57+
}
58+
4159
}
4260
}
4361
}
@@ -61,19 +79,18 @@
6179
},
6280
methods:{
6381
update(){
64-
alert('编辑: '+this.index)
65-
console.log(this.index)
66-
console.log(this.rowData[this.field])
6782
68-
console.log(this.rowData)
83+
// 参数根据业务场景随意构造
84+
let params = {type:'edit',index:this.index,rowData:this.rowData};
85+
this.$emit('on-custom-comp',params);
6986
},
7087
7188
deleteRow(){
72-
alert('删除: '+this.index)
73-
console.log(this.index)
74-
console.log(this.rowData[this.field])
7589
76-
console.log(this.rowData)
90+
// 参数根据业务场景随意构造
91+
let params = {type:'delete',index:this.index};
92+
this.$emit('on-custom-comp',params);
93+
7794
}
7895
}
7996
})

0 commit comments

Comments
 (0)