add.html 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <link rel="stylesheet" href="/static/editor.md/css/editormd.min.css" />
  2. <div class="layui-layout layui-layout-admin" style="padding-left: 40px;margin-top: 20px;">
  3. <form class="layui-form" action="" method="post">
  4. <div class="layui-form-item">
  5. <label class="layui-form-label">标题</label>
  6. <div class="layui-input-block " style="width: 400px">
  7. <input type="text" name="title" id="title" lay-verify="required" autocomplete="off" placeholder="请输入标题" class="layui-input" value="">
  8. </div>
  9. </div>
  10. <div class="layui-form-item">
  11. <label class="layui-form-label">内容</label>
  12. <div class="layui-input-inline" id="api-editormd" style="border: 1px solid #e4e4e4">
  13. <textarea name="content" id="content" style="display:none;">
  14. </textarea>
  15. </div>
  16. </div>
  17. <div class="layui-form-item">
  18. <div class="layui-input-block">
  19. <button class="layui-btn" lay-submit="" lay-filter="sub">保存</button>
  20. <button type="reset" class="layui-btn layui-btn-primary">重置</button>
  21. </div>
  22. </div>
  23. </form>
  24. </div>
  25. <script>
  26. var apiEditor;
  27. layui.use(['form','element','table','layer','jquery'],function(){
  28. var form = layui.form; //只有执行了这一步,部分表单元素才会自动修饰成功
  29. var $ = layui.jquery;
  30. var table = layui.table;
  31. form.on('submit(sub)', function(data){
  32. var form_data = data.field;
  33. $.post('{{urlfor "PropertyNoticeController.Add"}}', form_data, function (out) {
  34. if (out.status == 0) {
  35. layer.msg("操作成功",{icon: 1},function () {
  36. window.location.href="/propertynotice/index";
  37. })
  38. } else {
  39. layer.msg(out.message)
  40. }
  41. }, "json");
  42. return false;
  43. });
  44. form.render();
  45. });
  46. </script>
  47. {{template "public/editormd.html" .}}