edit.html 7.9 KB

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