loading js备份
loadingManageEdit.jsp
$(function(){ //组织 var lodingDeparts =[<c:forEach items="${lodingDeparts}" var="dept"> { deptId:"${dept.deptId}", deptName:"${dept.deptName}"},</c:forEach>]; var applist=new Array();//应用集合 var ruleTotalId = ""; var ruleTotalContent = ""; $.each(lodingDeparts,function(i,item){ if (i == 0){ ruleTotalContent ="<span style='word-break:hyphenate;' id='"+item.deptId+"' >" +item.deptName+" <a href='javascript:;' onclick='removeData(\""+item.deptId+"\")'>删除</a> </span>"; //动态添加到下边显示 $("#dept").find('td').eq(1).append(ruleTotalContent); }else{ ruleTotalId = item.deptId; ruleTotalContent = "<span style='word-break:hyphenate;' id='"+item.deptId+"' >"+","+item.deptName+" <a href='javascript:;' onclick='removeData(\""+item.deptId+"\")'>删除</a>"; $("#dept").find('td').eq(1).append(" "+ruleTotalContent+"</span>"); } //将id和name组合加入集合 applist.push(item.deptId); }); //将已选择的数组缓存在页面中 $("#alertSelectNode").val(applist.join()); //岗位 var lodingPosts = [<c:forEach items="${lodingPosts}" var="post"> { postId:"${post.postId}", postName:"${post.postName}"},</c:forEach>]; var postList=new Array();//应用集合 var postTotalId = ""; var postTotalContent = ""; $.each(lodingPosts,function(i,item){ if (i == 0){ ruleTotalContent ="<span style='word-break:hyphenate;' id='"+item.postId+"' >" +item.postName+" <a href='javascript:;' onclick='removePost(\""+item.postId+"\")'>删除</a> </span>"; //动态添加到下边显示 $("#post").find('td').eq(1).append(ruleTotalContent); }else{ postTotalId = item.postId; postTotalContent = "<span style='word-break:hyphenate;' id='"+item.postId+"' >"+","+item.postName+" <a href='javascript:;' onclick='removePost(\""+item.postId+"\")'>删除</a>"; $("#post").find('td').eq(1).append(" "+postTotalContent+"</span>"); } //将id和name组合加入集合 postList.push(item.postId); }); //将已选择的数组缓存在页面中 $("#alertSelectPost").val(postList.join()); //图片 var LoadingAttachs = [<c:forEach items="${LoadingAttachs}" var="attach"> { attachId:"${attach.attachId}", picPath:"${attach.picPath}", picSeq:"${attach.picSeq}"}, </c:forEach>]; $.each(LoadingAttachs,function(i,item){ if (i == 0){ $("#loadingAttachmentId").val(item.attachId); }else{ var attachmentIds = $("#loadingAttachmentId").val(); $("#loadingAttachmentId").val(attachmentIds+","+item.attachId); } //动态添加一行表格 $('#picTable tbody').append(); }); }) function removeData(id){ var ids = $("#alertSelectNode").val().split(","); for(var j = 0,len = ids.length; j < len; j++){ if(ids[j]==id){ ids.splice(j,1) } } $("#alertSelectNode").val(ids.join()); calcuUserCount(); $("#"+id).remove(); } function removePost(id){ var ids = $("#alertSelectPost").val().split(","); for(var j = 0,len = ids.length; j < len; j++){ if(ids[j]==id){ ids.splice(j,1); } } $("#alertSelectPost").val(ids.join()); calcuUserCount(); $("#"+id).remove(); } function removePic(id){ var ids = $("#loadingAttachmentId").val().split(","); var idValue=null; for(var j = 0,len = ids.length; j < len; j++){ if(ids[j]==id){ idValue= $('input[name='+id+']').val(); ids.splice(j,1); } } $("#loadingAttachmentId").val(ids.join()); $("#"+id).remove(); //调整排序 for(var j = 0,len = ids.length; j < len; j++){ var idValues= $('input[name='+ids[j]+']').val(); if(idValues>idValue){ $('input[name='+ids[j]+']').val(idValues-1); } } if(ids==null || ids==""){//将表格头隐藏 $('#picTable').attr("style","display:none;"); } } function calcuUserCount(){ var obj = window.top.document.getElementById("win_right"); //得到当前所选择的所有组织 var allDept = obj.contentWindow.$("#alertSelectNode").val(); //得到当前所选择的所有岗位 var allPost = obj.contentWindow.$("#alertSelectPost").val(); //请求数据 var url =ctx + "/loadingManageAction.do?method=calcuUserCount"; $.ajax({ type:'post',//请求方法的类型为post url:ctx + "/loadingManageAction.do?method=calcuUserCount",//请求地址 async:false, data : { allDept : allDept, allPost : allPost }, // 参数值 success:function(data){//成功时触发方法 if (data != null){ obj.contentWindow.$("#count").html(data); } } }); }
loadingManageEdit.js
function doSubmitHandle(){ //判断名称不能为空 var name = $("#name").val().trim(); if(name.length==0){ jboxAlert("名称不能为空"); return false; } var regName = new RegExp("^[0-9]*$");//从头到尾都是数字 if(regName.test(name)){ jboxAlert("请输入非数字字符串"); return false; } //判断权重不能为空 var weight = $("#weight").val().trim(); if(weight.length==0){ jboxAlert("权重不能为空"); return false; } var regPos = /^(([^0][0-9]+|0)\.([0-9]{1,2}))$/; //非负浮点数 if(!regName.test(weight)||weight>999||weight<=0||regPos.test(weight)){ jboxAlert("请输入1-999的整数"); return false; } //判断附件上传不能为空 var fileName = $("#loadingAttachmentId").val().trim(); if(fileName == "" ||fileName==null){ jboxAlert("请选择上传图片"); return false; } //判断广告关闭方式 var weight = $("#weight").val().trim(); var chkRadio = $('input:radio[name="isCompel"]:checked').val(); if(chkRadio==null){ jboxAlert("请选择广告关闭方式"); return false; } //判断播放时长 var showTime = $('input[name="showTime"]:checked').val(); if(showTime==null){ jboxAlert("请选择播放时长"); return false; } // 判断时间不能为空,并且开始时间要小于结束时间 if(($("#beginTime").val() == null || $("#beginTime").val() == "") && ($("#endTime").val() == null || $("#endTime").val() == "")){ jboxAlert("请选择起始日期和结束日期"); return false; } if(($("#beginTime").val() == null || $("#beginTime").val() == "") && !($("#endTime").val() == null || $("#endTime").val() == "")){ jboxAlert("请选择起始日期"); return false; } if(!($("#beginTime").val() == null || $("#beginTime").val() == "") && ($("#endTime").val() == null || $("#endTime").val() == "")){ jboxAlert("请选择结束日期"); return false; } //显示规则 var weight = $("#showRule").val().trim(); var chkRadio = $('input:radio[name="showRule"]:checked').val(); if(chkRadio==null){ jboxAlert("请选择显示规则"); return false; } //显示范围 var alertSelectNode = $("#alertSelectNode").val().trim(); if(alertSelectNode==null ||alertSelectNode==""){ jboxAlert("请选择显示范围"); return false; } //将排序方式从页面获取并放置到页面 var picSeqs=new Array();//应用集合 var seqs = $("#loadingAttachmentId").val().split(","); var picSeq = ""; for(i=0 ;i < seqs.length ; i++){ item = seqs[i] picSeq = $('input[name='+item+']').val(); if(picSeq==null ||picSeq==""){ jboxAlert("图片排序不能为空"); return false; } picSeqs.push(picSeq); } // 判断集合排序元素是否重复 for (var i = 0; i < picSeqs.length; i++) { if (parseInt(picSeqs[i],10) == parseInt(picSeqs[i + 1],10)) { jboxAlert("图片排序不能重复"); return false; } } $("#picSeqs").val(picSeqs.join()); var count = $("#count").html(); $("#countUv").val(count); $("#loadingManageForm").submit();
}
// 文件上传成功,给item添加成功class, 用样式标记上传成功。 uploader.on( 'uploadSuccess', function( file ,data) { if(data.success=="true"){ var attachmentIds = $("#loadingAttachmentId").val(); if(attachmentIds==null || attachmentIds==""){//之前没有上传图片 //如果是第一个添加进来的图片需要先将table显示出来 $('#picTable').attr("style","display:block;"); $("#loadingAttachmentId").val(data.file.id); }else{ var attachmentIds = $("#loadingAttachmentId").val(); $("#loadingAttachmentId").val(attachmentIds+","+data.file.id); } var size = $("#loadingAttachmentId").val().split(","); //动态添加一行表格 $('#picTable tbody').append("<tr id="+data.file.id+">"+ "<td><img style='width:60px;height:60px;margin-left: 50px;margin-top: 20px;'src="+data.file.uploadFilePath+">"+"</image></td>" + "<td><input type='text' value='"+size.length+"' name="+data.file.id+" style='text-align:center;width:45px;border-style:ridge;' onkeyup="+"this.value=this.value.replace(/[^0-9]/g,'') /></td>"+ "<td><a href='javascript:;' onclick='removePic(\""+data.file.id+"\")'>删除</a></td>"+"</tr>"); }else{ jboxAlert(data.message); } });
划船不用桨、杨帆不等风、一生全靠浪