calendar_old.html 8.4 KB

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