$("#example").dataTable().fnDraw(false); 此函数就是处理请求后,还维持在本页
下面是自己的jsp页面代码
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set value="${pageContext.request.contextPath}" var="ctx" />
<style type="text/css" title="currentStyle">
@import "${ctx}/js/DataTables-1.8.0/media/css/demo_page.css";
@import "${ctx}/js/DataTables-1.8.0/media/css/demo_table.css";
@import "${ctx}/css/hyipmessage.css";
@import "${ctx}/js/DataTables-1.8.0/examples/examples_support/themes/smoothness/jquery-ui-1.8.4.custom.css";
</style>
<link rel="stylesheet" type="text/css" media="screen" href="${ctx}/js/jquery-validation-1.8.1/demo/css/screen.css" />
<link rel="stylesheet" type="text/css" href="${ctx}/css/qbao.dialog.css" />
<link rel="stylesheet" type="text/css" href="${ctx}/js/My97DatePicker/skin/WdatePicker.css" />
<script type="text/javascript" src="${ctx}/js/DataTables-1.8.0/media/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="${ctx}/js/jquery-ui-1.8.13/js/jquery.form.min.js"></script>
<script type="text/javascript" src="${ctx}/js/moment/moment.js"></script>
<script type="text/javascript" src="${ctx}/js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="${ctx}/js/hyip.js"></script>
<script type="text/javascript">
$(document).ready(function () {
createTable();
$('#search').click(createTable);
$('#reasonDialog').dialog({
modal: true,
position: 'center',
autoOpen: false,
width: 500,
height: 350,
buttons: {
'确认': function () {
var idReason = $('#idReason').val();
var reason = $('#reason').val();
if (reason.length > 50) {
alert("原因不能大于50个字符");
return;
}
HYIP.ajax('${ctx}/checkManage/check.html', {
id: idReason,
checkStatus: 2,
reason: reason
}, function (data) {
$('#reasonDialog').dialog('close');
HYIP.showDynamicMsg('hyip_float_message', 'hyip-success', data.message);
$("#example").dataTable().fnDraw(false);
}, function (data) {
HYIP.showDynamicErrorMsg(data.message);
});
}, '取消': function () {
$('#reason').val('');
$('#reasonDialog').dialog('close');
}
}
});
$('#exportDialog').dialog({
modal: true,
position: 'center',
autoOpen: false,
width: 500,
height: 350,
buttons: {
'确认': function () {
//装载ajax参数
var shopId = $.trim($('#shopId').val());
var goodsId = $.trim($('#goodsId').val());
var applyId = $.trim($('#applyId').val());
var goodsName = $.trim($('#goodsName').val());
var checkStatus = $("#checkStatus").val();
var startTimeS = $.trim($('#startTimeS').val());
var startTimeE = $.trim($('#startTimeE').val());
var modelType = $.trim($('#modelType').val());
var categoryNameA = $.trim($('#categoryNameA').val());
$('#shopIdExcel').val(shopId);
$('#goodsIdExcel').val(goodsId);
$('#applyIdExcel').val(applyId);
$('#goodsNameExcel').val(goodsName);
$('#checkStatusExcel').val(checkStatus);
$('#modelTypeExcel').val(modelType);
$('#categoryNameAExcel').val(categoryNameA);
$('#startTimeSExcel').val(startTimeS);
$('#startTimeEExcel').val(startTimeE);
$("#hiddenForm").submit();
$('#exportDialog').dialog('close');
}, '取消': function () {
$('#exportDialog').dialog('close');
}
}
});
});
function createTable() {
$('#demo').html('<table cellpadding="0" cellspacing="0" border="0" class="display" id="example"></table>');
$('#example').dataTable({
'iDisplayLength': 15,
'bSortClasses': false,
'bSort': false,
'sPaginationType': 'full_numbers',
"sDom": '<"top"i>rtp<"clear">', //页面上元素位置
'aoColumns': [
{'sTitle': '申请ID', 'sClass': 'center', 'sWidth': '5%'},
{'sTitle': '商家ID', 'sClass': 'center', 'sWidth': '5%'},
{'sTitle': '商家名称', 'sClass': 'center', 'sWidth': '10%'},
{'sTitle': '商品信息', 'sClass': 'center', 'sWidth': '15%'},
{'sTitle': '商户类型', 'sClass': 'center', 'sWidth': '5%'},
{'sTitle': '一级类目', 'sClass': 'center', 'sWidth': '5%'},
{'sTitle': '拍卖类型', 'sClass': 'center', 'sWidth': '5%'},
{ 'sTitle': '申请时间', 'sClass': 'center', 'sWidth': '10%' },
{'sTitle': '原价(钱宝币)', 'sClass': 'center', 'sWidth': '9%'},
{'sTitle': '起拍价(钱宝币)', 'sClass': 'center', 'sWidth': '9%'},
{'sTitle': '最低竞拍价(钱宝币)', 'sClass': 'center', 'sWidth': '9%'},
{'sTitle': '可参与库存', 'sClass': 'center', 'sWidth': '10%'},
// { 'sTitle': '场次', 'sClass': 'center', 'sWidth': '10%' },
{'sTitle': '状态', 'sClass': 'center', 'sWidth': '9%'},
{'sTitle': '操作', 'sClass': 'center', 'sWidth': '10%'}
],
'oLanguage': {
'sProcessing': '加载数据中...',
'sInfo': '当前显示 _START_ 到 _END_ 条记录,总共 _TOTAL_ 条',
'sInfoEmpty': '',
'sZeroRecords': '暂无消息',
'oPaginate': {'sFirst': '首页', 'sPrevious': '上一页', 'sNext': '下一页', 'sLast': '末页'},
"sEmptyTable": "没有记录"
},
'bProcessing': true,
'bServerSide': true,
'sAjaxSource': '${ctx}/checkManage/listApplyRecords.html',
'fnServerData': function (sSource, aoData, fnCallback) {
//装载ajax参数
var shopId = $.trim($('#shopId').val());
if (shopId != null && shopId != '') {
aoData.push({name: 'shopId', value: shopId});
}
var categoryNameA = $.trim($('#categoryNameA').val());
if (categoryNameA != '') {
aoData.push({name: 'categoryNameA', value: categoryNameA});
}
var applyId = $.trim($('#applyId').val());
if (applyId != null && applyId != '') {
aoData.push({name: 'applyId', value: applyId});
}
var goodsId = $.trim($('#goodsId').val());
if (goodsId != null && goodsId != '') {
aoData.push({name: 'goodsId', value: goodsId});
}
var goodsName = $.trim($('#goodsName').val());
if (goodsName != null && goodsName != '') {
aoData.push({name: 'goodsName', value: goodsName});
}
var checkStatus = $("#checkStatus").val();
if (checkStatus != null && checkStatus != '') {
aoData.push({name: 'checkStatus', value: checkStatus});
}
var startTimeS = $.trim($('#startTimeS').val());
var startTimeE = $.trim($('#startTimeE').val());
if (startTimeS != '') aoData.push({name: 'startTimeS', value: startTimeS});
if (startTimeE != '') aoData.push({name: 'startTimeE', value: startTimeE});
var modelType = $.trim($('#modelType').val());
if (modelType != '') {
aoData.push({name: 'modelType', value: modelType});
}
HYIP.ajax(sSource, aoData, function (resp) {
var result = resp.data;
var records = result.aaData;
var aaData = [];
var buttons = [];
var modelType ;
if (records != null) {
for (var i = 0; i < records.length; i++) {
var record = records[i];
buttons = [];
buttons.push('<input type="button" class="btn" style="cursor:pointer;" οnclick="showDetail(' + record.id + ');" value="查看" />');
if (record.checkStatus == 0) {
buttons.push('<input type="button" class="btn" style="cursor:pointer;" οnclick="pass(' + record.id + ');" value="通过" />');
buttons.push('<input type="button" class="btn" style="cursor:pointer;" οnclick="refuse(' + record.id + ');" value="不通过" />');
}
var checkStatus = record.checkStatus;
var checkStatusStr = '';
if (checkStatus == 0) {
checkStatusStr = '待审核';
} else if (checkStatus == 1) {
checkStatusStr = '审核通过';
} else if (checkStatus == 2) {
checkStatusStr = '审核未通过';
} else if (checkStatus == 3) {
checkStatusStr = '已发布';
}else if (checkStatus == 4) {
checkStatusStr = '已撤销';
}
var shopInfo = null; // TODO
var operate = null;
var goodsInfo = record.goodsInfo;
var goodsInfoList = [];
if (goodsInfo == null || goodsInfo == '') {
goodsInfoList[0] = '';
goodsInfoList[1] = '';
goodsInfoList[2] = '';
} else {
goodsInfoList = goodsInfo.split(",");
}
if (record.type == 0) {
modelType = '下跌式';
} else if (record.type == 1) {
modelType = '加价式';
}else if (record.type == 2){
modelType = '幸运夺宝';
}else if (record.type == 3){
modelType = '限时抢';
}
if(record.applyTime != null && record.applyTime != ""){
applyTime = moment(record.applyTime).format("YYYY-MM-DD HH:mm:ss");
}
aaData.push([
record.id,
record.shopId,
record.shopName,
goodsInfoList[0] + '</br>商品ID:' + goodsInfoList[1] + '</br>' + goodsInfoList[2],
record.shopTypeName,
record.categoryNameA,
modelType,
applyTime,
record.normalPrice,
record.startPrice,
record.lowestPrice,
record.goodsNum,
// record.periodTimeStr,
checkStatusStr,
buttons.join(' ')
]);
}
}
fnCallback({
'sEcho': result.sEcho,
'iTotalRecords': result.itotalRecords,
'iTotalDisplayRecords': result.itotalDisplayRecords,
'aaData': aaData
});
});
}
});
}
function pass(id) {
HYIP.ajax('${ctx}/checkManage/check.html', {id: id, checkStatus: 1}, function (data) {
HYIP.showDynamicMsg('hyip_float_message', 'hyip-success', data.message);
// createTable();
$("#example").dataTable().fnDraw(false);
}, function (data) {
HYIP.showDynamicErrorMsg(data.message);
});
}
function refuse(id) {
$('#idReason').val(id);
$('#reasonDialog').dialog('open');
}
function trimText(obj) {
$(obj).val($.trim($(obj).val()));
}
function showDetail(id) {
window.location.href = '${ctx}/checkManage/toShowDetail.html?id=' + id;
}
function exportExcel(){
$('#exportDialog').dialog('open');
}
</script>
<div id="page_content" class="content">
<div class="span_title">审核管理</div>
<div class="selectBox">
申请ID:<input type="text" name="applyId" id="applyId" οnblur="trimText(this);" />
商家ID:<input type="text" name="shopId" id="shopId" οnblur="trimText(this);" />
商品ID:<input type="text" name="goodsId" id="goodsId" οnblur="trimText(this);" />
商品名称:<input type="text" name="goodsName" id="goodsName" οnblur="trimText(this);" />
<div class="div_blank"> </div>
<%--商户类型:--%>
<%--<select id="type">--%>
<%--<option value="-1">全部</option>--%>
<%--<option value="0">认证商家(付费)</option>--%>
<%--<option value="1">认证商家(达标)</option>--%>
<%--<option value="2">企业商家</option>--%>
<%--</select>--%>
一级类目:
<select id="categoryNameA" name="categoryNameA">
<option value="-99">全部</option>
<c:if test="${not empty categoryNameList}">
<c:forEach items="${categoryNameList}" var="categoryNameList" varStatus="idx">
<li <c:if test="${idx.index > 0 }">style="display: none;"</c:if>>
<option value=${categoryNameList.categoryNameA}>${categoryNameList.categoryNameA}</option>
</li>
</c:forEach>
</c:if>
</select>
拍卖类型:<select id="modelType" name="modelType">
<option value="99">全部</option>
<option value="0">下跌式</option>
<option value="1">加价式</option>
<option value="2">幸运夺宝</option>
<option value="3">限时抢</option>
</select>
申请时间:<input type="text" name="startTimeS" id="startTimeS" οnclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" /> 至
<input type="text" name="startTimeE" id="startTimeE" οnclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" />
审核状态:
<select id="checkStatus">
<option value="-1">全部</option>
<option value="0" selected="selected">待审核</option>
<option value="1">审核通过</option>
<option value="2">审核未通过</option>
<option value="4">已撤销</option>
</select>
<input type="button" value="查询" id="search" class="btn" style="cursor:pointer;" />
<input type="button" value="导出" id="exportExcel" class="btn" style="cursor:pointer;" οnclick="exportExcel()"/>
</div>
<div id="demo"></div>
<div id="reasonDialog" title="不通过原因" style="display: none">
<p><input id="idReason" type="hidden" />
原因:
<textarea id="reason" rows="3" cols="30"></textarea>
</p>
</div>
<div id="exportDialog" title="导出确认" style="display: none">
<p><input id="isExcelExport" type="hidden" />
确定要导出该数据吗?
</p>
</div>
<form id="hiddenForm" action="/checkManage/listCheckExport.html" method="post">
<input type="hidden" id="shopIdExcel" name="shopIdExcel" value="">
<input type="hidden" id="applyIdExcel" name="applyIdExcel" value="">
<input type="hidden" id="goodsIdExcel" name="goodsIdExcel" value="">
<input type="hidden" id="goodsNameExcel" name="goodsNameExcel" value="">
<input type="hidden" id="checkStatusExcel" name="checkStatusExcel" value="">
<input type="hidden" id="modelTypeExcel" name="modelTypeExcel" value="">
<input type="hidden" id="categoryNameAExcel" name="categoryNameAExcel" value="">
<input type="hidden" id="startTimeSExcel" name="startTimeSExcel" value="">
<input type="hidden" id="startTimeEExcel" name="startTimeEExcel" value="">
</form>
</div>