rabin hace 3 años
padre
commit
e85ffe9d51

+ 26 - 4
assets/layadmin/html/project/database/list.html

@@ -19,10 +19,10 @@
 }
 
 .table th,.table td {
-  min-width: 70px;
+  /*min-width: 70px;*/
 }
 #table_2,#table_1 {
-  overflow: auto;
+  overflow: hidden;
 }
 .layui-btn-xs
 {
@@ -45,6 +45,11 @@
   width: 100%;
   height:300px;
 }
+.table-header-fixed {
+    top: 0;
+    position: fixed;
+    z-index: 999;
+}
 </style>
 <div id="load_style" style="display:none;">
 </div>
@@ -167,15 +172,25 @@
     var form = layui.form; 
     var formSelects = layui.formSelects;
 
-    /*
+    
     table.render({
       elem: '#table'
       ,page: false
       ,limit:20
       ,cols: config.table.cols
       ,data: config.table.data
+      ,done:function(res, curr, count) {
+          let headerTop = $('.layui-table-header').offset().top; //获取表格头到文档顶部的距离
+          $(window).scroll(function () {
+             if ((headerTop - $(window).scrollTop()) < 0) { //超过了
+                 $('.layui-table-header').addClass('table-header-fixed'); //添加样式,固定住表头
+             } else { //没超过
+                 $('.layui-table-header').removeClass('table-header-fixed'); //移除样式
+             }
+          });
+      }
     });
-    */
+    
 
     init();
 
@@ -185,6 +200,13 @@
         showMsg('数据结构', $(this), '#struct');
       })
     }
+
+    //滚动body,header跟随滚动
+    $('.layui-table-body').on('scroll', function(e) {
+        var leftPx = $(e.target).scrollLeft(); //获取表格body,滚动条距离左边的长度
+        var left = 'translateX(-' + leftPx + 'px)';
+        $('.layui-table-header .layui-table').css('transform', left); //设置表格header的内容反向(-)移动
+    });
   });
   </script>
 </body>

+ 3 - 2
src/Database.php

@@ -1583,7 +1583,7 @@ class Database
                         (
                             'field' => 'checkbox',
                             'title' => '<input type="checkbox" class="checkbox-checkall" name="checkall" id="checkall" value="list" lay-ignore/>',
-                            'fixed' => 'left',
+                            //'fixed' => 'left',
                         );
                         $result[] = $layui;
                     } else {
@@ -1651,7 +1651,7 @@ class Database
                                 $layui = array
                                 (
                                     'field' => $k,
-                                    'title' => '<a href="' . $link . '" title="' . $text . '" style="color:black;">' . $v['name'] . '&nbsp;<span class="layui-icon layui-icon-' . $icon . '"></span></a>',
+                                    'title' => '<a href="' . $link . '" title="' . $text . '" style="color:black;">' . $v['name'] . '&nbsp;<span class="layui-icon layui-icon-' . $icon . '" style="font-size:12px"></span></a>',
                                 );
                                 $result[] = $layui;
                                 
@@ -1709,6 +1709,7 @@ class Database
 
         $data = array($this->list_thead('layui'));
         $data = Dever::json_encode($data);
+
         $html .= 'config.table.cols = ' . $data;
         return $html;
     }

+ 6 - 4
template/layadmin/project/database/list.php

@@ -35,18 +35,19 @@ $view
 ->fetch('#desc',	'manage/database.info#listDesc', 'none')
  
 # 数据列表的标题 
-/*
+
 ->loop('#list-thead-data', 'manage/database.list_thead_layui')      
 
 # 数据列表 
 ->loop('#list-tbody-data','manage/database.list_tbody_layui')  
-*/
 
+/*
 # 数据列表的标题 
 ->loop('#list-thead tr', 'manage/database.list_thead')      
 
 # 数据列表 
-->loop('#list-tbody','manage/database.list_tbody')  
+->loop('#list-tbody','manage/database.list_tbody') 
+*/
 
 # 统计数据 
 ->loop('#stat_data','manage/database.list_data')  
@@ -82,7 +83,8 @@ $view
 ->fetch('#menu@value', 'manage/database.info#menu')
 ->fetch('#menu_id@value', 'manage/database.info#menu_id')
 
-
+->fetch('#list-thead', ' ') 
+->fetch('#list-tbody', '')      
 # 总数据 加在头部里吧
 //->fetch('#list-desc', '<{Dever::load("manage/database.info#list_desc")}>(共<{Dever::total("current")}>条)')