index.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <div class="row content-nav">
  2. <div class="col-xs-12">
  3. <ul>
  4. <li><a href="javascript:;"><i></i>&nbsp;快捷登录</a></li>
  5. <li><a href="javascript:;">登录列表</a></li>
  6. </ul>
  7. </div>
  8. </div>
  9. <section class="content clearfix">
  10. <div class="layui-list-box">
  11. <table class="layui-hide" id="list-box" lay-filter="list-box"></table>
  12. </div>
  13. </section>
  14. <script type="text/html" id="list-toolbar">
  15. <div class="layui-btn-container">
  16. <button lay-event="refresh" type="button" class="layui-btn layui-btn-sm layui-bg-red"><i class="layui-icon">&#xe9aa;</i> 刷新</button>
  17. </div>
  18. </script>
  19. <script type="text/html" id="checkboxTpl">
  20. <input type="checkbox" name="status" value="{{d.id}}" title="开启" lay-filter="status-filter" {{ d.status == 0 ? 'checked' : '' }}>
  21. </script>
  22. <script type="text/html" id="list-bar">
  23. <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
  24. </script>
  25. <script>
  26. layui.use(['table','form'], function () {
  27. var table = layui.table;
  28. var form = layui.form;
  29. table.render({
  30. elem: '#list-box'
  31. , url: '{:createUrl("index")}'
  32. , toolbar: '#list-toolbar'
  33. , defaultToolbar: []
  34. , title: '数据表'
  35. , cols: [[
  36. {type: 'checkbox'}
  37. , {field: 'id', title: 'ID', width: 80, unresize: true, sort: true,align:"center"}
  38. , {field: 'name', title: '用户名'}
  39. , {field:'status', title:'状态', width:120,align:"center",templet: '#checkboxTpl'}
  40. , {fixed: 'right', align: 'center', title: '操作', toolbar: '#list-bar', width: 130}
  41. ]]
  42. , text: {
  43. none: '<div><i class="layui-icon">&#xe702;</i>暂无相关数据</div>'
  44. }
  45. , page: true
  46. , height: 'full-200'
  47. // ,limit:30
  48. });
  49. //头工具栏事件
  50. table.on('toolbar(list-box)', function (obj) {
  51. switch (obj.event) {
  52. case 'refresh':
  53. window.location.reload();
  54. break;
  55. }
  56. });
  57. //监听行工具事件
  58. table.on('tool(list-box)', function (obj) {
  59. var data = obj.data;
  60. if (obj.event === 'edit') {
  61. window.location.href = '{:createUrl("editor")}?id='+data.id;
  62. }
  63. });
  64. //监听锁定操作
  65. form.on('checkbox(status-filter)', function(obj){
  66. var that = this;
  67. $.get('{:createUrl("field")}',{
  68. name : that.name,
  69. value : (obj.elem.checked ? 0 : 1),
  70. id : that.value
  71. },function (result){
  72. if(!result.code){
  73. layer.msg(result.msg,{ icon : 2 });
  74. }
  75. },"json");
  76. });
  77. });
  78. </script>