calendar.html 8.1 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. </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')}" class="btn btn-sm btn-warning">表格显示</a>
  40. <a href="{:url('add',[],'')}/id/0?isCalendar=1&type=1" class="btn btn-sm btn-primary">新增计划</a>
  41. <a href="{:url('plan')}?type=2" class="btn btn-sm btn-success">复制月计划</a>
  42. <a href="{:url('batch')}?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. 设备维保任务列表
  52. </div>
  53. </div>
  54. <div class="panel-body">
  55. <div id="calendar"></div>
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. </div>
  61. {/block}
  62. {block name="script"}
  63. <script>
  64. var url = "{:url('DeviceTask/taskjson')}";
  65. var date = new Date();
  66. var d = date.getDate();
  67. var m = date.getMonth();
  68. var y = date.getFullYear();
  69. var calendar = $('#calendar').fullCalendar({
  70. firstDay: 1,
  71. locale:'zh-cn',
  72. currentTimezone: 'Asia/Shanghai',
  73. eventLimit: false, //多个记录,显示更多查看
  74. buttonText: {
  75. prev: '<',
  76. next: '>',
  77. prevYear: '去年',
  78. nextYear: '明年',
  79. today: '今天',
  80. month: '月',
  81. week: '周',
  82. day: '日'
  83. },
  84. header: {
  85. left: 'prev,next today',
  86. center: 'title',
  87. right: 'month,agendaWeek,agendaDay'
  88. },
  89. events: url,
  90. loading: function(bool) {
  91. if (bool) {
  92. var layerIndex = layer.load(1);
  93. } else {
  94. layer.closeAll('loading');
  95. }
  96. },
  97. eventRender: function(event, element) {
  98. element.html(event.title);
  99. },
  100. editable: false,
  101. selectable: true,
  102. selectHelper: true,
  103. select: function(start, end, allDay) {
  104. var start = formatDateTime(new Date(start));
  105. var end = formatDateTime(new Date(end));
  106. var addurl = "{:url('DeviceTask/add',[],'')}/id/0?type=1&start=" + start + "&end=" + end;
  107. lay_open("添加计划任务", addurl);
  108. calendar.fullCalendar('unselect');
  109. }
  110. ,
  111. eventClick: function(calEvent, jsEvent, view) {
  112. layer.confirm('请选择您想做的操作', {
  113. icon: 3,
  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('DeviceTask/add',[],'')}/id/0?type=1&start=" + start + "&end=" + end;
  121. lay_open("添加计划任务", addurl);
  122. calendar.fullCalendar('unselect');
  123. },
  124. btn2: function(index) {
  125. layer.close(index);
  126. var editurl = "{:url('DeviceTask/add',[],'')}/id/"+calEvent.taskid+"?type=1";
  127. lay_open("编辑/查看", editurl);
  128. },
  129. btn3: 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("DeviceTask/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}