layui_index.html 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <!-- <title>layui规则管理</title>-->
  6. <title>规则管控</title>
  7. <meta name="description" content="不会写前端只好用layui">
  8. <meta name="author" content="道长"/>
  9. <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
  10. <link rel="icon" href="/static/img/logo.png" type="image/x-icon">
  11. <script src="/static/plugin/layui/layui.js"></script>
  12. <link rel="stylesheet" href="/static/plugin/layui/css/layui.css">
  13. </head>
  14. <body>
  15. <div class="layui-layout layui-layout-admin">
  16. <div class="layui-header">
  17. <div class="layui-logo layui-hide-xs layui-bg-black">layout demo</div>
  18. <!-- 头部区域(可配合layui 已有的水平导航) -->
  19. <ul class="layui-nav layui-layout-left">
  20. </ul>
  21. <ul class="layui-nav layui-layout-right">
  22. <li class="layui-nav-item layui-hide layui-show-md-inline-block">
  23. <a href="javascript:;">
  24. <img src="//tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg" class="layui-nav-img">
  25. tester
  26. </a>
  27. <dl class="layui-nav-child">
  28. <dd><a href="">Your Profile</a></dd>
  29. <dd><a href="">Settings</a></dd>
  30. <dd><a href="">Sign out</a></dd>
  31. </dl>
  32. </li>
  33. <li class="layui-nav-item" lay-header-event="menuRight" lay-unselect>
  34. <a href="javascript:;">
  35. <i class="layui-icon layui-icon-more-vertical"></i>
  36. </a>
  37. </li>
  38. </ul>
  39. </div>
  40. <div class="layui-side layui-bg-black">
  41. <div class="layui-side-scroll">
  42. <!-- 左侧导航区域(可配合layui已有的垂直导航) -->
  43. <ul class="layui-nav layui-nav-tree" lay-filter="test">
  44. <li class="layui-nav-item layui-nav-itemed">
  45. <a class="" href="javascript:;">menu group 1</a>
  46. <dl class="layui-nav-child">
  47. <dd><a href="javascript:;">menu 1</a></dd>
  48. <dd><a href="javascript:;">menu 2</a></dd>
  49. <dd><a href="javascript:;">menu 3</a></dd>
  50. <dd><a href="">the links</a></dd>
  51. </dl>
  52. </li>
  53. <li class="layui-nav-item">
  54. <a href="javascript:;">menu group 2</a>
  55. <dl class="layui-nav-child">
  56. <dd><a href="javascript:;">list 1</a></dd>
  57. <dd><a href="javascript:;">list 2</a></dd>
  58. <dd><a href="">超链接</a></dd>
  59. </dl>
  60. </li>
  61. <li class="layui-nav-item"><a href="javascript:;">click menu item</a></li>
  62. <li class="layui-nav-item"><a href="">the links</a></li>
  63. </ul>
  64. </div>
  65. </div>
  66. <div class="layui-body">
  67. <table class="layui-hide" id="test"></table>
  68. </div>
  69. <div id="page"></div>
  70. <div class="layui-footer">
  71. <!-- 底部固定区域 -->
  72. 底部固定区域
  73. </div>
  74. </div>
  75. <script type="text/html" id="toolbarDemo">
  76. <div class="layui-btn-container">
  77. <button class="layui-btn layui-btn-sm" lay-event="getCheckData">获取选中行数据</button>
  78. </div>
  79. </script>
  80. <script>
  81. //JS
  82. layui.use(['element', 'layer', 'util','table','laypage'], function(){
  83. var element = layui.element
  84. ,layer = layui.layer
  85. ,util = layui.util
  86. ,$ = layui.$
  87. ,laypage = layui.laypage
  88. var table = layui.table;
  89. // table.render({
  90. // elem: '#test'
  91. // ,url: '/layui/api/list'
  92. // ,cellMinWidth: 80
  93. // ,totalRow: true // 开启合计行
  94. // ,page: true //是否显示分页
  95. // ,limit: 10
  96. // , request: {
  97. // pageName: 'page' //页码的参数名称,默认:page
  98. // ,limitName: 'limit' //每页数据量的参数名,默认:limit
  99. // }
  100. // ,cols: [[ //标题栏
  101. // {type: 'checkbox', fixed: 'left'}
  102. // ,{field: 'id', title: 'ID', width: 80, sort: true}
  103. // ,{field: 'name', title: '名称', width: 120}
  104. // ,{field: 'key', title: '唯一标识', width: 120}
  105. // ,{field: 'type', title: '类型', minWidth: 150}
  106. // ,{field: 'searchable', title: '可搜索', minWidth: 150}
  107. // ,{field: 'quickSearch', title: '可快速搜索', minWidth: 150}
  108. // ,{field: 'filterable', title: '可筛选', minWidth: 150}
  109. // ]]
  110. // ,skin: 'line' //表格风格
  111. // ,toolbar: '#toolbarDemo'
  112. // ,parseData: function(res){ //将原始数据解析成 table 组件所规定的数据
  113. // return {
  114. // "code": res.code, //解析接口状态
  115. // "msg": res.message, //解析提示文本
  116. // "count": res.total, //解析数据长度
  117. // "data": res.data //解析数据列表
  118. // };
  119. // }
  120. // });
  121. table.render({
  122. elem: '#test'
  123. ,url: '/layui/api/list' // 此处为静态模拟数据,实际使用时需换成真实接口
  124. ,toolbar: '#toolbarDemo'
  125. ,defaultToolbar: ['filter', 'exports', 'print', {
  126. title: '帮助'
  127. ,layEvent: 'LAYTABLE_TIPS'
  128. ,icon: 'layui-icon-tips'
  129. }]
  130. ,height: 'full-200' // 最大高度减去其他容器已占有的高度差
  131. ,cellMinWidth: 80
  132. // ,totalRow: true // 开启合计行
  133. ,page: true
  134. ,limit:10
  135. ,cols: [[
  136. {type: 'checkbox', fixed: 'left'}
  137. ,{field: 'id', title: 'ID', width: 80, sort: true}
  138. ,{field: 'name', title: '名称', width: 120}
  139. ,{field: 'key', title: '唯一标识', width: 120}
  140. ,{field: 'type', title: '类型', minWidth: 150}
  141. ,{field: 'searchable', title: '可搜索', minWidth: 150}
  142. ,{field: 'quickSearch', title: '可快速搜索', minWidth: 150}
  143. ,{field: 'filterable', title: '可筛选', minWidth: 150}
  144. // ,{field: 'id', fixed: 'left',title: 'ID', width: 80, sort: true,totalRowText: '合计:'}
  145. // ,{field: 'name', title: '名称', width: 120}
  146. // ,{field: 'key', title: '唯一标识', width: 120}
  147. // ,{field: 'type', title: '<i class="layui-icon layui-icon-email">类型</i>', minWidth: 150}
  148. // ,{field: 'searchable', title: '可搜索', minWidth: 150}
  149. // ,{field: 'quickSearch', title: '可快速搜索', minWidth: 150}
  150. // ,{field: 'filterable', title: '可筛选', minWidth: 150}
  151. // ,{field:'city', width:115, title: '城市', minWidth:115, templet: '#cityTpl', exportTemplet: function(d, obj){
  152. // //console.log(obj)
  153. // // 处理该字段的导出数据
  154. // var td = obj.td(this.field); //获取当前 td
  155. // return td.find('select').val();
  156. // }}
  157. // ,{fixed: 'right', title:'操作', width: 125, minWidth: 125, toolbar: '#barDemo'}
  158. ]]
  159. });
  160. //头部事件
  161. util.event('lay-header-event', {
  162. //左侧菜单事件
  163. menuLeft: function(othis){
  164. layer.msg('展开左侧菜单的操作', {icon: 0});
  165. }
  166. ,menuRight: function(){
  167. layer.open({
  168. type: 1
  169. ,content: '<div style="padding: 15px;">处理右侧面板的操作</div>'
  170. ,area: ['260px', '100%']
  171. ,offset: 'rt'
  172. ,anim: 5
  173. ,shadeClose: true
  174. });
  175. }
  176. });
  177. table.on('toolbar(test)', function(obj){
  178. var checkStatus = table.checkStatus(obj.config.id); //获取选中行状态
  179. switch(obj.event){
  180. case 'getCheckData':
  181. var data = checkStatus.data; //获取选中行数据
  182. layer.alert(JSON.stringify(data));
  183. break;
  184. }
  185. });
  186. });
  187. </script>
  188. </body>
  189. </html>