File tree Expand file tree Collapse file tree 4 files changed +52
-7
lines changed Expand file tree Collapse file tree 4 files changed +52
-7
lines changed Original file line number Diff line number Diff 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+ } ;
Original file line number Diff line number Diff line change 11<template >
22 <div class =" ajax-table" >
3- <el-table v-loading =" loading" :data =" tableData" >
3+ <el-table
4+ v-loading =" loading"
5+ :data =" tableData"
6+ :default-sort =" default_sort"
7+ >
48 <el-table-column
59 v-for =" item in columns"
610 :key =" item"
913 :width =" item.width"
1014 :align =" item.align"
1115 :header-align =" item.headerAlign"
16+ :sortable =" item.sortable"
1217 />
1318 </el-table >
1419 <el-pagination
@@ -36,6 +41,9 @@ export default {
3641 watch: {
3742 limit () {
3843 this .onPageChange (this .pageId );
44+ },
45+ costumData () {
46+ this .load_data ();
3947 }
4048 },
4149 methods: {
@@ -51,7 +59,8 @@ export default {
5159 .get (this .ajax_url , {
5260 params: {
5361 offset: this .offset ,
54- limit: this .limit
62+ limit: this .limit ,
63+ ... this .costumData
5564 }
5665 })
5766 .then (res => {
@@ -83,13 +92,20 @@ export default {
8392 type: Number ,
8493 default: 20
8594 },
95+ costumData: {
96+ type: Object
97+ },
8698 total: {
8799 type: Number ,
88100 required: true
89101 },
90102 process: {
91103 type: Function ,
92104 default : x => x
105+ },
106+ default_sort: {
107+ type: Object ,
108+ default: null
93109 }
94110 },
95111};
@@ -101,4 +117,4 @@ export default {
101117 margin-top : 20px ;
102118 text-align : center ;
103119}
104- </style >
120+ </style >
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ export default {
2626 },
2727 methods: {
2828 jump () {
29+ this .jumpToProblem = String (parseInt (this .jumpToProblem .trim ()));
2930 this .$router .push (' /problem/' + this .jumpToProblem );
3031 }
3132 }
Original file line number Diff line number Diff line change 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" >
4658 :limit =" limit"
4759 :total =" data_count"
4860 :process =" process"
61+ :default_sort =" {prop: 'pid', order: 'ascending'}"
62+ :costumData =" {title:this.title}"
4963 />
5064 </el-card >
5165 </div >
@@ -64,24 +78,30 @@ export default {
6478 alive: true ,
6579 ajax_url: apiurl (' /problem/list' ),
6680 limit: 50 ,
81+ searchTitle: ' ' ,
82+ title: null ,
6783 showTags: this .$store .state .tags .displayTags ,
6884 columns: [{
6985 name: ' score' ,
7086 label: ' Status' ,
7187 width: ' 120' ,
72- align: ' center'
88+ align: ' center' ,
89+ sortable: true
7390 }, {
7491 name: ' pid' ,
7592 label: ' Problem ID' ,
7693 width: ' 120' ,
77- align: ' center'
94+ align: ' center' ,
95+ sortable: true
7896 }, {
7997 name: ' title' ,
80- label: ' Title'
98+ label: ' Title' ,
99+ sortable: false
81100 }, {
82101 name: ' tag' ,
83102 width: ' 400' ,
84103 align: ' right' ,
104+ sortable: false
85105 }],
86106 data_count: 10
87107 };
@@ -118,6 +138,10 @@ export default {
118138 x .tag = (< listTag tags= { x .tags }>< / listTag> );
119139
120140 return x;
141+ },
142+ search () {
143+ this .searchTitle = this .searchTitle .trim ();
144+ this .title = this .searchTitle ;
121145 }
122146 },
123147 components: {
You can’t perform that action at this time.
0 commit comments