Kaynağa Gözat

清单精灵编辑器,收起定额、展开全部

zhongzewei 6 yıl önce
ebeveyn
işleme
9770950fa9

+ 2 - 2
web/maintain/billsGuidance_lib/html/zhiyin.html

@@ -44,7 +44,7 @@
                         <a id="downLevel" href="javascript:void(0);" class="btn btn-sm disabled" data-toggle="tooltip" data-placement="bottom" title=""><i class="fa fa-arrow-right" aria-hidden="true"></i> 降级</a>
                         <a id="downMove" href="javascript:void(0);" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title=""><i class="fa fa-arrow-down" aria-hidden="true"></i> 下移</a>
                         <a id="upMove" href="javascript:void(0);" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title=""><i class="fa fa-arrow-up" aria-hidden="true"></i> 上移</a>
-                        <!--<a id="expandContract" href="javascript:void(0);" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title=""><i class="fa fa-minus-square-o" aria-hidden="true"></i> 收起定额</a>-->
+                        <a id="expandContract" href="javascript:void(0);" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title=""><i class="fa fa-minus-square-o" aria-hidden="true"></i> 收起定额</a>
                       </div>
                     </div>
                       <div class="main-top-content">
@@ -138,4 +138,4 @@
     autoFlashHeight();
 </script>
 
-</html>
+</html>

+ 48 - 7
web/maintain/billsGuidance_lib/js/billsGuidance.js

@@ -1,5 +1,4 @@
 'use strict';
-
 /**
  *
  *
@@ -336,13 +335,17 @@ const billsGuidance = (function () {
         if(!node.guidance.tree){
             getItemsByBills(libID, node.data.ID, function (rstData) {
                 initTree(node.guidance, guideSheet, guideItem.treeSetting, rstData);
+                setNodesExpandState(node.guidance.tree.items, curExpandState);
+                renderSheetFunc(guideSheet, function () {
+                    TREE_SHEET_HELPER.refreshNodesVisible(node.guidance.tree.roots, guideSheet, true);
+                });
                 //设置底色
                 setNodesColor(guideSheet, node.guidance.tree.items);
                 //项目指引初始焦点
                 guideItemInitSel(guideSheet.getActiveRowIndex() ? guideSheet.getActiveRowIndex() : 0);
             });
-        }
-        else{
+        } else{
+            setNodesExpandState(node.guidance.tree.items, curExpandState);
             node.guidance.controller.showTreeData();
             //设置底色
             setNodesColor(guideSheet, node.guidance.tree.items);
@@ -351,13 +354,31 @@ const billsGuidance = (function () {
         }
     }
     //设置项目节点展开收起状态:展开全部、收起定额
-    //@param {Array}nodes(当前清单下的所有项目指引节点) {Number}expandState(展开全部1或收起定额0)
+    //@param {Array}nodes(当前清单下的所有项目指引节点) {Number}expandState(展开全部1或收起定额0).
     function setNodesExpandState(nodes, expandState) {
         if(expandState === itemExpandState.contract) {
-            //找出所有定额节点的父节点
-            let rationParents = [];
+            //找出所有定额的父节点
+            let rations = _.filter(nodes, function (node) {
+                return node.data.type === itemType.ration;
+            });
+            let rationParentIDs = [];
+            for(let ration of rations){
+                if(ration.data.ParentID != -1){
+                    rationParentIDs.push(ration.data.ParentID);
+                }
+            }
+            rationParentIDs = Array.from(new Set(rationParentIDs));
+            let rationParentNodes = _.filter(nodes, function (node) {
+                return rationParentIDs.includes(node.data.ID);
+            });
+            //收起定额
+            for(let node of rationParentNodes){
+                node.setExpanded(false);
+            }
         } else {
-
+            for(let node of nodes){
+                node.setExpanded(true);
+            }
         }
     }
     //根据奇偶层级设置节点底色,奇数层为蓝色(树节点深度为偶数)
@@ -455,6 +476,8 @@ const billsGuidance = (function () {
         if(node && node.nextSibling){
             $('#downMove').removeClass('disabled');
         }
+        //收起定额、展开全部
+        $('#expandContract').removeClass('disabled');
         //插入定额
         if(node && (node.children.length === 0 || allRationChildren(node))){
             $('#insertRation').removeClass('disabled');
@@ -1565,6 +1588,24 @@ const billsGuidance = (function () {
         $('#downMove').click(function () {
             downMove();
         });
+        //收起定额、展开全部
+        $('#expandContract').click(function () {
+            //目前状态时展开全部节点状态,点击则收起定额
+            let tree = bills.tree.selected.guidance.tree,
+                itemSheet = guideItem.workBook.getActiveSheet();
+            if(curExpandState === itemExpandState.expand){
+                curExpandState = itemExpandState.contract;
+                $(this).html('<i class="fa fa-plus-square-o" aria-hidden="true"></i> 展开全部');
+                setNodesExpandState(tree.items, itemExpandState.contract);
+            } else {
+                curExpandState = itemExpandState.expand;
+                $(this).html('<i class="fa fa-minus-square-o" aria-hidden="true"></i> 收起定额');
+                setNodesExpandState(tree.items, itemExpandState.expand);
+            }
+            renderSheetFunc(itemSheet, function () {
+                TREE_SHEET_HELPER.refreshNodesVisible(tree.roots, itemSheet, true);
+            });
+        });
         $('#insertRation').click(function () {
             let checkedRows = getCheckedRationRows();
             let insertDatas = getInsertRations(checkedRows);