BootStrap实现邮件列表的分页和模态框添加邮件的(3)

<pre>$(function(){//初始化页面 page1(); initTree(); shouwtree(); $('#treediv').mouseleave(function(){//在鼠标离开选择树的时候,选择书影藏 //alert("进来了"); $("#treediv").hide(); }); }); function Delete(mid){ swal({ title: "你确定要进行该操作?", text: "You will not be able to recover this imaginary file!", type: "warning", showCancelButton: true, confirmButtonColor: "#DD6B55", confirmButtonText: "是的, 删除!", cancelButtonText: "不, 取消", closeOnConfirm: false, closeOnCancel: false }, function(isConfirm){ if (isConfirm) { var action = "delete"; $.ajax({ type : "post", url : "MailBoxServlet", datatype:'json', data:{action:action,id:mid,a:Math.random()}, success : function(data){ var d= eval('('+data+')'); if(d.biaozhi==true){ swal("删除!", "删除成功", "success"); //window.location.reload();这种方式无法显示成功提示 $("#list").empty(); page1(); }else{ swal("Deleted!", "删除失败", "error"); } } }); } else { swal("", "你已经取消的该操作 ", "error"); } }); } function Edit(mid){ alert(mid); } function pl(){//批量删除 var checkedList = new Array(); var ids = ""; if($("input[name='deleteCusersid']:checked").length>0){ $("input[name='deleteCusersid']").each(function(){ if($(this).prop("checked")){//如果要未选中的 ==false 就可以了 //ids += $(this).val()+","; checkedList.push($(this).val()); } }); swal({ title: "你确定要删除这"+checkedList.length+"行?", //text: "You will not be able to recover this imaginary file!", type: "warning", showCancelButton: true, confirmButtonColor: "#DD6B55", confirmButtonText: "是的, 确定删除!", cancelButtonText: "不, 取消", closeOnConfirm: false, closeOnCancel: false }, function(isConfirm){ if (isConfirm) { var action = "pldelete"; $.ajax({ type : "post", url : "MailBoxServlet", datatype:'json', data:{action:action,a:Math.random(),deleteidlist:checkedList.toString()}, success : function(data){ var d= eval('('+data+')'); if(d.biaozhi==true){ swal("删除!", "批量删除成功", "success"); $("input[name='deleteCusersid']").prop("checked",false);//将其他有对号的清除 $("input[name='qx']").prop("checked",false);//将全选的对号清除 $("#list").empty(); page1(); //window.location.reload(); }else{ swal("Deleted!", "删除失败", "error"); } } }); } else { swal("", "你已经取消的该操作 ", "error"); $("input[name='qx']").prop("checked",false); $("input[name='deleteCusersid']").prop("checked",false); } }); }else{ swal("失败!", "你必须选择至少一行进行该操作!", "info"); } } function quanxuan(){//全选与全不选 if($("input[name='qx']").prop("checked")){ var checkbox = $("input[name='deleteCusersid']"); checkbox.prop("checked",true); }else{ var checkbox = $("input[name='deleteCusersid']"); checkbox.prop("checked",false); } } function addmail(){//写邮件 $("#btn_submit").click(function(){ var id = $("#menu_parent").val(); var zhuti = $("#zhuti").val();//获取主题 var content = $("#editor_id").val();//获取内容 if(zhuti==""||id==""){ if(zhuti==""){ swal("主题不能为空"); }else{ swal("收件人不能为空"); } return false; }else{ var action = "save"; $.ajax({ url: "MailBoxServlet", data : 'json', type : "post", data :{action:action,id :id,content :content,zhuti :zhuti,a : Math.random()}, success : function(data){ if(data !=null){ var d= eval('('+data+')'); if(d.biaozhi){ swal("邮件编写成功"); }else{ swal("邮件编写失败"); } } $("#zhuti").val(""); //关闭的时候将所有的值制空 $("#setvalue").val(""); KindEditor.instances[0].html('');//专门的将textarea值置空0表示第一个KindEditor编辑器对象 $("#list").empty();//置空 page1();//异步刷新页面 } }); } //swal("关闭"); }); $("#btn_close").click(function(){ $("#zhuti").val(""); //关闭的时候将所有的值制空 $("#setvalue").val(""); KindEditor.instances[0].html('');//专门的将textarea值置空0表示第一个KindEditor编辑器对象 swal("关闭"); }); $("#send").click(function(){ swal("发送成功"); }); } function initTree(){//初始化树 var action = "tree"; mydtree = new dTree('mydtree','${pageContext.request.contextPath}/style/default/images/dtree/','no','no'); mydtree.add(0, -1, "根目录", "javascript:setvalue('0','根目录')", "根目录", "_self", true); $.ajax({ url: "MailBoxServlet", data : 'json', type : "post", data :{action:action,a : Math.random()}, success : function(data){ if(data !=null){ $.each(eval("(" +data+ ")").treelist,function(index,item){ var id =item.nid; var pid = item.parentId; var nodesname = item.nodeName; mydtree.add(id,pid,nodesname,"javascript:setvalue('"+id+"','"+nodesname+"')",nodesname,"_self",false); }); //document.write(mydtree); //将树添加到指定div(jQuery) $("#treediv").html(mydtree.toString()); } } }); } function shouwtree(){ $("#setvalue").click(function(){ $("#treediv").show(); }); } function setvalue(id,name){ $("#setvalue").val(name); $("#menu_parent").val(id); $("#treediv").hide(); } function page1(){ var pageNumber = 1;//默认初始页为第一页 var action = "page";//定义一个要进入的条件 $.ajax({//ajax请求 url: "MailBoxServlet", data :'json', type: "Post", data:{action:action,pageNumber:pageNumber,a:Math.random()},//参数 success : function(data){//请求成功的方法 if(data !=null){ $.each(eval("(" + data + ")").mailbox, function (index, item) { //遍历返回的json var html = "<tr><td><input type='checkbox' value='"+item.mid+"'/></td><td>" + item.title + "</td><td>" + item.p_name + "</td><td>" + item.content + "</td><td>" +item.r_time+ "</td><td>" +item.status+ "</td><td>"; m1 ="编辑"; m2="删除"; html2="<div><button ><span></span> " +m1+"</button>" +"<button ><span></span> " +m2+"</button>" +"</div></td></tr>"; html+= html2; $("#list").append(html); }); var pageCount = eval("(" + data + ")").Page[0].totalPage; //取到pageCount的值(把返回数据转成object类型) var currentPage = eval("(" + data + ")").Page[0].currentPage; //得到urrentPage var options = { bootstrapMajorVersion: 2, //版本 currentPage: currentPage, //当前页数 totalPages: pageCount, //总页数 //numberOfPages:10, itemTexts: function (type, page, current) { switch (type) { case "first": return "首页"; case "prev": return "上一页"; case "next": return "下一页"; case "last": return "末页"; case "page": return page; } }, onPageClicked: function (event, originalEvent, type, page) { $("#list").empty(); $.ajax({ url: "MailBoxServlet?pageNumber=" + page, type: "Post", data:{action:"page",a:Math.random()}, success: function (data1) { if (data1 != null) { $.each(eval("(" + data1 + ")").mailbox, function (index, item) { //遍历返回的json var html = "<tr><td><input type='checkbox' value='"+item.mid+"'/></td><td>" + item.mid + "</td><td>" + item.p_name + "</td><td>" + item.content + "</td><td>" +item.r_time+ "</td><td>" +item.status+ "</td><td>"; m1 ="编辑"; m2="删除"; html2="<div><button ><span></span> " +m1+"</button>" +"<button ><span></span> " +m2+"</button>" +"</div></td></tr>"; html+= html2; $("#list").append(html); }); } } }); } }; $('#pageinfo').bootstrapPaginator(options); } } }); }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wzdswj.html