Bläddra i källkod

Merge branch 'budget' of http://192.168.1.41:3000/SmartCost/ConstructionCost into budget

zhangweicheng 4 år sedan
förälder
incheckning
45d63c92b4

+ 1 - 0
modules/all_models/projects.js

@@ -23,6 +23,7 @@ const ProjectSchema = new Schema({
     "code": {type: String, default: ''},
     chapterCode: String,
     sectionCode: String,
+    unit: String,
     "name": String,
     "projType": String,
     "recentDateTime": Date,

+ 2 - 1
modules/complementary_ration_lib/models/sectionTreeModel.js

@@ -13,12 +13,13 @@ const sectionTemplateModel = mongoose.model('complementary_ration_section_templa
 class SectionTreeDao {
     //从补充定额章节树模板中拷贝数据到用户的补充定额章节树中
     async copyDataFromTemplate(userId, compilationId){
+        const srcCompilationID = '5b52b027fd3bb0000b257cf8';
         // 如果已经有数据则不再生成
         const count = await compleRationSectionTreeModel.count({userId, compilationId});
         if (count) {
             return;
         }
-        let templateData = await sectionTemplateModel.find({compilationId: compilationId});
+        let templateData = await sectionTemplateModel.find({compilationId: srcCompilationID});
         if (templateData.length > 0) {
             let insertDatas = [],
                 uuidMapping = {};

+ 27 - 6
modules/main/facade/bill_facade.js

@@ -222,6 +222,7 @@ module.exports={
             item.equipmentFee = equipmentFeeItem ? equipmentFeeItem.totalFee : 0;
             item.otherFee = otherFeeItem ? otherFeeItem.totalFee : 0;
             item.totalFee = totalFeeItem ? totalFeeItem.totalFee : 0;
+            item.unitFee = totalFeeItem ? totalFeeItem.unitFee : 0;
             // 计算占总投资比例
             const rate = totalFee ?  scMathUtil.roundForObj(item.totalFee / totalFee, 4) : 0; 
             item.rate = rate * 100; // 转换为百分比
@@ -230,7 +231,7 @@ module.exports={
     },
     // 获取工程费用数据,作为概算汇总数据的拼接树数据
     getConstructionFeeData: async function (constructionID, nextID) {
-        const projects = await pmFacade.getPosterityProjects([constructionID], true, { _id: 0, ID: 1, ParentID: 1, NextSiblingID: 1, name: 1, projType: 1, chapterCode: 1, sectionCode: 1, 'property.engineeringName': 1});
+        const projects = await pmFacade.getPosterityProjects([constructionID], true, { _id: 0, ID: 1, ParentID: 1, NextSiblingID: 1, name: 1, projType: 1, chapterCode: 1, sectionCode: 1, quantity: 1, unit: 1, 'property.engineeringName': 1});
         const construction = projects.find(p => p.ID === constructionID);
         const items = getSortedTreeData(construction.ParentID, projects);
         // 转换为uuid
@@ -331,16 +332,31 @@ module.exports={
                     unitFeeObj[feeType] = unitFee;
                     singleFeeObj[feeType] = scMathUtil.roundForObj(singleFeeObj[feeType] + unitFee, processDecimal);
                 }
-                unit.fees = feeObj2Fees(unitFeeObj);
+                unit.fees = feeObj2Fees(unitFeeObj, unit.quantity);
             }
-            single.fees = feeObj2Fees(singleFeeObj);
+            single.fees = feeObj2Fees(singleFeeObj, single.quantity);
             // 汇算到建设项目
             constructionFeeObj.total = scMathUtil.roundForObj(constructionFeeObj.total + singleFeeObj.total, processDecimal);
             constructionFeeObj.building = scMathUtil.roundForObj(constructionFeeObj.building + singleFeeObj.building, processDecimal);
             constructionFeeObj.installation = scMathUtil.roundForObj(constructionFeeObj.installation + singleFeeObj.installation, processDecimal);
             constructionFeeObj.equipment = scMathUtil.roundForObj(constructionFeeObj.equipment + singleFeeObj.equipment, processDecimal);
         }
-        construction.fees = feeObj2Fees(constructionFeeObj);
+        construction.fees = feeObj2Fees(constructionFeeObj, construction.quantity);
+        // 更新fees字段
+        const bulks = [];
+        items.forEach(item => {
+            if (item.orgProjectID && item.fees) {
+                bulks.push({
+                    updateOne: {
+                        filter: { ID: item.orgProjectID },
+                        update: { $set: { fees: item.fees } }
+                    }
+                })
+            }
+        });
+        if (bulks.length) {
+            await projectModel.bulkWrite(bulks);
+        }
         // 获取设备购置费(旧)
         /* const equipmentFee = await this.getEquipmentFee(unitProjectIDs);
         const equipmentItem = items.find(item => item.flags && item.flags[0] && item.flags[0].flag === fixedFlag.CONSTRUCTION_EQUIPMENT_FEE);
@@ -350,9 +366,14 @@ module.exports={
         }
         construction.fees.push(equipmentFeeObj); */
 
-        function feeObj2Fees(feeObj) {
+        function feeObj2Fees(feeObj, quantity) {
+            const totalFee = scMathUtil.roundForObj(feeObj.total, decimal)
+            let unitFee = 0;
+            if (+quantity && totalFee) {
+                unitFee = scMathUtil.roundForObj(totalFee / (+quantity), 2);
+            }
             return [
-                { fieldName: 'common', totalFee: scMathUtil.roundForObj(feeObj.total, decimal) },
+                { fieldName: 'common', totalFee: scMathUtil.roundForObj(feeObj.total, decimal), unitFee },
                 { fieldName: 'building', totalFee: scMathUtil.roundForObj(feeObj.building, decimal) },
                 { fieldName: 'installation', totalFee: scMathUtil.roundForObj(feeObj.installation, decimal) },
                 { fieldName: 'equipment', totalFee: scMathUtil.roundForObj(feeObj.equipment, decimal) },

+ 2 - 1
modules/pm/facade/pm_facade.js

@@ -1841,12 +1841,13 @@ async function copyCompleRationSection(userId, compilationId) {
 
 //拷贝补充人材机分类树
 async function copyCompleGljSection(userId, compilationId) {
+    const srcCompilationID = '5b52b027fd3bb0000b257cf8';
     // 如果已有数据则不再生成
     const count = await compleGljSectionModel.count({userId, compilationId});
     if (count) {
         return;
     }
-    let templateData = await compleGljSectionTModel.find({compilationId: compilationId});
+    let templateData = await compleGljSectionTModel.find({compilationId: srcCompilationID});
     if (templateData.length > 0) {
         let insertDatas = [],
             uuidMapping = {};

+ 30 - 11
web/building_saas/budget-summary/js/budgetSummarySheet.js

@@ -72,7 +72,19 @@ const budgetSummaryObj = (() => {
       return '';
     },
     'feesIndex.common.unitFee': (node) => {
-      return _.get(node, 'data.feesIndex.common.unitFee', '') || '';
+      if (node && node.data.area === BudgetArea.CONSTRUCTION_FEE) {
+        // 实时计算显示单价
+        const totalFee = _.get(node, 'data.feesIndex.common.totalFee', 0);
+        const quantity = node.data.quantity || 0;
+        if (!totalFee || !quantity) {
+          return '';
+        }
+        return scMathUtil.roundForObj(totalFee / quantity, 2); // 小数位数写死2位置
+      }
+      if (node && node.data.area === BudgetArea.CONSTRUCTION_OTHER_FEE) {
+        return _.get(node, 'data.feesIndex.common.unitFee', '') || '';
+      }
+      return '';
     },
     'feesIndex.common.totalFee': (node) => {
       return _.get(node, 'data.feesIndex.common.totalFee', '') || '';
@@ -144,6 +156,7 @@ const budgetSummaryObj = (() => {
       // 验证不通过,恢复
       if (!isValid) {
         refreshData(sheet, changedCells);
+        return;
       }
     }
     let needCalc = false;
@@ -191,14 +204,14 @@ const budgetSummaryObj = (() => {
           data.calcBaseValue = node.data.calcBaseValue;
           data.tenderCalcBaseValue = node.data.tenderCalcBaseValue;
         }
-        if (['quantity', 'feesIndex.common.unitFee', 'calcBase', 'feeRate'].includes(field)) {
+        if (['quantity', 'feesIndex.common.unitFee', 'calcBase', 'feeRate'].includes(field) && node.data.area !== BudgetArea.CONSTRUCTION_FEE) {
           needCalc = true;
         }
       });
-      calcNodes = calcNodes ? calcNodes : nodes;
+      calcNodes = calcNodes ? calcNodes : needCalc ? nodes : [];
       // 重算节点
       const dataArr = [];
-      if ((needCalc && nodes.length) || (calcNodes && calcNodes.length)) {
+      if (calcNodes && calcNodes.length) {
         const changedNodes = projectObj.project.calcProgram.calcNodes(calcNodes, false, tree);
         for (const node of changedNodes) {
           nodes.push(node);
@@ -351,16 +364,22 @@ const budgetSummaryObj = (() => {
   // 单元格锁定判断
   const lockFactory = {
     code(node) {
-      return !!(node && node.getFlag());
+      return !!(node && (node.getFlag() || node.data.area === BudgetArea.CONSTRUCTION_FEE));
     },
     name(node) {
-      return !!(node && node.getFlag());
+      return !!(node && (node.getFlag() || node.data.area === BudgetArea.CONSTRUCTION_FEE));
+    },
+    'feesIndex.common.unitFee'(node) {
+      return !!(node && (node.data.area === BudgetArea.CONSTRUCTION_FEE));
     },
     calcBase(node) {
-      return !!(node && node.children.length);
+      return !!(node && (node.children.length  || node.data.area === BudgetArea.CONSTRUCTION_FEE));
     },
     feeRate(node) {
-      return !!(node && node.children.length);
+      return !!(node && (node.children.length || node.data.area === BudgetArea.CONSTRUCTION_FEE));
+    },
+    remark(node) {
+      return !!(node && node.data.area === BudgetArea.CONSTRUCTION_FEE);
     }
   };
   const lockData = (sheet, nodes, isMass = true) => {
@@ -370,7 +389,7 @@ const budgetSummaryObj = (() => {
         return 0;
       }
       // 工程费用区域,只读
-      const constructionFeeNode = nodes.find(node => node.getFlag() === fixedFlag.CONSTRUCTION_FEE);
+      /* const constructionFeeNode = nodes.find(node => node.getFlag() === fixedFlag.CONSTRUCTION_FEE);
       if (!constructionFeeNode) {
         return 0;
       }
@@ -389,7 +408,7 @@ const budgetSummaryObj = (() => {
           }
         }
       }
-      return endIndex;
+      return endIndex; */
     }
     if (isMass) {
       TREE_SHEET_HELPER.massOperationSheet(sheet, () => {
@@ -470,7 +489,7 @@ const budgetSummaryObj = (() => {
     setUnitCombo(sheet, data);
     TREE_SHEET_HELPER.massOperationSheet(sheet, () => {
       const startRow = lockData(sheet, tree.items, false);
-      setCells(sheet, startRow, tree.items);
+      setCells(sheet, 0, tree.items);
       // 表格格式化
       budgetSummaryTreeSetting.cols.forEach((item, index) => {
         sheet.setFormatter(-1, index, item.formatter || '@', GC.Spread.Sheets.SheetArea.viewport);

+ 6 - 5
web/building_saas/main/html/main.html

@@ -67,19 +67,20 @@
   <div class="main">
     <div class="main-nav">
       <ul class="nav nav-tabs flex-column" role="tablist">
-        <li class="nav-item"><a data-toggle="tab" href="#budget-summary" id="tab-budget-summary" role="tab">概算汇总</a>
-        </li>
         <li class="nav-item"><a class="active" data-toggle="tab" href="#zaojiashu" id="tab_zaojiashu" role="tab">造价书</a>
         </li>
         <li class="nav-item"><a data-toggle="tab" href="#project_glj" id="tab_project_glj" data-name="tab_project_glj"
-            role="tab">人材机汇总</a></li>
-            <li class="nav-item"><a data-toggle="tab" href="#equipment_purchase" id="tab_equipment_purchase" role="tab">设备购置</a></li>
+            role="tab">人材机汇总</a>
+        </li>
         <li class="nav-item"><a data-toggle="tab" href="#fee_rates" id="tab_fee_rate" role="tab">费率</a></li>
+        <li class="nav-item"><a data-toggle="tab" href="#gather_fees" id="tab_gather_fees" role="tab">费用汇总</a></li>
+        <li class="nav-item"><a data-toggle="tab" href="#equipment_purchase" id="tab_equipment_purchase" role="tab">设备购置</a></li>
+        <li class="nav-item"><a data-toggle="tab" href="#budget-summary" id="tab-budget-summary" role="tab">概算汇总</a>
+        </li>
         <li class="nav-item"><a data-toggle="tab" href="#calc_program_manage" id="tab_calc_program_manage" role="tab"
             style="display:none">总计算程序</a></li>
         <li class="nav-item"><a data-toggle="tab" href="#tender_price" id="tab_tender_price" role="tab" style="display:none">调价</a></li>
      
-              <li class="nav-item"><a data-toggle="tab" href="#gather_fees" id="tab_gather_fees" role="tab">费用汇总</a></li>
         <li class="nav-item"><a data-toggle="tab" href="#reports" role="tab" id="tab_report"
             onclick="rptTplObj.iniPage();">报表</a></li>
         <li class="nav-item"><a data-toggle="tab" href="#index" id="tab_index" role="tab" style="display:none">指标信息</a>

+ 1 - 1
web/building_saas/main/js/views/gather_fees_view.js

@@ -8,7 +8,7 @@ let gatherFeesView = {
         header:[
             // {headerName:"ID",headerWidth:80,dataCode:"ID", hAlign: "center"},
             {headerName:"费用类别",headerWidth:160,dataCode:"name", dataType: "String"},
-            {headerName:"金额",headerWidth:80,dataCode:"totalFee", dataType: "String",hAlign: "right"}
+            {headerName:"金额",headerWidth:100,dataCode:"totalFee", dataType: "String",hAlign: "right"}
         ],
         view:{
             comboBox:[],