关闭

周期规则

331人阅读 评论(0) 收藏 举报
分类:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%@include file="/WEB-INF/pages/system/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<base href="<%=basePath%>" />


		<meta http-equiv="pragma" content="no-cache" />
		<meta http-equiv="cache-control" content="no-cache" />
		<meta http-equiv="expires" content="0" />
		<title>周期规则</title>
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3" />
		<meta http-equiv="description" content="This is my page" />
		<link rel="stylesheet" type="text/css" href="css/css.css" />
		<link rel="stylesheet" href="css/sy.css" type="text/css"></link>
		<script type="text/javascript" src="js/public/jquery-1.4.2.js"></script>
		<script type="text/javascript" src="js/public/jquery.form.js"></script>
		<script type="text/javascript" src="js/My97DatePicker/WdatePicker.js"
			defer="defer"></script>
		<script type="text/javascript" src="js/util/math.js"></script>
		<script type="text/javascript">
		function chooseType(periodid) {
		    if (periodid == undefined || periodid == null) {
		        alert("请先点击\"保存\"按钮!");
		        return false;
		    }
		    var str = "toChooseMultipleSms.action?periodid=" + periodid + "&messageType=" + "1";
		    window.open(str, "_blank", "height=500px,width=900px,top=250,left=350,toolbar=no,menubar=no,scrollbars=1,resizable=no,location=no,status=no,alwaysRaised=yes,titlebar=no");
		
		}	
		
		function changeDayCycle(obj) {
		    $("input[name='cycle'][checked]").val("1");
		}
		function changeWeekCycle(obj) {
		    $("input[name='cycle'][checked]").val("2");
		}
				
		function changeSend(obj) {
		    if (!$(obj).attr("checked")) {
		        $(obj).attr("value", 0);
		    } else {
		        $(obj).attr("value", 1);
		    }
		}
		function save() {
		    var daystr = "";
		    daystr += '{"data":[';
		    var daytimecount = 0;
		    for (var i = 0; i < $("#cycle").parent().nextAll("span").length; i++) {
		        if (i != 0) {
		            daystr += ",";
		        }
		        daystr += "{";
		        var cycle = document.getElementsByName("cycle");
		        for (var j = 0; j < cycle.length; j++) {
		            if (cycle[j].checked) {
		                daystr += '"cycle":"' + $("input[name='cycle'][checked]").val() + '"';
		            }
		        }
		        daystr += ',"starttime":"' + $("#cycle").parent().nextAll("span").eq(i).find("input").eq(0).val() + '"';
		        daystr += ',"endtime":"' + $("#cycle").parent().nextAll("span").eq(i).find("input").eq(1).val() + '"';
		        daystr += ',"dayflag":"' + $("#cycle").parent().nextAll("span").eq(i).find("input").eq(2).val() + '"';
		        var daySmsList = $("#cycle").parent().nextAll("span").eq(i).find("input").eq(2).nextAll("span");
		        for (var k = 0; k < daySmsList.length; k++) {
		            daystr += ',"daySmsid":"' + $("#cycle").parent().nextAll("span").eq(i).find("input").eq(2).nextAll("span").eq(k).find("input").val() + '"';
		        }
		        var starttime = $("#cycle").parent().nextAll("span").eq(i).find("input").eq(0).val();
		        var endtime = $("#cycle").parent().nextAll("span").eq(i).find("input").eq(1).val();
		        if (starttime == "") {
		            alert("请选择开始时间!");
		            $("#cycle").parent().nextAll("span").eq(i).find("input").eq(0).focus();
		            return false;
		        }
		        if (endtime == "") {
		            alert("请选择结束时间!");
		            $("#cycle").parent().nextAll("span").eq(i).find("input").eq(1).focus();
		            return false;
		        }
		        if (starttime >= endtime) {
		            alert("开始时间不能大于等于结束时间!");
		            return false;
		        }
		
		        daystr += "}";
		        daytimecount++;
		    }
		
		    daystr += ']}';
		    var json = eval("(" + daystr + ")");
		    for (var i = 0; i < json.data.length; i++) {
		        if (json.data[i] != undefined && json.data[i + 1] != undefined && json.data[i] != undefined && json.data[i + 1] != undefined) {
		            if ((json.data[i + 1].starttime <= json.data[i].endtime) && (json.data[i].starttime <= json.data[i + 1].endtime)) {
		                {
		                    alert('每天的时间段里,时间有重叠的部分!');
		                    return false;
		                }
		            }
		        }
		    }
		    var count = 0;
		    var bool = 0;
		    var weekruleid = document.getElementsByName("weekruleid");
		    for (var i = 1; i < weekruleid.length + 1; i++) {
		        if (weekruleid[i].checked) {
		            count = i;
		            break;
		        } else {
		            count = 0;
		            break;
		        }
		    }
		    for (var i = 1; i < weekruleid.length + 1; i++) {
		        if (!weekruleid[i].checked || $(weekruleid[i]).next().children("span").length == 0) {
		            bool = i;
		            break;
		        }
		    }
		    var weekstr = "";
		    weekstr += '{"data":[';
		    var timecount = 0;
		    for (var i = 0; i < weekruleid.length; i++) {
		        if ($(weekruleid[i]).next().children("span").length != 0) {
		            if (i + 1 != count) {
		                weekstr += ",";
		            }
		            for (var j = 0; j < $(weekruleid[i]).next().children("span").length; j++) {
		                if (j != 0) {
		                    weekstr += ",";
		                }
		                weekstr += "{";
		                weekstr += '"weekruleid":"' + $(weekruleid[i]).val() + '"';
		                weekstr += ',"starttime":"' + $(weekruleid[i]).next().children("span").eq(j).find("input").eq(0).val() + '"';
		                weekstr += ',"endtime":"' + $(weekruleid[i]).next().children("span").eq(j).find("input").eq(1).val() + '"';
		                weekstr += ',"weekflag":"' + $(weekruleid[i]).next().children("span").eq(j).find("input").eq(2).val() + '"';
		                var weekSmsList = $(weekruleid[i]).next().children("span").eq(j).find("input").eq(2).nextAll("span");
		                for (var k = 0; k < weekSmsList.length; k++) {
		
		                    weekstr += ',"weekSmsid":"' + $(weekruleid[i]).next().children("span").eq(j).find("input").eq(2).nextAll("span").eq(k).find("input").val() + '"';
		                }
		                weekstr += "}";
		                var starttime = $(weekruleid[i]).next().children("span").eq(j).find("input").eq(0).val();
		                var endtime = $(weekruleid[i]).next().children("span").eq(j).find("input").eq(1).val();
		                if (starttime == "") {
		                    alert("请选择开始时间!");
		                    $(weekruleid[i]).next().children("span").eq(j).find("input").eq(0).focus();
		                    return false;
		                }
		                if (endtime == "") {
		                    alert("请选择结束时间!");
		                    $(weekruleid[i]).next().children("span").eq(j).find("input").eq(1).focus();
		                    return false;
		                }
		                if (starttime >= endtime) {
		                    alert("开始时间不能大于等于结束时间!");
		                    return false;
		                }
		            }
		            timecount++;
		        } else {
		
		            if (i + 1 != bool) {
		                weekstr += ",";
		            }
		            weekstr += "{";
		            weekstr += '"weekruleid":"' + $(weekruleid[i]).val() + '"';
		            weekstr += "}";
		        }
		    }
		    weekstr += ']}';
		    var weekjson = eval("(" + weekstr + ")");
		    for (var i = 0; i < weekjson.data.length; i++) {
		        if (weekjson.data[i] != undefined && weekjson.data[i + 1] != undefined && weekjson.data[i] != undefined && weekjson.data[i + 1] != undefined) {
		            if ((weekjson.data[i + 1].starttime <= weekjson.data[i].endtime) && (weekjson.data[i].starttime <= weekjson.data[i + 1].endtime)) {
		                {
		                    alert('每周的时间段里,时间有重叠的部分!');
		                    return false;
		                }
		            }
		        }
		    }
		    $("#jsonStr").val(weekstr);
		    $.ajax({
		        url: "timeRuleSaveOrUpdate.action",
		        type: "post",
		        dataType: "json",
		        data: {
		            'daystr': daystr,
		            'weekstr': weekstr,
		            'cycle': $("input[name='cycle'][checked]").val()
		        },
		        success: function(data) {
		
		            if (data.message != null && data.message != "") {
		                alert(data.message);
		                FormSubmit("get", "");
		            }
		        },
		        error: function(data) {
		            alert("操作失败!");
		        }
		    });
		
		}
		
		function FormSubmit(method, action) {
            var frm = $("#ruleForm")[0];
            frm.method = method;
            frm.action = action;
            frm.submit();
        }
		function add(obj) {
		    $(obj).next().after('<span name="sp2"> 开始时间 <input type="text" name="starttime" id="starttime" width="50px" class="text5" onclick="WdatePicker({skin:\'whyGreen\',dateFmt:\'HH:mm\'})"/> 结束时间  <input type="text" name="endtime" id="endtime" class="text5" onclick="WdatePicker({skin:\'whyGreen\',dateFmt:\'HH:mm\'})"/> <input name="weekflag" type="checkbox" id="weekflag" onclick="changeSend(this)" value="0"/>发送 <img src="<%=path%>/images/pic16.gif" width="14" height="13" border="0" style="margin-right: 3px;cursor:pointer" onclick="removeTime(this)" />删除  <img src="<%=path%>/images/smsSet_gray.gif"   onclick="chooseType()"  style="cursor:pointer"/><br /></span>');
		
		}
		function addDayTime(obj) {
		    $(obj).parent().after('<span name="sp2"> 开始时间 <input type="text" name="starttime" id="starttime" width="50px" class="text5" onclick="WdatePicker({skin:\'whyGreen\',dateFmt:\'HH:mm\'})"/> 结束时间 <input type="text" name="endtime" id="endtime" class="text5" onclick="WdatePicker({skin:\'whyGreen\',dateFmt:\'HH:mm\'})"/> <input name="weekflag" type="checkbox" id="weekflag" onclick="changeSend(this)" value="0"/>发送 <img src="<%=path%>/images/pic16.gif" width="14" height="13" border="0" style="margin-right: 3px;cursor:pointer" onclick="removeTime(this)" />删除  <img src="<%=path%>/images/smsSet_gray.gif"  onclick="chooseType()"  style="cursor:pointer"/><br /></span>');
		}

		function removeTime(obj) {
		    var msg = "您确定要删除该时间段吗?";
		    if (confirm(msg) == true) {
		        $(obj).parent().remove();
		        $(obj).remove();
		        save();
		    }
		}
		function deleteSmsPeriod(smsid, periodid, specialperiodid) {
		    var msg = "您确定要删除该信息吗?";
		    if (confirm(msg) == true) {
		        $(obj).parent().remove();
		        $(obj).remove();
		        $.ajax({
		            url: "deleteSmsPeriod.action",
		            type: "post",
		            dataType: "json",
		            data: {
		                'smsid': smsid,
		                'periodid': periodid,
		                'specialperiodid': specialperiodid
		            },
		            success: function(data) {
		                if (data.message != null && data.message != "") {
		                    alert(data.message);
		                    location.reload();
		                }
		            },
		            error: function(data) {
		                alert("操作失败");
		            }
		        });
		    }
		
		}
