add.html 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <!DOCTYPE html>
  2. <html lang="zh" xmlns:th="http://www.thymeleaf.org" >
  3. <head>
  4. <th:block th:include="include :: header('新增话题')" />
  5. </head>
  6. <body class="white-bg">
  7. <div class="wrapper wrapper-content animated fadeInRight ibox-content">
  8. <form class="form-horizontal m" id="form-notice-add">
  9. <div class="form-group">
  10. <label class="col-sm-2 control-label">标题:</label>
  11. <div class="col-sm-10">
  12. <input name="title" id="title" class="form-control" type="text" placeholder="请输入标题" required/>
  13. </div>
  14. </div>
  15. <div class="form-group">
  16. <label class="col-sm-2 control-label">图片:</label>
  17. <div class="col-sm-10">
  18. <img src="" id="picImage" style="width:250px;height:90px;" alt="">
  19. <input type="file" id="picUploadFile" name="uploadFile" accept="image/gif,image/jpeg,image/jpg,image/png,image/svg">
  20. <button class="btn btn-success" type="button" id="picUploadBtn">上传</button>
  21. <input type="hidden" id="pic" name="pic" class="form-control"/>
  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. <textarea name="lead" class="form-control" rows="5" cols="10" style="resize: none;" required></textarea>
  28. </div>
  29. </div>
  30. <div class="form-group">
  31. <label class="col-sm-2 control-label">排序设置:</label>
  32. <div class="col-sm-10">
  33. <input id="sort" min="1" name="sort" class="form-control" type="number" placeholder="请输入排序" required/>
  34. </div>
  35. </div>
  36. <div class="form-group">
  37. <label for="activation" class="col-sm-2 control-label">激活设置:</label>
  38. <div class="col-sm-10">
  39. <select name="activation" id="activation" class="form-control m-b" th:with="type=${@dict.getType('enable_status')}">
  40. <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
  41. </select>
  42. </div>
  43. </div>
  44. <div class="form-group">
  45. <label class="col-sm-2 control-label">PK设置:</label>
  46. <div class="col-sm-10">
  47. <select name="pk" id="pk" class="form-control m-b" th:with="type=${@dict.getType('pk_status')}">
  48. <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
  49. </select>
  50. </div>
  51. </div>
  52. <div class="form-group" id="redOption">
  53. <label class="col-sm-2 control-label">红方选项:</label>
  54. <div class="col-sm-10">
  55. <input name="redOption" class="form-control" type="text" placeholder="请输入红方选项"/>
  56. </div>
  57. </div>
  58. <div class="form-group" id="redDesc">
  59. <label class="col-sm-2 control-label">红方描述:</label>
  60. <div class="col-sm-10">
  61. <textarea name="redDesc" class="form-control" rows="5" cols="10" style="resize: none;"></textarea>
  62. </div>
  63. </div>
  64. <div class="form-group" id="blueOption" >
  65. <label class="col-sm-2 control-label">蓝方选项:</label>
  66. <div class="col-sm-10">
  67. <input name="blueOption" class="form-control" type="text" placeholder="请输入蓝方选项"/>
  68. </div>
  69. </div>
  70. <div class="form-group" id="blueDesc">
  71. <label class="col-sm-2 control-label">蓝方描述:</label>
  72. <div class="col-sm-10">
  73. <textarea name="blueDesc" class="form-control" rows="5" cols="10" style="resize: none;"></textarea>
  74. </div>
  75. </div>
  76. <div class="form-group">
  77. <label class="col-sm-2 control-label">默认访问数:</label>
  78. <div class="col-sm-10">
  79. <input name="examine" id="examine" class="form-control" type="number" placeholder="请输入默认访问数" required/>
  80. </div>
  81. </div>
  82. <div class="form-group">
  83. <label class="col-sm-2 control-label">访问叠加数:</label>
  84. <div class="col-sm-10">
  85. <input name="examineNum" id="examineNum" class="form-control" type="number" placeholder="请输入访问叠加数" required/>
  86. </div>
  87. </div>
  88. <div class="form-group">
  89. <label class="col-sm-2 control-label">PK叠加次数:</label>
  90. <div class="col-sm-10">
  91. <input name="pkVoteNum" id="pkVoteNum" class="form-control" type="number" placeholder="请输入PK叠加次数" required/>
  92. </div>
  93. </div>
  94. </form>
  95. </div>
  96. <th:block th:include="include :: footer" />
  97. <th:block th:include="include :: summernote-js" />
  98. <script type="text/javascript">
  99. var prefix = ctx + "dynamic/circle/topic";
  100. $("#form-notice-add").validate({
  101. focusCleanup: true
  102. });
  103. $(function(){
  104. $("#redOption").hide();
  105. $("#redDesc").hide();
  106. $("#blueOption").hide();
  107. $("#blueDesc").hide();
  108. $('input[name="redOption"]').attr("required", "false");
  109. $('input[name="redDesc"]').attr("required", "false");
  110. $('input[name="blueOption"]').attr("required", "false");
  111. $('input[name="blueDesc"]').attr("required", "false");
  112. });
  113. $("#pk").on("change", function (){
  114. var val = $(this).val();
  115. if(val == 1){
  116. $("#redOption").show();
  117. $("#redDesc").show();
  118. $("#blueOption").show();
  119. $("#blueDesc").show();
  120. $('input[name="redOption"]').attr("required", "true");
  121. $('input[name="redDesc"]').attr("required", "true");
  122. $('input[name="blueOption"]').attr("required", "true");
  123. $('input[name="blueDesc"]').attr("required", "true");
  124. }else {
  125. $("#redOption").hide();
  126. $("#redDesc").hide();
  127. $("#blueOption").hide();
  128. $("#blueDesc").hide();
  129. $('input[name="redOption"]').attr("required", "false");
  130. $('input[name="redDesc"]').attr("required", "false");
  131. $('input[name="blueOption"]').attr("required", "false");
  132. $('input[name="blueDesc"]').attr("required", "false");
  133. }
  134. });
  135. /**
  136. * 图片上传
  137. */
  138. $('#picUploadBtn').on('click',function () {
  139. if($('#picUploadFile').get(0).files[0]==undefined){
  140. $.modal.alertError("请选择要上传的文件!");
  141. return;
  142. }
  143. var formData = new FormData();
  144. formData.append("file", $('#picUploadFile').get(0).files[0]);
  145. $.ajax({
  146. url: ctx + "file/upload",
  147. data: formData,
  148. type: "post",
  149. processData: false,
  150. contentType: false,
  151. success: function(result) {
  152. $('#picImage').attr('src',result.data);
  153. $("#pic").val(result.data);
  154. }
  155. })
  156. });
  157. function submitHandler() {
  158. if ($.validate.form()) {
  159. $.operate.save(prefix + "/add", $('#form-notice-add').serialize());
  160. }
  161. }
  162. </script>
  163. </body>
  164. </html>