Skip to content

Commit 7f9a015

Browse files
authored
Merge pull request #88 from segment-oj/fix-search-fisher
fix search
2 parents 1b5612a + e22e85e commit 7f9a015

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

src/StringPrototype.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ if (String.prototype.replaceAll === undefined) {
2222
};
2323
}
2424

25-
String.prototype.trim = function () {
26-
return this.replace(/(^\s*)|(\s*$)/g, '');
27-
};
25+
if (String.prototype.trim === undefined) {
26+
String.prototype.trim = function () {
27+
return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
28+
};
29+
}

src/components/lib/AjaxTable.vue

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
layout="prev, pager, next, jumper"
2323
@current-change="this.onPageChange"
2424
class="pagination"
25-
:total="this.total"
25+
:total="this.own_total"
2626
/>
2727
</div>
2828
</template>
@@ -36,14 +36,20 @@ export default {
3636
tableData: null,
3737
offset: 0,
3838
pageId: 1,
39+
own_total: this.total,
3940
};
4041
},
4142
watch: {
4243
limit() {
4344
this.onPageChange(this.pageId);
45+
console.log(this.limit);
4446
},
45-
costumData() {
46-
this.load_data();
47+
costumData(new_val, old_val) {
48+
let json_new_val = JSON.stringify(new_val);
49+
let json_old_val = JSON.stringify(old_val);
50+
if (json_new_val != json_old_val) {
51+
this.onPageChange(1);
52+
}
4753
}
4854
},
4955
methods: {
@@ -65,7 +71,7 @@ export default {
6571
})
6672
.then(res => {
6773
if (limit === this.limit) {
68-
this.total = res.data.count;
74+
this.own_total = res.data.count;
6975
this.tableData = res.data.res.map(this.process);
7076
this.loading = false;
7177
}

src/components/problem/list.vue

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010
v-model="searchTitle"
1111
class="input-with-select"
1212
style="margin-top: 9px;"
13-
@clear="search"
1413
clearable
1514
>
16-
<el-button slot="append" icon="el-icon-check" @click="search"></el-button>
1715
</el-input>
1816
</el-card>
1917
</el-col>
@@ -59,7 +57,7 @@
5957
:total="data_count"
6058
:process="process"
6159
:default_sort="{prop: 'pid', order: 'ascending'}"
62-
:costumData="{title:this.title}"
60+
:costumData="{title:title}"
6361
/>
6462
</el-card>
6563
</div>
@@ -79,7 +77,6 @@ export default {
7977
ajax_url: apiurl('/problem/list'),
8078
limit: 50,
8179
searchTitle: '',
82-
title: null,
8380
showTags: this.$store.state.tags.displayTags,
8481
columns: [{
8582
name: 'score',
@@ -114,7 +111,12 @@ export default {
114111
},
115112
limit(val) {
116113
this.set_column(val);
117-
}
114+
},
115+
},
116+
computed: {
117+
title() {
118+
return this.searchTitle.trim();
119+
},
118120
},
119121
methods: {
120122
get_list_lenth() {
@@ -174,10 +176,6 @@ export default {
174176
175177
return x;
176178
},
177-
search() {
178-
this.searchTitle = this.searchTitle.trim();
179-
this.title = this.searchTitle;
180-
}
181179
},
182180
components: {
183181
AjaxTable,

0 commit comments

Comments
 (0)