您好,登錄后才能下訂單哦!
簡介
日程系統(tǒng),繁瑣的月日期開始結(jié)束計算、當(dāng)前頁面開始的天數(shù)(跨月)。。。等等,麻煩的事情都交給FullCalendar,世界安靜了。
官網(wǎng)
https://fullcalendar.io/
使用
1、頁面引用
<link href='/contrast/assets/global/plugins/fullcalendar-3.2.0/fullcalendar.min.css' rel='stylesheet' /> <link href='/contrast/assets/global/plugins/fullcalendar-3.2.0/fullcalendar.print.min.css' rel='stylesheet' media='print' /> <script src='/contrast/assets/global/plugins/fullcalendar-3.2.0/lib/moment.min.js'></script> <script src='/contrast/assets/global/plugins/fullcalendar-3.2.0/lib/jquery.min.js'></script> <script src='/contrast/assets/global/plugins/fullcalendar-3.2.0/fullcalendar.min.js'></script> <script src='/contrast/assets/global/plugins/fullcalendar-3.2.0/locale-all.js'></script>
2、頁面代碼
<!-- 頁面容器 --> <div id='calendar'></div> <!-- 隱藏按鈕,ajax自動請求觸發(fā)驗證 --> <button id="zhibiao-btn" type="button" class="btn btn-primary" data-toggle="modal" data-target=".bs-example-modal-lg">Large modal</button> <script> /** * 業(yè)務(wù)約束(預(yù)警顏色說明) * #指標(biāo)符合率# * 紅色(#FF3333):<95% * ×××(#FFCC66):>95% * 綠色(#CCFFCC):=100% * 灰色(#CCCCCC):數(shù)據(jù)未上傳 */ $(document).ready(function() { var initialLocaleCode = 'zh-cn'; $('#calendar').fullCalendar({ header: { left: 'prev,next today', center: 'title', right: 'month,listMonth' }, firstDay:0, defaultDate: new Date(), locale: initialLocaleCode, buttonIcons: false, // show the prev/next text navLinks: true, // can click day/week names to navigate views editable: false, eventLimit: true, // allow "more" link when too many events events: 'warningcalendar/fhl_json', eventClick: function(calEvent, jsEvent, view) { seeDate = calEvent.start.format('YYYY-MM-DD'); req_zhibiaodetail(""); $("#zhibiao-btn").click(); } }); }); /** * 獲取符合率明細(xì) */ var seeDate = ""; function req_zhibiaodetail(JGDM,JGMC){ if(seeDate==""){alert("查看日期不能為空。");return;} if(JGDM==""){ if($("#jgList").html()!=undefined){ JGDM = $("#jgList li:eq(0)").attr("jgdm"); JGMC = $("#jgList li:eq(0)").text(); } } $.ajax({ type : "get", url : 'warningcalendar/show_fhl_detail_json', dataType : "json", data : {seeDate:seeDate,JGDM:JGDM}, success : function(data) { $('#zhibiaoDetail').html(data.ERRORCENTENT); }, error : function(reslt) { alert("您好,"+JGMC+"暫無符合率請查看其它機(jī)構(gòu)"); } }); } </script>
3、后臺代碼
/** * 機(jī)構(gòu)符合率 */ @SuppressWarnings("unchecked") @RequestMapping(value = "/fhl_json") @ResponseBody public List<HashMap<String, Object>> fhlJson(HttpServletRequest request, HttpServletResponse response){ String sql = "select t1.d \"start\", nvl(t2.\"title\", '數(shù)據(jù)未上傳' ) \"title\", nvl (t2.\"color\", '#CCCCCC') \"color\" from ( select to_char ( to_date (#{startDate}, 'yyyy-MM-dd') + rownum - 1, 'yyyy-mm-dd' ) d from user_objects where to_date (#{startDate}, 'yyyy-MM-dd') + rownum - 1 <= to_date (#{endDate}, 'yyyy-MM-dd')) t1 left join ( select to_char (ERRORDATE, 'yyyy-MM-dd') \"start\", '符合率:' || trunc (sum(total) / count(total), 2) || '%' \"title\", case when trunc (sum(total) / count(total), 2) < 95 then '#FF3333' when trunc (sum(total) / count(total), 2) between 95 and 100 then '#FFCC66' when trunc (sum(total) / count(total), 2) = 100 then '#FFCC66' end as \"color\" from SYS_TONG_QUOTA_ERROR t where t .ERRORDATE >= to_date (#{startDate}, 'yyyy-MM-dd') and t .ERRORDATE <= to_date (#{endDate}, 'yyyy-MM-dd')"; HashMap<String, Object> prm = new HashMap<String, Object>(); //設(shè)置當(dāng)前日歷起止時間 prm.put("startDate", request.getParameter("start")); prm.put("endDate", request.getParameter("end")); //獲取當(dāng)前用戶 HashMap<String, Object> user = (HashMap<String, Object>) request.getSession().getAttribute(SessionUtils.SESSION_USER_KEY); //非管理只看本院 if(null!=user&&user.get("ISADMIN").equals("yiyuan")){ sql+=" and JGDM=#{jgdm}"; prm.put("jgdm", user.get("YLJGDM")); } sql+=" group by to_char (ERRORDATE, 'yyyy-MM-dd')) t2 on t1. d = t2.\"start\" where to_date(t1.d,'yyyy-mm-dd')<sysdate "; return curdManager.findList(sql, prm); }
FullCalendar默認(rèn)提交日期開始結(jié)束:“start”“end”
返回的格式如上Sql展示
以上,Ok!
使用ajax全程不用處理,扔給FullCalendar全程自動化
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。