Przeglądaj źródła

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

chenshilong 4 lat temu
rodzic
commit
4c83733fc0

+ 4 - 3
modules/equipment_purchase/facade/equipment_purchase_facade.js

@@ -15,19 +15,20 @@ let decimal_facade = require('../../main/facade/decimal_facade');
 const scMathUtil = require('../../../public/scMathUtil').getUtil();
 let _ = require('lodash')
 
+//返回 ID - total 映射如: {2566:60}
 async function getEquipmentTotalCost(projectIDs) {
-    let sum = 0;
     let decimal =2;
+    let totalMap ={};
     if(projectIDs.length > 0){
         let decimalObject =await decimal_facade.getProjectDecimal(projectIDs[0]);
          if(decimalObject&&decimalObject.glj&&decimalObject.glj.unitPrice)decimal = decimalObject.glj.unitPrice;
         let equipments = await equipmentPurchaseModel.find({projectID:{$in: projectIDs}}).lean();
         for(let e of equipments){
             let total =e.total?scMathUtil.roundForObj(e.total,decimal):0;
-            sum = scMathUtil.roundForObj(sum + total,6);
+            totalMap[e.projectID] = total;
         }
     }
-    return scMathUtil.roundForObj(sum,decimal);
+    return totalMap;
 }
 
 function sortEquipments(equipments) {

+ 46 - 18
modules/main/facade/bill_facade.js

@@ -23,6 +23,8 @@ const { getSortedTreeData, getEngineeringFeeType } = require('../../../public/co
 const { billType, constructionFeeNodeID, constructionEquipmentFeeNodeID, BudgetArea, fixedFlag } = require('../../../public/common_constants');
 const scMathUtil = require('../../../public/scMathUtil').getUtil();
 const uuidV1 = require('uuid/v1');
+const equipmentFacade = require('../../equipment_purchase/facade/equipment_purchase_facade');
+const gatherModel = mongoose.model('gather_calc_programs');
 
 const GLJController = require("../../glj/controllers/glj_controller");
 
@@ -129,17 +131,28 @@ module.exports={
             await bill_Model.bulkWrite(bulks);
         }
     },
-    // 获取单位工程ID 工程费用 映射表
+    // 获取单位工程ID 工程费用(费用汇总里的totalFee) 映射表
     getUnitsBudgetMap: async function (unitIDs) {
         const rst = {};
-        unitIDs.forEach(unitID => {
+        /* unitIDs.forEach(unitID => {
             rst[unitID] = 1000000;
+        }); */
+        const gatherData = await gatherModel.find({ projectID: { $in: unitIDs } }, '-_id projectID totalFee').lean();
+        const gatherMap = {};
+        gatherData.forEach(item => gatherMap[item.projectID] = item.totalFee || 0);
+        unitIDs.forEach(unitID => {
+            rst[unitID] = gatherMap[unitID] || 0;
         });
         return rst;
     },
     // 获取设备购置费
-    getEquipmentFee: async function (unitIDs) {
-        return 5000.15;
+    getUnitsEquipmentMap: async function (unitIDs) {
+        /* const rst = {};
+        unitIDs.forEach(unitID => {
+            rst[unitID] = 5000;
+        });
+        return rst; */
+        return await equipmentFacade.getEquipmentTotalCost(unitIDs);
     },
     // 获取概算汇总初始化数据
     initialBudgetSummary: async function (constructionID) {
@@ -164,6 +177,12 @@ module.exports={
         // 汇算工程费用
         await this.summarizeData(constructionFeeBills);
         const rst = [...constructionFeeBills, ...sortedOtherFeeBills];
+        const totalItem = rst.find(item => item.flags && item.flags[0] && item.flags[0].flag === fixedFlag.CONSTRUCTION_BUDGET);
+        let totalFee = 0;
+        if (totalItem) {
+            const totalFeeItem = totalItem.fees && totalItem.fees.find(f => f.fieldName === 'common');
+            totalFee = totalFeeItem ? +totalFeeItem.totalFee : 0;
+        }
         // 方便报表取数据,规范数据
         rst.forEach(item => {
             item.code = item.code || '';
@@ -180,7 +199,9 @@ module.exports={
             item.equipmentFee = equipmentFeeItem ? equipmentFeeItem.totalFee : 0;
             item.otherFee = otherFeeItem ? otherFeeItem.totalFee : 0;
             item.totalFee = totalFeeItem ? totalFeeItem.totalFee : 0;
-            item.rate = '0';
+            // 计算占总投资比例
+            const rate = totalFee ?  scMathUtil.roundForObj(item.totalFee / totalFee, 4) : 0; 
+            item.rate = rate * 100; // 转换为百分比
         });
         return rst;
     },
@@ -205,7 +226,7 @@ module.exports={
         let curSingleNo = 0;
         let curSingleID;
         let curUnitNo = 0;
-        let latestSingleNode;
+        // let latestSingleNode;
         items.forEach((item, index) => {
             item.area = BudgetArea.CONSTRUCTION_FEE;
             item.ID = IDMap[item.ID];
@@ -221,7 +242,7 @@ module.exports={
             } else {
                 item.type = billType.BILL;
                 if (item.ParentID === curConstructionID) {
-                    latestSingleNode = item;
+                    // latestSingleNode = item;
                     curSingleNo += 1;
                     curUnitNo = 0;
                     curSingleID = item.ID;
@@ -232,7 +253,7 @@ module.exports={
                 }
             }
         });
-        const constructionFeeNode = items[0];
+        /* const constructionFeeNode = items[0];
         // 设备及工器具购置费
         const constructionEquipmentNode = {
             type: billType.BILL,
@@ -245,7 +266,7 @@ module.exports={
             name: '设备及工器具购置费',
         };
         latestSingleNode.NextSiblingID = constructionEquipmentNode.ID;
-        items.push(constructionEquipmentNode);
+        items.push(constructionEquipmentNode); */
         return items;
     },
     // 汇算数据
@@ -264,18 +285,23 @@ module.exports={
         // 获取第一个单位工程的小数位数(清单合价)
         const theUnit = await projectModel.findOne({ ID: unitProjectIDs[0] }, { _id: 0, 'property.decimal': 1 }).lean();
         const decimal = theUnit && theUnit.property && theUnit.property.decimal && theUnit.property.decimal.bills && theUnit.property.decimal.bills.totalPrice || 2;
-        // 获取单位工程 工程费用映射表
+        // 获取单位工程 -工程费用映射表
         const unitBudgetMap = await this.getUnitsBudgetMap(unitProjectIDs);
+        // 获取单位工程 - 设备购置费映射表
+        const unitEquipmentMap = await this.getUnitsEquipmentMap(unitProjectIDs);
         // 汇算
-        const constructionFeeObj = { total: 0, building: 0, installation: 0 };
+        const constructionFeeObj = { total: 0, building: 0, installation: 0, equipment: 0 };
         for (const single of singles) {
-            const singleFeeObj = { total: 0, building: 0, installation: 0 };
+            const singleFeeObj = { total: 0, building: 0, installation: 0, equipment: 0 };
             const refUnits = units.filter(unit => unit.ParentID === single.ID);
             for (const unit of refUnits) {
-                const unitFee = unitBudgetMap[unit.orgProjectID];
+                const unitFee = unitBudgetMap[unit.orgProjectID]; // 费用汇总算出来的值
+                const unitEquipmentFee = unitEquipmentMap[unit.orgProjectID]; // 设备购置窗口的值
+                const unitTotalFee = scMathUtil.roundForObj(unitFee + unitEquipmentFee, decimal); // 费用汇总算出来的值 + 设备购置值
                 // 汇算到单项工程
-                singleFeeObj.total = scMathUtil.roundForObj(singleFeeObj.total + unitFee, processDecimal);
-                const unitFeeObj = { total: unitFee || 0, building: 0, installation: 0 };
+                singleFeeObj.total = scMathUtil.roundForObj(singleFeeObj.total + unitTotalFee, processDecimal);
+                singleFeeObj.equipment = scMathUtil.roundForObj(singleFeeObj.equipment + unitEquipmentFee, processDecimal);
+                const unitFeeObj = { total: unitTotalFee || 0, building: 0, installation: 0, equipment: unitEquipmentFee || 0 };
                 // 建筑工程费、安装工程费
                 const feeType = getEngineeringFeeType(unit.property && unit.property.engineeringName || '');
                 if (feeType) {
@@ -289,22 +315,24 @@ module.exports={
             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);
-        // 获取设备购置费
-        const equipmentFee = await this.getEquipmentFee(unitProjectIDs);
+        // 获取设备购置费(旧)
+        /* const equipmentFee = await this.getEquipmentFee(unitProjectIDs);
         const equipmentItem = items.find(item => item.flags && item.flags[0] && item.flags[0].flag === fixedFlag.CONSTRUCTION_EQUIPMENT_FEE);
         const equipmentFeeObj = { fieldName: 'equipment', totalFee: equipmentFee };
         if (equipmentItem) {
             equipmentItem.fees = [equipmentFeeObj];
         }
-        construction.fees.push(equipmentFeeObj);
+        construction.fees.push(equipmentFeeObj); */
 
         function feeObj2Fees(feeObj) {
             return [
                 { fieldName: 'common', totalFee: scMathUtil.roundForObj(feeObj.total, decimal) },
                 { 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 - 2
modules/main/templates/constructionBillsTemplate.js

@@ -56,7 +56,7 @@ const buildingTemplate = [
   { ID: 41, ParentID: 4, NextSiblingID: 42, code: '4.1', name: '车辆购置费', unit: '', calcBase: '', quantity: '', flags: [{ fieldName: 'fixed', flag: null }], type: billType.BILL },
   { ID: 42, ParentID: 4, NextSiblingID: 43, code: '4.2', name: '建设期贷款利息', unit: '', calcBase: '', quantity: '', flags: [{ fieldName: 'fixed', flag: fixedFlag.LOAN_INTEREST }], type: billType.BILL },
   { ID: 43, ParentID: 4, NextSiblingID: -1, code: '4.3', name: '铺底流动资金', unit: '', calcBase: '', quantity: '', flags: [{ fieldName: 'fixed', flag: null }], type: billType.BILL },
-  { ID: 5, ParentID: -1, NextSiblingID: -1, code: '5', name: '建设项目总概算', unit: '', calcBase: '', quantity: '', flags: [{ fieldName: 'fixed', flag: fixedFlag.CONSTRUCTION_BUDGET }], type: billType.DXFY },
+  { ID: 5, ParentID: -1, NextSiblingID: -1, code: '5', name: '建设项目总概算', unit: '', calcBase: '{工程费用}+{工程建设其他费用}+{预备费}+{专项费用}', quantity: '', flags: [{ fieldName: 'fixed', flag: fixedFlag.CONSTRUCTION_BUDGET }], type: billType.DXFY },
 ];
 
 /* 概算汇总,城市轨道交通工程,建设其他费清单模板 */
@@ -120,7 +120,7 @@ const railTemplate = [
   { ID: 41, ParentID: 4, NextSiblingID: 42, code: '4.1', name: '车辆购置费', unit: '', calcBase: '', quantity: '', flags: [{ fieldName: 'fixed', flag: null }], type: billType.BILL },
   { ID: 42, ParentID: 4, NextSiblingID: 43, code: '4.2', name: '建设期贷款利息', unit: '', calcBase: '', quantity: '', flags: [{ fieldName: 'fixed', flag: fixedFlag.LOAN_INTEREST }], type: billType.BILL },
   { ID: 43, ParentID: 4, NextSiblingID: -1, code: '4.3', name: '铺底流动资金', unit: '', calcBase: '', quantity: '', flags: [{ fieldName: 'fixed', flag: null }], type: billType.BILL },
-  { ID: 5, ParentID: -1, NextSiblingID: -1, code: '5', name: '建设项目总概算', unit: '', calcBase: '', quantity: '', flags: [{ fieldName: 'fixed', flag: fixedFlag.CONSTRUCTION_BUDGET }], type: billType.DXFY },
+  { ID: 5, ParentID: -1, NextSiblingID: -1, code: '5', name: '建设项目总概算', unit: '', calcBase: '{工程费用}+{工程建设其他费用}+{预备费}+{专项费用}', quantity: '', flags: [{ fieldName: 'fixed', flag: fixedFlag.CONSTRUCTION_BUDGET }], type: billType.DXFY },
 ];
 
 module.exports = {

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

@@ -36,6 +36,7 @@ const multiparty = require("multiparty");
 let logger = require("../../../logs/log_helper").logger;
 let rp = require('request-promise');
 const commonUtil = require('../../../public/common_util');
+const { BudgetType } = require('../../../public/common_constants');
 //统一回调函数
 let callback = function (req, res, err, message, data) {
     res.json({ error: err, message: message, data: data });
@@ -254,6 +255,8 @@ module.exports = {
             projInfo.property.basicInformation = constructionProperty && constructionProperty.basicInformation ? constructionProperty.basicInformation : [];
             //编制说明
             projInfo.property.compilationIllustrationProject = constructionProperty && constructionProperty.compilationIllustration ? constructionProperty.compilationIllustration : '';
+            // 概算类型
+            projInfo.property.budgetType = constructionProperty && constructionProperty.budgetType || BudgetType.BUILDING;
             //获取单位工程完整目录结构
             let fullPath = await pm_facade.getFullPath(projectID);
             projInfo.fullPath = fullPath;

+ 1 - 1
public/common_util.js

@@ -133,7 +133,7 @@ function deleteEmptyObject(arr) {
 
     // 判断单位工程的工程专业的金额所属是“建筑工程费”还是“安装工程费”
     const getEngineeringFeeType = (engineeringName) => {
-        if (['土建工程', '装饰工程', '市政工程', '城市轨道交通工程', '装配式建筑工程', '城市地下综合管廊工程', '轨道工程'].includes(engineeringName)) {
+        if (['土建工程', '装饰工程', '市政工程', '城市轨道交通工程', '装配式建筑工程', '城市地下综合管廊工程'].includes(engineeringName)) {
             return 'building';
         }
         if (['安装工程', '城市轨道交通安装']) {

+ 1 - 1
web/building_saas/budget-summary/js/budgetSummarySetting.js

@@ -91,7 +91,7 @@ const budgetSummaryTreeSetting = {
         width: 100,
         readOnly: true,
         head: {
-            titleNames: ["金额"],
+            titleNames: ["合价"],
             spanCols: [1],
             spanRows: [1],
             vAlign: [1],

+ 35 - 53
web/building_saas/budget-summary/js/budgetSummarySheet.js

@@ -119,22 +119,26 @@ const budgetSummaryObj = (() => {
 
   // 更新数据
   const bulkOperation = async (bulkData) => {
-    await ajaxPost('/bills/bulkOperation', { bulkData });
+    if (bulkData.length) {
+      await ajaxPost('/bills/bulkOperation', { bulkData });
+    }
   };
 
   // 编辑相关
-  const edit = async (sheet, changedCells) => {
-    if (!changedCells.length) {
+  const edit = async (sheet, changedCells, calcNodes = null) => {
+    if (!changedCells.length && !calcNodes) {
       return;
     }
-    // 单元格值验证
-    const isValid = changedCells.every(({ row, col }) => {
-      const val = sheet.getValue(row, col);
-      return getValidator(col)(val);
-    });
-    // 验证不通过,恢复
-    if (!isValid) {
-      refreshData(sheet, changedCells);
+    if (changedCells.length) {
+      // 单元格值验证
+      const isValid = changedCells.every(({ row, col }) => {
+        const val = sheet.getValue(row, col);
+        return getValidator(col)(val);
+      });
+      // 验证不通过,恢复
+      if (!isValid) {
+        refreshData(sheet, changedCells);
+      }
     }
     let needCalc = false;
     const nodes = [];
@@ -185,10 +189,11 @@ const budgetSummaryObj = (() => {
           needCalc = true;
         }
       });
+      calcNodes = calcNodes ? calcNodes : nodes;
       // 重算节点
       const dataArr = [];
-      if (needCalc && nodes.length) {
-        const changedNodes = projectObj.project.calcProgram.calcNodes(nodes, false, tree);
+      if ((needCalc && nodes.length) || (calcNodes && calcNodes.length)) {
+        const changedNodes = projectObj.project.calcProgram.calcNodes(calcNodes, false, tree);
         for (const node of changedNodes) {
           nodes.push(node);
           if (node.changed) {
@@ -210,6 +215,21 @@ const budgetSummaryObj = (() => {
       Object
         .entries(IDMap)
         .forEach(([ID, data]) => {
+          const node = tree.findNode(ID);
+          if (!node) {
+            return;
+          }
+          // 处理其他费用
+          if (node.isBelongToFlags([fixedFlag.CONSTRUCTION_OTHER_FEE])) {
+            const fees = data.fees || [];
+            const commonFeeItem = fees.find(item => item.fieldName === 'common');
+            const otherFeeItem = fees.find(item => item.fieldName === 'other');
+            if (otherFeeItem) {
+              otherFeeItem.totalFee = commonFeeItem && commonFeeItem.totalFee || 0;
+            } else {
+              fees.push({ fieldName: 'other', totalFee: commonFeeItem && commonFeeItem.totalFee || 0 });
+            }
+          }
           bulkData.push({ type: 'update', data: { ID, ...data } });
         });
       await bulkOperation(bulkData);
@@ -649,46 +669,6 @@ const budgetSummaryObj = (() => {
             remove(sheet, curNode);
           }
         },
-        /*       upLevel: {
-                name: '升级',
-                icon: 'fa-arrow-left',
-                disabled() {
-                  return !curNode || !curNode.canUpLevel() || isConstructionFeeArea(curNode);
-                },
-                callback() {
-                  upLevel(sheet, curNode);
-                }
-              },
-              downLevel: {
-                name: '降级',
-                icon: 'fa-arrow-right',
-                disabled() {
-                  return !curNode || !curNode.canDownLevel() || isConstructionFeeArea(curNode) || isConstructionFeeArea(curNode.preSibling);
-                },
-                callback() {
-                  downLevel(sheet, curNode);
-                }
-              },
-              upMove: {
-                name: '上移',
-                icon: 'fa-arrow-up',
-                disabled() {
-                  return !curNode || !curNode.canUpMove() || isConstructionFeeArea(curNode) || isConstructionFeeArea(curNode.preSibling);
-                },
-                callback() {
-                  upMove(sheet, curNode);
-                }
-              },
-              downMove: {
-                name: '下移',
-                icon: 'fa-arrow-down',
-                disabled() {
-                  return !curNode || !curNode.canDownMove() || isConstructionFeeArea(curNode) || isConstructionFeeArea(curNode.nextSibling);
-                },
-                callback() {
-                  downMove(sheet, curNode);
-                }
-              }, */
         refresh: {
           name: '刷新数据',
           icon: 'fa-refresh',
@@ -729,6 +709,8 @@ const budgetSummaryObj = (() => {
       });
       initTree(rawData, sheet, budgetSummaryTreeSetting);
       calcBase.initBudget();
+      // 造价计算
+      await edit(sheet, [], tree.roots.slice(1));
     } catch (err) {
       console.log(err);
       alert(err);

+ 14 - 14
web/building_saas/main/js/models/calc_base.js

@@ -1178,6 +1178,10 @@ let baseFigureTemplate = {
     SJF: function () {
         return cbTools.getBillsFee(fixedFlag.DESIGN_FEE, 'common', 'totalFee');
     },
+    // 工程建设其他费用: 取工程建设其他费用的金额
+    GCJSQTFY: function () {
+        return cbTools.getBillsFee(fixedFlag.CONSTRUCTION_OTHER_FEE, 'common', 'totalFee');
+    },
     // 预备费: 取预备费行的金额
     YBF: function () {
         return cbTools.getBillsFee(fixedFlag.BUDGET_RESERVE, 'common', 'totalFee');
@@ -1186,10 +1190,6 @@ let baseFigureTemplate = {
     ZXFY: function () {
         return cbTools.getBillsFee(fixedFlag.CONSTRUCTION_SPECIAL_FEE, 'common', 'totalFee');
     },
-    // 工程建设其他费用: 取工程建设其他费用的金额
-    GCJSQTFY: function () {
-        return cbTools.getBillsFee(fixedFlag.CONSTRUCTION_OTHER_FEE, 'common', 'totalFee');
-    },
     // 价差预备费
     JCYBF: function () {
         return 0;
@@ -1315,22 +1315,22 @@ const budgetFigureMap = {
         filter: [fixedFlag.DESIGN_COUNSEL_FEE],
         pick: true,
     },
+    '工程建设其他费用': {
+        base: 'GCJSQTFY',
+        fixedFlag: fixedFlag.CONSTRUCTION_OTHER_FEE,
+        filter: [fixedFlag.CONSTRUCTION_FEE, fixedFlag.CONSTRUCTION_OTHER_FEE],
+        pick: false,
+    },
     '预备费': {
         base: 'YBF',
         fixedFlag: fixedFlag.BUDGET_RESERVE,
-        filter: [fixedFlag.BUDGET_RESERVE],
+        filter: [fixedFlag.CONSTRUCTION_FEE, fixedFlag.CONSTRUCTION_OTHER_FEE, fixedFlag.BUDGET_RESERVE],
         pick: false,
     },
     '专项费用': {
         base: 'ZXFY',
         fixedFlag: fixedFlag.CONSTRUCTION_SPECIAL_FEE,
-        filter: [fixedFlag.CONSTRUCTION_SPECIAL_FEE],
-        pick: false,
-    },
-    '工程建设其他费用': {
-        base: 'GCJSQTFY',
-        fixedFlag: fixedFlag.CONSTRUCTION_OTHER_FEE,
-        filter: [fixedFlag.CONSTRUCTION_FEE, fixedFlag.CONSTRUCTION_OTHER_FEE],
+        filter: [fixedFlag.CONSTRUCTION_FEE, fixedFlag.CONSTRUCTION_OTHER_FEE, fixedFlag.BUDGET_RESERVE, fixedFlag.CONSTRUCTION_SPECIAL_FEE],
         pick: false,
     },
     /* '价差预备费': {
@@ -1858,7 +1858,7 @@ let calcBase = {
     getBaseBill: function (node) {
         return cbTools.getBaseBill(node);
     },
-    calculate: function (node, reCalc = null, alert = true) {
+    calculate: function (node, reCalc = null, showAlert = true) {
         let me = calcBase,
             $CBA = cbAnalyzer,
             $CBP = cbParser,
@@ -1906,7 +1906,7 @@ let calcBase = {
             if (node) {
                 err = `第${node.serialNo() + 1}行${err}`;
             }
-            if (alert) {
+            if (showAlert) {
                 alert(err);
             }
         }

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

@@ -517,7 +517,7 @@
                             </select>
                         </div>
                     </div>-->
-                    <div class="form-group row">
+                    <div class="form-group row" style="display: none;">
                         <label for="staticEmail" class="col-auto col-form-label col-form-label-sm">计算程序</label>
                         <div class="col">
                             <select class="form-control  form-control-sm" id="tender-calcProgram">

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

@@ -39,6 +39,28 @@ const FileKind = {
     tender: 1, //投标
     bid: 2  //招标
 };
+
+// 概算类型,对应可用工程专业
+const budgetEngineeringListMap = {
+    [commonConstants.BudgetType.BUILDING]: [
+        '房屋建筑工程',
+        '装配式钢结构建筑工程',
+        '装饰工程',
+        '构筑物',
+        '市政工程',
+        '机械(爆破)土石方工程',
+        '人工土石方工程',
+        '围墙工程',
+        '幕墙工程',
+        '安装工程',
+        '市政安装工程',
+    ],
+    [commonConstants.BudgetType.RAIL]: [
+        '城市轨道交通工程',
+        '城市轨道交通安装工程'
+    ],
+};
+
 let curTaxType = 1; //1:"一般计税",2:"简易计税"
 let curBudgetType = commonConstants.BudgetType.BUILDING;
 let curValutionType = 'bill',   //计价方式默认只有清单计价
@@ -372,8 +394,9 @@ const projTreeObj = {
             name: '导入招投标接口文件',
             icon: 'fa-cloud-upload',
             visible: function () {
-                const names = ['重庆定额(2018)', '广东定额(2018)'];
-                return compilationData && names.includes(compilationData.name);
+                return false;
+                /* const names = ['重庆定额(2018)', '广东定额(2018)'];
+                return compilationData && names.includes(compilationData.name); */
             },
             callback: function () {
                 $('#importInterface').modal('show');
@@ -2089,6 +2112,15 @@ $(document).ready(function() {
         changeEngineering();
     });
 
+    // 选择项目类型
+    $("input[name='budgetType-tender']").click(function () {
+        curBudgetType = +$(this).val();
+        const engineeringList = getEngineeringList();
+        const engineeringHtml = getEngineeringHtml(engineeringList);
+        $("#tender-engineering").html(engineeringHtml);
+        changeEngineering();
+    });
+
     //选择计价规则
     $("#valuation").change(function () {
         curValuation = $(this).val();
@@ -3655,6 +3687,7 @@ function setProjOptions(projs, selected){
     if(projs.length > 0){
         let firstProj = selected && selected.data.projType === projectType.project ? selected: projs[0];
         curTaxType = firstProj.data.property.taxType || 1;
+        curBudgetType = firstProj.data.property.budgetType || commonConstants.BudgetType.BUILDING;
         if (firstProj.data.property.valuationType) {
             curValutionType = firstProj.data.property.valuationType;
         }
@@ -3675,6 +3708,7 @@ function setProjOptions(projs, selected){
             $proj.attr("href", "javascript:void(0);");
             $proj.click(function () {
                 curTaxType = projs[i].data.property.taxType || 1;
+                curBudgetType = projs[i].data.property.budgetType || commonConstants.BudgetType.BUILDING;;
                 if (projs[i].data.property.valuationType) {
                     curValutionType = projs[i].data.property.valuationType;
                 }
@@ -3877,6 +3911,7 @@ function AddTender() {
 
         //let valuation = $("#valuation").val();
         let valuation = curValuation;   //跟建设项目一样的计价规则
+        debugger;
 
         let engineeringName = $("#tender-engineering").val();
         if (!engineeringName || engineeringName === '') {
@@ -4355,10 +4390,12 @@ function getEngineeringHtml(engineeringList) {
     if (engineeringList.length <= 0) {
         return result;
     }
+    console.log(engineeringList);
     let engLibNames = [];
     for(let i = 0; i < engineeringList.length; i++){
         let tmp = engineeringList[i];
-        if(engLibNames.includes(tmp.lib.name)){
+        const validEngNames = budgetEngineeringListMap[curBudgetType];
+        if(engLibNames.includes(tmp.lib.name) || !validEngNames.includes(tmp.lib.name)){
            continue;
         }
         result += `<option ${i === 0 ? 'selected' : ''} value="${tmp.lib.name}">${tmp.lib.name}</option>`;

+ 15 - 0
web/building_saas/report/js/rpt_main.js

@@ -108,11 +108,26 @@ let zTreeOprObj = {
         params.engineerId = projectObj.project.projectInfo.property.engineering;
         let private_chk_hide = function (chkTplItem) {
             //考虑未来拓展,统一在此判断报表模板是否显示
+            //*
             let rst = false;
             if (chkTplItem.hasOwnProperty('flags') && chkTplItem.flags.hasOwnProperty('taxType') && chkTplItem.flags['taxType'] !== null &&
                 parseInt(chkTplItem.flags['taxType']) !== parseInt(projectObj.project.projectInfo.property.taxType)) {
                 rst = true;
             }
+            /*/
+            let rst = true; //这里是概算的判断初始条件,默认是要remove的,只有符合条件的模板才保留
+            if (chkTplItem.hasOwnProperty('userId') || chkTplItem.nodeType === 1) {
+                rst = false; //顶节点或目录
+            } else {
+                if (chkTplItem.hasOwnProperty('flags') && chkTplItem.flags.hasOwnProperty('budgetType') && chkTplItem.flags['budgetType'] !== null &&
+                    parseInt(chkTplItem.flags['budgetType']) === parseInt(projectObj.project.projectInfo.property.budgetType)) {
+                    rst = false;
+                }
+                if (!rst) {
+                    //已经是概算,再进行其他条件判断(如果需要)
+                }
+            }
+            //*/
             return rst;
         };
         // projectObj.project.projectInfo.property.taxType === 1 //1: 一般计税 2: 简易计税