Przeglądaj źródła

优化表头固定

laiguoran 5 lat temu
rodzic
commit
194d0db6b0
1 zmienionych plików z 7 dodań i 1 usunięć
  1. 7 1
      app/public/js/tender_showhide.js

+ 7 - 1
app/public/js/tender_showhide.js

@@ -49,8 +49,12 @@ function localHideList() {
         removeLocalCache(uphlname);
         setLocalCache('pro_'+ pid + '_category_list', cate);
     }
+    setTopTr();
+}
+// 设置表头固定并动态调整宽度高度
+function setTopTr() {
     for(let item = 0; item < $(".c-body table>thead>tr>th").length; item ++) {
-        $(".c-body table>thead>tr>th").eq(item).outerWidth($(".c-body table>tbody>tr:last").children('td').eq(item).outerWidth());
+        $(".c-body table>thead>tr>th").eq(item).outerWidth($(".c-body table>tbody>tr:first").children('td').eq(item).outerWidth());
     }
     $('.c-body table').css('margin-top', $(".c-body table>thead").height() - 4);
 }
@@ -111,6 +115,7 @@ $(document).ready(() => {
             hideList.splice(index, 1);
             setLocalCache(uphlname, JSON.stringify(hideList));
         }
+        setTopTr();
     });
 
     // 一键展开和收起
@@ -135,6 +140,7 @@ $(document).ready(() => {
                 }
             }
         }
+        setTopTr();
     })
 });