Parcourir la source

fix: TASK #5388 调整(考虑文件夹情况)

Tony Kang il y a 2 mois
Parent
commit
ecf80aa618
1 fichiers modifiés avec 42 ajouts et 22 suppressions
  1. 42 22
      web/building_saas/pm/js/pm_newMain.js

+ 42 - 22
web/building_saas/pm/js/pm_newMain.js

@@ -555,34 +555,54 @@ const projTreeObj = {
         if (nodeSelections.length > 1 || nodeSelections[0].rowCount > 1) {
           // 多选情况
           // a. 收集所有顶节点(即建设项目)的row序号
-          const rootRows = [0];
+          const rootRows = [];
           const prjSelections = [];
-          let cnt = 0;
+          let prjIdx = 0;
+          const prjSet = [];
+          const chkAndSetProjectIndex = (parentNode) => {
+            if (parentNode.data.projType === 'Project') {
+              rootRows.push(prjIdx); // 记录建设项目所在的行index
+              prjSet.push(parentNode);
+            }
+            prjIdx++; // 注意:此计数器是必须+1,无论是不是建设项目类型
+            if (parentNode.children && parentNode.children.length > 0) {
+              for (const subNode of parentNode.children) {
+                chkAndSetProjectIndex(subNode);
+              }
+            }
+          };
           for (let nIdx = 0; nIdx < projTreeObj.tree._root.children.length; nIdx++) {
             const rNode = projTreeObj.tree._root.children[nIdx];
-            cnt += rNode.children.length + 1; // 要加上顶节点
-            rootRows.push(cnt);
+            chkAndSetProjectIndex(rNode); // 考虑到有文件夹类型,得换一种方式处理
           }
           // b. 判断所选节点所属建设项目并记录
           for (let nsIdx = 0; nsIdx < nodeSelections.length; nsIdx++) {
             const selection = nodeSelections[nsIdx];
-            for (let idx = 0; idx < rootRows.length - 1; idx++) {
-              // 还要考虑rowCount(连续选择情况)
-              for (let rIdx = 0; rIdx < selection.rowCount; rIdx++) {
-                if (selection.row + rIdx === rootRows[idx]) {
-                  if (!prjSelections.includes(projTreeObj.tree._root.children[idx])) {
-                    prjSelections.push(projTreeObj.tree._root.children[idx]);
-                  }
-                  break;
-                } else if (selection.row + rIdx > rootRows[idx] && selection.row + rIdx < rootRows[idx + 1]) {
-                  if (!prjSelections.includes(projTreeObj.tree._root.children[idx])) {
-                    prjSelections.push(projTreeObj.tree._root.children[idx]);
-                  }
-                  break;
+            for (let rIdx = 0; rIdx < selection.rowCount; rIdx++) {
+              const rowIdx = rootRows.indexOf(selection.row + rIdx);
+              if (rowIdx >= 0) {
+                if (!prjSelections.includes(prjSet[rowIdx])) {
+                  prjSelections.push(prjSet[rowIdx]);
                 }
-                //
               }
             }
+            // for (let idx = 0; idx < rootRows.length - 1; idx++) {
+            //   // 还要考虑rowCount(连续选择情况)
+            //   for (let rIdx = 0; rIdx < selection.rowCount; rIdx++) {
+            //     if (selection.row + rIdx === rootRows[idx]) {
+            //       if (!prjSelections.includes(projTreeObj.tree._root.children[idx])) {
+            //         prjSelections.push(projTreeObj.tree._root.children[idx]);
+            //       }
+            //       break;
+            //     } else if (selection.row + rIdx > rootRows[idx] && selection.row + rIdx < rootRows[idx + 1]) {
+            //       if (!prjSelections.includes(projTreeObj.tree._root.children[idx])) {
+            //         prjSelections.push(projTreeObj.tree._root.children[idx]);
+            //       }
+            //       break;
+            //     }
+            //     //
+            //   }
+            // }
           }
           // 间歇(2秒)并发导出
           const allSelectCnt = prjSelections.length;
@@ -591,7 +611,7 @@ const projTreeObj = {
             setTimeout(function () {
               const pSelection = prjSelections[curIdx];
               curIdx++;
-              projTreeObj.exportProject(pSelection.data.ID, pSelection.data.name);
+              projTreeObj.exportProject(pSelection.data.ID, pSelection.data.name, curIdx !== 1);
               if (curIdx < allSelectCnt) {
                 exportPrjFunc(2000);
               }
@@ -2286,8 +2306,8 @@ const projTreeObj = {
     //在一次的修改中,同一个建设下,单价文件、费率文件才有共用的情况,而refreshProjectData是传入单位工程ID,刷新整个建设项目,所以,只要传入修改的单位工程ID,刷新建设项目即可
     this.refreshProjectData(projectID);
   },
-  exportProject: async function (projectID, projectName) {
-    $.bootstrapLoading.progressStart();
+  exportProject: async function (projectID, projectName, disableProgress = false) {
+    if (!disableProgress) $.bootstrapLoading.progressStart();
     let spString = "|----|";
     try {
       let sumString = "";
@@ -2325,7 +2345,7 @@ const projTreeObj = {
       console.log(e);
     } finally {
       await setTimeoutSync(null, 500); //设置间隔
-      $.bootstrapLoading.progressEnd();
+      if (!disableProgress) $.bootstrapLoading.progressEnd();
     }
 
     async function getProjectInfo(data) {