My97DatePicker请假日期后端判断已选日期不可再选
程序员文章站
2022-04-11 07:50:29
对于后台进行请假日期验证,如果有重复可以判断,如法提交 1 public String doAddLeaves(){ 2 try { 3 TbUser tbUser=(TbUser) getFromSession("loginUser"); 4 leaveList=leaveService.getL ......
对于后台进行请假日期验证,如果有重复可以判断,如法提交
1 public string doaddleaves(){ 2 try { 3 tbuser tbuser=(tbuser) getfromsession("loginuser"); 4 leavelist=leaveservice.getleavesbyusername(tbuser.getid());//获取当前用户所有请假条 5 int row = 0; 6 //system.err.println("======="+tbleave.getbeginleave()+","+tbleave.getendleave()); 7 for (tbleave leaves : leavelist) { 8 if (tbleave.getendleave().compareto(leaves.getbeginleave())<=0 9 || tbleave.getbeginleave().compareto(leaves.getendleave())>=0 ) { 10 11 //system.err.println("1..."+tbleave.getbeginleave()+","+tbleave.getendleave()); 12 //system.err.println("2..."+leaves.getbeginleave()+","+leaves.getendleave()); 13 row=0; 14 15 }else{ 16 row=1; 17 break; 18 } 19 } 20 if (tbleave.getendleave().compareto(tbleave.getbeginleave())<0) { 21 log.info("fail!!!"); 22 resultmap.put("retcode", retcode.fail); 23 resultmap.put("retmsg", "请假时间需要大于开始时间"); 24 }else { 25 26 if (row==0) { 27 28 leaveservice.addleaves(tbleave); 29 //puttosession("leave", leave) 30 log.info("success!!!"); 31 resultmap.put("retcode", retcode.success); 32 resultmap.put("retmsg", "保存成功"); 33 }else{ 34 log.info("fail!!!"); 35 resultmap.put("retcode", retcode.fail); 36 resultmap.put("retmsg", "请假时间存在冲突"); 37 } 38 } 39 } catch (exception e) { 40 e.printstacktrace(); 41 log.error("method addemails bug:{}",e); 42 resultmap.put("retcode", retcode.unkown_wrong); 43 resultmap.put("retmsg", "未知错误,请重试或联系管理员"); 44 } 45 return success; 46 }
1 <tr> 2 <td align="right" width="30%">开始时间:</td> 3 <td align="left"><input type="text" name="tbleave.beginleave" readonly="readonly" 4 id="beginleave" 5 onclick="wdatepicker({mindate:'%y-%m-{%d+1}',maxdate:'#f{$dp.$d(\'endleave\')}',onpicked:function(){endleave.click();},disableddays:[0,6]})" class="wdate" /><br/> 6 </td> 7 </tr><br/> 8 <tr> 9 <td align="right" width="30%">结束时间:</td> 10 <td align="left"><input type="text" name="tbleave.endleave" readonly="readonly" 11 id="endleave" onclick="wdatepicker({errdealmode:3,mindate:'#f{$dp.$d(\'beginleave\')}',disableddays:[0,6]})" class="wdate"/><br/></td> 12 </tr>
1 <script type="text/javascript"> 2 $(function() { 3 4 $("#loginform").validate({ 5 rules : { 6 "tbleave.beginleave" : { 7 required : true, 8 }, 9 "tbleave.endleave" : { 10 required : true, 11 /* remote: { 12 url: "${ctx}/leave/begintoend.action", 13 type: "post", 14 datatype: "json", 15 data: { 16 "tbleave.beginleave": function(){ 17 return $("#beginleave").val() 18 }, 19 "tbleave.endleave": function(){ 20 return $("#endleave").val(); 21 } 22 } 23 } */ 24 }, 25 /* "tbleave.reason" : { 26 required : true, 27 } */ 28 }, 29 messages : { 30 "tbleave.beginleave" : { 31 required : "输入开始请假日期", 32 }, 33 "tbleave.endleave" : { 34 required : "输入结束请假日期", 35 //remote:"*请假日期不能重复" 36 }, 37 /* "tbleave.reason" : { 38 required : "输入请假原因", 39 } */ 40 41 } 42 }); 43 44 45 46 $("#sendleave").click(function() { 47 if ($("#loginform").valid()) { 48 if(confirm("是否要提交吗?")){ 49 var url = "${ctx}/leave/doaddleaves.action"; 50 $.post( 51 url, 52 { 53 "tbleave.isdelete" : $("#isdelete").val(), 54 "tbleave.read" : $("#read").val(), 55 "tbleave.tbuserbyuserid.id" : $("#isid").val(), 56 "tbleave.beginleave" : $("#beginleave").val(), 57 "tbleave.endleave" : $("#endleave").val(), 58 "tbleave.reason" : $("#reason").val() 59 }, 60 function(data) { 61 if (data.retcode == "0") { 62 alert("提交成功"); 63 window.location.href = "${ctx}/leave/findallleaves.action"; 64 } else { 65 alert(data.retmsg); 66 } 67 }); 68 } 69 } 70 }); 71 }); 72 </script>
上一篇: 标签--基础标签