edit.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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 :: datetimepicker-css" />
  6. <th:block th:include="include :: summernote-css" />
  7. <th:block th:include="include :: bootstrap-fileinput-css"/>
  8. <!-- 自定义 CSS -->
  9. <style>
  10. /* 修改文本域的背景颜色和文字颜色 */
  11. .note-editable {
  12. background-color: black !important; /* 黑色背景 */
  13. color: white !important; /* 白色文字 */
  14. }
  15. </style>
  16. </head>
  17. <body class="white-bg">
  18. <div class="wrapper wrapper-content animated fadeInRight ibox-content">
  19. <form class="form-horizontal m" id="form-competition-edit" th:object="${competition}">
  20. <input name="id" th:field="*{id}" type="hidden">
  21. <div class="col-xs-12">
  22. <div class="form-group">
  23. <label class="col-sm-2 control-label is-required">赛事标题:</label>
  24. <div class="col-sm-4">
  25. <input name="competitionTitle" th:field="*{competitionTitle}" class="form-control" type="text" maxlength="50" required>
  26. </div>
  27. <label class="col-sm-2 control-label is-required">赛事类型:</label>
  28. <div class="col-sm-4">
  29. <select name="competitionType" class="form-control" th:with="type=${@dict.getType('competition_type')}">
  30. <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{competitionType}"></option>
  31. </select>
  32. </div>
  33. </div>
  34. </div>
  35. <div class="col-xs-12">
  36. <div class="form-group">
  37. <label class="col-sm-2 control-label is-required">最大人数/团队数:</label>
  38. <div class="col-sm-4">
  39. <input name="teamMax" th:field="*{teamMax}" class="form-control" type="text" required>
  40. </div>
  41. <label class="col-sm-2 control-label">场地:</label>
  42. <div class="col-sm-4">
  43. <input name="competitionPlace" th:field="*{competitionPlace}" class="form-control" type="text" maxlength="50">
  44. </div>
  45. </div>
  46. </div>
  47. <div class="col-xs-12">
  48. <div class="form-group">
  49. <label class="col-sm-2 control-label is-required">报名费用:</label>
  50. <div class="col-sm-4">
  51. <input name="competitionExpense" th:field="*{competitionExpense}" class="form-control" type="text" required>
  52. </div>
  53. <label class="col-sm-2 control-label is-required">观看费用:</label>
  54. <div class="col-sm-4">
  55. <input name="viewingTicket" th:field="*{viewingTicket}" class="form-control" type="text" required>
  56. </div>
  57. </div>
  58. </div>
  59. <div class="col-xs-12">
  60. <div class="form-group">
  61. <label class="col-sm-2 control-label is-required">赛事开始时间:</label>
  62. <div class="col-sm-4">
  63. <div class="input-group date">
  64. <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
  65. <input name="applyStartTime" th:value="${#dates.format(competition.applyStartTime, 'yyyy-MM-dd HH:mm')}" type="text" class="form-control" id="applyStartTime" placeholder="年-月-日 时:分" required>
  66. </div>
  67. </div>
  68. <label class="col-sm-2 control-label is-required">赛事结束时间:</label>
  69. <div class="col-sm-4">
  70. <div class="input-group date">
  71. <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
  72. <input name="applyEndTime" th:value="${#dates.format(competition.applyEndTime, 'yyyy-MM-dd HH:mm')}" type="text" class="form-control" id="applyEndTime" placeholder="年-月-日 时:分" required>
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. <div class="col-xs-12">
  78. <div class="form-group">
  79. <label class="col-sm-2 control-label is-required">取消报名截至时间:</label>
  80. <div class="col-sm-4">
  81. <select th:field="*{applyBeforeTime}" name="applyBeforeTime" class="form-control">
  82. <option value="1">赛事开始前1小时</option>
  83. <option value="2">赛事开始前2小时</option>
  84. <option value="3">赛事开始前3小时</option>
  85. <option value="6">赛事开始前6小时</option>
  86. <option value="12">赛事开始前12小时</option>
  87. <option value="24">赛事开始前24小时</option>
  88. <option value="48">赛事开始前48小时</option>
  89. </select>
  90. </div>
  91. </div>
  92. </div>
  93. <div class="col-xs-12">
  94. <div class="form-group">
  95. <label class="col-sm-2 control-label is-required">赛事详情:</label>
  96. <div class="col-sm-4">
  97. <input type="hidden" class="form-control" th:field="*{competitionDetails}" required>
  98. <div class="summernote" id="competitionDetails"></div>
  99. </div>
  100. <label class="col-sm-2 control-label">报名须知:</label>
  101. <div class="col-sm-4">
  102. <input type="hidden" class="form-control" th:field="*{registrationNotes}">
  103. <div class="summernote" id="registrationNotes"></div>
  104. </div>
  105. </div>
  106. </div>
  107. <div class="form-group">
  108. <label class="col-sm-2 control-label">图片:</label>
  109. <div class="col-sm-10">
  110. <input type="hidden" name="noticeImg" th:field="*{competitionImg}">
  111. <div class="file-loading">
  112. <input class="form-control file-upload" id="competitionImg" name="file" type="file" >
  113. </div>
  114. </div>
  115. </div>
  116. </form>
  117. </div>
  118. <th:block th:include="include :: footer" />
  119. <th:block th:include="include :: datetimepicker-js" />
  120. <th:block th:include="include :: summernote-js" />
  121. <th:block th:include="include :: bootstrap-fileinput-js"/>
  122. <script th:inline="javascript">
  123. var prefix = ctx + "competition";
  124. $("#form-competition-edit").validate({
  125. focusCleanup: true
  126. });
  127. function submitHandler() {
  128. if ($.validate.form()) {
  129. $.operate.save(prefix + "/edit", $('#form-competition-edit').serialize());
  130. }
  131. }
  132. $("input[name='applyStartTime']").datetimepicker({
  133. format: "yyyy-mm-dd hh:ii",
  134. autoclose: true
  135. });
  136. $("input[name='applyEndTime']").datetimepicker({
  137. format: "yyyy-mm-dd hh:ii",
  138. autoclose: true
  139. });
  140. $(function() {
  141. console.log()
  142. $('.summernote').each(function(i) {
  143. $('#' + this.id).summernote({
  144. lang: 'zh-CN',
  145. dialogsInBody: true,
  146. height: 400,
  147. callbacks: {
  148. onChange: function(contents, $edittable) {
  149. $("input[name='" + this.id + "']").val(contents);
  150. },
  151. onImageUpload: function(files) {
  152. var obj = this;
  153. var data = new FormData();
  154. data.append("file", files[0]);
  155. $.ajax({
  156. type: "post",
  157. url: ctx + "common/upload",
  158. data: data,
  159. cache: false,
  160. contentType: false,
  161. processData: false,
  162. dataType: 'json',
  163. success: function(result) {
  164. if (result.code == web_status.SUCCESS) {
  165. $('#' + obj.id).summernote('insertImage', result.url);
  166. } else {
  167. $.modal.alertError(result.msg);
  168. }
  169. },
  170. error: function(error) {
  171. $.modal.alertWarning("图片上传失败。");
  172. }
  173. });
  174. }
  175. }
  176. });
  177. var content = $("input[name='" + this.id + "']").val();
  178. $('#' + this.id).summernote('code', content);
  179. })
  180. });
  181. $(".file-upload").each(function (i) {
  182. var inputName = this.id;
  183. var val = $("input[name='" + inputName + "']").val();
  184. // 将已上传的图片路径分割成数组
  185. var initialPreview = val ? val.split(',') : [];
  186. $(this).fileinput({
  187. uploadUrl: ctx + 'common/upload',
  188. initialPreviewAsData: true,
  189. initialPreview: initialPreview,
  190. maxFileCount: 1,
  191. allowedFileExtensions: ['jpg', 'png'],
  192. maxFileSize: 10240,
  193. multiple: false,
  194. }).on('fileuploaded', function (event, data, previewId, index) {
  195. var inputName = event.currentTarget.id;
  196. var existingValue = $("input[name='" + inputName + "']").val();
  197. var fullUrl = data.response.url; // 获取完整的URL
  198. var urlObject = new URL(fullUrl);
  199. var relativePath = urlObject.pathname; // 获取路径部分
  200. // var newBaseUrl = "http://192.168.4.27"; // 新的基URL
  201. var newBaseUrl = "http://localhost"; // 新的基URL
  202. var absoluteUrl = newBaseUrl + relativePath; // 拼接完整的URL
  203. // 如果已经存在值,则替换为新值
  204. $("input[name='" + inputName + "']").val(absoluteUrl);
  205. }).on('fileremoved', function (event, id, index) {
  206. var inputName = event.currentTarget.id;
  207. $("input[name='" + inputName + "']").val(''); // 移除后清空输入框
  208. });
  209. $(this).fileinput('_initFileActions');
  210. });
  211. </script>
  212. </body>
  213. </html>