Просмотр исходного кода

Merge branch 'master' of http://192.168.1.41:3000/SmartCost/YangHuCost

TonyKang 6 лет назад
Родитель
Сommit
3de092aa62

+ 3 - 2
modules/pm/controllers/pm_controller.js

@@ -451,10 +451,11 @@ module.exports = {
     },
 
     recGC: function(request, response){
-        let userID = request.session.sessionUser.id;
+        let userID = request.session.sessionUser.id,
+            compilationId = request.session.sessionCompilation._id;
         let data = JSON.parse(request.body.data);
         let nodes = data.nodes;
-        ProjectsData.recGC(userID, nodes, function (err, msg, data) {
+        ProjectsData.recGC(userID, compilationId, nodes, function (err, msg, data) {
             callback(request, response, err, msg, data);
         });
    },

+ 4 - 4
modules/pm/models/project_model.js

@@ -467,8 +467,8 @@ ProjectsDAO.prototype.getGCFiles = async function (fileType, userID) {
     return rst;
 };
 
-ProjectsDAO.prototype.getFirstNodeID = async function (userID, pid) {
-    let nodes = await Projects.find({userID: userID, ParentID: pid, deleteInfo: null});
+ProjectsDAO.prototype.getFirstNodeID = async function (userID, compilationId, pid) {
+    let nodes = await Projects.find({userID: userID, compilation: compilationId, ParentID: pid, deleteInfo: null});
     if (nodes.length === 0) {
         return -1;
     }
@@ -499,7 +499,7 @@ ProjectsDAO.prototype.getFirstNodeID = async function (userID, pid) {
     }
 };
 
-ProjectsDAO.prototype.recGC = async function (userID, datas, callback) {
+ProjectsDAO.prototype.recGC = async function (userID, compilationId, datas, callback) {
     let functions = [];
     let updateDatas = [];
     for (let i = 0, len = datas.length; i < len; i++) {
@@ -521,7 +521,7 @@ ProjectsDAO.prototype.recGC = async function (userID, datas, callback) {
                         datas[i].updateData.ParentID = -1;
                     }
                 }
-                let firstNodeID = await this.getFirstNodeID(userID, projPid);
+                let firstNodeID = await this.getFirstNodeID(userID, compilationId, projPid);
                 datas[i].updateData.NextSiblingID = firstNodeID;
             }
             updateDatas.push(datas[i])

+ 4 - 1
web/building_saas/pm/js/pm_tree.js

@@ -272,7 +272,10 @@ const pmTree = {
                     }
                     that.maxNodeId(node.id());
                     if(parent.childIndex(node) === -1){
-                        if(pre && parent.childIndex(pre) !== -1){
+                        if (!pre) {
+                            parent.children.unshift(node);
+                        }
+                        else if(pre && parent.childIndex(pre) !== -1){
                             parent.children.splice(parent.childIndex(pre) + 1, 0, node);
                         }
                         else if(next && parent.childIndex(next) !== -1){