zhongzewei 6 лет назад
Родитель
Сommit
d3c30efbf1

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

@@ -495,10 +495,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

@@ -497,8 +497,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;
     }
@@ -529,7 +529,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++) {
@@ -552,7 +552,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])

+ 3 - 9
web/building_saas/pm/js/pm_newMain.js

@@ -216,7 +216,6 @@ const projTreeObj = {
             this.bindEvent(newWorkBook);
             this.loadContextMenu();
             this.loadStartMenu();
-            this.loadBtn();
         }
         return newWorkBook;
     },
@@ -356,7 +355,7 @@ const projTreeObj = {
             }
         },
         importInterface: {
-            name: '导入标接口',
+            name: '导入招投标接口文件',
             icon: 'fa-cloud-upload',
             callback: function () {
                 $('#importInterface').modal('show');
@@ -1238,7 +1237,6 @@ const projTreeObj = {
         $("#mr_title").text(title);
         this.initHtmlByFromRadio();
         let result = from == "unitPriceFile"?await this.setUnitFileChangeFileData():await this.setFeeRateChangeFileData();
-        console.log(result);
         this.changeInfo = result;
         this.loadFileOptions(this.changeInfo,from);
 
@@ -1445,8 +1443,6 @@ const projTreeObj = {
         //发送文件改变消息
         data.oldFileIDs = _.uniq(oldFileIDs);
         socket.emit('multiFileChangeNotify', data);
-
-        console.log(result);
     },
     checkFileName:async function (fileID,name,type) {
         let node = this.tree.selected;
@@ -1579,6 +1575,8 @@ const projTreeObj = {
 
 };
 $(document).ready(function() {
+    //绑定项目管理的升降级、上下移按钮事件
+    projTreeObj.loadBtn();
     $('#sideTab').find('li').click(function () {
        //消除tooltip
         $('[data-toggle="tooltip"]').tooltip('hide');
@@ -1685,7 +1683,6 @@ $(document).ready(function() {
                 infoData = await ajaxPost('/pm/api/getBasicInfo', {user_id: userID});
                 //第一次默认是投标
                 needfulInfoData = getNeedfulBasicInfo(infoData, fileKind);
-                console.log(infoData);
             } catch (err) {
                 $('#add-project-dialog').modal('hide');
             }
@@ -1811,7 +1808,6 @@ $(document).ready(function() {
         curValuation = $(this).val();
         curValuationName = $(this).text();
         let engineeringList = getEngineeringList();
-        console.log(engineeringList);
         let engineeringHtml = getEngineeringHtml(engineeringList);
         $("#tender-engineering").html(engineeringHtml);
         $('#valuation-info').hide();
@@ -2448,7 +2444,6 @@ $(document).ready(function() {
         $("#copy-to-dialog").modal('hide');
         $.bootstrapLoading.start();
         CommonAjax.post('/pm/api/copyProjects',{projectMap:projectMap,user_id: userID},function (result) {
-            console.log(result);
             let newNode = projTreeObj.insert(result['copy'].document,parent,next);
             let refreshNodes = projTreeObj.calEngineeringCost(newNode);
             projTreeObj.refreshNodeData(refreshNodes);
@@ -4464,7 +4459,6 @@ function setShareToModal(selected){
         userIDs.push(user.userID);
     }
     CommonAjax.post('/user/getUsers', {userIDs: userIDs}, function (rstData) {
-        console.log(rstData);
         for(let userInfo of rstData){
             for(let user of selected.data.shareInfo){
                 if(user.userID === userInfo._id){

+ 37 - 2
web/building_saas/pm/js/pm_tree.js

@@ -371,8 +371,43 @@ const pmTree = {
 
             };
 
-            Tree.prototype.refreshData = function () {
-
+            Tree.prototype.check = function (roots, _root) {
+                return isValid(roots);
+                function isValid(nodes) {
+                    for (let node of nodes) {
+                        if (node.data.ParentID !== -1 &&
+                            (!node.parent || node.parent.data.ID !== node.data.ParentID)) {
+                            console.log(node);
+                            console.log(`node.data.ParentID !== -1 &&
+                            (!node.parent || node.parent.data.ID !== node.data.ParentID)`);
+                            return false;
+                        }
+                        if (node.data.ParentID === -1 && node.parent && node.parent !== _root) {
+                            console.log(node);
+                            console.log(`node.data.ParentID === -1 && node.parent && node.parent !== roots`);
+                            return false;
+                        }
+                        if (node.data.NextSiblingID !== -1 &&
+                            (!node.nextSibling || node.nextSibling.data.ID !== node.data.NextSiblingID)) {
+                            console.log(node);
+                            console.log(`node.data.NextSiblingID !== -1 &&
+                            (!node.nextSibling || node.nextSibling.data.ID !== node.data.NextSiblingID)`);
+                            return false;
+                        }
+                        if (node.data.NextSiblingID === -1 && node.nextSibling) {
+                            console.log(node);
+                            console.log(`node.data.NextSiblingID === -1 && node.nextSibling`);
+                            return false;
+                        }
+                        if (node.children.length) {
+                            let v = isValid(node.children);
+                            if (!v) {
+                                return false;
+                            }
+                        }
+                    }
+                    return true;
+                }
             };
 
             return Tree;