</script>
	</head>
	<body>
		<form action="toRule.action" name="ruleForm" id="ruleForm"
			method="get">
			<table width="100%" border="0" cellspacing="0" cellpadding="0" class="cen">
				<tr>
				<td valign="top" class="cen_rig">
	
						<div>
							<div class="right1"></div>
							<div align="center" class="gaodu">
							</div>
							<div class="cen_07">
								<div style="width: 100px; float: left;">
									周期规则
								</div>
								<div class="cen_15"></div>
							</div>
							<div class="cen_06"></div>
							<div class="downline"></div>
							<div style="margin-left: 20px; margin-right: 20px;">
								<table width="100%" border="0" cellspacing="0" cellpadding="0"
									class="cen_18">
									<tr>
										<th width="100">
											天规则
										</th>
										<td>
											<div class="cen_21">
												<input type="hidden" id="cycleruleid" value="${cmsCycleRule.ruleid }" />
												<input type="radio" id="cycle" value="${cmsCycleRule.cycle }" name="cycle"
												<c:if test="${cmsCycleRule.cycle==1 }"> checked="checked" </c:if>
												onclick="changeDayCycle(this)" style="width: 30px;" />
												每天固定时间段
												<img src="<%=path%>/images/pic15.gif" width="16" height="16" border="0" id="addTime" name="addTime" onclick="addDayTime(this)" style="cursor:pointer"/>新增时间段
												<br />
											</div>
											<c:forEach items="${cmsDayRule.cmsTimePeriodList}" var="time">
												<span>开始时间 <input type="text" name="daystarttime" id="starttime" onclick="WdatePicker({skin:'whyGreen',dateFmt:'HH:mm'})" value="${time.starttime }" class="text5" />
													     结束时间 <input type="text" name="dayendtime" id="endtime" onclick="WdatePicker({skin:'whyGreen',dateFmt:'HH:mm'})" class="text5" value="${time.endtime }" /> 
															 <c:if test="${time.flag==1}"><input name="dayflag" type="checkbox" id="dayflag" checked="checked" value="1" onclick="changeSend(this)" />发送</c:if> 
															<c:if test="${time.flag==0}"><input name="dayflag" type="checkbox" id="dayflag" value="0" onclick="changeSend(this)" />发送</c:if>
												   			  <img src="<%=path%>/images/pic16.gif" width="14" height="13" border="0" style="margin-right: 3px;cursor:pointer" onclick="removeTime(this)" />删除
												
												   			  <img src="<%=path%>/images/smsSet.gif"  onclick="chooseType('${time.periodid}')"  style="cursor:pointer"/>
																<br />
																<c:if test="${time.smsList!= null && fn:length(time.smsList) != 0}">
															            <img src="<%=path %>/images/chooseSms.jpg" style="cursor:pointer"/><br/>
																	<c:forEach items="${time.smsList}" var="sms" varStatus="xh">
																		<span><input type="hidden" name="smsid" value="${sms.smsid }"/></span>
																		<c:if test="${xh.count== fn:length(time.smsList)}">
																			<div class="time_mpNone"><strong>${xh.count}</strong>   ${sms.content }    <img src="<%=path%>/images/pic16.gif" width="14" height="13" border="0" style="cursor:pointer" onclick="deleteSmsPeriod('${sms.smsid }','${time.periodid }','')" />删除<br/></div>
																			</c:if>
																			<c:if test="${xh.count!= fn:length(time.smsList)}">
																			<div class="time_mp"><strong>${xh.count}</strong>   ${sms.content }    <img src="<%=path%>/images/pic16.gif" width="14" height="13" border="0" style="cursor:pointer" onclick="deleteSmsPeriod('${sms.smsid }','${time.periodid }','')" />删除<br/></div>
																			</c:if>
																	</c:forEach>

															     </c:if>
															     
															     	<c:if test="${time.mmsList!= null && fn:length(time.mmsList) != 0}">
															     	  	    <img src="<%=path %>/images/chooseMms.jpg"/><br/>
															    	<c:forEach items="${time.mmsList}" var="mms" varStatus="xhmms">
																		<span><input type="hidden" name="smsid" value="${mms.send_id }"/></span>
																		<c:if test="${xhmms.count== fn:length(time.mmsList)}">
																			<div class="time_mpNone"><strong>${xhmms.count}</strong>   ${mms.title }    <img src="<%=path%>/images/pic16.gif" width="14" height="13" border="0" style="cursor:pointer" onclick="deleteSmsPeriod('${mms.send_id }','${time.periodid }','')" />删除<br/></div>
																			</c:if>
																			<c:if test="${xhmms.count!= fn:length(time.mmsList)}">
																			<div class="time_mp"><strong>${xhmms.count}</strong>   ${mms.title}    <img src="<%=path%>/images/pic16.gif" width="14" height="13" border="0" style="cursor:pointer" onclick="deleteSmsPeriod('${mms.send_id }','${time.periodid }','')" />删除<br/></div>
																			</c:if>
																	</c:forEach>
																	</c:if>
												</span>
											</c:forEach>
										</td>
									</tr>
									<tr>
										<th width="100">
											周规则
										</th>
										<td class="p_ys">
											<div class="cen_21">
												<input type="radio" id="cycle" value="${cmsCycleRule.cycle }" name="cycle"
													<c:if test="${cmsCycleRule.cycle==2 }"> checked="checked" </c:if> onclick="changeWeekCycle(this)" style="width: 30px;" />
												每周固定时间段
											</div>
											<c:forEach items="${cmsWeekRuleList}" var="cmsWeekRule">
													<input type="hidden" value="${cmsWeekRule.weekruleid }" name="weekruleid"/>
												<span style="margin-top: 5px;"> 
															
															<c:if test="${cmsWeekRule.weekday=='1'}">星期一</c:if>
															<c:if test="${cmsWeekRule.weekday=='2'}">星期二</c:if>
															<c:if test="${cmsWeekRule.weekday=='3'}">星期三</c:if>
															<c:if test="${cmsWeekRule.weekday=='4'}">星期四</c:if>
															<c:if test="${cmsWeekRule.weekday=='5'}">星期五</c:if>
															<c:if test="${cmsWeekRule.weekday=='6'}">星期六</c:if>
															<c:if test="${cmsWeekRule.weekday=='0'}">星期日</c:if>
												<img src="<%=path%>/images/pic15.gif" width="16" height="16" border="0" id="addTime4" name="addTime" onclick="add(this)" style="cursor:pointer"/>新增时间段<br /> 
													<c:forEach items="${cmsWeekRule.cmsTimePeriodList}" var="time">
														<span> 
															开始时间 <input type="text" name="starttime" id="starttime" value="${time.starttime }" class="text5" onclick="WdatePicker({skin:'whyGreen',dateFmt:'HH:mm'})" />
															结束时间 <input type="text" name="endtime" id="endtime" class="text5" value="${time.endtime }" onclick="WdatePicker({skin:'whyGreen',dateFmt:'HH:mm'})" />
															<c:if test="${time.flag==1}"><input name="weekflag" type="checkbox" id="weekflag" checked="checked" value="1" onclick="changeSend(this)" />发送</c:if> 
															<c:if test="${time.flag==0}"><input name="weekflag" type="checkbox" id="weekflag" value="0" onclick="changeSend(this)" />发送</c:if>
															<img src="<%=path%>/images/pic16.gif" width="14" height="13" border="0" style="margin-right: 3px;cursor:pointer"  onclick="removeTime(this)" />删除
														
														 <img src="<%=path%>/images/smsSet.gif"  onclick="chooseType('${time.periodid}')" style="cursor:pointer"/>
																<br />
																<c:if test="${time.smsList!= null && fn:length(time.smsList) != 0}">
															            <img src="<%=path %>/images/chooseSms.jpg" style="cursor:pointer"/><br/>
																	<c:forEach items="${time.smsList}" var="sms" varStatus="xh">
																	<span><input type="hidden" name="weekSmsid" value="${sms.smsid }"/></span>
																		<c:if test="${xh.count== fn:length(time.smsList)}">
																			<div class="time_mpNone"><strong>${xh.count}</strong>   ${sms.content }    <img src="<%=path%>/images/pic16.gif" width="14" height="13" border="0" style="margin-right: 3px;cursor:pointer" onclick="deleteSmsPeriod('${sms.smsid }','${time.periodid }','')" />删除<br/></div>
																			</c:if>
																			<c:if test="${xh.count!= fn:length(time.smsList)}">
																			<div class="time_mp"><strong>${xh.count}</strong>   ${sms.content }    <img src="<%=path%>/images/pic16.gif" width="14" height="13" border="0" style="margin-right: 3px;cursor:pointer" onclick="deleteSmsPeriod('${sms.smsid }','${time.periodid }','')" />删除<br/></div>
																			</c:if>
																	</c:forEach>
															     </c:if>
															     
															          	<c:if test="${time.mmsList!= null && fn:length(time.mmsList) != 0}">
															          	    <img src="<%=path %>/images/chooseMms.jpg"/><br/>
															    	<c:forEach items="${time.mmsList}" var="mms" varStatus="xhmms">
																		<span><input type="hidden" name="smsid" value="${mms.send_id }"/></span>
																		<c:if test="${xhmms.count== fn:length(time.mmsList)}">
																			<div class="time_mpNone"><strong>${xhmms.count}</strong>   ${mms.title }    <img src="<%=path%>/images/pic16.gif" width="14" height="13" border="0" style="margin-right: 3px;cursor:pointer" onclick="deleteSmsPeriod('${mms.send_id }','${time.periodid }','')" />删除<br/></div>
																			</c:if>
																			<c:if test="${xhmms.count!= fn:length(time.mmsList)}">
																			<div class="time_mp"><strong>${xhmms.count}</strong>   ${mms.title}    <img src="<%=path%>/images/pic16.gif" width="14" height="13" border="0" style="margin-right: 3px;cursor:pointer" onclick="deleteSmsPeriod('${mms.send_id }','${time.periodid }','')" />删除<br/></div>
																			</c:if>
																	</c:forEach>
																	</c:if>
														</span>
													</c:forEach>
												</span>
											</c:forEach>
										</td>
									</tr>
									<tr>
										<td colspan="2"><span style="color: red; margin-left: 20px;">【注】</span>新增的时间段,必须先点击"保存"按钮,才可以点击"添加消息"按钮。</td>
									</tr>
								</table>
							</div>
							<div class="btn" align="center" style="margin-top:10px">
						
								<img src="<%=path%>/images/pic08.gif" border="0" onclick="save()"  style="cursor:pointer"/>
								<a href="com.hereis.system.home.action"><img
										src="<%=path%>/images/pic09.gif"
										border="0" onclick="window.close()" />
								</a>
							</div>
						</div>
					</td>
				</tr>
			</table>
		</form>
	</body>
