edit.html 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <div class="layui-layout layui-layout-admin" style="padding-left: 40px;margin-top: 20px;">
  2. <div style="margin: 10px 0px">
  3. <blockquote class="layui-elem-quote">
  4. 说明:公共状态码设置
  5. </blockquote>
  6. </div>
  7. <form class="layui-form" action="" method="post" >
  8. <div class="layui-form-item">
  9. <label class="layui-form-label">状态码</label>
  10. <div class="layui-input-inline">
  11. <input type="text" name="code" id="code" lay-verify="required" autocomplete="off" placeholder="状态码" class="layui-input" value="{{.code.code}}">
  12. </div>
  13. <div class="layui-form-mid layui-word-aux">*</div>
  14. </div>
  15. <div class="layui-form-item layui-form-text">
  16. <label class="layui-form-label">说明</label>
  17. <div class="layui-input-inline" style="width: 300px;">
  18. <textarea name="desc" id="desc" placeholder="请输入内容" class="layui-textarea">{{.code.desc}}</textarea>
  19. </div>
  20. </div>
  21. <div class="layui-form-item layui-form-text">
  22. <label class="layui-form-label">备注</label>
  23. <div class="layui-input-inline" style="width: 300px;">
  24. <textarea name="detail" id="detail" placeholder="请输入内容" class="layui-textarea">{{.code.detail}}</textarea>
  25. </div>
  26. </div>
  27. <input type="hidden" id="id" name="id" value="{{.code.id}}">
  28. <div class="layui-form-item">
  29. <div class="layui-input-block">
  30. <button class="layui-btn" lay-submit="" lay-filter="sub">立即提交</button>
  31. <button type="reset" class="layui-btn layui-btn-primary">重置</button>
  32. </div>
  33. </div>
  34. </form>
  35. </div>
  36. <script>
  37. var $;
  38. layui.config({
  39. base : "js/"
  40. }).use(['form','element','layer','jquery'],function(){
  41. var form = layui.form; //只有执行了这一步,部分表单元素才会自动修饰成功
  42. var $ = layui.jquery;
  43. form.on('submit(sub)', function(data){
  44. var form_data = $("form").serialize();
  45. $.post('{{urlfor "CodeController.AjaxSave"}}', form_data, function (out) {
  46. if (out.status == 0) {
  47. layer.msg("操作成功",{icon: 1},function () {
  48. window.location.href='{{urlfor "CodeController.List"}}'
  49. })
  50. } else {
  51. layer.msg(out.message)
  52. }
  53. }, "json");
  54. return false;
  55. });
  56. //但是,如果你的HTML是动态生成的,自动渲染就会失效
  57. //因此你需要在相应的地方,执行下述方法来手动渲染,跟这类似的还有 element.init();
  58. form.render();
  59. });
  60. </script>