15
15
class =" handle-del mr10"
16
16
@click =" delAllSelection"
17
17
>批量删除</el-button >
18
- <el-select v-model =" selectCate " placeholder =" 筛选省份 " class =" handle-select mr10" >
18
+ <el-select v-model =" query.address " placeholder =" 地址 " class =" handle-select mr10" >
19
19
<el-option key =" 1" label =" 广东省" value =" 广东省" ></el-option >
20
20
<el-option key =" 2" label =" 湖南省" value =" 湖南省" ></el-option >
21
21
</el-select >
22
- <el-input v-model =" selectWord " placeholder =" 筛选关键词 " class =" handle-input mr10" ></el-input >
22
+ <el-input v-model =" query.name " placeholder =" 用户名 " class =" handle-input mr10" ></el-input >
23
23
<el-button type =" primary" icon =" el-icon-search" @click =" handleSearch" >搜索</el-button >
24
24
</div >
25
25
<el-table
26
- :data =" data "
26
+ :data =" tableData "
27
27
border
28
28
class =" table"
29
29
ref =" multipleTable"
75
75
<el-pagination
76
76
background
77
77
layout =" total, prev, pager, next"
78
- :current-page =" page.index "
79
- :page-size =" page.size "
80
- :total =" page.total "
78
+ :current-page =" query.pageIndex "
79
+ :page-size =" query.pageSize "
80
+ :total =" pageTotal "
81
81
@current-change =" handlePageChange"
82
82
></el-pagination >
83
83
</div >
@@ -107,17 +107,17 @@ export default {
107
107
name: ' basetable' ,
108
108
data () {
109
109
return {
110
+ query: {
111
+ address: ' ' ,
112
+ name: ' ' ,
113
+ pageIndex: 1 ,
114
+ pageSize: 10
115
+ },
110
116
tableData: [],
111
117
multipleSelection: [],
112
118
delList: [],
113
- selectCate: ' ' ,
114
- selectWord: ' ' ,
115
119
editVisible: false ,
116
- page: {
117
- index: 1 ,
118
- size: 10 ,
119
- total: 50
120
- },
120
+ pageTotal: 0 ,
121
121
form: {},
122
122
idx: - 1 ,
123
123
id: - 1
@@ -126,38 +126,19 @@ export default {
126
126
created () {
127
127
this .getData ();
128
128
},
129
- computed: {
130
- data () {
131
- return this .tableData .filter (d => {
132
- let is_del = false ;
133
- for (let i = 0 ; i < this .delList .length ; i++ ) {
134
- if (d .name === this .delList [i].name ) {
135
- is_del = true ;
136
- break ;
137
- }
138
- }
139
- if (! is_del) {
140
- if (
141
- d .address .indexOf (this .selectCate ) > - 1 &&
142
- (d .name .indexOf (this .selectWord ) > - 1 || d .address .indexOf (this .selectWord ) > - 1 )
143
- ) {
144
- return d;
145
- }
146
- }
147
- });
148
- }
149
- },
150
129
methods: {
151
130
// 获取 easy-mock 的模拟数据
152
131
getData () {
153
- fetchData ({
154
- page: this .page .index
155
- }).then (res => {
132
+ fetchData (this .query ).then (res => {
156
133
this .tableData = res .list ;
134
+ this .pageTotal = res .pageTotal || 50 ;
157
135
});
158
136
},
159
137
// 触发搜索按钮
160
- handleSearch () {},
138
+ handleSearch () {
139
+ this .$set (this .query , ' pageIndex' , 1 );
140
+ this .getData ();
141
+ },
161
142
// 删除操作
162
143
handleDelete (index , row ) {
163
144
// 二次确认删除
@@ -187,7 +168,6 @@ export default {
187
168
// 编辑操作
188
169
handleEdit (index , row ) {
189
170
this .idx = index;
190
- this .id = row .id ;
191
171
this .form = row;
192
172
this .editVisible = true ;
193
173
},
@@ -199,7 +179,7 @@ export default {
199
179
},
200
180
// 分页导航
201
181
handlePageChange (val ) {
202
- this .page . index = val;
182
+ this .$set ( this . query , ' pageIndex ' , val) ;
203
183
this .getData ();
204
184
}
205
185
}
0 commit comments