datetime.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <th:block th:include="include :: header('日期和时间')" />
  5. <th:block th:include="include :: datetimepicker-css" />
  6. </head>
  7. <body class="gray-bg">
  8. <div class="wrapper wrapper-content animated fadeInRight">
  9. <div class="row">
  10. <div class="col-sm-6">
  11. <div class="ibox float-e-margins">
  12. <div class="ibox-title">
  13. <h5>日期选择器 <small>https://github.com/smalot/bootstrap-datetimepicker</small></h5>
  14. </div>
  15. <div class="ibox-content">
  16. <div class="form-group">
  17. <label class="font-noraml">简单示例</label>
  18. <div class="input-group date">
  19. <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
  20. <input type="text" class="form-control" id="datetimepicker-demo-1" placeholder="yyyy-MM-dd HH:mm">
  21. </div>
  22. </div>
  23. <div class="form-group">
  24. <label class="font-noraml">显示年月日</label>
  25. <div class="input-group date">
  26. <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
  27. <input type="text" class="form-control" id="datetimepicker-demo-2" placeholder="yyyy-MM-dd">
  28. </div>
  29. </div>
  30. <div class="form-group">
  31. <label class="font-noraml">显示年月日时分秒</label>
  32. <div class="input-group date">
  33. <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
  34. <input type="text" class="form-control" id="datetimepicker-demo-3" placeholder="yyyy-MM-dd HH:mm:ss">
  35. </div>
  36. </div>
  37. <div class="form-group">
  38. <label class="font-noraml">带清空的按钮</label>
  39. <div class="input-group date form_date">
  40. <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
  41. <input class="form-control" size="16" type="text" readonly>
  42. <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
  43. </div>
  44. </div>
  45. <div class="form-group">
  46. <label class="font-noraml">日期范围选择</label>
  47. <div class="input-daterange input-group">
  48. <input type="text" class="input-sm form-control" id="datetimepicker-startTime" placeholder="yyyy-MM-dd"/>
  49. <span class="input-group-addon">到</span>
  50. <input type="text" class="input-sm form-control" id="datetimepicker-endTime" placeholder="yyyy-MM-dd"/>
  51. </div>
  52. </div>
  53. <hr>
  54. <div class="form-group">
  55. <label class="font-noraml">相关参数详细信息</label>
  56. <div><a href="http://doc.ruoyi.vip/ruoyi/document/zjwd.html#bootstrap-datetimepicker" target="_blank">http://doc.ruoyi.vip/ruoyi/document/zjwd.html#bootstrap-datetimepicker</a></div>
  57. </div>
  58. </div>
  59. </div>
  60. </div>
  61. <div class="col-sm-6">
  62. <div class="ibox float-e-margins">
  63. <div class="ibox-title">
  64. <h5>日期选择器 <small>https://github.com/sentsin/laydate</small></h5>
  65. </div>
  66. <div class="ibox-content">
  67. <div class="form-group">
  68. <label class="font-noraml">简单示例</label>
  69. <div class="input-group date">
  70. <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
  71. <input type="text" class="form-control" id="laydate-demo-1" placeholder="yyyy-MM-dd">
  72. </div>
  73. </div>
  74. <div class="form-group">
  75. <label class="font-noraml">显示年月日</label>
  76. <div class="input-group date">
  77. <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
  78. <input type="text" class="form-control" id="laydate-demo-2" placeholder="yyyy-MM-dd">
  79. </div>
  80. </div>
  81. <div class="form-group">
  82. <label class="font-noraml">显示年月日时分秒</label>
  83. <div class="input-group date">
  84. <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
  85. <input type="text" class="form-control" id="laydate-demo-3" placeholder="yyyy-MM-dd HH:mm:ss">
  86. </div>
  87. </div>
  88. <div class="form-group">
  89. <label class="font-noraml">单框范围选择</label>
  90. <div class="input-group date">
  91. <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
  92. <input type="text" class="form-control" id="laydate-demo-4" placeholder="yyyy-MM-dd - yyyy-MM-dd">
  93. </div>
  94. </div>
  95. <div class="form-group">
  96. <label class="font-noraml">日期范围选择</label>
  97. <div class="input-daterange input-group">
  98. <input type="text" class="input-sm form-control" id="laydate-startTime" placeholder="yyyy-MM-dd"/>
  99. <span class="input-group-addon">到</span>
  100. <input type="text" class="input-sm form-control" id="laydate-endTime" placeholder="yyyy-MM-dd"/>
  101. </div>
  102. </div>
  103. <hr>
  104. <div class="form-group">
  105. <label class="font-noraml">相关参数详细信息</label>
  106. <div><a href="http://doc.ruoyi.vip/ruoyi/document/zjwd.html#laydate" target="_blank">http://doc.ruoyi.vip/ruoyi/document/zjwd.html#laydate</a></div>
  107. </div>
  108. </div>
  109. </div>
  110. </div>
  111. </div>
  112. </div>
  113. <th:block th:include="include :: footer" />
  114. <th:block th:include="include :: datetimepicker-js" />
  115. <script type="text/javascript">
  116. $(function(){
  117. <!-- datetimepicker示例 -->
  118. $("#datetimepicker-demo-1").datetimepicker();
  119. $("#datetimepicker-demo-2").datetimepicker({
  120. format: "yyyy-mm-dd",
  121. minView: "month",
  122. autoclose: true
  123. });
  124. $("#datetimepicker-demo-3").datetimepicker({
  125. format: "yyyy-mm-dd hh:ii:ss",
  126. autoclose: true
  127. });
  128. $('.form_date').datetimepicker({
  129. format: "yyyy-mm-dd",
  130. minView: "month",
  131. autoclose: true
  132. });
  133. $("#datetimepicker-startTime").datetimepicker({
  134. format: 'yyyy-mm-dd',
  135. minView: "month",
  136. todayBtn: true,
  137. autoclose: true,
  138. endDate : new Date(),
  139. }).on('changeDate', function(event) {
  140. event.preventDefault();
  141. event.stopPropagation();
  142. var startTime = event.date;
  143. $('#datetimepicker-endTime').datetimepicker('setStartDate', startTime);
  144. });
  145. $("#datetimepicker-endTime").datetimepicker({
  146. format: 'yyyy-mm-dd',
  147. minView: "month",
  148. todayBtn: true,
  149. autoclose: true,
  150. endDate : new Date(),
  151. }).on('changeDate', function(event) {
  152. event.preventDefault();
  153. event.stopPropagation();
  154. var endTime = event.date;
  155. $("#datetimepicker-startTime").datetimepicker('setEndDate', endTime);
  156. });
  157. <!-- laydate示例 -->
  158. layui.use('laydate', function(){
  159. var laydate = layui.laydate;
  160. laydate.render({
  161. elem: '#laydate-demo-1'
  162. });
  163. laydate.render({
  164. elem: '#laydate-demo-2',
  165. type: 'date'
  166. });
  167. laydate.render({
  168. elem: '#laydate-demo-3',
  169. type: 'datetime',
  170. trigger: 'click'
  171. });
  172. laydate.render({
  173. elem: '#laydate-demo-4',
  174. range: true
  175. });
  176. var startDate = laydate.render({
  177. elem: '#laydate-startTime',
  178. max: $('#laydate-endTime').val(),
  179. theme: 'molv',
  180. trigger: 'click',
  181. done: function(value, date) {
  182. // 结束时间大于开始时间
  183. if (value !== '') {
  184. endDate.config.min.year = date.year;
  185. endDate.config.min.month = date.month - 1;
  186. endDate.config.min.date = date.date;
  187. } else {
  188. endDate.config.min.year = '';
  189. endDate.config.min.month = '';
  190. endDate.config.min.date = '';
  191. }
  192. }
  193. });
  194. var endDate = laydate.render({
  195. elem: '#laydate-endTime',
  196. min: $('#laydate-startTime').val(),
  197. theme: 'molv',
  198. trigger: 'click',
  199. done: function(value, date) {
  200. // 开始时间小于结束时间
  201. if (value !== '') {
  202. startDate.config.max.year = date.year;
  203. startDate.config.max.month = date.month - 1;
  204. startDate.config.max.date = date.date;
  205. } else {
  206. startDate.config.max.year = '';
  207. startDate.config.max.month = '';
  208. startDate.config.max.date = '';
  209. }
  210. }
  211. });
  212. });
  213. });
  214. </script>
  215. </body>
  216. </html>