ajax之分页

前端之家收集整理的这篇文章主要介绍了ajax之分页前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

ajax之分页

前台页面

  1. <%@pagecontentType="text/html;charset=GBK"%>
  2. <%@tagliburi="http://java.sun.com/jstl/core"prefix="c"%>
  3. <%@tagliburi="/WEB-INF/tld/utiltags.tld"prefix="util"%>
  4. <scripttype="text/javascript"
  5. src="<%=request.getContextPath()%>/js/common.js"></script>
  6. <scriptlanguage="javascript"
  7. src="<%=request.getContextPath()%>/js/xmlcommon.js"></script>
  8. src="<%=request.getContextPath()%>/css/tabber.js"></script>
  9. src="<%=request.getContextPath()%>/js/calendar.js"></script>
  10. <linkrel="stylesheet"
  11. href="<%=request.getContextPath()%>/css/example.css"TYPE="text/css"
  12. MEDIA="screen"/>
  13. <linkrel="stylesheet"
  14. href="<%=request.getContextPath()%>/css/style.css"type="text/css"/>
  15. src="<%=request.getContextPath()%>/js/jquery-1.3.2.min.js"></script>
  16. <head>
  17. <util:message/>
  18. <Metahttp-equiv="Content-Type"content="text/html;charset=GBK">
  19. <title>电话销售系统</title>
  20. </head>
  21. <body>
  22. <formname="form1"method="post"action="">
  23. <tablewidth="99%"border="0"align="center"cellpadding="0"
  24. cellspacing="0">
  25. <tr>
  26. <tdwidth="22"height="32"
  27. background="<%=request.getContextPath()%>/images/main/frame_q.jpg">
  28. </td>
  29. <td
  30. background="<%=request.getContextPath()%>/images/main/frame_w.jpg"
  31. class="MainTitle">
  32. <!--呼入控制数据设置-->
  33. 呼入屏蔽设置
  34. <tdwidth="22"height="32"
  35. background="<%=request.getContextPath()%>/images/main/frame_e.jpg">
  36. </td>
  37. </tr>
  38. <td
  39. background="<%=request.getContextPath()%>/images/main/frame_a.jpg">
  40. <tdvalign="top"bgcolor="#EFEFEF">
  41. <tablewidth="100%"border="0"cellspacing="0"cellpadding="0">
  42. <td></td>
  43. </tr>
  44. </table>
  45. <tablewidth="100%"border="0"cellpadding="0"cellspacing="0"
  46. bgcolor="#EFEFEF">
  47. <tdclass="SecondTitle">.:设置查询:.</td>
  48. <tr>
  49. <tdbgcolor="#999999">
  50. <tablename="tableA"border="0"cellspacing="1"cellpadding="1"
  51. width="100%">
  52. <trwidth="100%">
  53. <tdwidth="14%"align="right"class="general-td">数据来源:</td>
  54. <tdalign="left"class="general-td"><select
  55. name="dataSource"class="selectCtrl"id="dataSource">
  56. <optionvalue="">全部</option>
  57. <optionvalue="1"<c:iftest='${result.blackListDTO.dataSource=="1"}'>selected</c:if>>电销系统</option>
  58. <optionvalue="2"<c:iftest='${result.blackListDTO.dataSource=="2"}'>selected</c:if>>承保系统</option>
  59. </select></td>
  60. <tdwidth="14%"align="right"class="general-td">类型:</td>
  61. <tdalign="left"class="general-td"><select
  62. name="type"class="selectCtrl"id="type">
  63. <optionvalue="">全部</option>
  64. <optionvalue="1-1"<c:iftest='${result.blackListDTO.type=="1-1"}'>selected</c:if>>黑名单(电销)</option>
  65. <optionvalue="1-2"<c:iftest='${result.blackListDTO.type=="1-2"}'>selected</c:if>>黑名单(承保)</option>
  66. <optionvalue="2"<c:iftest='${result.blackListDTO.type=="2"}'>selected</c:if>>号码屏蔽</option>
  67. <trwidth="100%">
  68. <tdwidth="14%"align="right"class="general-td">类型明细:</td>
  69. name="typeDetail"class="selectCtrl"id="typeDetail">
  70. <c:forEachvar="blackList"
  71. items="${result.blackListRemarkList}">
  72. <optionvalue='<c:outvalue="${blackList.paramId}"/>'<c:iftest="${result.blackListDTO.typeDetail==blackList.paramId}">selected</c:if>>
  73. <c:outvalue="${blackList.paramValue}"/>
  74. </option>
  75. </c:forEach>
  76. <optionvalue="hc"<c:iftest='${result.blackListDTO.typeDetail=="hc"}'>selected</c:if>>呼出</option>
  77. <optionvalue="dx"<c:iftest='${result.blackListDTO.typeDetail=="dx"}'>selected</c:if>>短信</option>
  78. </select></td>
  79. <tdwidth="14%"align="right"class="general-td">是否屏蔽:</td>
  80. name="isExcluded"class="selectCtrl"id="isExcluded">
  81. <optionvalue="1"<c:iftest='${result.blackListDTO.isExcluded=="1"}'>selected</c:if>></option>
  82. <optionvalue="0"<c:iftest='${result.blackListDTO.isExcluded=="0"}'>selected</c:if>></option>
  83. <tdcolspan="4"align="right"class="general-td"><input
  84. name="efdag3"type="button"class="btn"value="查询"
  85. onclick="searchCallInControlDataList();"></td>
  86. </table>
  87. <tablewidth="100%"border="0"cellspacing="0"cellpadding="0">
  88. <td></td>
  89. <tablewidth="100%"border="0"cellpadding="0"cellspacing="0"
  90. bgcolor="#EFEFEF">
  91. <tdclass="SecondTitle">.:查询结果:.</td>
  92. <tdbgcolor="#999999">
  93. <tablename="tableB"border="0"cellspacing="1"cellpadding="1"
  94. width="100%">
  95. <tdwidth="10%"align="center"bgcolor="#DFE0E4"class="title-td">
  96. 选择
  97. <inputtype="checkBox"name="checkAll"id="checkAll"onclick="gotocheckAll(this);">
  98. <tdwidth="10%"align="center"bgcolor="#DFE0E4"
  99. class="title-td">数据来源</td>
  100. class="title-td">类型</td>
  101. class="title-td">类型明细</td>
  102. class="title-td">是否屏蔽</td>
  103. class="title-td">最新操作时间</td>
  104. <c:forEachvar="black"items="${result.blackList}">
  105. <tdstyle="display:none;"><inputtype="hidden"name="id"value='<c:outvalue="${black.id}"/>'></td>
  106. <tdwidth="7%"align="center"class="general-td"><input
  107. type="checkBox"name="toBeEdited"></td>
  108. <tdwidth="7%"align="center"class="general-td"id="dataSource1"
  109. style="color:<c:iftest='${emptyblack.isExcluded}'>red;</c:if>">
  110. <c:iftest="${black.dataSource==1}">电销系统</c:if>
  111. <c:iftest="${black.dataSource==2}">承保系统</c:if>
  112. <tdwidth="6%"align="center"class="general-td"id="type1"
  113. style="color:<c:iftest='${emptyblack.isExcluded}'>red;</c:if>">
  114. <c:iftest='${black.type=="1-1"||black.type=="1-2"}'>黑名单</c:if>
  115. <c:iftest='${black.type=="2"}'>号码屏蔽</c:if>
  116. <tdwidth="9%"align="center"class="general-td"id="tyepDetail1"
  117. <c:forEachvar="blackList"items="${result.blackListRemarkList}">
  118. <c:iftest='${blackList.paramId==black.typeDetail}'>
  119. <c:outvalue="${blackList.paramValue}"/>
  120. </c:if>
  121. </c:forEach>
  122. <tdalign="center"class="general-td">
  123. <c:iftest="${black.isExcluded==1}"></c:if>
  124. <c:iftest="${black.isExcluded==0}"></c:if>
  125. <c:outvalue="${black.updatedDate}"/>
  126. <tdalign="right"class="general-td"colspan="9"><input
  127. name="efdag2"type="button"class="btn"value="修改"onclick="edit();"></td>
  128. <tdclass="general-td"colspan="9">
  129. <tableid="table1"align="center"width="500"border="0"
  130. cellpadding="0"cellspacing="0">
  131. <tdid="td1"align="center"valign="middle"><input
  132. type="hidden"name="pageTotal"id="pageTotal1"
  133. value='<c:outvalue="${result.totalPage}"/>'><span><c:out
  134. value="${result.totalPage}"/>
  135. </span><inputtype=buttonname="prevPage1"value="上一页"id="prevPage1"
  136. onClick="gotoPrevPage1()"class="btn2"><inputid="nextPage1"
  137. type=buttonname="nextPage1"value="下一页"
  138. onclick="gotoNextPage1();"class="btn2"><inputid="jump1"
  139. type=buttonname="jump1"value="跳至"onclick="gotoJump1()"
  140. class="btn2"><span><inputid="pageNo1"
  141. name="pageNo"style="text-align:center"
  142. value='<c:outvalue="${result.pageNo}"/>'
  143. class="inputbg3">
  144. </span></td>
  145. <tdclass="SecondTitle">.:临时数据处理:.</td>
  146. <tdwidth="14%"align="center"class="general-td">电话号码:</td>
  147. <tdwidth="38%"align="left"class="general-td"><inputid="phoneNo"
  148. maxlength="15"name="phoneNo"type="text"class="inputbg">
  149. <tdcolspan="4"align="right"class="general-td"><inputid="query2"
  150. onclick="searchCallInControlDataListByPhoneNo(this);"></td>
  151. <tablename="tableA"border="0"cellspacing="1"cellpadding="1"
  152. <trwidth="100%"id="insert">
  153. class="title-td">电话号码</td>
  154. class="title-td">状态</td>
  155. class="title-td">创建时间</td>
  156. class="title-td">更新时间</td>
  157. class="title-td">操作</td>
  158. <tdclass="general-td"colspan="9">
  159. <tableid="table1"align="center"width="500"border="0"
  160. cellpadding="0"cellspacing="0">
  161. <tdstyle="display:none;"><inputtype="hidden"id="hiddenPageNo2"></td>
  162. <tdid="td1"align="center"valign="middle">
  163. <spanid="pageTotal2">0</span>
  164. <inputtype=buttonname="prevPage2"value="上一页"id="prevPage2"
  165. onClick="searchCallInControlDataListByPhoneNo(this)"class="btn2"disabled="disabled"><input
  166. type=buttonname="nextPage2"value="下一页"id="nextPage2"
  167. onClick="searchCallInControlDataListByPhoneNo(this)"class="btn2"disabled="disabled"><inputid="jump2"
  168. type=buttonname="jump2"value="跳至"onclick="searchCallInControlDataListByPhoneNo(this)"
  169. class="btn2"disabled="disabled">
  170. <span>
  171. <inputname="pageNo2"style="text-align:center"value="0"class="inputbg3"id="pageNo2">
  172. </span>
  173. </form>
  174. </body>
  175. <scripttype="text/javascript">
  176. varpageNo=$("#pageNo1").val();
  177. vardataSource=$("#dataSource").val();
  178. vartype=$("#type").val();
  179. vartypeDetail=$("#typeDetail").val();
  180. varisExcluded=$("#isExcluded").val();
  181. if($("#pageTotal1").val()<="1")
  182. {
  183. $("#prevPage1").attr("disabled","disabled");
  184. $("#nextPage1").attr("disabled","disabled");
  185. $("#jump1").attr("disabled",85); line-height:18px"> }else{
  186. if(pageNo==$("#pageTotal1").val())
  187. $("#nextPage1").attr("disabled",85); line-height:18px"> }elseif(pageNo=="1"){
  188. }
  189. }
  190. functiongotoPrevPage1()
  191. pageNo=parseInt($("#pageNo1").val());
  192. if(pageNo>1)
  193. {
  194. pageNo=pageNo-1;
  195. window.location.href="<%=request.getContextPath()%>/callInControlData.goto.do?dataSource="
  196. +dataSource+"&type="+type+"&typeDetail="+typeDetail+"&isExcluded="+isExcluded+"&pageNo="+pageNo;
  197. functiongotoNextPage1()
  198. if(pageNo<$("#pageTotal1").val())
  199. pageNo=parseInt(pageNo)+1;
  200. functiongotoJump1()
  201. vartemp=pageNo;
  202. pageNo=$("#pageNo1").val();
  203. if(isNaN(pageNo)||parseInt(pageNo)>$("#pageTotal1").val()||parseInt(pageNo)<1)
  204. alert("您输入的页数不存在!");
  205. returnfalse;
  206. window.location.href="<%=request.getContextPath()%>/callInControlData.goto.do?dataSource="
  207. +dataSource+"&type="+type+"&typeDetail="+typeDetail+"&isExcluded="+isExcluded+"&pageNo="+pageNo;
  208. functionsearchCallInControlDataList()
  209. dataSource=$("#dataSource").val();
  210. type=$("#type").val();
  211. typeDetail=$("#typeDetail").val();
  212. isExcluded=$("#isExcluded").val();
  213. +dataSource+"&type="+type+"&typeDetail="+typeDetail+"&isExcluded="+isExcluded;
  214. functionedit(){
  215. vartoBeEdited=$('input[name="toBeEdited"]:checked');
  216. if(toBeEdited.length==0){
  217. alert("请至少选择一条记录!");
  218. return;
  219. varids=newArray();
  220. for(vari=0;i<toBeEdited.length;i++){
  221. var_ids=toBeEdited.parent().prev().children();
  222. ids.push(_ids[i].value);
  223. window.location.href="<%=request.getContextPath()%>/callInControlData.goto.do?flag=edit&ids="+ids;
  224. functiongotocheckAll(obj){
  225. if(obj.checked){
  226. $('input[name="toBeEdited"]').attr("checked","checked");
  227. }else{
  228. functionsearchCallInControlDataListByPhoneNo(obj){
  229. varpageNo;
  230. if(obj.id=="query2"){
  231. pageNo="1";
  232. }elseif(obj.id=="prevPage2"){
  233. pageNo=parseInt($("#hiddenPageNo2").val())-1;
  234. if(pageNo==1){
  235. $("#prevPage2").attr("disabled",226); color:inherit; line-height:18px"> }elseif(obj.id=="nextPage2"){
  236. pageNo=parseInt($("#hiddenPageNo2").val())+1;
  237. if(pageNo==parseInt($("#pageTotal2").html())){
  238. $("#nextPage2").attr("disabled",85); line-height:18px"> }elseif(obj.id=="jump2"){
  239. if(isNaN($("#pageNo2").val())||$("#pageNo2").val()<1||$("#pageNo2").val()>$("#pageTotal2").html()){
  240. alert("您输入的页数不存在!");
  241. return;
  242. else{
  243. pageNo=$("#pageNo2").val();
  244. $.ajax({
  245. url:"<%=request.getContextPath()%>/callInControlData.goto.do",
  246. data:{flag:"queryByPhone",phoneNo:$("#phoneNo").val(),pageNo:pageNo},
  247. dataType:"json",
  248. type:"post",85); line-height:18px"> success:function(data){
  249. $("#pageTotal2").html(Math.ceil(data[0].pageTotal/10));
  250. if($("#pageTotal2").html()!=0){
  251. $("#pageNo2").val(pageNo);
  252. $("#hiddenPageNo2").val(pageNo);
  253. if($("#pageTotal2").html()>1){
  254. if(pageNo!=1){
  255. if(pageNo!=$("#pageTotal2").html()){
  256. $("#nextPage2").attr("disabled","");
  257. $("#jump2").attr("disabled",226); color:inherit; line-height:18px"> vardataSource="";
  258. vartype="";
  259. vartypeDetail="";
  260. varvalidFlag="";
  261. $('tr[name="dataInserted"]').remove();
  262. for(vari=0;i<data[0].blackList.length;i++){
  263. if(data[0].blackList[i].dataSource=="1"){
  264. dataSource="电销系统";
  265. }elseif(data[0].blackList[i].dataSource=="2"){
  266. dataSource="承保系统";
  267. if(data[0].blackList[i].type=="1-1"||data[0].blackList[i].type=="1-2"){
  268. type="黑名单";
  269. }elseif(data[0].blackList[i].type=="2"){
  270. type="号码屏蔽";
  271. if(data[0].blackList[i].validFlag=="1"){
  272. validFlag="有效";
  273. }elseif(data[0].blackList[i].validFlag=="0"){
  274. validFlag="无效";
  275. for(varj=0;j<data[0].blackListRemarkList.length;j++){
  276. if(data[0].blackList[i].typeDetail==data[0].blackListRemarkList[j].paramId){
  277. typeDetail=data[0].blackListRemarkList[j].paramValue;
  278. break;
  279. $('<trwidth="100%"name="dataInserted">'+
  280. '<tdalign="center"class="general-td">'+data[0].blackList[i].phoneNo+'</td>'+
  281. '<tdalign="center"class="general-td">'+dataSource+'</td>'+
  282. '<tdalign="center"class="general-td">'+type+'</td>'+
  283. '<tdalign="center"class="general-td">'+typeDetail+'</td>'+
  284. '<tdalign="center"class="general-td">'+validFlag+'</td>'+
  285. '<tdalign="center"class="general-td">'+data[0].blackList[i].createdDate+'</td>'+
  286. '<tdalign="center"class="general-td">'+data[0].blackList[i].updatedDate+'</td>'+
  287. '<tdalign="center"class="general-td"><inputtype="button"value="解锁呼入"class="btn"></td>'+
  288. '</tr>').insertAfter($("#insert"));
  289. },85); line-height:18px"> error:function(data){
  290. alert("系统异常,请联系管理员!");
  291. });
  292. </script>

后台java:
[java]
    packagecom.tpaic.callCenter.web.controller.comeInControlData;
  1. importjava.util.ArrayList;
  2. importjava.util.HashMap;
  3. importjava.util.List;
  4. importjava.util.Map;
  5. importjavax.servlet.http.HttpServletRequest;
  6. importjavax.servlet.http.HttpServletResponse;
  7. importnet.sf.json.JSONArray;
  8. importorg.apache.java.lang.Bytes;
  9. importorg.springframework.web.servlet.ModelAndView;
  10. importcom.tpaic.callCenter.biz.util.sqlNamesUtil;
  11. importcom.tpaic.callCenter.dto.CodeTableDTO;
  12. importcom.tpaic.callCenter.dto.blackList.BlackListDTO;
  13. importcom.tpaic.callCenter.util.StringUtil;
  14. importcom.tpaic.callCenter.web.controller.common.AbstractCommonController;
  15. importcom.tpaic.callCenter.web.util.CommonUtils;
  16. importcom.tpaic.callCenter.web.util.ServiceRequestId;
  17. /**
  18. *@authorex_zhangkenan
  19. *呼入控制数据设置
  20. */
  21. publicclassCallInControlDataGotoControllerextendsAbstractCommonController{
  22. privateStringeditView;
  23. publicStringgetEditView(){
  24. returneditView;
  25. publicvoidsetEditView(StringeditView){
  26. this.editView=editView;
  27. protectedModelAndViewhandleRequestInternal(HttpServletRequestrequest,HttpServletResponseresponse)throwsException{
  28. Map<String,Object>resultMap=newHashMap<String,Object>();
  29. Stringflag=request.getParameter("flag");
  30. if(flag==null){
  31. //查询电销系统黑名单原因列表
  32. @SuppressWarnings("unchecked")
  33. List<Object>blackListRemarkList=(List<Object>)this.getDispatch().dispatchRequest(
  34. CommonUtils.getAggregatedSearchDTO(
  35. sqlNamesUtil.CODETABLE_SEARCH_CODETYPE,"blackListRemark"),226); color:inherit; line-height:18px"> ServiceRequestId.AGGREGATED_SEARCH_ACTION);
  36. resultMap.put("blackListRemarkList",blackListRemarkList);
  37. //查询电销系统blacklist表
  38. StringpageNo=request.getParameter("pageNo");
  39. StringdataSource=request.getParameter("dataSource");
  40. Stringtype=request.getParameter("type");
  41. StringtypeDetail=request.getParameter("typeDetail");
  42. StringisExcluded=request.getParameter("isExcluded");
  43. BlackListDTOblackListDTO=newBlackListDTO();
  44. if(StringUtil.isEmpty(pageNo)){
  45. blackListDTO.setPageNo(1);
  46. }else{
  47. blackListDTO.setPageNo(Integer.parseInt(pageNo));
  48. blackListDTO.setDataSource(dataSource);
  49. blackListDTO.setType(type);
  50. blackListDTO.setTypeDetail(typeDetail);
  51. blackListDTO.setIsExcluded(isExcluded);
  52. StringtotalPage=(String)this.getDispatch().dispatchRequest(CommonUtils.getAggregatedSearchDTO(
  53. sqlNamesUtil.Search_Blacklist_For_Total_Page,blackListDTO,false),
  54. ServiceRequestId.AGGREGATED_SEARCH_ACTION);
  55. List<BlackListDTO>blackList=(List<BlackListDTO>)this.getDispatch().dispatchRequest(CommonUtils.getAggregatedSearchDTO(
  56. sqlNamesUtil.Search_Blacklist_For_List,blackListDTO),85); line-height:18px"> resultMap.put("pageNo",blackListDTO.getPageNo());
  57. resultMap.put("totalPage",totalPage);
  58. resultMap.put("blackList",blackList);
  59. resultMap.put("blackListDTO",blackListDTO);
  60. returnnewModelAndView(this.getSuccessView(),"result",resultMap);
  61. }elseif(flag.equals("edit")){
  62. Stringids=request.getParameter("ids");
  63. @SuppressWarnings({"unchecked"})
  64. sqlNamesUtil.Search_Blacklist_For_List_By_Ids,ids),226); color:inherit; line-height:18px"> resultMap.put("blackList",blackList);
  65. @SuppressWarnings("unchecked")
  66. List<CodeTableDTO>blackListRemarkList=(List<CodeTableDTO>)this.getDispatch().dispatchRequest(
  67. CommonUtils.getAggregatedSearchDTO(
  68. sqlNamesUtil.CODETABLE_SEARCH_CODETYPE,226); color:inherit; line-height:18px"> resultMap.put("blackListRemarkList",blackListRemarkList);
  69. returnnewModelAndView(this.getEditView(),226); color:inherit; line-height:18px"> }elseif(flag.equals("save")){
  70. StringisOrNotExcluded=request.getParameter("isOrNotExcluded");
  71. List<BlackListDTO>blackListDTO=newArrayList<BlackListDTO>();
  72. for(inti=0;i<ids.split(",").length;i++){
  73. BlackListDTOdto=newBlackListDTO();
  74. dto.setId(ids.split(",")[i]);
  75. dto.setIsExcluded(isOrNotExcluded.split(",")[i]);
  76. blackListDTO.add(dto);
  77. Stringdata="1";
  78. Map<String,Object>map=newHashMap<String,Object>();
  79. map.put("blackListDTO",85); line-height:18px"> try{
  80. this.getDispatch().dispatchRequest(map,ServiceRequestId.UPDATE_BLACK_LIST_FOR_ISEXCLUDED_ACTION);
  81. }catch(Exceptione){
  82. data="0";
  83. response.getWriter().write(data);
  84. returnnull;
  85. }elseif(flag.equals("queryByPhone")){
  86. StringphoneNo=request.getParameter("phoneNo");
  87. dto.setPhoneNo(phoneNo);
  88. dto.setPageNo(Integer.parseInt(pageNo));
  89. sqlNamesUtil.Search_Blacklist_For_List_By_Phone,dto),226); color:inherit; line-height:18px"> StringpageTotal=(String)this.getDispatch().dispatchRequest(CommonUtils.getAggregatedSearchDTO(
  90. sqlNamesUtil.Search_Blacklist_By_Phone_For_Num,phoneNo,85); line-height:18px"> map.put("blackList",226); color:inherit; line-height:18px"> map.put("blackListRemarkList",85); line-height:18px"> map.put("pageTotal",pageTotal);
  91. JSONArrayjsonArray=JSONArray.fromObject(map);
  92. response.setCharacterEncoding("UTF-8");
  93. response.getWriter().write(jsonArray.toString());
  94. }
效果
原文链接:https://www.f2er.com/ajax/164734.html

猜你在找的Ajax相关文章