...
|
...
|
@@ -17,9 +17,9 @@ |
|
|
<div class="contentpanel project-index-page" style="padding-bottom:0;">
|
|
|
<div class="panel panel-default">
|
|
|
<div class="panel-body">
|
|
|
<label style="margin-right:20px;"><input type="checkbox" style="margin-right:5px;">全选</label>
|
|
|
<label style="margin-right:20px;"><input id="allSelected" type="checkbox" style="margin-right:5px;">全选</label>
|
|
|
<a data-toggle="modal" href="#pop" class="btn btn-default" style="margin-right:10px;">增加</a>
|
|
|
<button class="btn btn-default" type="submit">删除</button>
|
|
|
<a class="btn btn-default deleteAll">删除</a>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
...
|
...
|
@@ -41,17 +41,15 @@ |
|
|
<div class="panel panel-default">
|
|
|
<div class="panel-body">
|
|
|
<table id="table-oper-log" class="table table-striped table-bordered building-table">
|
|
|
<thead>
|
|
|
<tr>
|
|
|
<th>ID</th>
|
|
|
<th>关键词</th>
|
|
|
<th>操作</th>
|
|
|
</tr>
|
|
|
</thead>
|
|
|
|
|
|
</table>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<ul class="pager">
|
|
|
<li><a class="privious pages">上一页</a></li>
|
|
|
<li><a class="next pages">下一页</a></li>
|
|
|
</ul>
|
|
|
<style>
|
|
|
.nostyle{
|
|
|
background: transparent;
|
...
|
...
|
@@ -74,21 +72,62 @@ |
|
|
bottom: 0;
|
|
|
margin:auto;
|
|
|
}
|
|
|
.pager{
|
|
|
float: right;
|
|
|
margin-right: 20px;
|
|
|
margin-top:0;
|
|
|
}
|
|
|
.pages{
|
|
|
cursor: pointer;
|
|
|
}
|
|
|
</style>
|
|
|
<script>
|
|
|
var currentPage=1,pageCount=10,pageTotal;
|
|
|
var tabHead='<thead><tr><th>ID</th><th>关键词</th><th>操作</th></tr></thead>';
|
|
|
//展示列表
|
|
|
$(document).on('ready pjax:success', function() {
|
|
|
$.get('/keywords/getKeywords', function(data){
|
|
|
$.get('/keywords/getKeywords?', {currentPage:currentPage, pageCount:pageCount}, function(data){
|
|
|
var html='';
|
|
|
let datas=data.data;
|
|
|
if(datas){
|
|
|
datas.forEach(function(item, index){
|
|
|
html+=tableHtml(item, index);
|
|
|
});
|
|
|
$('#table-oper-log').html(tabHead+html);
|
|
|
pageTotal=Math.ceil(data.total/pageCount);
|
|
|
}
|
|
|
|
|
|
});
|
|
|
});
|
|
|
$('.privious').on('click', function() {
|
|
|
if(currentPage==1)return;
|
|
|
$.get('/keywords/getKeywords?',{currentPage:--currentPage, pageCount:pageCount}, function(data){
|
|
|
var html='';
|
|
|
let datas=data.data;
|
|
|
if(datas){
|
|
|
datas.forEach(function(item, index){
|
|
|
html+=tableHtml(item, index);
|
|
|
});
|
|
|
$('#table-oper-log').html(tabHead+html);
|
|
|
}
|
|
|
|
|
|
});
|
|
|
});
|
|
|
$('.next').on('click', function() {
|
|
|
if(currentPage>=pageTotal)return;
|
|
|
$.get('/keywords/getKeywords?',{currentPage:++currentPage, pageCount:pageCount}, function(data){
|
|
|
var html='';
|
|
|
let datas=data.data;
|
|
|
if(datas){
|
|
|
datas.forEach(function(item, index){
|
|
|
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>';
|
|
|
html+=tableHtml(item, index);
|
|
|
});
|
|
|
$('#table-oper-log').html($('#table-oper-log').html()+html);
|
|
|
$('#table-oper-log').html(tabHead+html);
|
|
|
}
|
|
|
|
|
|
});
|
|
|
});
|
|
|
//删除
|
|
|
$(document).on('click', '.delete', function(){
|
|
|
var val=$($(this).parents('tr').find('input')[1]).val();
|
|
|
var parent=$(this).parents('tr');
|
...
|
...
|
@@ -108,7 +147,14 @@ |
|
|
var val=input.val();
|
|
|
$.get('/keywords/editKeywords', {keywords:JSON.stringify([val, oldValue])}, function(data){
|
|
|
if(data.code===200){
|
|
|
input.attr('disabled',true);
|
|
|
var isSame=false;
|
|
|
$('table .values').each(function(){
|
|
|
if($(this)!=input){
|
|
|
if($(this).val()==input.val())isSame=true;
|
|
|
}
|
|
|
});
|
|
|
if(isSame) location.reload();
|
|
|
else input.attr('disabled',true);
|
|
|
}
|
|
|
});
|
|
|
});
|
...
|
...
|
@@ -122,4 +168,27 @@ |
|
|
}
|
|
|
});
|
|
|
});
|
|
|
//全选
|
|
|
$('#allSelected').on('click', function(){
|
|
|
var check=false;
|
|
|
if($(this).attr('checked')){
|
|
|
check=true;
|
|
|
}
|
|
|
$("table :checkbox").attr("checked", check);
|
|
|
});
|
|
|
$('.deleteAll').on('click',function(){
|
|
|
let arr=[];
|
|
|
$("table :checkbox:checked").each(function(item){
|
|
|
arr.push($($(this).parents('tr').find('input')[1]).val());
|
|
|
});
|
|
|
if(!arr.length)return;
|
|
|
$.get('/keywords/delKeywords', {keywords:JSON.stringify(arr)}, function(data){
|
|
|
if(data.code===200){
|
|
|
location.reload();
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
function tableHtml(item, index){
|
|
|
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>';
|
|
|
}
|
|
|
</script> |
|
|
\ No newline at end of file |
...
|
...
|
|