对做过的功能做个记录吧,就为下次遇到同样的问题能够快速解决。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
$(function(){ //高度 minHeight(); //初始化加载添加页面 laydate.render({ elem: '#dutyCalendar', position: 'static', showBottom: false, theme: 'grid', ready: function (date) { var nowDate = date.year+'年'+date.month+'月'+date.date+'日'; setDateValue(date); var _nowDate=$("#selectedDate").val(); $("#nowDate").text(nowDate); $("#weekDate").text(getCurWeek(date)); getUserScheduleData(_nowDate); $("#reportList").load("${ctx}/oa/workprediction/oaWorkPrediction/loadAllList",{ "currentDate" : _nowDate}); }, change: function (value, date) { var chageDate = date.year+'年'+date.month+'月'+date.date+'日'; setDateValue(date); var _chageDate=$("#selectedDate").val(); $("#nowDate").text(chageDate); $("#weekDate").text(getCurWeek(date)); getUserScheduleData(_chageDate); $("#reportList").load("${ctx}/oa/workprediction/oaWorkPrediction/loadAllList",{ "currentDate" : _chageDate}); } }); }); $(window).resize(function(){ minHeight(); /* initialWidth(); */ }); function setDateValue(date) { if (date.month < 10) { date.month = "0" + date.month; } if (date.date < 10) { date.date = "0" + date.date; } $("#selectedDate").val(date.year + "-" + date.month + "-" + date.date); } function getUserScheduleData(_cdate) { var loadIndex = layer.load(1, { shade: [0.3, '#000'] //0.1透明度的白色背景 }); $.ajax({ url: "${ctx}/oa/workprediction/oaWorkPrediction/userPredictionDataInMonth?date=" + _cdate, method: 'get', dataType: 'json', success: function (data) { layer.close(loadIndex); $("td[lay-ymd]", ".layui-laydate-content").removeClass("GreenColor").removeClass("GreenColor"); $(data.dutiedList).each(function (i, d) { var data=formateDate(d.predictionDay,'yyyy-MM-dd'); var strs= new Array(); //定义一数组 strs=data.split("-"); //字符分割 var n=strs[0]; var y=strs[1]; //分割后的字符输出 var r=strs[2]; if (y< 10) { y = y.replace(/^0/, ''); } if (r < 10) { r = r.replace(/^0/, ''); } var data=n + "-" + y + "-" + r; $("td[lay-ymd='" + data + "']", ".layui-laydate-content").addClass("GreenColor").attr("logid", d.id);//染色 }); } }) } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
/** * 当前用户在指定日期所在月份的工作预报数据 * * @param date * @param request * @param response * @param model * @return */ @RequestMapping("userPredictionDataInMonth") @ResponseBody public String userPredictionDataInMonth(String date, HttpServletRequest request, HttpServletResponse response, Model model) { Map<String, Object> datas = Maps.newHashMap(); List<OaWorkPrediction> predictList = oaWorkPredictionService.findUserPredictList(UserUtils.getUser(), date); datas.put("dutiedList",predictList); return renderString(response, datas); } public List<OaWorkPrediction> findUserPredictList(User user, String dateStr) { OaWorkPrediction param = new OaWorkPrediction(); param.setCreateBy(user); Date searchDate = DateUtils.parseDate(dateStr); Calendar calendar = Calendar.getInstance(); //搜索日期对应的1号作为开始日期 calendar.setTime(searchDate); calendar.set(Calendar.HOUR, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); calendar.set(Calendar.DAY_OF_MONTH, 1); Date dateMin = calendar.getTime(); param.setBeginDate(dateMin); //当前时间所在日期作为结束日期 calendar.setTime(new Date()); calendar.set(Calendar.HOUR, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); Date dateMax = calendar.getTime(); param.setEndDate(dateMax); return dao.findUserPredictList(param); } |
1 2 3 4 5 6 7 8 9 10 11 |
<select id="findUserPredictList" resultType="OaWorkPrediction"> SELECT DISTINCT PREDICTION_DAY FROM oa_work_prediction a <include refid="oaWorkPredictionJoins"/> <where> a.del_flag = #{DEL_FLAG_NORMAL} AND (a.PREDICTION_DAY >= #{beginDate} AND a.PREDICTION_DAY <= #{endDate}) AND a.create_by = #{createBy.id} </where> </select> |