edit.html 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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. <div class="input-group date">
  35. <input name="newsInfoTime" th:value="${#dates.format(newsInfo.newsInfoTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
  36. <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
  37. </div>
  38. </div>
  39. </div>
  40. <div class="form-group">
  41. <label class="col-sm-3 control-label">新闻点击数量:</label>
  42. <div class="col-sm-8">
  43. <input name="newsInfoClick" th:field="*{newsInfoClick}" class="form-control" type="text">
  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. <div class="input-group date">
  50. <input name="newsInfoInittime" th:value="${#dates.format(newsInfo.newsInfoInittime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
  51. <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
  52. </div>
  53. </div>
  54. </div>
  55. <div class="form-group">
  56. <label class="col-sm-3 control-label is-required">新闻类型:</label>
  57. <div class="col-sm-8">
  58. <select name="newsInfoType" class="form-control m-b" th:with="type=${@dict.getType('sys_info_word_type')}" required>
  59. <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{newsInfoType}"></option>
  60. </select>
  61. </div>
  62. </div>
  63. <div class="form-group">
  64. <label class="col-sm-3 control-label">是否是轮播(0不是,1是):</label>
  65. <div class="col-sm-8">
  66. <div class="radio-box" th:each="dict : ${@dict.getType('sys_0_1')}">
  67. <input type="radio" th:id="${'newsInfoCarousel_' + dict.dictCode}" name="newsInfoCarousel" th:value="${dict.dictValue}" th:field="*{newsInfoCarousel}">
  68. <label th:for="${'newsInfoCarousel_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
  69. </div>
  70. </div>
  71. </div>
  72. <div class="form-group">
  73. <label class="col-sm-3 control-label">是否为静态轮播(0不是,1是):</label>
  74. <div class="col-sm-8">
  75. <div class="radio-box" th:each="dict : ${@dict.getType('sys_0_1')}">
  76. <input type="radio" th:id="${'newsInfoSc_' + dict.dictCode}" name="newsInfoSc" th:value="${dict.dictValue}" th:field="*{newsInfoSc}">
  77. <label th:for="${'newsInfoSc_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
  78. </div>
  79. </div>
  80. </div>
  81. <div class="form-group">
  82. <label class="col-sm-3 control-label">是否为推荐文章(0不是,1是):</label>
  83. <div class="col-sm-8">
  84. <div class="radio-box" th:each="dict : ${@dict.getType('sys_0_1')}">
  85. <input type="radio" th:id="${'newsInfoRecommend_' + dict.dictCode}" name="newsInfoRecommend" th:value="${dict.dictValue}" th:field="*{newsInfoRecommend}">
  86. <label th:for="${'newsInfoRecommend_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
  87. </div>
  88. </div>
  89. </div>
  90. <div class="form-group">
  91. <label class="col-sm-3 control-label">封面地址:</label>
  92. <div class="col-sm-8">
  93. <input type="hidden" name="newsInfoUrl" th:field="*{newsInfoUrl}">
  94. <div class="file-loading">
  95. <input class="form-control file-upload" id="newsInfoUrl" name="file" type="file">
  96. </div>
  97. </div>
  98. </div>
  99. <div class="form-group">
  100. <label class="col-sm-3 control-label is-required">新闻正文:</label>
  101. <div class="col-sm-8">
  102. <input type="hidden" class="form-control" th:field="*{newsInfoContent}">
  103. <div class="summernote" id="newsInfoContent"></div>
  104. </div>
  105. </div>
  106. </form>
  107. </div>
  108. <th:block th:include="include :: footer" />
  109. <th:block th:include="include :: datetimepicker-js" />
  110. <th:block th:include="include :: bootstrap-fileinput-js"/>
  111. <th:block th:include="include :: summernote-js" />
  112. <script th:inline="javascript">
  113. var prefix = ctx + "system/info";
  114. $("#form-info-edit").validate({
  115. focusCleanup: true
  116. });
  117. function submitHandler() {
  118. if ($.validate.form()) {
  119. $.operate.save(prefix + "/edit", $('#form-info-edit').serialize());
  120. }
  121. }
  122. $("input[name='newsInfoTime']").datetimepicker({
  123. format: "yyyy-mm-dd",
  124. minView: "month",
  125. autoclose: true
  126. });
  127. $("input[name='newsInfoInittime']").datetimepicker({
  128. format: "yyyy-mm-dd",
  129. minView: "month",
  130. autoclose: true
  131. });
  132. $(".file-upload").each(function (i) {
  133. var val = $("input[name='" + this.id + "']").val()
  134. $(this).fileinput({
  135. 'uploadUrl': ctx + 'common/upload',
  136. initialPreviewAsData: true,
  137. initialPreview: [val],
  138. maxFileCount: 1,
  139. autoReplace: true
  140. }).on('fileuploaded', function (event, data, previewId, index) {
  141. $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
  142. }).on('fileremoved', function (event, id, index) {
  143. $("input[name='" + event.currentTarget.id + "']").val('')
  144. })
  145. $(this).fileinput('_initFileActions');
  146. });
  147. $(function() {
  148. $('.summernote').each(function(i) {
  149. $('#' + this.id).summernote({
  150. lang: 'zh-CN',
  151. dialogsInBody: true,
  152. callbacks: {
  153. onChange: function(contents, $edittable) {
  154. $("input[name='" + this.id + "']").val(contents);
  155. },
  156. onImageUpload: function(files) {
  157. var obj = this;
  158. var data = new FormData();
  159. data.append("file", files[0]);
  160. $.ajax({
  161. type: "post",
  162. url: ctx + "common/upload",
  163. data: data,
  164. cache: false,
  165. contentType: false,
  166. processData: false,
  167. dataType: 'json',
  168. success: function(result) {
  169. if (result.code == web_status.SUCCESS) {
  170. $('#' + obj.id).summernote('insertImage', result.url);
  171. } else {
  172. $.modal.alertError(result.msg);
  173. }
  174. },
  175. error: function(error) {
  176. $.modal.alertWarning("图片上传失败。");
  177. }
  178. });
  179. }
  180. }
  181. });
  182. var content = $("input[name='" + this.id + "']").val();
  183. $('#' + this.id).summernote('code', content);
  184. })
  185. });
  186. </script>
  187. </body>
  188. </html>