Browse Source

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

TonyKang 4 năm trước cách đây
mục cha
commit
27a412ef20

+ 2 - 0
modules/all_models/bills.js

@@ -13,6 +13,8 @@ let billsSchema = new Schema({
     chapterID: Number,
     billsLibId: Number,
     code: String,
+    chapterCode: String,
+    sectionCode: String,
     fullCode: String,
     type:{type: Number,default:4},//1 :大项费用 2:分部 3分项 4清单;5补项
     isAdd:{type: Number,default:0},//1 true 0 false是否新增

+ 3 - 0
modules/all_models/projects.js

@@ -21,6 +21,9 @@ const ProjectSchema = new Schema({
     "userID": {type:String,index: true},
     "importedByInterface": {type: Boolean, default: false},
     "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 = {};

+ 2 - 2
modules/main/controllers/bills_controller.js

@@ -272,8 +272,8 @@ module.exports = {
     initialBudgetSummary: async function (req, res) {
         const data = JSON.parse(req.body.data);
         try {
-            const bills = await bill_facade.initialBudgetSummary(data.constructionID);
-            callback(req, res, 0, 'success', bills);
+            const rst = await bill_facade.initialBudgetSummary(data.constructionID);
+            callback(req, res, 0, 'success', rst);
         } catch (err) {
             console.log(err);
             callback(req, res, 1, err, null);

+ 37 - 9
modules/main/facade/bill_facade.js

@@ -20,7 +20,7 @@ let bill_Model = require('../models/bills').model;
 let billsLibDao = require("../../bills_lib/models/bills_lib_interfaces");
 const pmFacade = require('../../pm/facade/pm_facade');
 const { getSortedTreeData, getEngineeringFeeType } = require('../../../public/common_util');
-const { billType, constructionFeeNodeID, constructionEquipmentFeeNodeID, BudgetArea, fixedFlag } = require('../../../public/common_constants');
+const { billType, constructionFeeNodeID, constructionEquipmentFeeNodeID, BudgetArea, fixedFlag, BudgetType } = require('../../../public/common_constants');
 const scMathUtil = require('../../../public/scMathUtil').getUtil();
 const uuidV1 = require('uuid/v1');
 const equipmentFacade = require('../../equipment_purchase/facade/equipment_purchase_facade');
@@ -149,10 +149,12 @@ module.exports={
     // 获取概算汇总初始化数据
     initialBudgetSummary: async function (constructionID) {
         const treeData = await this.getBudgetSummary(constructionID);
-        const construction = await projectModel.findOne({ ID: constructionID }, { 'property.costGrowthRate': 1, 'property.growthPeriod': 1 }).lean();
+        const construction = await projectModel.findOne({ ID: constructionID }, { 'property.costGrowthRate': 1, 'property.growthPeriod': 1, 'property.budgetType': 1 }).lean();
         const costGrowthRate = construction && construction.property && construction.property.costGrowthRate || 0;
         const growthPeriod = construction && construction.property && construction.property.growthPeriod || 0;
+        const budgetType = construction && construction.property && construction.property.budgetType || BudgetType.BUILDING;
         return {
+            budgetType,
             treeData,
             costGrowthRate,
             growthPeriod,
@@ -164,13 +166,18 @@ module.exports={
         const task = [];
         for (const constructionID of constructionIDs) {
             task.push(this.getBudgetSummary(constructionID, true));
-            
         }
         const summaryResult = await Promise.all(task);
         summaryResult.forEach(items => {
+            const constructionBudget = items.find(item => item.flags && item.flags[0] && item.flags[0].flag === fixedFlag.CONSTRUCTION_BUDGET);
             items.forEach(item => {
                 if (item.orgProjectID) {
                     map[item.orgProjectID] = item;
+                    if (item.projType === 'Project' && constructionBudget) {
+                        // 建设项目的总价需要取建设项目总概算
+                        map[item.orgProjectID].totalFee = constructionBudget.totalFee;
+                        map[item.orgProjectID].fees = constructionBudget.fees;
+                    }
                 }
             });
         });
@@ -215,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; // 转换为百分比
@@ -223,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, '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
@@ -324,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);
@@ -343,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 = {};

+ 2 - 2
modules/pm/models/project_property_template.js

@@ -4,8 +4,8 @@
 
 //默认的小数位数,用于定义用户可编辑的字段(入库),用户不可编辑的字段在前端defaultDecima._def中定义即可
 const defaultDecimal = {
-    bills: { unitPrice: 2, totalPrice: 2 },
-    ration: { quantity: 4, unitPrice: 2, totalPrice: 2 },
+    bills: { unitPrice: 2, totalPrice: 0 },
+    ration: { quantity: 4, unitPrice: 2, totalPrice: 0 },
     glj: { quantity: 4, unitPriceHasMix: 2, unitPrice: 2 },
     feeRate: 3,
     quantity_detail: 4,

+ 265 - 4
web/building_saas/budget-summary/js/budgetSummarySetting.js

@@ -1,4 +1,5 @@
-const budgetSummaryTreeSetting = {
+// 建筑安装工程
+const budgetInstallationSetting = {
     rowHeaderWidth: 15,
     treeCol: 0,
     emptyRows: 0,
@@ -56,7 +57,7 @@ const budgetSummaryTreeSetting = {
     }, {
         width: 70,
         head: {
-            titleNames: ["量"],
+            titleNames: ["工程总量"],
             spanCols: [1],
             spanRows: [1],
             vAlign: [1],
@@ -73,7 +74,7 @@ const budgetSummaryTreeSetting = {
     }, {
         width: 100,
         head: {
-            titleNames: ["单价"],
+            titleNames: ["技术经济指标"],
             spanCols: [1],
             spanRows: [1],
             vAlign: [1],
@@ -223,4 +224,264 @@ const budgetSummaryTreeSetting = {
         }
     },
     ]
-};
+};
+
+// 轨道工程
+const budgetRailSetting = {
+    rowHeaderWidth: 15,
+    treeCol: 0,
+    emptyRows: 0,
+    headRows: 1,
+    headRowHeight: [40],
+    defaultRowHeight: 21,
+    cols: [{
+        width: 140,
+        head: {
+            titleNames: ["编码"],
+            spanCols: [1],
+            spanRows: [1],
+            vAlign: [1],
+            hAlign: [1],
+            font: ["Arial"]
+        },
+        data: {
+            field: "code",
+            vAlign: 1,
+            hAlign: 0,
+            font: "Arial"
+        }
+    },{
+        width: 100,
+        head: {
+            titleNames: ["章编号"],
+            spanCols: [1],
+            spanRows: [1],
+            vAlign: [1],
+            hAlign: [1],
+            font: ["Arial"]
+        },
+        data: {
+            field: "chapterCode",
+            vAlign: 1,
+            hAlign: 0,
+            font: "Arial"
+        }
+    }, {
+        width: 100,
+        head: {
+            titleNames: ["节编号"],
+            spanCols: [1],
+            spanRows: [1],
+            vAlign: [1],
+            hAlign: [1],
+            font: ["Arial"]
+        },
+        data: {
+            field: "sectionCode",
+            vAlign: 1,
+            hAlign: 0,
+            font: "Arial"
+        }
+    }, {
+        width: 140,
+        head: {
+            titleNames: ["名称"],
+            spanCols: [1],
+            spanRows: [1],
+            vAlign: [1],
+            hAlign: [1],
+            font: ["Arial"]
+        },
+        data: {
+            field: "name",
+            vAlign: 1,
+            hAlign: 0,
+            font: "Arial"
+        }
+    }, {
+        width: 60,
+        head: {
+            titleNames: ["单位"],
+            spanCols: [1],
+            spanRows: [1],
+            vAlign: [1],
+            hAlign: [1],
+            font: ["Arial"]
+        },
+        data: {
+            field: "unit",
+            vAlign: 1,
+            hAlign: 1,
+            font: "Arial"
+        }
+    }, {
+        width: 70,
+        head: {
+            titleNames: ["工程总量"],
+            spanCols: [1],
+            spanRows: [1],
+            vAlign: [1],
+            hAlign: [1],
+            font: ["Arial"]
+        },
+        data: {
+            field: "quantity",
+            type: 'number',
+            vAlign: 1,
+            hAlign: 2,
+            font: "Arial",
+        }
+    }, {
+        width: 100,
+        head: {
+            titleNames: ["技术经济指标"],
+            spanCols: [1],
+            spanRows: [1],
+            vAlign: [1],
+            hAlign: [1],
+            font: ["Arial"],
+        },
+        data: {
+            field: "feesIndex.common.unitFee",
+            type: 'number',
+            vAlign: 1,
+            hAlign: 2,
+            font: "Arial"
+        }
+    }, {
+        width: 100,
+        readOnly: true,
+        head: {
+            titleNames: ["合价"],
+            spanCols: [1],
+            spanRows: [1],
+            vAlign: [1],
+            hAlign: [1],
+            font: ["Arial"]
+        },
+        data: {
+            field: "feesIndex.common.totalFee",
+            vAlign: 1,
+            hAlign: 2,
+            font: "Arial"
+        }
+    }, {
+        width: 140,
+        head: {
+            titleNames: ["计算基数"],
+            spanCols: [1],
+            spanRows: [1],
+            vAlign: [1],
+            hAlign: [1],
+            font: ["Arial"]
+        },
+        data: {
+            field: "calcBase",
+            vAlign: 1,
+            hAlign: 0,
+            font: "Arial"
+        }
+    }, {
+        width: 80,
+        head: {
+            titleNames: ["费率(%)"],
+            spanCols: [1],
+            spanRows: [1],
+            vAlign: [1],
+            hAlign: [1],
+            font: ["Arial"]
+        },
+        data: {
+            field: "feeRate",
+            type: 'number',
+            vAlign: 1,
+            hAlign: 2,
+            font: "Arial"
+        }
+    }, {
+        width: 100,
+        readOnly: true,
+        head: {
+            titleNames: ["建筑工程费"],
+            spanCols: [1],
+            spanRows: [1],
+            vAlign: [1],
+            hAlign: [1],
+            font: ["Arial"]
+        },
+        data: {
+            field: "feesIndex.building.totalFee",
+            vAlign: 1,
+            hAlign: 2,
+            font: "Arial"
+        }
+    }, {
+        width: 100,
+        readOnly: true,
+        head: {
+            titleNames: ["安装工程费"],
+            spanCols: [1],
+            spanRows: [1],
+            vAlign: [1],
+            hAlign: [1],
+            font: ["Arial"]
+        },
+        data: {
+            field: "feesIndex.installation.totalFee",
+            vAlign: 1,
+            hAlign: 2,
+            font: "Arial"
+        }
+    }, {
+        width: 100,
+        readOnly: true,
+        head: {
+            titleNames: ["设备购置费"],
+            spanCols: [1],
+            spanRows: [1],
+            vAlign: [1],
+            hAlign: [1],
+            font: ["Arial"]
+        },
+        data: {
+            field: "feesIndex.equipment.totalFee",
+            vAlign: 1,
+            hAlign: 2,
+            font: "Arial"
+        }
+    }, {
+        width: 80,
+        readOnly: true,
+        head: {
+            titleNames: ["其他费用"],
+            spanCols: [1],
+            spanRows: [1],
+            vAlign: [1],
+            hAlign: [1],
+            font: ["Arial"]
+        },
+        data: {
+            field: "feesIndex.other.totalFee",
+            vAlign: 1,
+            hAlign: 2,
+            font: "Arial"
+        }
+    }, {
+        width: 140,
+        head: {
+            titleNames: ["备注"],
+            spanCols: [1],
+            spanRows: [1],
+            vAlign: [1],
+            hAlign: [1],
+            font: ["Arial"]
+        },
+        data: {
+            field: "remark",
+            vAlign: 1,
+            hAlign: 0,
+            font: "Arial"
+        }
+    },
+    ]
+};

+ 55 - 14
web/building_saas/budget-summary/js/budgetSummarySheet.js

@@ -1,8 +1,13 @@
+
+let budgetSummaryTreeSetting;
 /* 建设其他费表格相关 */
 const budgetSummaryObj = (() => {
 
   const { isEmptyVal, isDef, isNumber } = window.commonUtil;
-  const { fixedFlag, BudgetArea } = window.commonConstants;
+  const { fixedFlag, BudgetArea, BudgetType } = window.commonConstants;
+
+
+  let curBudgetType = BudgetType.BUILDING;
 
   // 原始数据
   let rawData = [];
@@ -67,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', '') || '';
@@ -139,6 +156,7 @@ const budgetSummaryObj = (() => {
       // 验证不通过,恢复
       if (!isValid) {
         refreshData(sheet, changedCells);
+        return;
       }
     }
     let needCalc = false;
@@ -186,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);
@@ -231,7 +249,9 @@ const budgetSummaryObj = (() => {
               fees.push({ fieldName: 'other', totalFee: commonFeeItem && commonFeeItem.totalFee || 0 });
             }
           }
-          bulkData.push({ type: 'update', data: { ID, ...data } });
+          const actualID = node.data.area === BudgetArea.CONSTRUCTION_FEE ? node.data.orgProjectID : ID;
+          const updateType = node.data.area === BudgetArea.CONSTRUCTION_FEE ? 'updateProject' : 'update';
+          bulkData.push({ type: updateType, data: { ...data, ID: actualID } });
         });
       await bulkOperation(bulkData);
       Object
@@ -344,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) => {
@@ -363,13 +389,26 @@ 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;
       }
       const endIndex =  constructionFeeNode.posterityCount() + 1;
       sheet.getRange(0, 0, endIndex, budgetSummaryTreeSetting.cols.length, GC.Spread.Sheets.SheetArea.viewport).locked(true);
-      return endIndex;
+      // 除第一行,章编号 节编号可编辑
+      if (curBudgetType === BudgetType.RAIL) {
+        const chapterCodeCol = budgetSummaryTreeSetting.cols.findIndex(item => item.data.field === 'chapterCode');
+        const sectionCodeCol = budgetSummaryTreeSetting.cols.findIndex(item => item.data.field === 'sectionCode');
+        for (let row = 1; row < endIndex; row++) {
+          if (chapterCodeCol > -1) {
+            sheet.getCell(row, chapterCodeCol).locked(false);
+          }
+          if (sectionCodeCol > -1) {
+            sheet.getCell(row, sectionCodeCol).locked(false);
+          }
+        }
+      }
+      return endIndex; */
     }
     if (isMass) {
       TREE_SHEET_HELPER.massOperationSheet(sheet, () => {
@@ -450,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);
@@ -689,7 +728,9 @@ const budgetSummaryObj = (() => {
       $.bootstrapLoading.start();
       // 得先计算费用汇总(概算汇总计算基于费用汇总算出来的总金额)
       await projectObj.project.calcProgram.getGatherFeeData();
-      const { treeData, costGrowthRate, growthPeriod } = await ajaxPost('/bills/initialBudgetSummary', { constructionID });
+      const { budgetType, treeData, costGrowthRate, growthPeriod } = await ajaxPost('/bills/initialBudgetSummary', { constructionID });
+      budgetSummaryTreeSetting = budgetType === BudgetType.BUILDING ? budgetInstallationSetting : budgetRailSetting;
+      curBudgetType = budgetType;
       calcSetting.costGrowthRate = costGrowthRate;
       calcSetting.growthPeriod = growthPeriod;
       $('#costGrowthRate').val(costGrowthRate);

+ 3 - 3
web/building_saas/js/global.js

@@ -6,12 +6,12 @@ function autoFlashHeight(){
     let btntoolsbarHeight = $(".btn-toolbar").height();
     // var feeRateToolsbarHeight = $(".toolsbar_feeRate").height();
     let toolsBarHeightQ = $(".tools-bar-height-q").height();
-    let toolsBarHeightD = $(".tools-bar-height-d").height();
+    let toolsBarHeightD = $("#deToolsBar").height();
     let toolsBarHeightZ = $(".tools-bar-height-z").height();
     //$(".main-data-side-q").height($(window).height()-headerHeight-toolsbarHeight-toolsBarHeightQ-302);
     $(".main-data-side-q").height($(window).height()-headerHeight-toolsbarHeight-toolsBarHeightQ-$('#qd').find('.bottom-content').find('.p-0').height()-5);
-    //$(".main-data-side-d").height($(window).height()-headerHeight-toolsbarHeight-toolsBarHeightD-302);
-    $(".main-data-side-d").height($(window).height()-headerHeight-toolsbarHeight-toolsBarHeightD-$('#stdSectionRations').height()-5);
+  
+    //$(".main-data-side-d").height($(window).height()-headerHeight-toolsbarHeight-toolsBarHeightD-$('#stdSectionRations').height());
     $(".main-data-side-zb").height(($(window).height()-headerHeight-toolsbarHeight-toolsBarHeightZ));
     /*$(".main-data-side-zi").height($(window).height()-headerHeight-toolsbarHeight- toolsBarHeightZ - $(".main-data-side-zb").height());*/
     $('.main-content').width($(window).width()-$('.main-nav').width()-$('.main-side').width()-5);

+ 2 - 2
web/building_saas/main/html/gather_fees.html

@@ -14,10 +14,10 @@
 
     <div class="container-fluid">
         <div class="row">
-            <div class="col-lg-2 p-0">
+            <div class="col-lg-3 p-0">
                 <div class="grid main-data-full" id="gfMainSpread"></div>
             </div>
-            <div class="col-lg-10 p-0">
+            <div class="col-lg-9 p-0">
                 <div class="grid main-data-full" id="gfDetailSpread"></div>
             </div>
         </div>

+ 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>

+ 20 - 4
web/building_saas/main/js/views/equipment_purchase_view.js

@@ -293,7 +293,7 @@ let equipmentPurchaseObj  = {
         doc.freight = freight;
         doc.sparePartCost = sparePartCost;
         doc.unitPrice = unitPrice;
-        doc.totalPrice = scMathUtil.roundForObj(quantity * unitPrice,getDecimal('glj.unitPrice'));
+        doc.totalPrice = scMathUtil.roundForObj(quantity * unitPrice,getDecimal('bills.totalPrice'));
         return newValue;
     },
     //计算序列号,返回要改变的兄弟节点数据
@@ -363,10 +363,10 @@ let equipmentPurchaseObj  = {
             //累加所有底层节点就行
             if(!this.parentMap[d.ID] && !temParentMap[d.ID] ){
                 if(deleteMap[d.ID]) continue;
-                let totalPrice = d.totalPrice?scMathUtil.roundForObj(d.totalPrice,getDecimal('glj.unitPrice')):0;
+                let totalPrice = d.totalPrice?scMathUtil.roundForObj(d.totalPrice,getDecimal('bills.totalPrice')):0;
                 let data = dataMap[d.ID];
                 if(data && gljUtil.isDef(data.doc.totalPrice))totalPrice = data.doc.totalPrice;
-                total =scMathUtil.roundForObj(total + totalPrice,getDecimal('glj.unitPrice')) 
+                total =scMathUtil.roundForObj(total + totalPrice,getDecimal('bills.totalPrice')) 
             }
         }
         return total;
@@ -381,6 +381,22 @@ let equipmentPurchaseObj  = {
         await this.updateEquipments(updateData);
        }
     },
+    getDeleteData: function(sourceID){
+      let data = [];  
+      let me = this;  
+      deleteNode(sourceID);
+      return data;
+
+       function deleteNode(ID){
+            data.push({ID,type:'delete'});
+            if(me.parentMap[ID]){
+                for(let c of me.parentMap[ID]){
+                    deleteNode(c.ID);
+                }
+            }
+       } 
+    },
+
     updateEquipments:async function(updateData){
         try {
             this.calcParent(updateData);
@@ -491,7 +507,7 @@ let equipmentPurchaseObj  = {
                 },
                 callback: function (key, opt) {
                   let row = me.rightClickTarget.row;
-                  me.updateEquipments([{ID:me.data[row].ID,type:'delete'}]);
+                  me.updateEquipments(me.getDeleteData(me.data[row].ID));
                   //me.preApplyInfoPrice(row);
                 }
               }

+ 10 - 7
web/building_saas/main/js/views/gather_fees_view.js

@@ -7,8 +7,8 @@ let gatherFeesView = {
     mainSetting: {
         header:[
             // {headerName:"ID",headerWidth:80,dataCode:"ID", hAlign: "center"},
-            {headerName:"费用类别",headerWidth:120,dataCode:"name", dataType: "String"},
-            {headerName:"金额",headerWidth:80,dataCode:"totalFee", dataType: "String",hAlign: "right"}
+            {headerName:"费用类别",headerWidth:160,dataCode:"name", dataType: "String"},
+            {headerName:"金额",headerWidth:100,dataCode:"totalFee", dataType: "String",hAlign: "right"}
         ],
         view:{
             comboBox:[],
@@ -94,12 +94,15 @@ let gatherFeesView = {
       $('#lblGatherFee').text(`费用汇总 ${obj.totalFee}`);
       sheetCommonObj.showData(me.mainSheet, me.mainSetting, me.datas);
       me.mainSheet.setRowCount(me.datas.length);
-      sheetCommonObj.showData(me.detailSheet, me.detailSetting, me.datas[0].calcItems);
-      me.getfeeRateColor(me.datas[0].calcItems);
-      customRowHeader(me.detailSheet, me.datas[0].calcItems.length);
 
-      let count = gatherFeesView.datas[gatherFeesView.mainSheet.getActiveRowIndex()].calcItems.length;
-      gatherFeesView.detailSheet.setRowCount(count, GC.Spread.Sheets.SheetArea.viewport);
+      let count = 0;
+      if (me.datas.length > 0){
+          sheetCommonObj.showData(me.detailSheet, me.detailSetting, me.datas[0].calcItems);
+          me.getfeeRateColor(me.datas[0].calcItems);
+          customRowHeader(me.detailSheet, me.datas[0].calcItems.length);
+          count = me.datas[me.mainSheet.getActiveRowIndex()].calcItems.length;
+      }
+      me.detailSheet.setRowCount(count, GC.Spread.Sheets.SheetArea.viewport);
       $.bootstrapLoading.end();
     },
     onMainEnterCell: function(sender, args) {

+ 11 - 5
web/building_saas/main/js/views/project_view.js

@@ -97,6 +97,9 @@ var projectObj = {
                      if(node.children[0].data.type==billType.FX || node.children[0].data.type==billType.BX){ //焦点行子项是分项
                          return false;
                      }
+                     if(node.children.length>0&&node.children[0].sourceType !== that.project.Bills.getSourceType()){//有子项,并且子项不是清单
+                        return false;
+                    }
                 }
                 if(node.data.type == billType.BILL &&node.nextSibling){//焦点行是清单有后兄弟
                     if(node.data.calcBase&&node.data.calcBase!=""){//有基数计算
@@ -130,13 +133,16 @@ var projectObj = {
                 }else if(node.preSibling.data.calcBase&&node.preSibling.data.calcBase!=""){//前兄弟有基数计算
                     return false
                 }
-                if(node.preSibling.children.length>0){//前兄弟有子项,子项是分项,灰显。
-                    if(node.data.type==billType.FB&&(node.preSibling.children[0].data.type==billType.FX||node.preSibling.children[0].data.type==billType.BX)){//焦点行是分部前兄弟有子项,子项是分项,灰显。
+                if(node.preSibling.children.length>0){//前兄弟有子项,子项是定额/量价/工料机灰显
+                    if(node.data.type==billType.FB&&node.preSibling.children[0].sourceType !== that.project.Bills.getSourceType()){//焦点行是清单,子项不是清单
+                        return false
+                    }
+                   /*  if(node.data.type==billType.FB&&(node.preSibling.children[0].data.type==billType.FX||node.preSibling.children[0].data.type==billType.BX)){//焦点行是分部前兄弟有子项,子项是分项,灰显。
                         return false;
                     }
                     if(node.data.type==billType.BILL&&node.preSibling.children[0].sourceType !== that.project.Bills.getSourceType()){//焦点行是清单,子项不是清单
                         return false
-                    }
+                    } */
                 }
             }
             return true;
@@ -2381,8 +2387,8 @@ $('#insert').click(function () {
 $('#delete').click(function () {
     let project = projectObj.project;
     let selected = project.mainTree.selected;
-    if(isSingleSelect()&&selected.sourceType == project.Bills.getSourceType()&&selected.data.type==billType.FB&&selected.children.length<=0){//选中的是分部,并且没有子项,直接删除
-        project.Bills.deleteSelectedNode();
+    if(selected.sourceType == project.Bills.getSourceType()&&selected.data.type==billType.FB&&selected.children.length<=0){//选中的是分部,并且没有子项,直接删除
+        project.Bills.deleteSelectedNodes();//project.Bills.deleteSelectedNode();
     }else {
         $("#delete_row").modal({show:true});//弹出删除提示框;
     }

+ 8 - 0
web/building_saas/main/js/views/std_ration_lib.js

@@ -187,6 +187,14 @@ var rationLibObj = {
     },
     loadSectionRations: function (sectionID) {
         let me = this;
+        if(sectionID === undefined && me.rationChapterSpread){
+           let sel = me.rationChapterSpread.getSheet(0).getSelections();
+           if(sel && sel.length > 0){
+              let node = me.tree.items[sel[0].row];
+              if(node) sectionID = node.data.ID;  
+            }
+        }
+        // rationLibObj.rationChapterSpread.getSheet(0)
         var showDatas = function (datas, setting) {
             let rationSheet = rationLibObj.sectionRationsSpread.getActiveSheet();
             /*TREE_SHEET_HELPER.massOperationSheet(rationSheet, function () {

+ 1 - 1
web/building_saas/pm/js/pm_newMain.js

@@ -3047,7 +3047,7 @@ function initProjects(callback, expandCallback) {
             sheet.frozenColumnCount(2);
             sheet.name('projectSheet');
             sheetCommonObj.spreadDefaultStyle(projTreeObj.workBook);
-            projTreeObj.sumEngineeringCost();
+            //projTreeObj.sumEngineeringCost();
             if (expandCallback) {
                 expandCallback();
             } else {