calendar.html 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. {extend name="common/common2" /}
  2. {block name="main"}
  3. <script src="/static/fullcalendar-3.10.2/lib/jquery.min.js"></script>
  4. <script src='/static/fullcalendar-3.10.2/lib/moment.min.js'></script>
  5. <script src="/static/fullcalendar-3.10.2/fullcalendar.min.js"></script>
  6. <script src="/static/fullcalendar-3.10.2/locale/zh-cn.js"></script>
  7. <link rel="stylesheet" href="/static/fullcalendar-3.10.2/fullcalendar.min.css" />
  8. <link href='/static/fullcalendar-3.10.2/fullcalendar.print.min.css' rel='stylesheet' media='print' />
  9. <style>
  10. .bgstatus{
  11. display: inline-block;
  12. width: 60px;
  13. height: 20px;
  14. line-height: 20px;
  15. color: #fff;
  16. border-radius: 3px;
  17. text-align: center;
  18. }
  19. .bgs0{
  20. background-color: #777777;
  21. }
  22. .bgs1{
  23. background-color: #478fca;
  24. }
  25. .bgs2{
  26. background-color: #69aa46;
  27. }
  28. .bgs3{
  29. background-color: #dd5a43;
  30. }
  31. .bgs5{
  32. background-color: #53a2a7;
  33. }
  34. .bgs6{
  35. background-color: #5b53a7;
  36. }
  37. </style>
  38. <div class="ibox float-e-margins">
  39. {if $back >0}
  40. <div class="ibox-content">
  41. <div class="row">
  42. <div class="col-xs-3">
  43. <a href="{:url('year',[],'')}?year={$year}" class="btn btn-sm btn-primary">返回</a>
  44. </div>
  45. </div>
  46. </div>
  47. {/if}
  48. <div class="ibox-content">
  49. <div id="calendar"></div>
  50. </div>
  51. </div>
  52. {/block}
  53. {block name="script"}
  54. <script>
  55. var url = "{:url('calendardata')}";
  56. var date = new Date();
  57. var d = date.getDate();
  58. var m = date.getMonth();
  59. var y = date.getFullYear();
  60. var calendar = $('#calendar').fullCalendar({
  61. firstDay: 1,
  62. locale:'zh-cn',
  63. defaultDate:'{$curMonth}',
  64. currentTimezone: 'Asia/Shanghai',
  65. eventLimit: false, //多个记录,显示更多查看
  66. buttonText: {
  67. prev: '<',
  68. next: '>',
  69. prevYear: '去年',
  70. nextYear: '明年',
  71. today: '今天',
  72. month: '月',
  73. week: '周',
  74. day: '日'
  75. },
  76. header: {
  77. left: 'prev,next today',
  78. center: 'title',
  79. right: 'month,agendaWeek,agendaDay'
  80. },
  81. events: url,
  82. loading: function(bool) {
  83. if (bool) {
  84. var layerIndex = layer.load(1);
  85. } else {
  86. layer.closeAll('loading');
  87. }
  88. },
  89. eventRender: function(event, element) {
  90. element.html(event.title);
  91. },
  92. editable: false,
  93. selectable: true,
  94. selectHelper: true,
  95. select: function(start, end, allDay) {
  96. // var start = formatDateTime(new Date(start));
  97. // var end = formatDateTime(new Date(end));
  98. // var addurl = "{:url('edit',[],false,false)}/id/0/mode/?type=1&start=" + start + "&end=" + end;
  99. // lay_open("添加计划任务", addurl);
  100. // calendar.fullCalendar('unselect');
  101. }
  102. ,
  103. eventClick: function(calEvent, jsEvent, view) {
  104. if(calEvent.status == 0){
  105. var editurl = "{:url('edit',[],'')}/id/"+calEvent.taskid;
  106. lay_open("编辑", editurl);
  107. }else{
  108. var editurl = "{:url('detail',[],'')}/id/"+calEvent.taskid;
  109. lay_open("查看", editurl);
  110. }
  111. // layer.confirm('请选择您想做的操作', {
  112. // icon: 3,
  113. // // btn: ['编辑', '删除'],
  114. // btn: ['编辑'],
  115. // skin: 'layer-ext-moon',
  116. // // btn1: function(index) {
  117. // // layer.close(index);
  118. // // var start = formatDateTime(new Date(calEvent.start));
  119. // // var end = formatDateTime(new Date(calEvent.end));
  120. // // var addurl = "{:url('PatrolTask/add',[],'')}/id/0/mode/?type=1&start=" + start + "&end=" + end;
  121. // // lay_open("添加计划任务", addurl);
  122. // // calendar.fullCalendar('unselect');
  123. // // },
  124. // btn1: function(index) {
  125. // layer.close(index);
  126. // var editurl = "{:url('edit',[],'')}/id/"+calEvent.taskid;
  127. // lay_open("编辑/查看", editurl);
  128. // },
  129. // /*btn2: function(index) {
  130. // layer.close(index);
  131. // layer.confirm('您确定要删除?', {
  132. // icon: 3,
  133. // btn: ['删除', '取消'],
  134. // skin: 'layer-ext-moon',
  135. // yes: function (index2) {
  136. // layer.close(index2);
  137. // $.ajax({
  138. // url: '{:url("PatrolTask/del",[],"")}/id/' + calEvent.taskid,
  139. // type: "GET",
  140. // success: function (result) {
  141. // if (result.code == 1) {
  142. // calendar.fullCalendar('removeEvents', function (ev) {
  143. // return (ev._id == calEvent._id);
  144. // });
  145. // } else {
  146. // layer.alert(result.msg, {
  147. // icon: 2,
  148. // skin: 'layer-ext-moon',
  149. // yes: function (index3) {
  150. // layer.close(index3);
  151. // }
  152. // });
  153. // }
  154. // },
  155. // error: function (result) {
  156. // layer.alert('请求出错,请重试', {
  157. // icon: 2,
  158. // skin: 'layer-ext-moon',
  159. // yes: function (index3) {
  160. // layer.close(index3);
  161. // }
  162. // });
  163. // }
  164. // });
  165. // }
  166. // });
  167. // }*/
  168. // });
  169. }
  170. });
  171. var formatDateTime = function(date) {
  172. date = new Date(date.getTime() + date.getTimezoneOffset() * 60000);
  173. var y = date.getFullYear();
  174. var m = date.getMonth() + 1;
  175. m = m < 10 ? ('0' + m) : m;
  176. var d = date.getDate();
  177. d = d < 10 ? ('0' + d) : d;
  178. var h = date.getHours();
  179. h = h < 10 ? ('0' + h) : h;
  180. var minute = date.getMinutes();
  181. minute = minute < 10 ? ('0' + minute) : minute;
  182. var second = date.getSeconds();
  183. second = second < 10 ? ('0' + second) : second;
  184. return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + second;
  185. };
  186. function lay_open (title,url) {
  187. layer.open({
  188. type: 2,
  189. title: title,
  190. shadeClose: true,
  191. shade: 0.3,
  192. maxmin: true,
  193. area: ['90%', '90%'],
  194. content: url,
  195. end: function () {
  196. }
  197. });
  198. }
  199. </script>
  200. {/block}