add.html 3.3 KB

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