@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; }?
?