0
0

calendar.html 8.8 KB

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