add.html 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <!DOCTYPE html>
  2. <html lang="zh" xmlns:th="http://www.thymeleaf.org" >
  3. <head>
  4. <th:block th:include="include :: header('新增文章管理')" />
  5. <th:block th:include="include :: datetimepicker-css" />
  6. <th:block th:include="include :: bootstrap-fileinput-css"/>
  7. <th:block th:include="include :: summernote-css" />
  8. </head>
  9. <body class="white-bg">
  10. <div class="wrapper wrapper-content animated fadeInRight ibox-content">
  11. <form class="form-horizontal m" id="form-info-add">
  12. <div class="form-group">
  13. <label class="col-sm-3 control-label is-required">新闻标题:</label>
  14. <div class="col-sm-8">
  15. <input name="newsInfoTitle" class="form-control" type="text" required>
  16. </div>
  17. </div>
  18. <div class="form-group">
  19. <label class="col-sm-3 control-label is-required">新闻作者:</label>
  20. <div class="col-sm-8">
  21. <input name="newsInfoAuthor" class="form-control" type="text" required>
  22. </div>
  23. </div>
  24. <div class="form-group">
  25. <label class="col-sm-3 control-label">新闻来源:</label>
  26. <div class="col-sm-8">
  27. <input name="newsInfoSource" class="form-control" type="text">
  28. </div>
  29. </div>
  30. <div class="form-group">
  31. <label class="col-sm-3 control-label is-required">新闻正文:</label>
  32. <div class="col-sm-8">
  33. <input type="hidden" class="form-control" name="newsInfoContent">
  34. <div class="summernote" id="newsInfoContent"></div>
  35. </div>
  36. </div>
  37. <div class="form-group">
  38. <label class="col-sm-3 control-label is-required">新闻时间:</label>
  39. <div class="col-sm-8">
  40. <div class="input-group date">
  41. <input name="newsInfoTime" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
  42. <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
  43. </div>
  44. </div>
  45. </div>
  46. <div class="form-group">
  47. <label class="col-sm-3 control-label">新闻点击数量:</label>
  48. <div class="col-sm-8">
  49. <input name="newsInfoClick" class="form-control" type="text">
  50. </div>
  51. </div>
  52. <div class="form-group">
  53. <label class="col-sm-3 control-label">创建新闻时间:</label>
  54. <div class="col-sm-8">
  55. <div class="input-group date">
  56. <input name="newsInfoInittime" class="form-control" placeholder="yyyy-MM-dd" type="text">
  57. <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
  58. </div>
  59. </div>
  60. </div>
  61. <div class="form-group">
  62. <label class="col-sm-3 control-label">是否是轮播(0不是,1是):</label>
  63. <div class="col-sm-8">
  64. <input name="newsInfoCarousel" class="form-control" type="text">
  65. </div>
  66. </div>
  67. <div class="form-group">
  68. <label class="col-sm-3 control-label">封面标题:</label>
  69. <div class="col-sm-8">
  70. <input type="hidden" name="newsInfoUrl">
  71. <div class="file-loading">
  72. <input class="form-control file-upload" id="newsInfoUrl" name="file" type="file">
  73. </div>
  74. </div>
  75. </div>
  76. <div class="form-group">
  77. <label class="col-sm-3 control-label">用户作者id:</label>
  78. <div class="col-sm-8">
  79. <input name="newsInfoAuthorid" class="form-control" type="text">
  80. </div>
  81. </div>
  82. </form>
  83. </div>
  84. <th:block th:include="include :: footer" />
  85. <th:block th:include="include :: datetimepicker-js" />
  86. <th:block th:include="include :: bootstrap-fileinput-js"/>
  87. <th:block th:include="include :: summernote-js" />
  88. <script th:inline="javascript">
  89. var prefix = ctx + "system/info"
  90. $("#form-info-add").validate({
  91. focusCleanup: true
  92. });
  93. function submitHandler() {
  94. if ($.validate.form()) {
  95. $.operate.save(prefix + "/add", $('#form-info-add').serialize());
  96. }
  97. }
  98. $("input[name='newsInfoTime']").datetimepicker({
  99. format: "yyyy-mm-dd",
  100. minView: "month",
  101. autoclose: true
  102. });
  103. $("input[name='newsInfoInittime']").datetimepicker({
  104. format: "yyyy-mm-dd",
  105. minView: "month",
  106. autoclose: true
  107. });
  108. $(".file-upload").fileinput({
  109. uploadUrl: ctx + 'common/upload',
  110. maxFileCount: 1,
  111. autoReplace: true
  112. }).on('fileuploaded', function (event, data, previewId, index) {
  113. $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
  114. }).on('fileremoved', function (event, id, index) {
  115. $("input[name='" + event.currentTarget.id + "']").val('')
  116. })
  117. $(function() {
  118. $('.summernote').summernote({
  119. lang: 'zh-CN',
  120. dialogsInBody: true,
  121. callbacks: {
  122. onChange: function(contents, $edittable) {
  123. $("input[name='" + this.id + "']").val(contents);
  124. },
  125. onImageUpload: function(files) {
  126. var obj = this;
  127. var data = new FormData();
  128. data.append("file", files[0]);
  129. $.ajax({
  130. type: "post",
  131. url: ctx + "common/upload",
  132. data: data,
  133. cache: false,
  134. contentType: false,
  135. processData: false,
  136. dataType: 'json',
  137. success: function(result) {
  138. if (result.code == web_status.SUCCESS) {
  139. $('#' + obj.id).summernote('insertImage', result.url);
  140. } else {
  141. $.modal.alertError(result.msg);
  142. }
  143. },
  144. error: function(error) {
  145. $.modal.alertWarning("图片上传失败。");
  146. }
  147. });
  148. }
  149. }
  150. });
  151. });
  152. </script>
  153. </body>
  154. </html>