list.html 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <div class="layui-layout layui-layout-admin" style="padding-left: 20px;">
  2. <div class="layui-row" style="margin-top: 20px;">
  3. <div class="layui-col-xs6">
  4. <a class="layui-btn" data-type="tabAdd" href="/env/add">新增</a>
  5. </div>
  6. <div class="layui-col-xs6 search_text">
  7. <form class="layui-form" action="" onsubmit="javascript:return false;">
  8. <div class="demoTable">
  9. <div class="layui-inline" style="width: 40%">
  10. <input class="layui-input" name="envName" id="envName" autocomplete="off" placeholder="环境名称" >
  11. </div>
  12. <button class="layui-btn" data-type="reload">查询</button>
  13. </div>
  14. </form>
  15. </div>
  16. </div>
  17. <table class="layui-hide" id="table_list" lay-filter="table_filter">
  18. </table>
  19. <script type="text/html" id="bar">
  20. <!-- <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a> -->
  21. <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
  22. <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
  23. </script>
  24. </div>
  25. <script>
  26. layui.use(['table','form','element'], function(){
  27. var table = layui.table;
  28. var form = layui.form;
  29. var element = layui.element;
  30. //方法级渲染
  31. table.render({
  32. elem: '#table_list'
  33. ,url: '/env/table'
  34. ,cols: [[
  35. // {checkbox: true, fixed: true},
  36. {field:'id', title: 'ID', align:'center',sort: true, width:150}
  37. ,{field:'env_name',title: '环境名称'}
  38. ,{field:'env_host', title: 'URL地址'}
  39. ,{field:'detail', title: '备注'}
  40. ,{field:'create_time', title: '创建时间'}
  41. ,{field:'update_time', title: '修改时间'}
  42. ,{fixed: 'right', width:160, align:'center', toolbar: '#bar'}
  43. ]]
  44. ,id: 'listReload'
  45. ,page: true
  46. ,height: "full-130"
  47. });
  48. var $ = layui.$, active = {
  49. reload: function(){
  50. table.reload('listReload', {
  51. where: {
  52. envName: $('#envName').val(),
  53. }
  54. });
  55. }
  56. };
  57. //监听工具条
  58. table.on('tool(table_filter)', function(obj){
  59. var data = obj.data;
  60. if(obj.event === 'detail'){
  61. //layer.msg('ID:'+ data.id + ' 的查看操作');
  62. } else if(obj.event === 'del'){
  63. layer.confirm('真的删除【'+data.env_name+'】么', function(index){
  64. var jsData = {'id':data.id}
  65. $.post('{{urlfor "EnvController.AjaxDel"}}', jsData, function (out) {
  66. if (out.status == 0) {
  67. layer.alert('删除成功了', {icon: 1},function(index){
  68. layer.close(index);
  69. window.location.reload();
  70. });
  71. } else {
  72. layer.msg(out.message)
  73. }
  74. }, "json");
  75. obj.del();
  76. layer.close(index);
  77. });
  78. } else if(obj.event === 'edit'){
  79. window.location.href="/env/edit?id="+data.id
  80. }
  81. });
  82. $('.demoTable .layui-btn').on('click', function(){
  83. var type = $(this).data('type');
  84. active[type] ? active[type].call(this) : '';
  85. });
  86. });
  87. </script>