add.html 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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-designer-add">
  9. <div class="col-xs-12">
  10. <div class="form-group">
  11. <label class="col-sm-3 control-label">昵称:</label>
  12. <div class="col-sm-8">
  13. <input name="designerName" class="form-control" type="text">
  14. </div>
  15. </div>
  16. </div>
  17. <div class="col-xs-12">
  18. <div class="form-group">
  19. <label class="col-sm-3 control-label">设计师头像:</label>
  20. <div class="col-sm-8">
  21. <img id="designerAvatarImg" width="30%" height="30%">
  22. <input type="file" class="form-control" name="designerAvatarUrl" id="designerAvatarUrl" accept="image/*"/>
  23. <input type="hidden" lass="form-control" name="designerAvatar" id="designerAvatar" />
  24. </div>
  25. </div>
  26. </div>
  27. <div class="col-xs-12">
  28. <div class="form-group">
  29. <label class="col-sm-3 control-label">设计师描述:</label>
  30. <div class="col-sm-8">
  31. <textarea name="description" class="form-control"></textarea>
  32. </div>
  33. </div>
  34. </div>
  35. </form>
  36. </div>
  37. <th:block th:include="include :: footer" />
  38. <script th:inline="javascript">
  39. var prefix = ctx + "master/designer"
  40. $('#designerAvatarUrl').change(function () {
  41. var fileSize = this.files[0].size;
  42. fileSize = Math.round(fileSize/1024*100)/100;
  43. if(fileSize>2048){
  44. layer.msg('上传文件不得大于2M,请重新上传。', {time: 3000, icon:6});
  45. return false;
  46. }
  47. if (!/image\/\w+/.test(this.files[0].type)) {
  48. layer.msg('上传的不是图片文件,请重新上传。', {time: 3000, icon:6});
  49. return false;
  50. }
  51. if ($(this).val()) {
  52. var formdata = new FormData();
  53. formdata.append("imageFile", this.files[0]);
  54. $.ajax({
  55. url: ctx + "common/upload/file/designerAvatar",
  56. data: formdata,
  57. type: "post",
  58. processData: false,
  59. contentType: false,
  60. beforeSend: function () {
  61. $.modal.loading("正在处理中,请稍后...");
  62. $.modal.disable();
  63. },
  64. success: function (result) {
  65. if (result.code === web_status.SUCCESS) {
  66. $('#designerAvatarImg').attr('src', result.imageUrl);
  67. $('#designerAvatar').val(result.imageUrl);
  68. $.modal.alertSuccess(result.msg)
  69. } else if (result.code === web_status.WARNING) {
  70. $.modal.alertWarning(result.msg)
  71. } else {
  72. $.modal.alertError(result.msg);
  73. }
  74. $.modal.closeLoading();
  75. $.modal.enable();
  76. }
  77. })
  78. }
  79. });
  80. $("#form-designer-add").validate({
  81. focusCleanup: true
  82. });
  83. function submitHandler() {
  84. if ($.validate.form()) {
  85. $.operate.save(prefix + "/add", $('#form-designer-add').serialize());
  86. }
  87. }
  88. </script>
  89. </body>
  90. </html>