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">公告标题:</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.isDefault == 'Y' ? true : false}">
  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. callbacks: {
  52. onImageUpload: function (files) {
  53. sendFile(files[0], this);
  54. }
  55. }
  56. });
  57. // 上传文件
  58. function sendFile(file, obj) {
  59. var data = new FormData();
  60. data.append("file", file);
  61. $.ajax({
  62. type: "POST",
  63. url: ctx + "common/upload",
  64. data: data,
  65. cache: false,
  66. contentType: false,
  67. processData: false,
  68. dataType: 'json',
  69. success: function(result) {
  70. if (result.code == web_status.SUCCESS) {
  71. $(obj).summernote('editor.insertImage', result.url, result.fileName);
  72. } else {
  73. $.modal.alertError(result.msg);
  74. }
  75. },
  76. error: function(error) {
  77. $.modal.alertWarning("图片上传失败。");
  78. }
  79. });
  80. }
  81. $("#form-notice-add").validate({
  82. focusCleanup: true
  83. });
  84. function submitHandler() {
  85. if ($.validate.form()) {
  86. var sHTML = $('.summernote').summernote('code');
  87. $("#noticeContent").val(sHTML);
  88. $.operate.save(prefix + "/add", $('#form-notice-add').serialize());
  89. }
  90. }
  91. </script>
  92. </body>
  93. </html>