常見的列表分頁展示方法

<!DOCTYPE html>

<html>

 

<head>

<title>${logo.cnName}</title>

<meta charSet="utf-8" />

<meta httpEquiv="X-UA-Compatible" content="IE=edge" />

<meta httpEquiv="Cache-Control" content="no-siteapp" />

<meta name="renderer" content="webkit" />

<meta name="keywords" content="demo" />

<meta name="description" content="demo" />

<meta http-equiv="content-type" content="text/html; charset=UTF-8" />

<meta name="viewport" content="width=device-width, initial-scale=1" />

<link rel="stylesheet" type="text/css" href="${basePath}/resource/dist/css/bootstrap/bootstrap-table.min.css">

<link rel="stylesheet" type="text/css" href="${basePath}/resource/dist/css/bootstrap/bootstrap.min.css">

<link rel="stylesheet" type="text/css" href="${basePath}/resource/dist/css/_common.css">

<link rel="stylesheet" type="text/css" href="${basePath}/resource/dist/css/style.css">

<link rel="stylesheet" type="text/css" href="${basePath}/resource/dist/css/sweetalert/sweetalert.css">

<link rel="stylesheet" type="text/css" href="${basePath}/resource/dist/css/laydate.css">

<link rel="stylesheet" type="text/css" href="${basePath}/resource/dist/js/lib/laydate/theme/default/laydate.css">

<style>

.table{

table-layout: fixed;

}

.table thead tr {

color: #42A5F5;

font-size: 14px;

}

.table tbody tr td {

vertical-align: middle;

}

.headerTr {

font-size:14px;

}

.colStyle{

text-overflow: ellipsis;

overflow: hidden;

white-space: nowrap;

}

.colStyle :hover{

height: auto;

text-decoration: none;

}

.btn{

padding: 2px 8px;

}

.table .btn {

padding: 3px 12px;

margin: 0 3px;

font-size: 12px;

outline: none;

}

.btn-default:hover,.btn-default:active:focus{

color: #42A5F5;

background-color: #fff;

border-color: #42A5F5;

outline: none;

}

.btn-default:active,.btn-default.focus, .btn-default:focus{

background-color: #fff;

border-color: #ccc;

}

.btn:active{

-webkit-box-shadow:none;

box-shadow: none;

}

.new-window {

display: none;

position: fixed;

top: 0;

right: 0;

bottom: 0;

left: 0;

background: rgba(0, 0, 0, .4);

z-index: 1001;

}

.new-window .btn{

width: 60px;

height: 30px;

font-size: 14px;

outline: none;

background-color: #d2e4f9;

}

.new-window .window-content {

height: 470px;

position: absolute;

top: 50%;

left: 50%;

width: 600px;

margin-left: -300px;

margin-top: -235px;

background: #fff;

z-index: 1002

}

.window-title {

border-bottom: 2px solid #48A4E7;

}

.window-title span {

margin: 10px;

font-size: 18px;

font-weight: bold;

color: #333;

display: inline-block;

}

.window-title button {

float: right;

margin: 10px;

width: 20px;

height: 20px;

line-height: 20px;

cursor: pointer;

border: none;

outline: none;

background: none;

}

.window-msg {

width: 100%;

height: 75%;

padding: 20px;

}

.set-select li{

font-size: 13px;

margin-bottom: 20px;

vertical-align: top;

text-align: center;

}

.set-select li span{

font-size: 14px;

margin-bottom: 20px;

}

.set-select li input{

width: 70%;

height: 32px;

}

.serve-window table{

width: 100%;

height: 100%;

}

.serve-window tr{

width: 100%;

height: 50px;

}

.serve-window th{

width: 25%;

height: 50px;

font-size: 15px;

text-align: right;

}

.serve-window td{

height: 50px;

width: 75%;

text-align:left;

}

.serve-window td input{

width: 372px;

height: 30px;

line-height: 30px;

text-indent: 10px;

}

.serve-window td textarea{

padding: 10px 12px;

width: 372px;

resize: none;

outline: none;

}

.commentDetailStar{

float: left;

margin-left: 10px;

height: 18px;

width: 18px;

background: url(${basePath}/resource/dist/img/evaluate-afterstar.png) no-repeat;

}

</style>

</head>

 

<body>

<div class="wraper">

 

<#include "/header.html">

<div class="ZW-main">

<div class="content_main">

