2727 border
2828 class =" table"
2929 ref =" multipleTable"
30+ header-cell-class-name =" table-header"
3031 @selection-change =" handleSelectionChange"
3132 >
3233 <el-table-column type =" selection" width =" 55" align =" center" ></el-table-column >
33- <el-table-column prop =" date" label =" 日期" sortable width =" 150" ></el-table-column >
34- <el-table-column prop =" name" label =" 姓名" width =" 120" ></el-table-column >
35- <el-table-column prop =" address" label =" 地址" :formatter =" formatter" ></el-table-column >
34+ <el-table-column prop =" id" label =" ID" width =" 55" align =" center" ></el-table-column >
35+ <el-table-column prop =" name" label =" 用户名" ></el-table-column >
36+ <el-table-column label =" 账户余额" >
37+ <template slot-scope="scope">¥{{scope.row.money}}</template >
38+ </el-table-column >
39+ <el-table-column label =" 头像(查看大图)" align =" center" >
40+ <template slot-scope="scope">
41+ <el-image
42+ class =" table-td-thumb"
43+ :src =" scope.row.thumb"
44+ :preview-src-list =" [scope.row.thumb]"
45+ ></el-image >
46+ </template >
47+ </el-table-column >
48+ <el-table-column prop =" address" label =" 地址" ></el-table-column >
49+ <el-table-column label =" 状态" align =" center" >
50+ <template slot-scope="scope">
51+ <el-tag
52+ :type =" scope.row.state==='成功'?'success':(scope.row.state==='失败'?'danger':'')"
53+ >{{scope.row.state}}</el-tag >
54+ </template >
55+ </el-table-column >
56+
57+ <el-table-column prop =" date" label =" 注册时间" ></el-table-column >
3658 <el-table-column label =" 操作" width =" 180" align =" center" >
3759 <template slot-scope="scope">
3860 <el-button
5274 <div class =" pagination" >
5375 <el-pagination
5476 background
77+ layout =" total, prev, pager, next"
78+ :current-page =" page.index"
79+ :page-size =" page.size"
80+ :total =" page.total"
5581 @current-change =" handleCurrentChange"
56- layout =" prev, pager, next"
57- :total =" 1000"
5882 ></el-pagination >
5983 </div >
6084 </div >
6185
6286 <!-- 编辑弹出框 -->
6387 <el-dialog title =" 编辑" :visible.sync =" editVisible" width =" 30%" >
64- <el-form ref =" form" :model =" form" label-width =" 50px" >
65- <el-form-item label =" 日期" >
66- <el-date-picker
67- type =" date"
68- placeholder =" 选择日期"
69- v-model =" form.date"
70- value-format =" yyyy-MM-dd"
71- style =" width : 100% ;"
72- ></el-date-picker >
73- </el-form-item >
74- <el-form-item label =" 姓名" >
88+ <el-form ref =" form" :model =" form" label-width =" 70px" >
89+ <el-form-item label =" 用户名" >
7590 <el-input v-model =" form.name" ></el-input >
7691 </el-form-item >
7792 <el-form-item label =" 地址" >
8398 <el-button type =" primary" @click =" saveEdit" >确 定</el-button >
8499 </span >
85100 </el-dialog >
86-
87- <!-- 删除提示框 -->
88- <el-dialog title =" 提示" :visible.sync =" delVisible" width =" 300px" center >
89- <div class =" del-dialog-cnt" >删除不可恢复,是否确定删除?</div >
90- <span slot =" footer" class =" dialog-footer" >
91- <el-button @click =" delVisible = false" >取 消</el-button >
92- <el-button type =" primary" @click =" deleteRow" >确 定</el-button >
93- </span >
94- </el-dialog >
95101 </div >
96102</template >
97103
@@ -107,13 +113,12 @@ export default {
107113 select_cate: ' ' ,
108114 select_word: ' ' ,
109115 del_list: [],
110- is_search: false ,
111116 editVisible: false ,
112- delVisible : false ,
113- form : {
114- name : ' ' ,
115- date : ' ' ,
116- address : ' '
117+ form : {} ,
118+ page : {
119+ index : 1 ,
120+ size : 10 ,
121+ total : 50
117122 },
118123 idx: - 1 ,
119124 id: - 1
@@ -157,30 +162,32 @@ export default {
157162 this .tableData = res .list ;
158163 });
159164 },
160- search () {
161- this .is_search = true ;
162- },
163- formatter (row , column ) {
164- return row .address ;
165- },
166- filterTag (value , row ) {
167- return row .tag === value;
168- },
165+ search () {},
169166 handleEdit (index , row ) {
170167 this .idx = index;
171168 this .id = row .id ;
172- this .form = {
173- id: row .id ,
174- name: row .name ,
175- date: row .date ,
176- address: row .address
177- };
169+ this .form = row;
178170 this .editVisible = true ;
179171 },
180172 handleDelete (index , row ) {
181- this .idx = index;
182- this .id = row .id ;
183- this .delVisible = true ;
173+ // 二次确认删除
174+ this .$confirm (' 确定要删除吗?' , ' 提示' , {
175+ type: ' warning'
176+ })
177+ .then (() => {
178+ this .$message .success (' 删除成功' );
179+ if (this .tableData [index].id === row .id ) {
180+ this .tableData .splice (index, 1 );
181+ } else {
182+ for (let i = 0 ; i < this .tableData .length ; i++ ) {
183+ if (this .tableData [i].id === row .id ) {
184+ this .tableData .splice (i, 1 );
185+ return ;
186+ }
187+ }
188+ }
189+ })
190+ .catch (() => {});
184191 },
185192 delAll () {
186193 const length = this .multipleSelection .length ;
@@ -209,21 +216,6 @@ export default {
209216 }
210217 }
211218 }
212- },
213- // 确定删除
214- deleteRow () {
215- this .$message .success (' 删除成功' );
216- this .delVisible = false ;
217- if (this .tableData [this .idx ].id === this .id ) {
218- this .tableData .splice (this .idx , 1 );
219- } else {
220- for (let i = 0 ; i < this .tableData .length ; i++ ) {
221- if (this .tableData [i].id === this .id ) {
222- this .tableData .splice (i, 1 );
223- return ;
224- }
225- }
226- }
227219 }
228220 }
229221};
@@ -256,4 +248,10 @@ export default {
256248.mr10 {
257249 margin-right : 10px ;
258250}
251+ .table-td-thumb {
252+ display : block ;
253+ margin : auto ;
254+ width : 40px ;
255+ height : 40px ;
256+ }
259257 </style >
0 commit comments