add.html 7.8 KB

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