<div class="F_crumbs_hasicon">

<span class="now_add">您當前所在的位置:</span>

<div class="blue_color main_page"><i class="wy_home_icon"></i>首頁</div>

<span class="to_next">></span>

<span class="blue_color now_add_blue">我參與的評論</span>

</div>

<div class="person_conts fn-clear">

<#include "/personalcenter/personal_left.html">

<div class="person_right">

<h3 class="personR_title">

<span>評論列表</span>

</h3>

<div id="collectApp2" class="collectApp" style="margin-top: 20px;">

<!-- 列表區域 -->

<table id="listTable"></table>

</div>

</div>

 

</div>

</div>

</div>

<#include "/footer.html">

</div>

<!-- 詳情頁面 -->

<div class="new-window serve-window">

<div class="window-content">

<div class="window-title">

<span>評論詳情</span>

<button class="close-window" style="font-size: 16px;">×</button>

</div>

<div class="window-msg">

<ul id="set-select" class="set-select"></ul>

</div>

<div style="text-align: center"><button id="closeWin" class="btn btn-default">關閉</button></div>

</div>

</div>

<script type="text/javascript" src="${basePath}/resource/dist/js/lib/jquery/jquery-1.11.3.min.js"></script>

<script type="text/javascript" src="${basePath}/resource/dist/js/lib/viewport/viewport.js"></script>

<script type="text/javascript" src="${basePath}/resource/dist/js/lib/pager.js"></script>

<script type="text/javascript" src="${basePath}/resource/dist/js/lib/nicescroll/jquery.nicescroll.min.js"></script>

<script type="text/javascript" src="${basePath}/resource/dist/js/lib/handlebars/handlebars.min.js"></script>

<script type="text/javascript" src="${basePath}/resource/dist/js/lib/page/jqPaginator.js"></script>

<script type="text/javascript" src="${basePath}/resource/dist/js/lib/page/Conditions.js"></script>

<script type="text/javascript" src="${basePath}/resource/dist/js/lib/util/ajax.js"></script>

<script type="text/javascript" src="${basePath}/resource/dist/js/lib/bootstrap/bootstrap-table.min.js"></script>

<script type="text/javascript" src="${basePath}/resource/dist/js/lib/bootstrap/bootstrap.min.js"></script>

<script type="text/javascript" src="${basePath}/resource/dist/js/lib/bootstrap/bootstrap-table-zh-CN.js"></script>

<script type="text/javascript" src="${basePath}/resource/dist/js/lib/sweetalert/sweetalert.min.js"></script>

<script>

var access_token = sessionStorage.getItem('access_token');

$(function () {

$("#commentData").addClass("ctrl_list_other_active");

$('.ctrl_list_other').click(function (event) {

$(this).addClass('ctrl_list_other_active').parents('.ctrl_list').siblings().children(

'.ctrl_list_other').removeClass('ctrl_list_other_active');

$(this).addClass('ctrl_list_other_active').siblings().removeClass(

'ctrl_list_other_active');

});

var columns = [{

title: '序號',

align: 'center',

halign: 'center',

width: '70px',

formatter: function (value, row, index) {

var options = $('#listTable').bootstrapTable('getOptions');

return options.pageSize * (options.pageNumber - 1) + index + 1;

}

},

{

title: '<span class = "headerTr">目錄名稱</span>',

field: 'catalogName',

align: 'center',

valign: 'middle',

class: 'colStyle',

},

{

title: '<span class = "headerTr">評論人</span>',

field: 'createUser',

align: 'center',

valign: 'middle',

class: 'colStyle',

width: '200px',

},

{

title: '<span class = "headerTr">所在部門</span>',

field: 'commentDeptName',

align: 'center',

width: '150px',

class: 'colStyle',

 

},

{

title: '<span class = "headerTr">評論時間</span>',

field: 'createTime',

align: 'center',

width: '120px',

 

},

{

title: '<span class = "headerTr">操作</span>',

field: 'id',

align: 'center',

width: '150px',

formatter: function (value, row, index) {

var e = '<button class="btn btn-default" onclick="recoveryDetail(\'' + row.id +

'\')">詳&nbsp;情</button> ';

var d = '<button class="btn btn-default" onclick="recoveryDel(\'' + row.id +

'\')">刪&nbsp;除</button> ';

return e + d;

}

}

];

queryData('/commentManage/listPageComment', columns);

});

 

