Skip to content

Commit 92131a8

Browse files
author
黄书伟
committed
support cell edit
1 parent 01f997d commit 92131a8

20 files changed

+228
-46
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ Based on vue2.x flexible table components.
2323
自定义列、自定义单元格样式、loading效果等
2424
6. With paging components
2525
自带分页组件
26+
7. Cell edit
27+
单元格编辑
2628

2729
## Install
2830

examples/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import demoBox from './comp/DemoBox.vue'
1616
Vue.component('demo-box', demoBox);
1717

1818

19-
import '../packages/themes-base/index.css'
20-
import {VTable,VPagination} from '../packages/index.js'
19+
import '../libs/themes-base/index.css'
20+
import {VTable,VPagination} from '../libs/index.js'
2121

2222
Vue.component(VTable.name, VTable)
2323
Vue.component(VPagination.name, VPagination)

examples/doc/strart.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
4. 排序,支持单个、多个字段排序
1111
5. 自定义列、自定义单元格样式、loading效果等
1212
6. 自带分页组件
13+
7. 单元格编辑
1314

1415
### 安装
1516

examples/doc/table/api.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,11 @@
6060
### Table Event
6161
| 事件名称 | 说明 | 回调参数 |
6262
|---------- |-------- |---------- |
63-
| on-row-click | 行点击回调 | |
63+
| on-row-click | 行点击回调 | rowIndex, rowData, column |
6464
| row-mouse-enter| 鼠标进入表体行的回调| rowIndex |
6565
| row-mouse-leave| 鼠标离开表体行的回调| rowIndex |
6666
| sort-change| 点击排序回调| sortColumns(排序的列对象信息) |
67+
| cell-edit-done| 单元格编辑完成回调| newValue,oldValue,rowData,column,index|
6768

6869

6970

examples/doc/table/cell-edit.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
2+
:::demo 实例
3+
4+
```html
5+
<template>
6+
<v-table
7+
:columns="tableConfig.columns"
8+
:table-data="tableConfig.tableData"
9+
row-hover-color="#eee"
10+
row-click-color="#edf7ff"
11+
:cell-edit-done="cellEditDone"
12+
></v-table>
13+
</template>
14+
15+
<script>
16+
17+
import mockData from '../../mock/tableData.js'
18+
19+
export default{
20+
data() {
21+
return {
22+
tableConfig: {
23+
tableData:[],
24+
columns: [
25+
{field: 'name', title:'姓名', width: 100, titleAlign: 'center',columnAlign:'center',isEdit:true},
26+
{field: 'tel', title: '手机号码', width: 260, titleAlign: 'center',columnAlign:'center',isEdit:true},
27+
{field: 'hobby', title: '爱好', width: 380, titleAlign: 'center',columnAlign:'center',isEdit:true},
28+
{field: 'address', title: '地址', width: 358, titleAlign: 'center',columnAlign:'left',isEdit:true}
29+
],
30+
titleBgColor: "#e1e1e1"
31+
}
32+
}
33+
},
34+
methods:{
35+
// 单元格编辑回调
36+
cellEditDone(newValue,oldValue,rowData,field,index){
37+
console.log(newValue)
38+
console.log(oldValue)
39+
console.log(rowData)
40+
console.log(field)
41+
console.log(index)
42+
}
43+
},
44+
created(){
45+
46+
this.tableConfig.tableData = mockData;
47+
}
48+
}
49+
</script>
50+
```
51+
:::
52+

examples/doc/table/main.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@
3737

3838
</div>
3939

40+
<div class="mt30">
41+
<h3>单元格编辑</h3>
42+
43+
<div class="mt30">
44+
<div class="bold">支持单元格编辑</div>
45+
<cell-edit></cell-edit>
46+
</div>
47+
</div>
4048

4149
<div class="mt30">
4250
<h3>表格排序</h3>
@@ -128,6 +136,8 @@
128136
import setCellClassName from './set-cell-class-name.md'
129137
import customColumns from './custom-columns.md'
130138
139+
import cellEdit from './cell-edit.md'
140+
131141
import sortBySingleColumns from './sort-by-single-columns.md'
132142
import sortByMultipleColumns from './sort-by-multiple-columns.md'
133143
@@ -160,6 +170,8 @@
160170
complexHeaderFixedColumn,
161171
frozenTitleColumns,
162172
173+
cellEdit,
174+
163175
sortByMultipleColumns,
164176
sortBySingleColumns,
165177

libs/themes-base/index.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
@import "v-select.css";
55
@import "v-table.css";
66

7+
/*多主题放开后,此处作废*/
8+
@import "../themes-blue/v-pagination.css";
9+
@import "../themes-blue/v-select.css";
10+
@import "../themes-blue/v-table.css";
11+
712

813

914

libs/themes-base/v-table.css

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,36 +121,40 @@
121121
padding:0 3px;
122122
vertical-align: middle;
123123
word-break: break-all;
124+
overflow: hidden;
125+
line-height: 1.2em;
124126
}
125127

126128
.v-table-sort-icon {
127129
position: relative;
128130
display: inline-block;
129131
vertical-align: middle;
130-
font-size:16px;
132+
/*font-size:16px;*/
131133
width:16px;
132-
height: 16px;
134+
height: 19px;
135+
margin-left: -8px;
133136
overflow: hidden;
137+
cursor: pointer;
134138
}
135139

136140
.v-table-sort-icon i {
137141

138142
position: absolute;
139143
display: block;
140144
width:16px;
141-
height: 12px;
142-
line-height: 12px;
145+
height: 15px;
146+
/*line-height: 12px;*/
143147
overflow: hidden;
144148
color: #a6a6a6;
145149
transition: color .2s ease-in-out;
146150
}
147151

148152
.v-table-sort-icon i:first-child {
149-
top: -3px;
153+
top: -4px;
150154
}
151155

152156
.v-table-sort-icon i:last-child {
153-
bottom: -1px;
157+
bottom: -0px;
154158
}
155159

156160
.v-table-header .cursorPointer{
@@ -161,11 +165,6 @@
161165
-ms-user-select: none;
162166
}
163167

164-
.v-table-sort-icon .checked{
165-
color:#48576a;
166-
}
167-
168-
169168
.vertical-border{
170169
border-right-width: 1px !important;
171170
}

libs/v-table/src/drag-width-mixin.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,14 @@ exports.default = {
4747

4848
target = event.target;
4949

50-
while (target && target.className && target.className.indexOf('v-table-title-cell') === -1) {
50+
while (target && (target.className && target.className.indexOf('v-table-title-cell') === -1 || !target.className)) {
5151
target = target.parentNode;
5252
}
5353

5454
rect = target.getBoundingClientRect();
5555

5656
var bodyStyle = document.body.style;
57+
5758
if (rect.width >= this.minColumnWidth && rect.right - event.pageX < 10) {
5859

5960
if (!this.isDragging) {

libs/v-table/src/table-empty.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<template>
1+
npm <template>
22

33
<div class="v-table-empty">
44
<!--表格无数据的提示信息-->

0 commit comments

Comments
 (0)