edit.html 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 :: summernote-css" />
  6. </head>
  7. <body class="white-bg">
  8. <div class="wrapper wrapper-content animated fadeInRight ibox-content">
  9. <form class="form-horizontal m" id="form-notice-edit" th:object="${notice}">
  10. <input id="noticeId" name="noticeId" th:field="*{noticeId}" type="hidden">
  11. <div class="form-group">
  12. <label class="col-sm-2 control-label is-required">公告标题:</label>
  13. <div class="col-sm-10">
  14. <input id="noticeTitle" name="noticeTitle" th:field="*{noticeTitle}" class="form-control" type="text" required>
  15. </div>
  16. </div>
  17. <div class="form-group">
  18. <label class="col-sm-2 control-label">公告类型:</label>
  19. <div class="col-sm-10">
  20. <select name="noticeType" class="form-control m-b" th:with="type=${@dict.getType('sys_notice_type')}">
  21. <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{noticeType}"></option>
  22. </select>
  23. </div>
  24. </div>
  25. <div class="form-group">
  26. <label class="col-sm-2 control-label">公告内容:</label>
  27. <div class="col-sm-10">
  28. <input id="noticeContent" name="noticeContent" th:field="*{noticeContent}" type="hidden">
  29. <div id="editor" class="summernote"></div>
  30. </div>
  31. </div>
  32. <div class="form-group">
  33. <label class="col-sm-2 control-label">公告状态:</label>
  34. <div class="col-sm-10">
  35. <div class="radio-box" th:each="dict : ${@dict.getType('sys_notice_status')}">
  36. <input type="radio" th:id="${dict.dictCode}" name="status" th:value="${dict.dictValue}" th:field="*{status}">
  37. <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
  38. </div>
  39. </div>
  40. </div>
  41. </form>
  42. </div>
  43. <th:block th:include="include :: footer" />
  44. <th:block th:include="include :: summernote-js" />
  45. <script type="text/javascript">
  46. var prefix = ctx + "system/notice";
  47. $(function() {
  48. $('.summernote').summernote({
  49. placeholder: '请输入公告内容',
  50. height : 192,
  51. lang : 'zh-CN',
  52. followingToolbar: false,
  53. callbacks: {
  54. onImageUpload: function (files) {
  55. sendFile(files[0], this);
  56. }
  57. }
  58. });
  59. var content = $("#noticeContent").val();
  60. $('#editor').summernote('code', content);
  61. });
  62. // 上传文件
  63. function sendFile(file, obj) {
  64. var data = new FormData();
  65. data.append("file", file);
  66. $.ajax({
  67. type: "POST",
  68. url: ctx + "common/upload",
  69. data: data,
  70. cache: false,
  71. contentType: false,
  72. processData: false,
  73. dataType: 'json',
  74. success: function(result) {
  75. if (result.code == web_status.SUCCESS) {
  76. $(obj).summernote('editor.insertImage', result.url, result.fileName);
  77. } else {
  78. $.modal.alertError(result.msg);
  79. }
  80. },
  81. error: function(error) {
  82. $.modal.alertWarning("图片上传失败。");
  83. }
  84. });
  85. }
  86. $("#form-notice-edit").validate({
  87. focusCleanup: true
  88. });
  89. function submitHandler() {
  90. if ($.validate.form()) {
  91. var sHTML = $('.summernote').summernote('code');
  92. $("#noticeContent").val(sHTML);
  93. $.operate.save(prefix + "/edit", $('#form-notice-edit').serialize());
  94. }
  95. }
  96. </script>
  97. </body>
  98. </html>