Authored by 王涛

首页资源下探,默认展示空白问题

@@ -50,10 +50,22 @@ layui.define(['laytpl', 'admin', 'form', 'table', 'soulTable', 'sessions', 'comm @@ -50,10 +50,22 @@ layui.define(['laytpl', 'admin', 'form', 'table', 'soulTable', 'sessions', 'comm
50 var getTpl = document.getElementById("biz_reslist_restype_tab_tpl").innerHTML; 50 var getTpl = document.getElementById("biz_reslist_restype_tab_tpl").innerHTML;
51 laytpl(getTpl).render(res.data, function (html) { 51 laytpl(getTpl).render(res.data, function (html) {
52 $('#biz_reslist_restype_tab').html(html); 52 $('#biz_reslist_restype_tab').html(html);
  53 + var active = '';
  54 + var activeItem = '';
  55 + var data = res.data;
  56 + for (let i = 0; i < data.length; i++) {
  57 + var v = data[i];
  58 + if(v.resNum > 0){
  59 + activeItem = v;
  60 + $('#biz_reslist_restype_tab').find('[data-id="'+v.resTypeCode+'"]').addClass('layui-this');
  61 + break;
  62 + }
  63 + }
  64 +
53 // 默认加载第一个 65 // 默认加载第一个
54 - if (res.data[0]) {  
55 - var resType = res.data[0]["resTypeCode"];  
56 - activeResType = res.data[0]["resTypeCode"]; 66 + if (activeItem) {
  67 + var resType = activeItem.resTypeCode;//res.data[0]["resTypeCode"];
  68 + activeResType = activeItem.resTypeCode;//res.data[0]["resTypeCode"];
57 if (resType && $.inArray(resType, treeTableResTypes) !== -1) { 69 if (resType && $.inArray(resType, treeTableResTypes) !== -1) {
58 renderTreeTable(bizId, resType); 70 renderTreeTable(bizId, resType);
59 } else { 71 } else {
@@ -881,4 +893,4 @@ layui.define(['laytpl', 'admin', 'form', 'table', 'soulTable', 'sessions', 'comm @@ -881,4 +893,4 @@ layui.define(['laytpl', 'admin', 'form', 'table', 'soulTable', 'sessions', 'comm
881 $("#biz_reslist_server_state").val(''); 893 $("#biz_reslist_server_state").val('');
882 }; 894 };
883 }); 895 });
884 -});  
  896 +});
@@ -309,7 +309,7 @@ @@ -309,7 +309,7 @@
309 <script type="text/html" id="biz_reslist_restype_tab_tpl"> 309 <script type="text/html" id="biz_reslist_restype_tab_tpl">
310 {{# layui.each(d, function(index, item){ }} 310 {{# layui.each(d, function(index, item){ }}
311 {{# var acive = '', hideCls = ''}} 311 {{# var acive = '', hideCls = ''}}
312 - {{# if(index==0){ acive = "layui-this" } }} 312 + {{# if(index==0){ acive = "" } }}
313 {{# if(item.resNum == 0){ hideCls = "hide" } }} 313 {{# if(item.resNum == 0){ hideCls = "hide" } }}
314 314
315 <li class="{{acive}} {{hideCls}}" data-id="{{item.resTypeCode}}"> 315 <li class="{{acive}} {{hideCls}}" data-id="{{item.resTypeCode}}">
@@ -323,4 +323,4 @@ @@ -323,4 +323,4 @@
323 layui.use('bizreslist', function (fn) { 323 layui.use('bizreslist', function (fn) {
324 fn(); 324 fn();
325 }); 325 });
326 -</script>  
  326 +</script>