@requestmapping("/listsetplanall.htm") public modelandview listsetplanall(@requestparam("userid")integer userid,integer pageno, @modelattribute("setplan")setplan setplan,@modelattribute("employee") employee employee) throws businessexception{ modelandview mav = new modelandview(); //通过住户id得到所有的住户所属方案 供下拉列表框使用 list<planinfo> planinfoofuser = planinfobo.selectplaninfobyuserid(userid); //分页 pagebean pb = null; pb = new pagebean(pageno,setplanbo.selectsetplanbyuseridcount(userid)); //通过住户id得到方案的时间分配方式 分页显示 方案的时间模块 list<setplan> setplanall = setplanbo.selectsetplanbyuseridbypage(userid, pb);// int useridcur = userid;// //提取数据库中已经存储的 开始和结束日期 供给前台判断// list<string> startdatestring = setplanbo.selectstartdatebyuserid(userid);// list<string> enddatestring = setplanbo.selectenddatebyuserid(userid);// int countrow = pb.gettotalcount();// list<date> startdateallofuser = new arraylist<date>();// list<date> enddateallofuser = new arraylist<date>();// simpledateformat insdf = new simpledateformat("yyyy-mm-dd"); // for(int i = 0;i<countrow;i++){// try {// startdateallofuser.add(i,insdf.parse(startdatestring.get(i)));// } catch (parseexception e) {// e.printstacktrace();// }// try {// enddateallofuser.add(i,insdf.parse(enddatestring.get(i)));// } catch (parseexception e) {// e.printstacktrace();// }// } // string[] startdatestringarray = new string[countrow]; // string[] enddatestringarray = new string[countrow]; // for(int i = 0;i<countrow;i++){// startdatestringarray[i]= startdatestring.get(i);// enddatestringarray[i]=enddatestring.get(i);// }// string[][] startandenddateofuser = new string[countrow][2];// for(int i = 0;i<countrow;i++){// startandenddateofuser[i][0]= startdatestring.get(i);// startandenddateofuser[i][1]= enddatestring.get(i);// }// mav.addobject("startandenddateofuser", startandenddateofuser);// mav.addobject("startdatestringarray", startdatestringarray);// mav.addobject("enddatestringarray", enddatestringarray);// mav.addobject("startdateallofuser", startdateallofuser);// mav.addobject("enddateallofuser", enddateallofuser);// mav.addobject("countrow", countrow);// mav.addobject("useridcur", useridcur);// mav.addobject("setplan", setplan);// mav.addobject("employee", employee); mav.addobject("planinfoofuser", planinfoofuser); mav.addobject("setplanall", setplanall); mav.addobject("paging", pb); mav.setviewname("/plan/listsetplanall"); return mav; }
//部分为后台传入前台的主要代码
以下是js代码:
function createsetplanpage(startandenddateofuser,countrow){ var i=0; for(i = 0;i<countrow;i++){ var startdatestring=new date(startandenddateofuser[i][0]); var enddatestring=new date(startandenddateofuser[i][1]); if(selstartdate>=startdatestring && selstartdate<=enddatestring){ alert("方案实施时间有重叠,请重新选择开始时间!"); continue failcreat; } else if(selenddate>=startdatestring && selenddate<=enddatestring){ alert("方案实施时间有重叠,请重新选择结束时间!"); continue failcreat; } else if (selstartdate<startdatestring && selenddate>enddatestring){ alert("方案实施时间有重叠,请重新选择开始时间和结束时间!"); continue failcreat; } } alert("方案创建成功!本方案供暖日,从:"+starty+"年"+startm+"月"+startd+"日,第"+startw+"周 至 "+endy+"年"+endm+"月"+endd+"日,第"+endw+"周"); $("#createform").submit(); break; failcreat: alert("请重新创建"); break; }