function queryData(dataurl, columns) {

$('#listTable').bootstrapTable({

url: dataurl + "?access_token=" + access_token,

method: "get",

dataType: "json",

contentType: "application/x-www-form-urlencoded",

striped: true, //隔行變色

cache: false, //是否使用緩存

showColumns: false, // 列

// toobar:'#toolbar',

pagination: true, //分頁

paginationLoop: false,

paginationPreText: '上一頁',

paginationNextText: '下一頁',

// showFooter:true,//顯示列腳

// showRefresh:true,//顯示刷新

showPaginationSwitch: false, //是否顯示數據條數選擇框

sortable: false, //是否啓用排序

singleSelect: false,

search: false, //顯示搜索框

buttonsAlign: "right", //按鈕對齊方式

showRefresh: false, //是否顯示刷新按鈕

sidePagination: "server", //服務端處理分頁

pageNumber: 1,

pageSize: 10,

pageList: [10, 15, 20],

undefinedText: '--',

uniqueId: "id", //每一行的唯一標識,一般爲主鍵列

queryParamsType: '',

queryParams: queryParams, //傳遞參數(*)

columns: columns

});

 

//得到查詢的參數

function queryParams(params) {

var loginUser = JSON.parse(sessionStorage.getItem('loginUser'));

var cnds = new Cnds();

if (loginUser != null) {

cnds.addCnd('commentUserId', '=', loginUser.user.id);

} else {

cnds.addCnd('commentUserId', '=', "");

}

cnds.addCnd('createTime', 'DESC');

var temp = { //這裏的鍵的名字和控制器的變量名必須一直,這邊改動,控制器也需要改成一樣的

pageSize: params.pageSize, //頁面大小

pageNumber: params.pageNumber, //頁碼

searchParam: encodeURI(JSON.stringify(cnds))

};

return temp;

};

}

function recoveryDel(commentId) {

var paramObj = {};

paramObj.id = commentId;

swal({

title: "提示!",

text: "是否刪除所選評論",

type: "info",

showCancelButton: true,

confirmButtonColor: "#DD6B55",

confirmButtonText: "確定",

cancelButtonText: "取消",

closeOnConfirm: false

},

function () {

getAjaxJson("commentManage/deleteComment", paramObj, function (res) {

if (res.resultCode == 0) {

$("#listTable").bootstrapTable('refresh');

swal.close();

}

});

});

}

//詳情彈窗

function recoveryDetail(commentId) {

getComment(commentId);

$(".serve-window").show();

}

//搜索

function serachUser() {

$("#listTable").bootstrapTable('refresh');

}

 

//關閉彈窗

$('.close-window').click(function () {

$(this).parents('.new-window').hide();

})

$('#closeWin').click(function () {

$(this).parents('.new-window').hide();

})

//查詢單條糾錯信息

function getComment(commentId) {

var paramObj = {};

paramObj.id = commentId;

var html = "";

getAjaxJson("commentManage/getCommentById", paramObj, function (res) {

if (res.resultCode == 0) {

var commentData = res.resultData;

var userStr = "";

var deptStr = "";

var descStr = "";

var catalogNameStr = "";

if ("" != commentData.catalogName && null != commentData.catalogName) {

catalogNameStr = commentData.catalogName;

}

if ("" != commentData.createUser && null != commentData.createUser) {

userStr = commentData.createUser;

}

if ("" != commentData.commentDeptName && null != commentData.commentDeptName) {

deptStr = commentData.commentDeptName;

}

if ("" != commentData.commentDesc && null != commentData.commentDesc) {

descStr = commentData.commentDesc;

}

 

html += '<table><tr><th>目錄名稱:</th>' + '<td><input readonly value="' + catalogNameStr + '"></td></tr>'

+ '<tr><th>評論人:</th>' + '<td><input readonly value="' + userStr + '"></td></tr>'

+ '<th><span>所在部門:</th>' + '<td><input readonly value="' + deptStr + '"></td></tr>'

+ '<tr><th>評論星級:</th> <td>'

for (var i = 0; i < commentData.commentStar; i++) {

html += '<span class="commentDetailStar"></span>'

}

html += '</td></tr><tr><th>評論內容:</th>' +

'<td><textarea readonly rows="4">' + descStr + '</textarea></td></tr></table>';

$("#set-select").html(html);

}

});

}

</script>

</body>

 

</html>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章