|  | @@ -1,7 +1,8 @@
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  |   * Created by Tony on 2017/1/23.
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  | -const NODE_ID = "ID", P_ID = "ParentID", NEXT_ID = "NextSiblingID", ADHOC_PRE_ID="Previous_ID", CHILDREN_NODE = "items", SUB_ID = "sub_ids", EMPTY_ID_VAL = -1, TREE_LEVEL = 'treeLevel';
 | 
	
		
			
				|  |  | +const NODE_ID = "ID", P_ID = "ParentID", NEXT_ID = "NextSiblingID", ADHOC_PRE_ID="Previous_ID", CHILDREN_NODE = "items", SUB_ID = "sub_ids",
 | 
	
		
			
				|  |  | +      EMPTY_ID_VAL = -1, TREE_LEVEL = 'treeLevel', TOP_BILL_ID = "topBillID";
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  let tree_Data_Helper = {
 | 
	
		
			
				|  |  |      buildTreeNodeDirectly: function(data, addLevel) {
 | 
	
	
		
			
				|  | @@ -16,7 +17,7 @@ let tree_Data_Helper = {
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              return tmpNodeRst;
 | 
	
		
			
				|  |  |          };
 | 
	
		
			
				|  |  | -        let private_buildNodeData = function(parentItem, idArr, treeLevel) {
 | 
	
		
			
				|  |  | +        let private_buildNodeData = function(parentItem, idArr, treeLevel, tbID) {
 | 
	
		
			
				|  |  |              let iter = [], nextNode = private_getStartNode(idArr);
 | 
	
		
			
				|  |  |              while (nextNode !== null && nextNode !== undefined ) {
 | 
	
		
			
				|  |  |                  if (parentItem) {
 | 
	
	
		
			
				|  | @@ -25,11 +26,19 @@ let tree_Data_Helper = {
 | 
	
		
			
				|  |  |                      rst.push(nextNode);
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  iter.push(nextNode);
 | 
	
		
			
				|  |  | +                nextNode[TOP_BILL_ID] = tbID;
 | 
	
		
			
				|  |  | +                if (parentItem === null) {
 | 
	
		
			
				|  |  | +                    nextNode[TOP_BILL_ID] = nextNode[NODE_ID];
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  |                  if (addLevel) nextNode[TREE_LEVEL] = treeLevel;
 | 
	
		
			
				|  |  |                  nextNode = tmpNodes[prefix + nextNode[NEXT_ID]];
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              for (let i = 0; i < iter.length; i++) {
 | 
	
		
			
				|  |  | -                private_buildNodeData(iter[i], iter[i][SUB_ID], (treeLevel + 1));
 | 
	
		
			
				|  |  | +                let rtbID = tbID;
 | 
	
		
			
				|  |  | +                if (parentItem === null) {
 | 
	
		
			
				|  |  | +                    rtbID = iter[i][NODE_ID];
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                private_buildNodeData(iter[i], iter[i][SUB_ID], (treeLevel + 1), rtbID);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          };
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -52,7 +61,7 @@ let tree_Data_Helper = {
 | 
	
		
			
				|  |  |                  tmpNodes[prefix + data[i][P_ID]][SUB_ID].push(data[i][NODE_ID]);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        private_buildNodeData(null, topArr, 0);
 | 
	
		
			
				|  |  | +        private_buildNodeData(null, topArr, 0, -1);
 | 
	
		
			
				|  |  |          //try to release and return
 | 
	
		
			
				|  |  |          tmpNodes = null;
 | 
	
		
			
				|  |  |          topArr.length = 0;
 |