add.html 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 :: jasny-bootstrap-css" />
  6. </head>
  7. <body class="white-bg">
  8. <div class="wrapper wrapper-content animated fadeInRight ibox-content">
  9. <form class="form-horizontal m" id="form-company_honour-add">
  10. <div class="form-group">
  11. <label class="col-sm-3 control-label">荣誉描述:</label>
  12. <div class="col-sm-8">
  13. <textarea name="des" class="form-control"></textarea>
  14. </div>
  15. </div>
  16. <div class="form-group">
  17. <label class="col-sm-3 control-label">荣誉图片:</label>
  18. <div class="col-sm-8">
  19. <input id="input-img" name="img" type="hidden">
  20. <div class="fileinput fileinput-new" data-provides="fileinput">
  21. <div class="fileinput-preview thumbnail" style="width: 200px; height: 150px;">
  22. </div>
  23. <div>
  24. <span class="btn btn-white btn-file">
  25. <span class="fileinput-new">选择图片</span>
  26. <span class="fileinput-exists">更改</span>
  27. <input id="input-fileinput" type="file">
  28. </span>
  29. <a href="#" class="btn btn-white fileinput-exists" data-dismiss="fileinput">清除</a>
  30. </div>
  31. </div>
  32. </div>
  33. </div>
  34. </form>
  35. </div>
  36. <th:block th:include="include :: footer" />
  37. <th:block th:include="include :: jasny-bootstrap-js" />
  38. <script type="text/javascript">
  39. var prefix = ctx + "company/honour"
  40. $("#form-company_honour-add").validate({
  41. focusCleanup: true
  42. });
  43. /*选择后提交图片到服务器*******/
  44. $('.fileinput').on('change.bs.fileinput ', function (e) {
  45. if ($("#input-fileinput").val() == '') {
  46. return;
  47. }var data = new FormData();
  48. data.append('file', document.getElementById('input-fileinput').files[0]);
  49. $.ajax({
  50. url:ctx+"common/upload",
  51. type:"post",
  52. data: data,
  53. cache: false,
  54. contentType: false,
  55. processData: false,
  56. dataType: 'json',
  57. success: function(result) {
  58. if (result.code == web_status.SUCCESS) {
  59. $("#input-img").val(result.data.fileName);
  60. } else {
  61. $.modal.alertError(result.msg);
  62. }
  63. },
  64. error:function(result) {
  65. alert("上传失败")
  66. }
  67. });
  68. });
  69. function submitHandler() {
  70. if($("#input-img").val()==undefined||$("#input-img").val()==""){
  71. $.modal.msgError("请选择荣誉图片")
  72. }
  73. if ($.validate.form()) {
  74. $.operate.save(prefix + "/add", $('#form-company_honour-add').serialize());
  75. }
  76. }
  77. </script>
  78. </body>
  79. </html>