Skip to content

Commit c9bec98

Browse files
committed
add inline edit table demo
1 parent 45c65c8 commit c9bec98

File tree

3 files changed

+105
-2
lines changed

3 files changed

+105
-2
lines changed

src/router/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const Theme = resolve => require(['../views/theme/index'], resolve);
5454
const DynamicTable = resolve => require(['../views/example/dynamictable'], resolve);
5555
const Table = resolve => require(['../views/example/table'], resolve);
5656
const DragTable = resolve => require(['../views/example/dragTable'], resolve);
57+
const InlineEditTable = resolve => require(['../views/example/inlineEditTable'], resolve);
5758
const Form1 = resolve => require(['../views/example/form1'], resolve);
5859
// const Form2 = resolve => require(['../views/example/form2'], resolve);
5960

@@ -180,6 +181,7 @@ export default new Router({
180181
children: [
181182
{ path: 'dynamictable', component: DynamicTable, name: '动态table' },
182183
{ path: 'dragtable', component: DragTable, name: '拖拽table' },
184+
{ path: 'inline_edit_table', component: InlineEditTable, name: 'table内编辑' },
183185
{ path: 'table', component: Table, name: '综合table' },
184186
{ path: 'form1', component: Form1, name: '综合form1' }
185187
// { path: 'form2', component: Form2, name: '综合form2' }

src/views/example/dragTable.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
<el-table-column min-width="300px" label="标题">
1919
<template scope="scope">
20-
<span class="link-type" @click="handleUpdate(scope.row)">{{scope.row.title}}</span>
20+
<span>{{scope.row.title}}</span>
2121
</template>
2222
</el-table-column>
2323

@@ -35,7 +35,7 @@
3535

3636
<el-table-column align="center" label="阅读数" width="95">
3737
<template scope="scope">
38-
<span class="link-type" @click='handleFetchPv(scope.row.pageviews)'>{{scope.row.pageviews}}</span>
38+
<span>{{scope.row.pageviews}}</span>
3939
</template>
4040
</el-table-column>
4141

src/views/example/inlineEditTable.vue

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<template>
2+
<div class="app-container calendar-list-container">
3+
4+
<el-table :data="list" v-loading.body="listLoading" border fit highlight-current-row style="width: 100%">
5+
6+
<el-table-column align="center" label="序号" width="80">
7+
<template scope="scope">
8+
<span>{{scope.row.id}}</span>
9+
</template>
10+
</el-table-column>
11+
12+
<el-table-column width="180px" align="center" label="时间">
13+
<template scope="scope">
14+
<span>{{scope.row.timestamp | parseTime('{y}-{m}-{d} {h}:{i}')}}</span>
15+
</template>
16+
</el-table-column>
17+
18+
<el-table-column width="120px" align="center" label="作者">
19+
<template scope="scope">
20+
<span>{{scope.row.author}}</span>
21+
</template>
22+
</el-table-column>
23+
24+
<el-table-column width="100px" label="重要性">
25+
<template scope="scope">
26+
<wscn-icon-svg v-for="n in +scope.row.importance" icon-class="wujiaoxing" class="meta-item__icon" :key="n" />
27+
</template>
28+
</el-table-column>
29+
30+
<el-table-column class-name="status-col" label="状态" width="100">
31+
<template scope="scope">
32+
<el-tag :type="scope.row.status | statusFilter">{{scope.row.status}}</el-tag>
33+
</template>
34+
</el-table-column>
35+
36+
<el-table-column min-width="300px" label="标题">
37+
<template scope="scope">
38+
<el-input v-show="scope.row.edit" size="small" v-model="scope.row.title"></el-input>
39+
<span v-show="!scope.row.edit">{{ scope.row.title }}</span>
40+
</template>
41+
</el-table-column>
42+
43+
<el-table-column align="center" label="编辑" width="120">
44+
<template scope="scope">
45+
<el-button v-show='!scope.row.edit' type="primary" @click='scope.row.edit=true' size="small" icon="edit">编辑</el-button>
46+
<el-button v-show='scope.row.edit' type="success" @click='scope.row.edit=false' size="small" icon="check">完成</el-button>
47+
</template>
48+
</el-table-column>
49+
50+
</el-table>
51+
</div>
52+
</template>
53+
54+
<script>
55+
import { fetchList } from 'api/article_table';
56+
57+
export default {
58+
name: 'inline_edit-table_demo',
59+
data() {
60+
return {
61+
list: null,
62+
total: null,
63+
listLoading: true,
64+
listQuery: {
65+
page: 1,
66+
limit: 10
67+
}
68+
}
69+
},
70+
created() {
71+
this.getList();
72+
},
73+
filters: {
74+
statusFilter(status) {
75+
const statusMap = {
76+
published: 'success',
77+
draft: 'gray',
78+
deleted: 'danger'
79+
};
80+
return statusMap[status]
81+
}
82+
},
83+
methods: {
84+
getList() {
85+
this.listLoading = true;
86+
fetchList(this.listQuery).then(response => {
87+
this.list = response.items.map(v => {
88+
v.edit = false;
89+
return v
90+
});
91+
this.total = response.total;
92+
this.listLoading = false;
93+
})
94+
}
95+
}
96+
}
97+
</script>
98+
99+
<style >
100+
101+
</style>

0 commit comments

Comments
 (0)