|
@@ -17,9 +17,13 @@ |
|
@@ -17,9 +17,13 @@ |
17
|
<div class="contentpanel project-index-page" style="padding-bottom:0;">
|
17
|
<div class="contentpanel project-index-page" style="padding-bottom:0;">
|
18
|
<div class="panel panel-default">
|
18
|
<div class="panel panel-default">
|
19
|
<div class="panel-body">
|
19
|
<div class="panel-body">
|
20
|
- <label style="margin-right:20px;"><input type="checkbox" style="margin-right:5px;">全选</label>
|
20
|
+ <label style="margin-right:20px;"><input id="allSelected" type="checkbox" style="margin-right:5px;">全选</label>
|
21
|
<a data-toggle="modal" href="#pop" class="btn btn-default" style="margin-right:10px;">增加</a>
|
21
|
<a data-toggle="modal" href="#pop" class="btn btn-default" style="margin-right:10px;">增加</a>
|
22
|
- <button class="btn btn-default" type="submit">删除</button>
|
22
|
+ <a class="btn btn-default deleteAll">删除</a>
|
|
|
23
|
+ <button class="btn btn-default search" style="float:right;">搜索</button>
|
|
|
24
|
+ <div class="col-sm-3" style="float:right;">
|
|
|
25
|
+ <input type="text" class="form-control" id="firstname" placeholder="请输入关键词">
|
|
|
26
|
+ </div>
|
23
|
</div>
|
27
|
</div>
|
24
|
</div>
|
28
|
</div>
|
25
|
</div>
|
29
|
</div>
|
|
@@ -41,17 +45,15 @@ |
|
@@ -41,17 +45,15 @@ |
41
|
<div class="panel panel-default">
|
45
|
<div class="panel panel-default">
|
42
|
<div class="panel-body">
|
46
|
<div class="panel-body">
|
43
|
<table id="table-oper-log" class="table table-striped table-bordered building-table">
|
47
|
<table id="table-oper-log" class="table table-striped table-bordered building-table">
|
44
|
- <thead>
|
|
|
45
|
- <tr>
|
|
|
46
|
- <th>ID</th>
|
|
|
47
|
- <th>关键词</th>
|
|
|
48
|
- <th>操作</th>
|
|
|
49
|
- </tr>
|
|
|
50
|
- </thead>
|
48
|
+
|
51
|
</table>
|
49
|
</table>
|
52
|
</div>
|
50
|
</div>
|
53
|
</div>
|
51
|
</div>
|
54
|
</div>
|
52
|
</div>
|
|
|
53
|
+<ul class="pager">
|
|
|
54
|
+ <li><a class="privious pages">上一页</a></li>
|
|
|
55
|
+ <li><a class="next pages">下一页</a></li>
|
|
|
56
|
+ </ul>
|
55
|
<style>
|
57
|
<style>
|
56
|
.nostyle{
|
58
|
.nostyle{
|
57
|
background: transparent;
|
59
|
background: transparent;
|
|
@@ -74,21 +76,62 @@ |
|
@@ -74,21 +76,62 @@ |
74
|
bottom: 0;
|
76
|
bottom: 0;
|
75
|
margin:auto;
|
77
|
margin:auto;
|
76
|
}
|
78
|
}
|
|
|
79
|
+ .pager{
|
|
|
80
|
+ float: right;
|
|
|
81
|
+ margin-right: 20px;
|
|
|
82
|
+ margin-top:0;
|
|
|
83
|
+ }
|
|
|
84
|
+ .pages{
|
|
|
85
|
+ cursor: pointer;
|
|
|
86
|
+ }
|
77
|
</style>
|
87
|
</style>
|
78
|
<script>
|
88
|
<script>
|
|
|
89
|
+ var currentPage=1,pageCount=10,pageTotal;
|
|
|
90
|
+ var tabHead='<thead><tr><th>ID</th><th>关键词</th><th>操作</th></tr></thead>';
|
|
|
91
|
+ //展示列表
|
79
|
$(document).on('ready pjax:success', function() {
|
92
|
$(document).on('ready pjax:success', function() {
|
80
|
- $.get('/keywords/getKeywords', function(data){
|
93
|
+ $.get('/keywords/getKeywords?', {currentPage:currentPage, pageCount:pageCount}, function(data){
|
|
|
94
|
+ var html='';
|
|
|
95
|
+ let datas=data.data;
|
|
|
96
|
+ if(datas){
|
|
|
97
|
+ datas.forEach(function(item, index){
|
|
|
98
|
+ html+=tableHtml(item, index);
|
|
|
99
|
+ });
|
|
|
100
|
+ $('#table-oper-log').html(tabHead+html);
|
|
|
101
|
+ pageTotal=Math.ceil(data.total/pageCount);
|
|
|
102
|
+ }
|
|
|
103
|
+
|
|
|
104
|
+ });
|
|
|
105
|
+ });
|
|
|
106
|
+ $('.privious').on('click', function() {
|
|
|
107
|
+ if(currentPage==1)return;
|
|
|
108
|
+ $.get('/keywords/getKeywords?',{currentPage:--currentPage, pageCount:pageCount}, function(data){
|
|
|
109
|
+ var html='';
|
|
|
110
|
+ let datas=data.data;
|
|
|
111
|
+ if(datas){
|
|
|
112
|
+ datas.forEach(function(item, index){
|
|
|
113
|
+ html+=tableHtml(item, index);
|
|
|
114
|
+ });
|
|
|
115
|
+ $('#table-oper-log').html(tabHead+html);
|
|
|
116
|
+ }
|
|
|
117
|
+
|
|
|
118
|
+ });
|
|
|
119
|
+ });
|
|
|
120
|
+ $('.next').on('click', function() {
|
|
|
121
|
+ if(currentPage>=pageTotal)return;
|
|
|
122
|
+ $.get('/keywords/getKeywords?',{currentPage:++currentPage, pageCount:pageCount}, function(data){
|
81
|
var html='';
|
123
|
var html='';
|
82
|
let datas=data.data;
|
124
|
let datas=data.data;
|
83
|
if(datas){
|
125
|
if(datas){
|
84
|
datas.forEach(function(item, index){
|
126
|
datas.forEach(function(item, index){
|
85
|
- html+='<tr><td><label><input type="checkbox">'+index+'</label></td><td><input value="'+item+'" disabled></td><td><button class="btn btn-default nostyle edit">编辑</button><button class="btn btn-default nostyle delete">删除</button></td></tr>';
|
127
|
+ html+=tableHtml(item, index);
|
86
|
});
|
128
|
});
|
87
|
- $('#table-oper-log').html($('#table-oper-log').html()+html);
|
129
|
+ $('#table-oper-log').html(tabHead+html);
|
88
|
}
|
130
|
}
|
89
|
|
131
|
|
90
|
});
|
132
|
});
|
91
|
});
|
133
|
});
|
|
|
134
|
+ //删除
|
92
|
$(document).on('click', '.delete', function(){
|
135
|
$(document).on('click', '.delete', function(){
|
93
|
var val=$($(this).parents('tr').find('input')[1]).val();
|
136
|
var val=$($(this).parents('tr').find('input')[1]).val();
|
94
|
var parent=$(this).parents('tr');
|
137
|
var parent=$(this).parents('tr');
|
|
@@ -108,7 +151,14 @@ |
|
@@ -108,7 +151,14 @@ |
108
|
var val=input.val();
|
151
|
var val=input.val();
|
109
|
$.get('/keywords/editKeywords', {keywords:JSON.stringify([val, oldValue])}, function(data){
|
152
|
$.get('/keywords/editKeywords', {keywords:JSON.stringify([val, oldValue])}, function(data){
|
110
|
if(data.code===200){
|
153
|
if(data.code===200){
|
111
|
- input.attr('disabled',true);
|
154
|
+ var isSame=false;
|
|
|
155
|
+ $('table .values').each(function(){
|
|
|
156
|
+ if($(this)!=input){
|
|
|
157
|
+ if($(this).val()==input.val())isSame=true;
|
|
|
158
|
+ }
|
|
|
159
|
+ });
|
|
|
160
|
+ if(isSame) location.reload();
|
|
|
161
|
+ else input.attr('disabled',true);
|
112
|
}
|
162
|
}
|
113
|
});
|
163
|
});
|
114
|
});
|
164
|
});
|
|
@@ -122,4 +172,42 @@ |
|
@@ -122,4 +172,42 @@ |
122
|
}
|
172
|
}
|
123
|
});
|
173
|
});
|
124
|
});
|
174
|
});
|
|
|
175
|
+ //全选
|
|
|
176
|
+ $('#allSelected').on('click', function(){
|
|
|
177
|
+ var check=false;
|
|
|
178
|
+ if($(this).attr('checked')){
|
|
|
179
|
+ check=true;
|
|
|
180
|
+ }
|
|
|
181
|
+ $("table :checkbox").attr("checked", check);
|
|
|
182
|
+ });
|
|
|
183
|
+ $('.deleteAll').on('click',function(){
|
|
|
184
|
+ let arr=[];
|
|
|
185
|
+ $("table :checkbox:checked").each(function(item){
|
|
|
186
|
+ arr.push($($(this).parents('tr').find('input')[1]).val());
|
|
|
187
|
+ });
|
|
|
188
|
+ if(!arr.length)return;
|
|
|
189
|
+ $.get('/keywords/delKeywords', {keywords:JSON.stringify(arr)}, function(data){
|
|
|
190
|
+ if(data.code===200){
|
|
|
191
|
+ location.reload();
|
|
|
192
|
+ }
|
|
|
193
|
+ });
|
|
|
194
|
+ });
|
|
|
195
|
+ function tableHtml(item, index){
|
|
|
196
|
+ return '<tr><td><label><input type="checkbox">'+index+'</label></td><td><input class="values" value="'+item+'" disabled></td><td><button class="btn btn-default nostyle edit">编辑</button><button class="btn btn-default nostyle delete">删除</button></td></tr>';
|
|
|
197
|
+ }
|
|
|
198
|
+ //搜索
|
|
|
199
|
+ $('.search').on('click',function(){
|
|
|
200
|
+ if(!$('#firstname').val())return;
|
|
|
201
|
+ $.get('/keywords/searchKeywords', {association:$('#firstname').val()}, function(data){
|
|
|
202
|
+ var html='';
|
|
|
203
|
+ let datas=data.data;
|
|
|
204
|
+ if(data.code===200){
|
|
|
205
|
+ datas.forEach(function(item, index){
|
|
|
206
|
+ html+=tableHtml(item, index);
|
|
|
207
|
+ });
|
|
|
208
|
+ $('#table-oper-log').html(tabHead+html);
|
|
|
209
|
+ pageTotal=Math.ceil(data.total/pageCount);
|
|
|
210
|
+ }
|
|
|
211
|
+ });
|
|
|
212
|
+ });
|
125
|
</script> |
213
|
</script> |