add.html 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. <input type="hidden" name="globalUserIds" id="globalUserIds">
  11. <input type="hidden" name="globalDeptIds" id="globalDeptIds">
  12. <div class="form-group">
  13. <label class="label_wid control-label is-required">公告标题:</label>
  14. <div class="col-sm-5">
  15. <input id="noticeTitle" name="noticeTitle" class="form-control" type="text" required>
  16. </div>
  17. </div>
  18. <div class="form-group">
  19. <label class="label_wid control-label">公告类型:</label>
  20. <div class="col-sm-5">
  21. <select name="noticeType" class="form-control m-b" th:with="type=${@dict.getType('sys_notice_type')}">
  22. <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
  23. </select>
  24. </div>
  25. </div>
  26. <div class="form-group">
  27. <label class="label_wid control-label">公告内容:</label>
  28. <div class="col-sm-5">
  29. <input id="noticeContent" name="noticeContent" type="hidden">
  30. <div class="summernote"></div>
  31. </div>
  32. </div>
  33. <div class="form-group">
  34. <label class="label_wid control-label">公告状态:</label>
  35. <div class="col-sm-5">
  36. <div class="radio-box" th:each="dict : ${@dict.getType('sys_notice_status')}">
  37. <input type="radio" th:id="${dict.dictCode}" name="status" th:value="${dict.dictValue}"
  38. th:checked="${dict.default}">
  39. <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
  40. </div>
  41. </div>
  42. </div>
  43. <div class="form-group">
  44. <label class="label_wid control-label">是否群发:</label>
  45. <div class="col-sm-5">
  46. <select name="isGroupNotice" class="form-control m-b" onchange="changeGroupNotice(this)">
  47. <option value="1">是</option>
  48. <option value="0">否</option>
  49. </select>
  50. </div>
  51. </div>
  52. <input name="deptId" type="hidden" id="treeId"/>
  53. <button onclick="selectDeptTree()" class="hidden-group" hidden>接收部门</button>
  54. <ul id="deptUL" class="hidden-group" >
  55. </ul>
  56. <button onclick="confirmReport()" class="hidden-group" hidden>接收人员</button>
  57. <ul id="userUL" class="hidden-group" >
  58. </ul>
  59. </form>
  60. </div>
  61. <th:block th:include="include :: footer"/>
  62. <th:block th:include="include :: summernote-js"/>
  63. <script type="text/javascript">
  64. //是否群发
  65. function changeGroupNotice(that) {
  66. var isGroupNotice = $(that).val();
  67. //alert(isGroupNotice)
  68. if(isGroupNotice == 1){//群发模式 关闭人员选择器
  69. $(".hidden-group").hide();
  70. }else {//选择模式 打开人员选择器
  71. $(".hidden-group").show();
  72. }
  73. }
  74. var prefix = ctx + "system/notice";
  75. $('.summernote').summernote({
  76. placeholder: '请输入公告内容',
  77. height: 192,
  78. lang: 'zh-CN',
  79. followingToolbar: false,
  80. callbacks: {
  81. onImageUpload: function (files) {
  82. sendFile(files[0], this);
  83. }
  84. }
  85. });
  86. // 上传文件
  87. function sendFile(file, obj) {
  88. var data = new FormData();
  89. data.append("file", file);
  90. $.ajax({
  91. type: "POST",
  92. url: ctx + "common/upload",
  93. data: data,
  94. cache: false,
  95. contentType: false,
  96. processData: false,
  97. dataType: 'json',
  98. success: function (result) {
  99. if (result.code == web_status.SUCCESS) {
  100. $(obj).summernote('editor.insertImage', result.url, result.fileName);
  101. } else {
  102. $.modal.alertError(result.msg);
  103. }
  104. },
  105. error: function (error) {
  106. $.modal.alertWarning("图片上传失败。");
  107. }
  108. });
  109. }
  110. $("#form-notice-add").validate({
  111. focusCleanup: true
  112. });
  113. function submitHandler() {
  114. if ($.validate.form()) {
  115. var sHTML = $('.summernote').summernote('code');
  116. $("#noticeContent").val(sHTML);
  117. $.operate.save(prefix + "/add", $('#form-notice-add').serialize());
  118. }
  119. }
  120. /**选择归属部门**/
  121. function selectDeptTree() {
  122. var treeId = $("#treeId").val();
  123. var deptId = $.common.isEmpty(treeId) ? "100" : $("#treeId").val();
  124. var url = ctx + "system/dept/selectDeptTree/" + deptId;
  125. var options = {
  126. title: '选择部门',
  127. width: "380",
  128. url: url,
  129. callBack: doSubmit
  130. };
  131. $.modal.openOptions(options);
  132. }
  133. function doSubmit(index, layero){
  134. var tree = layero.find("iframe")[0].contentWindow.$._tree;
  135. if ($.tree.notAllowParents(tree)) {
  136. var body = layer.getChildFrame('body', index);
  137. $("#treeId").val(body.find('#treeId').val());
  138. $("#treeName").val(body.find('#treeName').val());
  139. var cancle = $("<button>X</button>");
  140. var li = $("<li>").text(body.find('#treeName').val()).append(cancle);
  141. var hidden = $("<input type='hidden' class='dept-li-data'>").val(body.find('#treeId').val());
  142. li.append(hidden);
  143. $("#deptUL").append(li);
  144. cancle.click(function () {
  145. li.remove()
  146. });
  147. var globalDeptIds = '';
  148. var deptIdArray = document.getElementsByClassName("dept-li-data");
  149. for (var i = 0; i < deptIdArray.length; i++) {
  150. //alert(deptIdArray[i].value)
  151. globalDeptIds += deptIdArray[i].value + ",";
  152. }
  153. if(globalDeptIds.startsWith(",") != -1){
  154. globalDeptIds = globalDeptIds.substr(0,globalDeptIds.length-1);
  155. }
  156. $("#globalDeptIds").val(globalDeptIds)
  157. //alert(globalDeptIds+"=globalDeptIds")
  158. layer.close(index);
  159. }
  160. }
  161. /**
  162. * 选择人员
  163. */
  164. function confirmReport() {
  165. var options = {
  166. title: '选择人员',
  167. width: $(document).width(),
  168. url: "/visualization/confirm/selectUser",
  169. callBack: doSubmitConfirm
  170. };
  171. $.modal.openOptions(options);
  172. }
  173. function doSubmitConfirm(index, layero){
  174. var body = layer.getChildFrame('body', index);
  175. var userIds = body.find('#selectorx').val();
  176. var options = body.find('#selectorx').find("option:selected");
  177. if (userIds == null || userIds === "" || userIds.length === 0) {
  178. $.modal.alertWarning("请至少选择一条记录");
  179. return;
  180. }else{
  181. $("#userUL").html("");
  182. options.each(function (i,item) {
  183. var li = $("<li>").text($(item).html());
  184. $("#userUL").append(li);
  185. })
  186. //globalUserIds = userIds;
  187. $("#globalUserIds").val(userIds)
  188. layer.close(index);
  189. }
  190. // var obj = new Object();
  191. // obj.id = confirm_id;
  192. // obj.userIds = userIds.toString();
  193. // drivingFireEvents(confirm_action,obj);
  194. }
  195. </script>
  196. </body>
  197. </html>