Browse Source

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

chenshilong 6 years ago
parent
commit
3b4f7c9284

+ 1 - 1
config/config.js

@@ -94,4 +94,4 @@ module.exports = {
         }
         }
         return importURL
         return importURL
     }
     }
-}
+}

+ 21 - 9
modules/pm/facade/pm_facade.js

@@ -1365,10 +1365,14 @@ async function importFeeRateFiles(mainData,projectIDMap,feeRateFileIDMap,userID)
 async function checkFiles(projects) {
 async function checkFiles(projects) {
     // fileID - tenderID 映射
     // fileID - tenderID 映射
     const mapping = {};
     const mapping = {};
+    const tenderItems = [];
     const unitFileIDs = [];
     const unitFileIDs = [];
     const rateFileIDs = [];
     const rateFileIDs = [];
+    const task = [];
     projects.forEach(project => {
     projects.forEach(project => {
-        if (project.projType === projectType.tender) {
+        const isErrorRootProjectTender = project.projType === projectType.tender && project.property.rootProjectID === -1;
+        if (isErrorRootProjectTender) {
+            tenderItems.push({ ID: project.ID, ParentID: project.ParentID });
             const priceFileID = project.property.unitPriceFile.id;
             const priceFileID = project.property.unitPriceFile.id;
             const feeFileID = project.property.feeFile.id;
             const feeFileID = project.property.feeFile.id;
             if (!mapping[priceFileID]) {
             if (!mapping[priceFileID]) {
@@ -1383,8 +1387,7 @@ async function checkFiles(projects) {
     });
     });
     // 检查是否存在rootProjectID为-1的
     // 检查是否存在rootProjectID为-1的
     const errorUnitFiles = await unitPriceFileModel.find({id: {$in: unitFileIDs}, root_project_id: -1});
     const errorUnitFiles = await unitPriceFileModel.find({id: {$in: unitFileIDs}, root_project_id: -1});
-    console.log(`errorUnitFiles`);
-    console.log(errorUnitFiles);
+    const errorRateFiles = await feeRateFileModel.find({ID: {$in: rateFileIDs}, rootProjectID: -1});
     const unitFileTask = errorUnitFiles.map(file => {
     const unitFileTask = errorUnitFiles.map(file => {
         const rootProjectID = mapping[file.id].ParentID;
         const rootProjectID = mapping[file.id].ParentID;
         return {
         return {
@@ -1395,11 +1398,8 @@ async function checkFiles(projects) {
         };
         };
     });
     });
     if (unitFileTask.length) {
     if (unitFileTask.length) {
-       await unitPriceFileModel.bulkWrite(unitFileTask);
+        task.push(unitPriceFileModel.bulkWrite(unitFileTask));
     }
     }
-    const errorRateFiles = await feeRateFileModel.find({ID: {$in: rateFileIDs}, rootProjectID: -1});
-    console.log(`errorRateFiles`);
-    console.log(errorRateFiles);
     const rateFileTask = errorRateFiles.map(file => {
     const rateFileTask = errorRateFiles.map(file => {
         const rootProjectID = mapping[file.ID].ParentID;
         const rootProjectID = mapping[file.ID].ParentID;
         return {
         return {
@@ -1410,6 +1410,18 @@ async function checkFiles(projects) {
         };
         };
     });
     });
     if (rateFileTask.length) {
     if (rateFileTask.length) {
-        await feeRateFileModel.bulkWrite(rateFileTask);
+        task.push(feeRateFileModel.bulkWrite(rateFileTask));
     }
     }
-}
+    const tenderTask = tenderItems.map(item => {
+        return {
+            updateOne: {
+                filter: {ID: item.ID},
+                update: {$set: {'property.rootProjectID': item.ParentID}}
+            }
+        }
+    });
+    if (tenderTask.length) {
+        task.push(projectModel.bulkWrite(tenderTask));
+    }
+    await Promise.all(task);
+}

+ 1 - 10
web/building_saas/pm/html/project-management.html

@@ -134,16 +134,10 @@
         <div class="side-content">
         <div class="side-content">
             <!--建设项目汇总-->
             <!--建设项目汇总-->
             <div class="p-3" id="summary-project">
             <div class="p-3" id="summary-project">
-
-
-
-                        <legend>单价文件</legend>
+            <legend>单价文件</legend>
                         <table class="table table-bordered table-hover table-sm" id="summary-project-unit-price-table">
                         <table class="table table-bordered table-hover table-sm" id="summary-project-unit-price-table">
                             <thead><th style="width: 25px;"></th><th style="width: 330px;">名称</th><th style="width:40px;">使用</th></thead>
                             <thead><th style="width: 25px;"></th><th style="width: 330px;">名称</th><th style="width:40px;">使用</th></thead>
                             <tbody>
                             <tbody>
-                            <tr><td>1</td><td>A单价文件</td></tr>
-                            <tr><td>2</td><td>B单价文件</td></tr>
-                            <tr><td>3</td><td>C单价文件</td></tr>
                             </tbody>
                             </tbody>
                         </table>
                         </table>
 
 
@@ -152,9 +146,6 @@
                         <table class="table table-bordered table-hover table-sm" id="summary-project-fee-table">
                         <table class="table table-bordered table-hover table-sm" id="summary-project-fee-table">
                             <thead><th style="width: 25px;"></th><th style="width: 330px;">名称</th><th style="width:40px;">使用</th></thead>
                             <thead><th style="width: 25px;"></th><th style="width: 330px;">名称</th><th style="width:40px;">使用</th></thead>
                             <tbody>
                             <tbody>
-                            <tr><td>1</td><td>A费率文件</td></tr>
-                            <tr><td>2</td><td>B费率文件</td></tr>
-                            <tr><td>3</td><td>C费率文件</td></tr>
                             </tbody>
                             </tbody>
                         </table>
                         </table>