edit.html 6.2 KB

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