edit.html 2.7 KB

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