add.html 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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. <select name="allowPurse" id="allowPurse" class="form-control m-b" th:with="type=${@dict.getType('headwear_type')}">
  13. <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
  14. </select>
  15. </div>
  16. </div>
  17. <div class="form-group">
  18. <label class="col-sm-2 control-label">购买类型:</label>
  19. <div class="col-sm-10">
  20. <select name="buyType" id="buyType" class="form-control m-b" th:with="type=${@dict.getType('buy_type')}">
  21. <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
  22. </select>
  23. </div>
  24. </div>
  25. <div class="form-group" id="chargeErBanNo">
  26. <label class="col-sm-2 control-label">头饰名称:</label>
  27. <div class="col-sm-10">
  28. <input name="headwearName" id="headwearName" class="form-control" type="text" placeholder="请输入头饰名称" required/>
  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="leftLevel" min="0" name="leftLevel" class="form-control" type="number" placeholder="请输入等级要求" required/>
  35. </div>
  36. </div>
  37. <div class="form-group">
  38. <label class="col-sm-2 control-label">头饰金币:</label>
  39. <div class="col-sm-10">
  40. <input id="goldPrice" min="0" name="goldPrice" class="form-control" type="number" placeholder="请输入头饰金币" required/>
  41. </div>
  42. </div>
  43. <div class="form-group">
  44. <label class="col-sm-2 control-label">头饰状态:</label>
  45. <div class="col-sm-3">
  46. <div class="radio-box">
  47. <input type="radio" id="headwearStatus" name="headwearStatus" value="1" checked>
  48. <label for="headwearStatus">有效</label>
  49. </div>
  50. <div class="radio-box">
  51. <input type="radio" id="headwearStatus2" name="headwearStatus" value="2">
  52. <label for="headwearStatus2">无效</label>
  53. </div>
  54. </div>
  55. <label class="col-sm-2 control-label">vgg特效:</label>
  56. <div class="col-sm-3">
  57. <div class="radio-box">
  58. <input type="radio" id="hasVggPic" name="hasVggPic" value="0" checked>
  59. <label for="hasVggPic">否</label>
  60. </div>
  61. <div class="radio-box">
  62. <input type="radio" id="hasVggPic2" name="hasVggPic" value="1">
  63. <label for="hasVggPic2">是</label>
  64. </div>
  65. </div>
  66. </div>
  67. <div class="form-group">
  68. <label class="col-sm-2 control-label">头饰图片:</label>
  69. <div class="col-sm-10">
  70. <img src="" id="picImage" style="width:250px;height:90px;" alt="">
  71. <input type="file" id="picUploadFile" name="uploadFile" accept="image/gif,image/jpeg,image/jpg,image/png,image/svg">
  72. <button class="btn btn-success" type="button" id="picUploadBtn">上传</button>
  73. <input type="hidden" id="picUrl" name="picUrl" class="form-control validate[required]"/>
  74. </div>
  75. </div>
  76. <div class="form-group">
  77. <label class="col-sm-2 control-label">vgg图片:</label>
  78. <div class="col-sm-10">
  79. <img src="" id="imgUrl" style="width:250px;height:90px;" alt="">
  80. <input type="file" id="uploadFile" name="uploadFile" accept="image/gif,image/jpeg,image/jpg,image/png,image/svg">
  81. <button class="btn btn-success" type="button" id="uploadBtn">上传</button>
  82. <input type="hidden" id="vggUrl" name="vggUrl" class="form-control validate[required]"/>
  83. </div>
  84. </div>
  85. <div class="form-group">
  86. <label class="col-sm-2 control-label">角标图片:</label>
  87. <div class="col-sm-10">
  88. <img src="" id="markImage" style="width:250px;height:90px;" alt="">
  89. <input type="file" id="markPicFile" name="uploadFile" accept="image/gif,image/jpeg,image/jpg,image/png,image/svg">
  90. <button class="btn btn-success" type="button" id="markPicBtn">上传</button>
  91. <input type="hidden" id="markPic" name="markPic" class="form-control validate[required]"/>
  92. </div>
  93. </div>
  94. <div class="form-group" >
  95. <label class="col-sm-2 control-label">排序:</label>
  96. <div class="col-sm-10">
  97. <input id="seqNo" name="seqNo" min="1" class="form-control" type="number" placeholder="请输入排序" required/>
  98. </div>
  99. </div>
  100. <div class="form-group" >
  101. <label class="col-sm-2 control-label">有效期(天):</label>
  102. <div class="col-sm-10">
  103. <input id="effectiveTime" min="1" name="effectiveTime" class="form-control" type="number" placeholder="请输入有效期(天)" required/>
  104. </div>
  105. </div>
  106. </form>
  107. </div>
  108. <th:block th:include="include :: footer" />
  109. <th:block th:include="include :: summernote-js" />
  110. <script type="text/javascript">
  111. var prefix = ctx + "mall/headwear";
  112. $("#form-notice-add").validate({
  113. onkeyup: false,
  114. rules:{
  115. headwearName:{
  116. minlength: 1,
  117. remote: {
  118. url: prefix + "/checkHeadWearName",
  119. type: "post",
  120. dataType: "json",
  121. data: {
  122. headWearName : function() {
  123. return $.common.trim($("#headwearName").val());
  124. }
  125. },
  126. dataFilter: function(data, type) {
  127. return $.validate.unique(data);
  128. }
  129. }
  130. }
  131. },
  132. messages: {
  133. "carName": {
  134. remote: "该头饰名称已经存在!"
  135. }
  136. },
  137. focusCleanup: true
  138. });
  139. /**
  140. * 图片上传
  141. */
  142. $('#picUploadBtn').on('click',function () {
  143. if($('#picUploadFile').get(0).files[0]==undefined){
  144. $.modal.alertError("请选择要上传的文件!");
  145. return;
  146. }
  147. var formData = new FormData();
  148. formData.append("file", $('#picUploadFile').get(0).files[0]);
  149. $.ajax({
  150. url: ctx + "file/upload",
  151. data: formData,
  152. type: "post",
  153. processData: false,
  154. contentType: false,
  155. success: function(result) {
  156. $('#picImage').attr('src',result.data);
  157. $("input[name='picUrl']").val(result.data);
  158. }
  159. })
  160. });
  161. /**
  162. * vgg图片上传
  163. */
  164. $('#uploadBtn').on('click',function () {
  165. if($('#uploadFile').get(0).files[0]==undefined){
  166. $.modal.alertError("请选择要上传的文件!");
  167. return;
  168. }
  169. var formData = new FormData();
  170. formData.append("file", $('#uploadFile').get(0).files[0]);
  171. $.ajax({
  172. url: ctx + "file/upload",
  173. data: formData,
  174. type: "post",
  175. processData: false,
  176. contentType: false,
  177. success: function(result) {
  178. $('#imgUrl').attr('src',result.data);
  179. $("input[name='vggUrl']").val(result.data);
  180. }
  181. })
  182. });
  183. /**
  184. * 角标图片上传
  185. */
  186. $('#markPicBtn').on('click',function () {
  187. if($('#markPicFile').get(0).files[0]==undefined){
  188. $.modal.alertError("请选择要上传的文件!");
  189. return;
  190. }
  191. var formData = new FormData();
  192. formData.append("file", $('#markPicFile').get(0).files[0]);
  193. $.ajax({
  194. url: ctx + "file/upload",
  195. data: formData,
  196. type: "post",
  197. processData: false,
  198. contentType: false,
  199. success: function(result) {
  200. $('#markImage').attr('src',result.data);
  201. $("input[name='markPic']").val(result.data);
  202. }
  203. })
  204. });
  205. function submitHandler() {
  206. if ($.validate.form()) {
  207. $.operate.save(prefix + "/add", $('#form-notice-add').serialize());
  208. }
  209. }
  210. </script>
  211. </body>
  212. </html>