</html>

			$('#cycle').parent().nextAll('span').each(function(i) {
			    if (i != 0) {
			        daystr += ",";
			    }
			    daystr += "{";
			    var cycle = document.getElementsByName("cycle");
			    for (var j = 0; j < cycle.length; j++) {
			        if (cycle[j].checked) {
			            daystr += '"cycle":"' + $("input[name='cycle'][checked]").val() + '"';
			        }
			    }
			
			    daystr += ',"cycleruleid":"' + $("#cycleruleid").val() + '"';
			    daystr += ',"dayruleid":"' + $("#dayruleid").val() + '"';
			    daystr += ',"starttime":"' + $(this).find('input').eq(0).val() + '"';
			    daystr += ',"endtime":"' + $(this).find('input').eq(1).val() + '"';
			    daystr += ',"dayflag":"' + $(this).find('input').eq(2).val() + '"';
			    daystr += ',"periodid":"' + $(this).find('input').eq(3).val() + '"';


			    var starttime = $(this).find('input').eq(0).val();
			    var endtime = $(this).find('input').eq(1).val();
			    if (starttime == "") {
			        alert("请选择开始时间!");
			        $(this).find('input').eq(0).focus();
			        return false;
			    }
			    if (endtime == "") {
			        alert("请选择结束时间!");
			        $(this).find('input').eq(1).focus();
			        return false;
			    }
			    if (starttime >= endtime) {
			        alert("开始时间不能大于等于结束时间!");
			        return false;
			    }
			    var divid = $(this).find('input').eq(3).val();
			    var userTypeidList = new Array();
			
			    if (divid != undefined && divid != "") {
			
			        $('#' + divid + ' input[name="typeName"]:checked').each(function() {
			            userTypeidList.push($(this).val());
			        });
			        if (userTypeidList.length == 0) {
			            alert("请您至少选择一个客户类别!");
			            return false;
			        }
			        daystr += ',"userTypeidList":"' + userTypeidList + '"';
			    }
			
			    daystr += "}";
			    daytimecount++;
			})











0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:2506次
    • 积分:84
    • 等级:
    • 排名:千里之外
    • 原创:6篇
    • 转载:1篇
    • 译文:0篇
    • 评论:0条
    文章分类
    文章存档