| 
					
				 | 
			
			
				@@ -523,6 +523,9 @@ module.exports = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             //添加分享 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             let shareData = {userID: data.userID, allowCopy: data.allowCopy, shareDate: moment(Date.now()).format('YYYY-MM-DD HH:mm:ss')}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if(data.type === 'create'){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                //覆盖 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                await projectModel.update({ID: data.projectID, $or: [{deleteInfo: null}, {'deleteInfo.deleted': false}]}, {$pull: {shareInfo: {userID: data.userID}}}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                //新增 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 await projectModel.update({ID: data.projectID, $or: [{deleteInfo: null}, {'deleteInfo.deleted': false}]}, {$addToSet: {shareInfo: shareData}}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             //取消分享 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -535,6 +538,52 @@ module.exports = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             callback(req, res, 1, err, null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    //接收到的分享项目,返回未定义组、已定义组 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    receiveProjects: async function(req, res) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            let rst = {grouped: [], ungrouped: []} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            let userID = req.session.sessionUser.id; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            let receiveProjects = await projectModel.find({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $or: [{deleteInfo: null}, {'deleteInfo.deleted': false}], compilation: req.session.sessionCompilation._id, 'shareInfo.userID': userID}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //设置原项目用户信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(receiveProjects.length > 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                let orgUserIDs = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                for(let proj of receiveProjects){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    orgUserIDs.push(proj.userID); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                orgUserIDs = Array.from(new Set(orgUserIDs)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                let userObjIDs = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                for(let uID of orgUserIDs){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    userObjIDs.push(mongoose.Types.ObjectId(uID)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                let orgUsersInfo = await userModel.find({_id: {$in : userObjIDs}}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                for(let proj of receiveProjects){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    //获取分享项目子项 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (proj.projType !== projType.tender) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        proj._doc.children = await pm_facade.getPosterityProjects([proj.ID]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    //设置分组,单位工程及单项工程分到未分组那 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (proj.projType === projType.tender || proj.projType === projType.engineering) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        rst.ungrouped.push(proj); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        rst.grouped.push(proj); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    //设置项目类型为来自别人分享 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    proj._doc.shareType = 'receive'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    for(let userData of orgUsersInfo){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if(proj.userID == userData._id.toString()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            let userInfo = {name: userData.real_name, mobile: userData.mobile, company: userData.company, email: userData.email}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            proj._doc.userInfo = userInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            callback(req, res, 0, 'success', rst); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        catch (err){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            callback(req, res, 1, err, null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     getShareProjects: async function (req, res) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             let userID = req.session.sessionUser.id; 
			 |