|  | @@ -96,18 +96,13 @@ module.exports = app => {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          async getLastChild(tree_pid) {
 | 
	
		
			
				|  |  | -            if (tree_pid === -1) {
 | 
	
		
			
				|  |  | -                const result = await this.getAllDataByCondition({ where: { tree_pid, project_id: this.ctx.session.sessionProject.id }, orders: [['tree_order', 'asc']], limit: 1, offset: 0 });
 | 
	
		
			
				|  |  | -                return result[0];
 | 
	
		
			
				|  |  | -            } else {
 | 
	
		
			
				|  |  | -                const result = await this.getAllDataByCondition({ where: { tree_pid }, orders: [['tree_order', 'asc']], limit: 1, offset: 0 });
 | 
	
		
			
				|  |  | -                return result[0];
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | +            const result = await this.getAllDataByCondition({ where: { tree_pid, project_id: this.ctx.session.sessionProject.id }, orders: [['tree_order', 'desc']], limit: 1, offset: 0 });
 | 
	
		
			
				|  |  | +            return result[0];
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          async getPosterityData(id){
 | 
	
		
			
				|  |  |              const result = [];
 | 
	
		
			
				|  |  | -            let cur = await this.getAllDataByCondition({ where: { tree_pid: id } });
 | 
	
		
			
				|  |  | +            let cur = await this.getAllDataByCondition({ where: { tree_pid: id, project_id: this.ctx.session.sessionProject.id } });
 | 
	
		
			
				|  |  |              let iLevel = 1;
 | 
	
		
			
				|  |  |              while (cur.length > 0 && iLevel < 6) {
 | 
	
		
			
				|  |  |                  result.push(...cur);
 | 
	
	
		
			
				|  | @@ -127,7 +122,7 @@ module.exports = app => {
 | 
	
		
			
				|  |  |                      step = step + 1;
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            return await this.getAllDataByCondition({ where: { tree_pid: node.tree_pid, tree_order, project_id: this.ctx.session.sessionProject.id }, orders: [['tree_order', 'desc']]});
 | 
	
		
			
				|  |  | +            return await this.getAllDataByCondition({ where: { tree_pid: node.tree_pid, tree_order, project_id: this.ctx.session.sessionProject.id }, orders: [['tree_order', 'asc']]});
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          async addFolder(data) {
 | 
	
	
		
			
				|  | @@ -271,12 +266,12 @@ module.exports = app => {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          async _topMove(node) {
 | 
	
		
			
				|  |  | -            const lastChild = await this.getLastChild(-1);
 | 
	
		
			
				|  |  | +            const lastChild = await this.getLastChild(rootId);
 | 
	
		
			
				|  |  |              const posterity = await this.getPosterityData(node.id);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              const conn = await this.db.beginTransaction();
 | 
	
		
			
				|  |  |              try {
 | 
	
		
			
				|  |  | -                const updateData = { id: node.id, tree_pid: -1, tree_level: 1, tree_order: lastChild ? lastChild.tree_order + 1 : 1 };
 | 
	
		
			
				|  |  | +                const updateData = { id: node.id, tree_pid: rootId, tree_level: 1, tree_order: lastChild ? lastChild.tree_order + 1 : 1 };
 | 
	
		
			
				|  |  |                  await conn.update(this.tableName, updateData);
 | 
	
		
			
				|  |  |                  if (node.tree_level !== 1 && posterity.length > 0) {
 | 
	
		
			
				|  |  |                      const posterityUpdateData = posterity.map(x => {
 |