edit.html 4.0 KB

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