|  | @@ -1,5 +1,4 @@
 | 
	
		
			
				|  |  |  'use strict';
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  |   *
 | 
	
		
			
				|  |  |   *
 | 
	
	
		
			
				|  | @@ -90,6 +89,13 @@ const billsGuidance = (function () {
 | 
	
		
			
				|  |  |          update: 'update',
 | 
	
		
			
				|  |  |          del: 'delete'
 | 
	
		
			
				|  |  |      };
 | 
	
		
			
				|  |  | +    //项目指引节点状态:展开全部、收起定额
 | 
	
		
			
				|  |  | +    const itemExpandState = {
 | 
	
		
			
				|  |  | +        expand: 1,
 | 
	
		
			
				|  |  | +        contract: 0
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  | +    //项目指引当前节点展开收缩状态,默认展开全部
 | 
	
		
			
				|  |  | +    let curExpandState = 1;
 | 
	
		
			
				|  |  |      const guideItem = {
 | 
	
		
			
				|  |  |          dom: $('#guideItemSpread'),
 | 
	
		
			
				|  |  |          workBook: null,
 | 
	
	
		
			
				|  | @@ -329,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);
 | 
	
	
		
			
				|  | @@ -343,7 +353,36 @@ const billsGuidance = (function () {
 | 
	
		
			
				|  |  |              guideItemInitSel(guideSheet.getActiveRowIndex() ? guideSheet.getActiveRowIndex() : 0);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +    //设置项目节点展开收起状态:展开全部、收起定额
 | 
	
		
			
				|  |  | +    //@param {Array}nodes(当前清单下的所有项目指引节点) {Number}expandState(展开全部1或收起定额0).
 | 
	
		
			
				|  |  | +    function setNodesExpandState(nodes, expandState) {
 | 
	
		
			
				|  |  | +        if(expandState === itemExpandState.contract) {
 | 
	
		
			
				|  |  | +            //找出所有定额的父节点
 | 
	
		
			
				|  |  | +            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);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |      //根据奇偶层级设置节点底色,奇数层为蓝色(树节点深度为偶数)
 | 
	
		
			
				|  |  | +    //@param {Object}sheet {Array}nodes @return {void}
 | 
	
		
			
				|  |  |      function setNodesColor(sheet, nodes) {
 | 
	
		
			
				|  |  |          const color = '#DFE8F9';
 | 
	
		
			
				|  |  |          renderSheetFunc(sheet, function () {
 | 
	
	
		
			
				|  | @@ -437,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');
 | 
	
	
		
			
				|  | @@ -1547,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);
 |