add.html 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <!DOCTYPE html>
  2. <html lang="zh" xmlns:th="http://www.thymeleaf.org" >
  3. <head>
  4. <th:block th:include="include :: header('新增点点币pk活动')" />
  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 id="title" name="title" class="form-control" type="text" 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="addRedPic" style="width:250px;height:90px;" alt="">
  19. <input type="file" id="addUploadFile" name="uploadFile" accept="image/gif,image/jpeg,image/jpg,image/png,image/svg">
  20. <button class="btn btn-success" type="button" id="addUploadBtn">上传</button>
  21. <input type="hidden" id="addRedPicUrl" name="redPic" class="form-control validate[required]" required/>
  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. <img src="" id="addBluePic" style="width:250px;height:90px;" alt="">
  28. <input type="file" id="addUploadFile2" name="uploadFile" accept="image/gif,image/jpeg,image/jpg,image/png,image/svg">
  29. <button class="btn btn-success" type="button" id="addUploadBtn2">上传</button>
  30. <input type="hidden" id="addBluePicUrl" name="bluePic" class="form-control validate[required]" required/>
  31. </div>
  32. </div>
  33. <div class="form-group" >
  34. <label class="col-sm-2 control-label">红方选项:</label>
  35. <div class="col-sm-10">
  36. <input type="text" id="addRedAnswer" name="redAnswer" class="form-control validate[required]" required>
  37. </div>
  38. </div>
  39. <div class="form-group" >
  40. <label class="col-sm-2 control-label">蓝方选项:</label>
  41. <div class="col-sm-10">
  42. <input type="text" id="addBlueAnswer" name="blueAnswer" class="form-control validate[required]" required>
  43. </div>
  44. </div>
  45. <div class="form-group" >
  46. <label class="col-sm-2 control-label">活动状态:</label>
  47. <div class="col-sm-10">
  48. <select name="pkStatus" id="pkStatus" class="form-control m-b" th:with="type=${@dict.getType('point_pk_activity_status')}">
  49. <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
  50. </select>
  51. </div>
  52. </div>
  53. <div class="form-group select-time" >
  54. <label class="col-sm-2 control-label">开奖时间:</label>
  55. <div class="col-sm-10">
  56. <input id="time" name="lotteryTime" class="form-control time-input" type="text" required/>
  57. </div>
  58. </div>
  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. var prefix = ctx + "activity/point/pk";
  65. $("#form-notice-add").validate({
  66. focusCleanup: true
  67. });
  68. /**
  69. * 红方图片上传
  70. */
  71. $('#addUploadBtn').on('click',function () {
  72. if($('#addUploadFile').get(0).files[0]==undefined){
  73. $.modal.alertError("请选择要上传的文件!");
  74. return;
  75. }
  76. var formData = new FormData();
  77. formData.append("file", $('#addUploadFile').get(0).files[0]);
  78. $.ajax({
  79. url: ctx + "file/upload",
  80. data: formData,
  81. type: "post",
  82. processData: false,
  83. contentType: false,
  84. success: function(result) {
  85. $('#addRedPic').attr('src',result.data);
  86. $("input[name='redPic']").val(result.data);
  87. }
  88. })
  89. });
  90. /**
  91. * 蓝方图片上传
  92. */
  93. $('#addUploadBtn2').on('click',function () {
  94. if($('#addUploadFile2').get(0).files[0]==undefined){
  95. $.modal.alertError("请选择要上传的文件!");
  96. return;
  97. }
  98. var formData = new FormData();
  99. formData.append("file", $('#addUploadFile2').get(0).files[0]);
  100. $.ajax({
  101. url: ctx + "file/upload",
  102. data: formData,
  103. type: "post",
  104. processData: false,
  105. contentType: false,
  106. success: function(result) {
  107. $('#addBluePic').attr('src',result.data);
  108. $("input[name='bluePic']").val(result.data);
  109. }
  110. })
  111. });
  112. function submitHandler() {
  113. if ($.validate.form()) {
  114. $.operate.save(prefix + "/add", $('#form-notice-add').serialize());
  115. }
  116. }
  117. </script>
  118. </body>
  119. </html>