calendar.html 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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">
  39. <div class="alert alert-info">
  40. 不同颜色的背景代表不同的任务状态:
  41. <span class="bgstatus bgs0">未执行</span>
  42. <span class="bgstatus bgs1">执行中</span>
  43. <span class="bgstatus bgs2">已完成</span>
  44. <span class="bgstatus bgs3">未完成</span>
  45. <span class="bgstatus bgs5">中断</span>
  46. <span class="bgstatus bgs6">已关闭</span>
  47. </div>
  48. <div class="ibox-content">
  49. <div class="row">
  50. <div class="col-xs-8">
  51. <a href="{:url('index')}" class="btn btn-sm btn-warning">表格显示</a>
  52. </div>
  53. </div>
  54. </div>
  55. <div class="ibox-content">
  56. <div class="panel-group">
  57. <div class="panel panel-default">
  58. <div class="panel-heading clearfix">
  59. <div class="btn-group pull-left">
  60. 绿化养护任务列表
  61. </div>
  62. </div>
  63. <div class="panel-body">
  64. <div id="calendar"></div>
  65. </div>
  66. </div>
  67. </div>
  68. </div>
  69. </div>
  70. {/block}
  71. {block name="script"}
  72. <script>
  73. var url = "{:url('GreenTask/taskjson')}";
  74. var date = new Date();
  75. var d = date.getDate();
  76. var m = date.getMonth();
  77. var y = date.getFullYear();
  78. var calendar = $('#calendar').fullCalendar({
  79. firstDay: 1,
  80. locale:'zh-cn',
  81. currentTimezone: 'Asia/Shanghai',
  82. eventLimit: false, //多个记录,显示更多查看
  83. buttonText: {
  84. prev: '<',
  85. next: '>',
  86. prevYear: '去年',
  87. nextYear: '明年',
  88. today: '今天',
  89. month: '月',
  90. week: '周',
  91. day: '日'
  92. },
  93. header: {
  94. left: 'prev,next today',
  95. center: 'title',
  96. right: 'month,agendaWeek,agendaDay'
  97. },
  98. events: url,
  99. loading: function(bool) {
  100. if (bool) {
  101. var layerIndex = layer.load(1);
  102. } else {
  103. layer.closeAll('loading');
  104. }
  105. },
  106. eventRender: function(event, element) {
  107. element.html(event.title);
  108. },
  109. editable: false,
  110. selectable: true,
  111. selectHelper: true,
  112. select: function(start, end, allDay) {
  113. // var start = formatDateTime(new Date(start));
  114. // var end = formatDateTime(new Date(end));
  115. // var addurl = "{:url('PatrolTask/add',[],'')}/id/0?type=1&start=" + start + "&end=" + end;
  116. // lay_open("添加计划任务", addurl);
  117. // calendar.fullCalendar('unselect');
  118. }
  119. ,
  120. eventClick: function(calEvent, jsEvent, view) {
  121. if(calEvent.status != 0){
  122. return false;
  123. }
  124. layer.confirm('请选择您想做的操作', {
  125. icon: 3,
  126. // btn: ['编辑', '删除'],
  127. btn: ['编辑'],
  128. skin: 'layer-ext-moon',
  129. // btn1: function(index) {
  130. // layer.close(index);
  131. // var start = formatDateTime(new Date(calEvent.start));
  132. // var end = formatDateTime(new Date(calEvent.end));
  133. // var addurl = "{:url('PatrolTask/add',[],'')}/id/0?type=1&start=" + start + "&end=" + end;
  134. // lay_open("添加计划任务", addurl);
  135. // calendar.fullCalendar('unselect');
  136. // },
  137. btn1: function(index) {
  138. layer.close(index);
  139. var editurl = "{:url('GreenTask/add',[],'')}/id/"+calEvent.taskid+"?type=1";
  140. lay_open("编辑/查看", editurl);
  141. },
  142. /*btn2: function(index) {
  143. layer.close(index);
  144. layer.confirm('您确定要删除?', {
  145. icon: 3,
  146. btn: ['删除', '取消'],
  147. skin: 'layer-ext-moon',
  148. yes: function (index2) {
  149. layer.close(index2);
  150. $.ajax({
  151. url: '{:url("PatrolTask/del",[],"")}/id/' + calEvent.taskid,
  152. type: "GET",
  153. success: function (result) {
  154. if (result.code == 1) {
  155. calendar.fullCalendar('removeEvents', function (ev) {
  156. return (ev._id == calEvent._id);
  157. });
  158. } else {
  159. layer.alert(result.msg, {
  160. icon: 2,
  161. skin: 'layer-ext-moon',
  162. yes: function (index3) {
  163. layer.close(index3);
  164. }
  165. });
  166. }
  167. },
  168. error: function (result) {
  169. layer.alert('请求出错,请重试', {
  170. icon: 2,
  171. skin: 'layer-ext-moon',
  172. yes: function (index3) {
  173. layer.close(index3);
  174. }
  175. });
  176. }
  177. });
  178. }
  179. });
  180. }*/
  181. });
  182. }
  183. });
  184. var formatDateTime = function(date) {
  185. date = new Date(date.getTime() + date.getTimezoneOffset() * 60000);
  186. var y = date.getFullYear();
  187. var m = date.getMonth() + 1;
  188. m = m < 10 ? ('0' + m) : m;
  189. var d = date.getDate();
  190. d = d < 10 ? ('0' + d) : d;
  191. var h = date.getHours();
  192. h = h < 10 ? ('0' + h) : h;
  193. var minute = date.getMinutes();
  194. minute = minute < 10 ? ('0' + minute) : minute;
  195. var second = date.getSeconds();
  196. second = second < 10 ? ('0' + second) : second;
  197. return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + second;
  198. };
  199. function lay_open (title,url) {
  200. layer.open({
  201. type: 2,
  202. title: title,
  203. shadeClose: true,
  204. shade: 0.3,
  205. maxmin: true,
  206. area: ['90%', '90%'],
  207. content: url,
  208. end: function () {
  209. }
  210. });
  211. }
  212. </script>
  213. {/block}