Skip to content

Commit dec8858

Browse files
committed
add search problem
Signed-off-by: zhangtianli2006 <49156174+zhangtianli2006@users.noreply.github.com>
1 parent 0011436 commit dec8858

File tree

4 files changed

+35
-3
lines changed

4 files changed

+35
-3
lines changed

src/StringPrototype.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,8 @@ if (String.prototype.replaceAll === undefined) {
2020

2121
return res;
2222
};
23-
}
23+
}
24+
25+
String.prototype.trim = function () {
26+
return this.replace(/(^\s*)|(\s*$)/g, '');
27+
};

src/components/lib/AjaxTable.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ export default {
4141
watch: {
4242
limit() {
4343
this.onPageChange(this.pageId);
44+
},
45+
title() {
46+
this.load_data();
4447
}
4548
},
4649
methods: {
@@ -56,7 +59,8 @@ export default {
5659
.get(this.ajax_url, {
5760
params: {
5861
offset: this.offset,
59-
limit: this.limit
62+
limit: this.limit,
63+
title: this.title
6064
}
6165
})
6266
.then(res => {
@@ -88,6 +92,9 @@ export default {
8892
type: Number,
8993
default: 20
9094
},
95+
title: {
96+
type: String
97+
},
9198
total: {
9299
type: Number,
93100
required: true
@@ -97,7 +104,8 @@ export default {
97104
default: x => x
98105
},
99106
default_sort: {
100-
107+
type: Object,
108+
default: null
101109
}
102110
},
103111
};

src/components/problem/list.vue

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33
<el-row :gutter="20">
44
<el-col :span="10">
55
<el-card>
6+
<i class="el-icon-search" />
7+
Search
8+
<el-input
9+
placeholder="Search"
10+
v-model="searchTitle"
11+
class="input-with-select"
12+
style="margin-top: 9px;"
13+
@clear="search"
14+
clearable
15+
>
16+
<el-button slot="append" icon="el-icon-check" @click="search"></el-button>
17+
</el-input>
618
</el-card>
719
</el-col>
820
<el-col :span="6">
@@ -47,6 +59,7 @@
4759
:total="data_count"
4860
:process="process"
4961
:default_sort="{prop: 'pid', order: 'ascending'}"
62+
:title="title"
5063
/>
5164
</el-card>
5265
</div>
@@ -65,6 +78,8 @@ export default {
6578
alive: true,
6679
ajax_url: apiurl('/problem/list'),
6780
limit: 50,
81+
searchTitle: '',
82+
title: null,
6883
showTags: this.$store.state.tags.displayTags,
6984
columns: [{
7085
name: 'score',
@@ -123,6 +138,10 @@ export default {
123138
x.tag = (<listTag tags={ x.tags }></listTag>);
124139
125140
return x;
141+
},
142+
search() {
143+
this.searchTitle = this.searchTitle.trim();
144+
this.title = this.searchTitle;
126145
}
127146
},
128147
components: {

src/components/user/edit.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ export default {
165165
}
166166
})
167167
.catch(err => {
168+
this.buttonLoading = false;
168169
if (err.request.status === 404) {
169170
this.$SegmentMessage.error(this, 'User not found');
170171
} else if (err.request.status === 403) {

0 commit comments

Comments
 (0)