ソースを参照

调价计算基数

zhongzewei 7 年 前
コミット
69b9988631

+ 1 - 0
modules/all_models/bills.js

@@ -27,6 +27,7 @@ let billsSchema = new Schema({
     programID: Number,
     calcBase: String,
     calcBaseValue: String,     // 计算基数表达式的值
+    tenderCalcBaseValue: String,     // 调价后计算基数表达式的值
     // 工程量计算规则
     ruleText: String,
     // 说明

+ 16 - 2
modules/all_models/user.js

@@ -11,6 +11,20 @@ let Schema = mongoose.Schema;
 // 表名
 let collectionName = 'user';
 
+const invalidSchema = new Schema({
+    invalid: Boolean,
+    invalidDate: String,
+    invalidBy: String   //管理者名
+});
+
+const versionSchema = new Schema({
+    compilationId: String,
+    activateCode: String,
+    activatedDate: String,
+    activatedBy: String,
+    invalidInfo: [invalidSchema]
+});
+
 // 表结构
 let schema = {
     ssoId: Number,
@@ -30,8 +44,8 @@ let schema = {
         default: -1
     },
     version: {
-        type: String,
-        default: ''
+        type: [versionSchema],
+        default: []
     },
     company_type: {
         type: Number,

+ 5 - 2
modules/users/controllers/user_controller.js

@@ -200,7 +200,7 @@ class UserController extends BaseController {
             let sessionUser = request.session.sessionUser;
             let data = JSON.parse(request.body.data);
             let activateCode = data.activateCode,
-                activateCompilation = data.activateCompilation;
+                compilationId = data.compilationId;
             let isActivated = true;//调激活接口
             if(!isActivated){
                 throw '激活失败';
@@ -208,8 +208,10 @@ class UserController extends BaseController {
             //激活成功,更新入库
             let userObjId = mongoose.Types.ObjectId(sessionUser.id);
             let versionInfo = {};
-            versionInfo.compilationId = activateCompilation;
+            versionInfo.compilationId = compilationId;
             versionInfo.activatedDate = moment(Date.now()).format('YYYY-MM-DD HH:mm:ss');
+            //失效信息{invalid: boolean, invalidDate: String}
+            versionInfo.invalidInfo = null;
             await userModel.addVersion({_id: userObjId}, versionInfo);
             response.json({error: 0, msg: 'success'});
         }
@@ -230,6 +232,7 @@ class UserController extends BaseController {
                 let versionInfo = {};
                 versionInfo.compilationId = compilationId;
                 versionInfo.activatedDate = moment(Date.now()).format('YYYY-MM-DD HH:mm:ss');
+                versionInfo.invalidInfo = null;
                 await userModel.addVersion({_id: mongoose.Types.ObjectId(userId)}, versionInfo);
             }
             else{

+ 135 - 86
web/building_saas/main/js/models/calc_base.js

@@ -315,59 +315,70 @@ let cbTools = {
 };
 
 let baseFigureTemplate = {
-    'FBFXGCF': function () {
+    'FBFXGCF': function (tender) {
+        const totalFeeType = tender ? 'tenderTotalFee' : 'totalFee';
         let bill = calcBase.fixedBills[calcBase.fixedFlag.SUB_ENGINERRING]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return cbTools.isDef(bill.feesIndex.common) && cbTools.isDef(bill.feesIndex.common.totalFee) ? bill.feesIndex.common.totalFee : 0;
+        return cbTools.isDef(bill.feesIndex.common) && cbTools.isDef(bill.feesIndex.common[totalFeeType]) ? bill.feesIndex.common[totalFeeType] : 0;
     },
-    'FBFXDEJJRGF': function () {
+    'FBFXDEJJRGF': function (tender) {
+        const totalFeeType = tender ? 'tenderTotalFee' : 'totalFee';
         let bill = calcBase.fixedBills[calcBase.fixedFlag.SUB_ENGINERRING]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return cbTools.isDef(bill.feesIndex.labour) && cbTools.isDef(bill.feesIndex.labour.totalFee) ? bill.feesIndex.labour.totalFee : 0;
+        return cbTools.isDef(bill.feesIndex.labour) && cbTools.isDef(bill.feesIndex.labour[totalFeeType]) ? bill.feesIndex.labour[totalFeeType] : 0;
     },
-    'FBFXDEJJCLF': function () {
+    'FBFXDEJJCLF': function (tender) {
+        const totalFeeType = tender ? 'tenderTotalFee' : 'totalFee';
         let bill = calcBase.fixedBills[calcBase.fixedFlag.SUB_ENGINERRING]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return cbTools.isDef(bill.feesIndex.material) && cbTools.isDef(bill.feesIndex.material.totalFee) ? bill.feesIndex.material.totalFee : 0;
+        return cbTools.isDef(bill.feesIndex.material) && cbTools.isDef(bill.feesIndex.material[totalFeeType]) ? bill.feesIndex.material[totalFeeType] : 0;
     },
-    'FBFXDEJJJXF': function () {
+    'FBFXDEJJJXF': function (tender) {
+        const totalFeeType = tender ? 'tenderTotalFee' : 'totalFee';
         let bill = calcBase.fixedBills[calcBase.fixedFlag.SUB_ENGINERRING]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return cbTools.isDef(bill.feesIndex.machine) && cbTools.isDef(bill.feesIndex.machine.totalFee) ? bill.feesIndex.machine.totalFee : 0;
+        return cbTools.isDef(bill.feesIndex.machine) && cbTools.isDef(bill.feesIndex.machine[totalFeeType]) ? bill.feesIndex.machine[totalFeeType] : 0;
     },
-    'FBFXTZRGF': function () {
+    'FBFXTZRGF': function (tender) {
+        const totalFeeType = tender ? 'tenderTotalFee' : 'totalFee';
         let bill = calcBase.fixedBills[calcBase.fixedFlag.SUB_ENGINERRING]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return cbTools.isDef(bill.feesIndex.adjustLabour) && cbTools.isDef(bill.feesIndex.adjustLabour.totalFee) ? bill.feesIndex.adjustLabour.totalFee : 0;
+        return cbTools.isDef(bill.feesIndex.adjustLabour) && cbTools.isDef(bill.feesIndex.adjustLabour[totalFeeType]) ? bill.feesIndex.adjustLabour[totalFeeType] : 0;
     },
-    'FBFXTZJSRGF': function () {
+    'FBFXTZJSRGF': function (tender) {
+        const totalFeeType = tender ? 'tenderTotalFee' : 'totalFee';
         let bill = calcBase.fixedBills[calcBase.fixedFlag.SUB_ENGINERRING]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return cbTools.isDef(bill.feesIndex.adjustMachineLabour) && cbTools.isDef(bill.feesIndex.adjustMachineLabour.totalFee) ? bill.feesIndex.adjustMachineLabour.totalFee : 0;
+        return cbTools.isDef(bill.feesIndex.adjustMachineLabour) && cbTools.isDef(bill.feesIndex.adjustMachineLabour[totalFeeType]) ? bill.feesIndex.adjustMachineLabour[totalFeeType] : 0;
     },
-    'FBFXZCF': function () {
+    'FBFXZCF': function (tender) {
+        const totalFeeType = tender ? 'tenderTotalFee' : 'totalFee';
         let bill = calcBase.fixedBills[calcBase.fixedFlag.SUB_ENGINERRING]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return cbTools.isDef(bill.feesIndex.mainMaterial) && cbTools.isDef(bill.feesIndex.mainMaterial.totalFee) ? bill.feesIndex.mainMaterial.totalFee : 0;
+        return cbTools.isDef(bill.feesIndex.mainMaterial) && cbTools.isDef(bill.feesIndex.mainMaterial[totalFeeType]) ? bill.feesIndex.mainMaterial[totalFeeType] : 0;
     },
-    'FBFXSBF': function () {
+    'FBFXSBF': function (tender) {
+        const totalFeeType = tender ? 'tenderTotalFee' : 'totalFee';
         let bill = calcBase.fixedBills[calcBase.fixedFlag.SUB_ENGINERRING]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return cbTools.isDef(bill.feesIndex.equipment) && cbTools.isDef(bill.feesIndex.equipment.totalFee) ? bill.feesIndex.equipment.totalFee : 0;
+        return cbTools.isDef(bill.feesIndex.equipment) && cbTools.isDef(bill.feesIndex.equipment[totalFeeType]) ? bill.feesIndex.equipment[totalFeeType] : 0;
     },
-    'FBFXWJJCLF': function () {
-        return (this['FBFXZCF']() + this['FBFXSBF']()).toDecimal(decimalObj.bills.totalPrice);
+    'FBFXWJJCLF': function (tender) {
+        return (this['FBFXZCF'](tender) + this['FBFXSBF'](tender)).toDecimal(decimalObj.bills.totalPrice);
     },
     //统计分部分项下工料机类型为“人工”的总消耗量
-    'FBFXRGGR': function () {
+    'FBFXRGGR': function (tender) {
+        const totalFeeType = tender ? 'tenderTotalFee' : 'totalFee';
+        const quantityType = tender ? 'tenderQuantity' : 'quantity';
+        //todo 调用subdivisionTenderQuantity
         let projGljs = calcBase.project.projectGLJ.datas.gljList;
         let rst = 0;
         for(let glj of projGljs){
@@ -379,92 +390,105 @@ let baseFigureTemplate = {
         }
         return rst;
     },
-    'FBFXDEJJZJGCF': function () {
-        return (this['FBFXDEJJRGF']() + this['FBFXDEJJCLF']() + this['FBFXDEJJJXF']()).toDecimal(decimalObj.bills.totalPrice);
+    'FBFXDEJJZJGCF': function (tender) {
+        return (this['FBFXDEJJRGF'](tender) + this['FBFXDEJJCLF'](tender) + this['FBFXDEJJJXF'](tender)).toDecimal(decimalObj.bills.totalPrice);
     },
-    'CSXMF': function () {
+    'CSXMF': function (tender) {
+        const totalFeeType = tender ? 'tenderTotalFee' : 'totalFee';
         let bill = calcBase.fixedBills[calcBase.fixedFlag.MEASURE]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return cbTools.isDef(bill.feesIndex.common) && cbTools.isDef(bill.feesIndex.common.totalFee) ? bill.feesIndex.common.totalFee : 0;
+        return cbTools.isDef(bill.feesIndex.common) && cbTools.isDef(bill.feesIndex.common[totalFeeType]) ? bill.feesIndex.common[totalFeeType] : 0;
     },
-    'ZZCSXMF': function () {
+    'ZZCSXMF': function (tender) {
+        const totalFeeType = tender ? 'tenderTotalFee' : 'totalFee';
         let bill = calcBase.fixedBills[calcBase.fixedFlag.CONSTRUCTION_ORGANIZATION]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return cbTools.isDef(bill.feesIndex.common) && cbTools.isDef(bill.feesIndex.common.totalFee) ? bill.feesIndex.common.totalFee : 0;
+        return cbTools.isDef(bill.feesIndex.common) && cbTools.isDef(bill.feesIndex.common[totalFeeType]) ? bill.feesIndex.common[totalFeeType] : 0;
     },
-    'ZZCSXMDEJJZJGCF': function () {
-        return (this['ZZCSXMDEJJRGF']() + this['ZZCSXMDEJJCLF']() + this['ZZCSXMDEJJJXF']()).toDecimal(decimalObj.bills.totalPrice);
+    'ZZCSXMDEJJZJGCF': function (tender) {
+        return (this['ZZCSXMDEJJRGF'](tender) + this['ZZCSXMDEJJCLF'](tender) + this['ZZCSXMDEJJJXF'](tender)).toDecimal(decimalObj.bills.totalPrice);
     },
-    'ZZCSXMDEJJRGF': function () {
+    'ZZCSXMDEJJRGF': function (tender) {
+        const totalFeeType = tender ? 'tenderTotalFee' : 'totalFee';
         let bill = calcBase.fixedBills[calcBase.fixedFlag.CONSTRUCTION_ORGANIZATION]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return cbTools.isDef(bill.feesIndex.labour) && cbTools.isDef(bill.feesIndex.labour.totalFee) ? bill.feesIndex.labour.totalFee : 0;
+        return cbTools.isDef(bill.feesIndex.labour) && cbTools.isDef(bill.feesIndex.labour[totalFeeType]) ? bill.feesIndex.labour[totalFeeType] : 0;
     },
-    'ZZCSXMDEJJCLF': function () {
+    'ZZCSXMDEJJCLF': function (tender) {
+        const totalFeeType = tender ? 'tenderTotalFee' : 'totalFee';
         let bill = calcBase.fixedBills[calcBase.fixedFlag.CONSTRUCTION_ORGANIZATION]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return cbTools.isDef(bill.feesIndex.material) && cbTools.isDef(bill.feesIndex.material.totalFee) ? bill.feesIndex.material.totalFee : 0;
+        return cbTools.isDef(bill.feesIndex.material) && cbTools.isDef(bill.feesIndex.material[totalFeeType]) ? bill.feesIndex.material[totalFeeType] : 0;
     },
-    'ZZCSXMDEJJJXF': function () {
+    'ZZCSXMDEJJJXF': function (tender) {
+        const totalFeeType = tender ? 'tenderTotalFee' : 'totalFee';
         let bill = calcBase.fixedBills[calcBase.fixedFlag.CONSTRUCTION_ORGANIZATION]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return cbTools.isDef(bill.feesIndex.machine) && cbTools.isDef(bill.feesIndex.machine.totalFee) ? bill.feesIndex.machine.totalFee : 0;
+        return cbTools.isDef(bill.feesIndex.machine) && cbTools.isDef(bill.feesIndex.machine[totalFeeType]) ? bill.feesIndex.machine[totalFeeType] : 0;
     },
-    'JSCSXMF': function () {
+    'JSCSXMF': function (tender) {
+        const totalFeeType = tender ? 'tenderTotalFee' : 'totalFee';
         let bill = calcBase.fixedBills[calcBase.fixedFlag.CONSTRUCTION_TECH]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return cbTools.isDef(bill.feesIndex.common) && cbTools.isDef(bill.feesIndex.common.totalFee) ? bill.feesIndex.common.totalFee : 0;
+        return cbTools.isDef(bill.feesIndex.common) && cbTools.isDef(bill.feesIndex.common[totalFeeType]) ? bill.feesIndex.common[totalFeeType] : 0;
     },
-    'JSCSXMDEJJRGF': function () {
+    'JSCSXMDEJJRGF': function (tender) {
+        const totalFeeType = tender ? 'tenderTotalFee' : 'totalFee';
         let bill = calcBase.fixedBills[calcBase.fixedFlag.CONSTRUCTION_TECH]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return cbTools.isDef(bill.feesIndex.labour) && cbTools.isDef(bill.feesIndex.labour.totalFee) ? bill.feesIndex.labour.totalFee : 0;
+        return cbTools.isDef(bill.feesIndex.labour) && cbTools.isDef(bill.feesIndex.labour[totalFeeType]) ? bill.feesIndex.labour[totalFeeType] : 0;
     },
-    'JSCSXMDEJJCLF': function () {
+    'JSCSXMDEJJCLF': function (tender) {
+        const totalFeeType = tender ? 'tenderTotalFee' : 'totalFee';
         let bill = calcBase.fixedBills[calcBase.fixedFlag.CONSTRUCTION_TECH]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return cbTools.isDef(bill.feesIndex.material) && cbTools.isDef(bill.feesIndex.material.totalFee) ? bill.feesIndex.material.totalFee : 0;
+        return cbTools.isDef(bill.feesIndex.material) && cbTools.isDef(bill.feesIndex.material[totalFeeType]) ? bill.feesIndex.material[totalFeeType] : 0;
     },
-    'JSCSXMDEJJJXF': function () {
+    'JSCSXMDEJJJXF': function (tender) {
+        const totalFeeType = tender ? 'tenderTotalFee' : 'totalFee';
         let bill = calcBase.fixedBills[calcBase.fixedFlag.CONSTRUCTION_TECH]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return cbTools.isDef(bill.feesIndex.machine) && cbTools.isDef(bill.feesIndex.machine.totalFee) ? bill.feesIndex.machine.totalFee : 0;
+        return cbTools.isDef(bill.feesIndex.machine) && cbTools.isDef(bill.feesIndex.machine[totalFeeType]) ? bill.feesIndex.machine[totalFeeType] : 0;
     },
-    'JSCSXMTZRGF': function () {
+    'JSCSXMTZRGF': function (tender) {
+        const totalFeeType = tender ? 'tenderTotalFee' : 'totalFee';
         let bill = calcBase.fixedBills[calcBase.fixedFlag.CONSTRUCTION_TECH]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return cbTools.isDef(bill.feesIndex.adjustLabour) && cbTools.isDef(bill.feesIndex.adjustLabour.totalFee) ? bill.feesIndex.adjustLabour.totalFee : 0;
+        return cbTools.isDef(bill.feesIndex.adjustLabour) && cbTools.isDef(bill.feesIndex.adjustLabour[totalFeeType]) ? bill.feesIndex.adjustLabour[totalFeeType] : 0;
     },
-    'JSCSXMTZJSRGF': function () {
+    'JSCSXMTZJSRGF': function (tender) {
+        const totalFeeType = tender ? 'tenderTotalFee' : 'totalFee';
         let bill = calcBase.fixedBills[calcBase.fixedFlag.CONSTRUCTION_TECH]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return cbTools.isDef(bill.feesIndex.adjustMachineLabour) && cbTools.isDef(bill.feesIndex.adjustMachineLabour.totalFee) ? bill.feesIndex.adjustMachineLabour.totalFee : 0;
+        return cbTools.isDef(bill.feesIndex.adjustMachineLabour) && cbTools.isDef(bill.feesIndex.adjustMachineLabour[totalFeeType]) ? bill.feesIndex.adjustMachineLabour[totalFeeType] : 0;
     },
-    'JSCSXMZCF': function () {
+    'JSCSXMZCF': function (tender) {
+        const totalFeeType = tender ? 'tenderTotalFee' : 'totalFee';
         let bill = calcBase.fixedBills[calcBase.fixedFlag.CONSTRUCTION_TECH]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return cbTools.isDef(bill.feesIndex.mainMaterial) && cbTools.isDef(bill.feesIndex.mainMaterial.totalFee) ? bill.feesIndex.mainMaterial.totalFee : 0;
+        return cbTools.isDef(bill.feesIndex.mainMaterial) && cbTools.isDef(bill.feesIndex.mainMaterial[totalFeeType]) ? bill.feesIndex.mainMaterial[totalFeeType] : 0;
     },
-    'JSCSXMSBF': function () {
+    'JSCSXMSBF': function (tender) {
+        const totalFeeType = tender ? 'tenderTotalFee' : 'totalFee';
         let bill = calcBase.fixedBills[calcBase.fixedFlag.CONSTRUCTION_TECH]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return cbTools.isDef(bill.feesIndex.equipment) && cbTools.isDef(bill.feesIndex.equipment.totalFee) ? bill.feesIndex.equipment.totalFee : 0;
+        return cbTools.isDef(bill.feesIndex.equipment) && cbTools.isDef(bill.feesIndex.equipment[totalFeeType]) ? bill.feesIndex.equipment[totalFeeType] : 0;
     },
-    'JSCSXMWJJCLF': function () {
-        return (this['JSCSXMZCF']() + this['JSCSXMSBF']()).toDecimal(decimalObj.bills.totalPrice);
+    'JSCSXMWJJCLF': function (tender) {
+        return (this['JSCSXMZCF'](tender) + this['JSCSXMSBF'](tender)).toDecimal(decimalObj.bills.totalPrice);
     },
     'JSCSXMRGGR': function () {
         let rst = 0;
@@ -478,36 +502,39 @@ let baseFigureTemplate = {
         }
         return rst;
     },
-    'JSCSXMDEJJZJGCF': function () {
-        return (this['JSCSXMDEJJRGF']() + this['JSCSXMDEJJCLF']() + this['JSCSXMDEJJJXF']()).toDecimal(decimalObj.bills.totalPrice);
+    'JSCSXMDEJJZJGCF': function (tender) {
+        return (this['JSCSXMDEJJRGF'](tender) + this['JSCSXMDEJJCLF'](tender) + this['JSCSXMDEJJJXF'](tender)).toDecimal(decimalObj.bills.totalPrice);
     },
-    'QTXMF': function () {
+    'QTXMF': function (tender) {
+        const totalFeeType = tender ? 'tenderTotalFee' : 'totalFee';
         let bill = calcBase.fixedBills[calcBase.fixedFlag.OTHER]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return cbTools.isDef(bill.feesIndex.common) && cbTools.isDef(bill.feesIndex.common.totalFee) ? bill.feesIndex.common.totalFee : 0;
+        return cbTools.isDef(bill.feesIndex.common) && cbTools.isDef(bill.feesIndex.common[totalFeeType]) ? bill.feesIndex.common[totalFeeType] : 0;
     },
-    'GF': function () {
+    'GF': function (tender) {
+        const totalFeeType = tender ? 'tenderTotalFee' : 'totalFee';
         let bill = calcBase.fixedBills[calcBase.fixedFlag.CHARGE]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return cbTools.isDef(bill.feesIndex.common) && cbTools.isDef(bill.feesIndex.common.totalFee) ? bill.feesIndex.common.totalFee : 0;
+        return cbTools.isDef(bill.feesIndex.common) && cbTools.isDef(bill.feesIndex.common[totalFeeType]) ? bill.feesIndex.common[totalFeeType] : 0;
     },
-    'SJ': function () {
+    'SJ': function (tender) {
+        const totalFeeType = tender ? 'tenderTotalFee' : 'totalFee';
         let bill = calcBase.fixedBills[calcBase.fixedFlag.TAX]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return cbTools.isDef(bill.feesIndex.common) && cbTools.isDef(bill.feesIndex.common.totalFee) ? bill.feesIndex.common.totalFee : 0;
+        return cbTools.isDef(bill.feesIndex.common) && cbTools.isDef(bill.feesIndex.common[totalFeeType]) ? bill.feesIndex.common[totalFeeType] : 0;
     },
-    'SQGCZJ': function () {//税前工程造价
+    'SQGCZJ': function (tender) {//税前工程造价
         let bill = calcBase.fixedBills[calcBase.fixedFlag.SAFETY_CONSTRUCTION]['bill'];
         if(cbTools.isUnDef(bill) || cbTools.isUnDef(bill.ID)) return 0;
         let node = cbTools.getNodeByID(bill.ID);
         if(cbTools.isUnDef(node)) return 0;
-        return projectObj.project.calcProgram.getBeforeTaxTotalFee([node]);
+        return projectObj.project.calcProgram.getBeforeTaxTotalFee([node], tender);
     },
-    'RCJJC': function () {//人材机价差
-        return (this['RGJC']() + this['CLJC']() + this['JXJC']()).toDecimal(decimalObj.bills.totalPrice);
+    'RCJJC': function (tender) {//人材机价差
+        return (this['RGJC'](tender) + this['CLJC'](tender) + this['JXJC'](tender)).toDecimal(decimalObj.bills.totalPrice);
     },
     'RGJC': function () {//人工价差
         let rst = 0;
@@ -551,8 +578,8 @@ let baseFigureTemplate = {
         }
         return rst;
     },
-    'FBFXRCJJC': function () {//分部分项人材机价差
-        return (this['FBFXRGJC']() + this['FBFXCLJC']() + this['FBFXJXJC']()).toDecimal(decimalObj.bills.totalPrice);
+    'FBFXRCJJC': function (tender) {//分部分项人材机价差
+        return (this['FBFXRGJC'](tender) + this['FBFXCLJC'](tender) + this['FBFXJXJC'](tender)).toDecimal(decimalObj.bills.totalPrice);
     },
     'FBFXRGJC': function () {//分部分项人工价差
         let rst = 0;
@@ -596,8 +623,8 @@ let baseFigureTemplate = {
         }
         return rst;
     },
-    'JSCSXMRCJJC': function () {//技术措施项目人材机价差
-        return (this['JSCSXMRGJC']() + this['JSCSXMCLJC']() + this['JSCSXMJXJC']()).toDecimal(decimalObj.bills.totalPrice);
+    'JSCSXMRCJJC': function (tender) {//技术措施项目人材机价差
+        return (this['JSCSXMRGJC'](tender) + this['JSCSXMCLJC'](tender) + this['JSCSXMJXJC'](tender)).toDecimal(decimalObj.bills.totalPrice);
     },
     'JSCSXMRGJC': function () {//技术措施项目人工价差
         let rst = 0;
@@ -801,76 +828,84 @@ let baseFigureTemplate = {
         }
         return rst;
     },
-    'ZGCLFFZM': function () {//暂估材料费(从子目汇总)
+    'ZGCLFFZM': function (tender) {//暂估材料费(从子目汇总)
+        const totalFeeType = tender ? 'tenderTotalFee' : 'totalFee';
         let bill = calcBase.fixedBills[calcBase.fixedFlag.ENGINEERINGCOST]['bill'];
         if(cbTools.isUnDef(bill)) return 0;
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
-        return cbTools.isDef(bill.feesIndex.estimate) && cbTools.isDef(bill.feesIndex.estimate.totalFee) ? bill.feesIndex.estimate.totalFee : 0;
+        return cbTools.isDef(bill.feesIndex.estimate) && cbTools.isDef(bill.feesIndex.estimate[totalFeeType]) ? bill.feesIndex.estimate[totalFeeType] : 0;
     },
     'ZGCLFFGLJ': function () {//暂估材料费(从工料机汇总表汇总)
         return 0;
     },
-    'FBF': function () {//分包费
+    'FBF': function (tender) {//分包费
+        const totalFeeType = tender ? 'tenderTotalFee' : 'totalFee';
         let rst = 0;
         let rations = calcBase.project.Ration.datas;
         for(let ration of rations){
             if(ration.isSubcontract && ration.feesIndex && ration.feesIndex.common){
-                rst = parseFloat(rst + ration.feesIndex.common.totalFee).toDecimal(decimalObj.ration.totalPrice)
+                rst = parseFloat(rst + ration.feesIndex.common[totalFeeType]).toDecimal(decimalObj.ration.totalPrice)
             }
         }
         return rst;
     },
-    'FBDEJJRGF': function () {//分包定额基价人工费
+    'FBDEJJRGF': function (tender) {//分包定额基价人工费
+        const totalFeeType = tender ? 'tenderTotalFee' : 'totalFee';
         let rst = 0;
         let rations = calcBase.project.Ration.datas;
         for(let ration of rations){
             if(ration.isSubcontract && ration.feesIndex && ration.feesIndex.labour){
-                rst = parseFloat(rst + ration.feesIndex.labour.totalFee).toDecimal(decimalObj.ration.totalPrice)
+                rst = parseFloat(rst + ration.feesIndex.labour[totalFeeType]).toDecimal(decimalObj.ration.totalPrice)
             }
         }
         return rst;
     },
-    'FBDEJJCLF': function () {//分包定额基价材料费
+    'FBDEJJCLF': function (tender) {//分包定额基价材料费
+        const totalFeeType = tender ? 'tenderTotalFee' : 'totalFee';
         let rst = 0;
         let rations = calcBase.project.Ration.datas;
         for(let ration of rations){
             if(ration.isSubcontract && ration.feesIndex && ration.feesIndex.material){
-                rst = parseFloat(rst + ration.feesIndex.material.totalFee).toDecimal(decimalObj.ration.totalPrice)
+                rst = parseFloat(rst + ration.feesIndex.material[totalFeeType]).toDecimal(decimalObj.ration.totalPrice)
             }
         }
         return rst;
     },
-    'FBDEJJJXF': function(){//分包定额基价机械费
+    'FBDEJJJXF': function(tender){//分包定额基价机械费
+        const totalFeeType = tender ? 'tenderTotalFee' : 'totalFee';
         let rst = 0;
         let rations = calcBase.project.Ration.datas;
         for(let ration of rations){
             if(ration.isSubcontract && ration.feesIndex && ration.feesIndex.machine){
-                rst = parseFloat(rst + ration.feesIndex.machine.totalFee).toDecimal(decimalObj.ration.totalPrice)
+                rst = parseFloat(rst + ration.feesIndex.machine[totalFeeType]).toDecimal(decimalObj.ration.totalPrice)
             }
         }
         return rst;
     },
-    'FBZCF': function () {//分包主材费
+    'FBZCF': function (tender) {//分包主材费
+        const totalFeeType = tender ? 'tenderTotalFee' : 'totalFee';
         let rst = 0;
         let rations = calcBase.project.Ration.datas;
         for(let ration of rations){
             if(ration.isSubcontract && ration.feesIndex && ration.feesIndex.mainMaterial){
-                rst = parseFloat(rst + ration.feesIndex.mainMaterial.totalFee).toDecimal(decimalObj.ration.totalPrice)
+                rst = parseFloat(rst + ration.feesIndex.mainMaterial[totalFeeType]).toDecimal(decimalObj.ration.totalPrice)
             }
         }
         return rst;
     },
-    'FBSBF': function () {//分包设备费
+    'FBSBF': function (tender) {//分包设备费
+        const totalFeeType = tender ? 'tenderTotalFee' : 'totalFee';
         let rst = 0;
         let rations = calcBase.project.Ration.datas;
         for(let ration of rations){
             if(ration.isSubcontract && ration.feesIndex && ration.feesIndex.equipment){
-                rst = parseFloat(rst + ration.feesIndex.equipment.totalFee).toDecimal(decimalObj.ration.totalPrice)
+                rst = parseFloat(rst + ration.feesIndex.equipment[totalFeeType]).toDecimal(decimalObj.ration.totalPrice)
             }
         }
         return rst;
     },
-    'FBRGGR': function () {//分包人工工日
+    'FBRGGR': function (tender) {//分包人工工日
+        const quantityType = tender ? 'tenderQuantity' : 'quantity';
         let rst = 0;
         let rationObjs = [];//查找定额工料机
         let rations = calcBase.project.Ration.datas;
@@ -879,22 +914,22 @@ let baseFigureTemplate = {
             if(ration.isSubcontract){
                 //定额
                 if(ration.type === rationType.ration){
-                    rationObjs.push({ID: ration.ID, quantity: ration.quantity});
+                    rationObjs.push({ID: ration.ID, quantity: ration[quantityType]});
                 }
                 //量人 type 2, subType 1
                 else if(ration.type === rationType.volumePrice && ration.subType === volumePriceMaps['量人']){
-                    rst = parseFloat(rst + ration.quantity).toDecimal(decimalObj.glj.quantity);
+                    rst = parseFloat(rst + ration[quantityType]).toDecimal(decimalObj.glj.quantity);
                 }
                 //定额类型的人工工料机,type 3, subType 1
                 else if(ration.type === rationType.gljRation && ration.subType === gljType.LABOUR){
-                    rst = parseFloat(rst + ration.quantity).toDecimal(decimalObj.glj.quantity);
+                    rst = parseFloat(rst + ration[quantityType]).toDecimal(decimalObj.glj.quantity);
                 }
             }
         }
         for(let ration of rationObjs){
             for(let glj of rationGljs){
                 if(ration.ID === glj.rationID && glj.type === gljType.LABOUR){
-                    rst = parseFloat(rst + parseFloat(glj.quantity * ration.quantity).toDecimal(decimalObj.glj.quantity)).toDecimal(decimalObj.glj.quantity);
+                    rst = parseFloat(rst + parseFloat(glj[quantityType] * ration.quantity).toDecimal(decimalObj.glj.quantity)).toDecimal(decimalObj.glj.quantity);
                 }
             }
         }
@@ -1325,6 +1360,13 @@ let cbCalctor = {
         }
         return baseFigureTemplate[calcBase.baseFigures[figure]['base']]();
     },
+    //调价后计算基数
+    tenderBase: function (figure) {
+        if(figure === 'NONE'){
+            return 0;
+        }
+        return baseFigureTemplate[calcBase.baseFigures[figure]['base']](true);
+    },
     //ID引用
     ref: function (fExp) {
         let ID = cbParser.getUID([fExp]);
@@ -1400,11 +1442,18 @@ let calcBase = {
             if(!cbTools.isNum(calcBaseValue)){
                 throw '表达式不正确';
             }
+            //调价
+            let tenderCalcExp = calcExp.replace(new RegExp('base', 'g'), 'tenderBase');
+            let tenderCalcBaseValue = eval(tenderCalcExp);
+            if(!cbTools.isNum(tenderCalcBaseValue)){
+                throw '表达式不正确';
+            }
 
             //存储
             me.success = true;
             node.data.calcBase = exp;
             node.data.calcBaseValue = parseFloat(calcBaseValue).toDecimal(decimalObj.decimal('totalPrice', node));
+            node.data.tenderCalcBaseValue = parseFloat(tenderCalcBaseValue).toDecimal(decimalObj.decimal('totalPrice', node));
             node.changed = true;
         }
         catch (err){

+ 6 - 5
web/building_saas/main/js/models/calc_program.js

@@ -1858,8 +1858,9 @@ class CalcProgram {
     };
 
     // 排除指定项的综合合价计算(用于带循环计算的情况。这里的汇总只到清单级别即可:清单单价取费时,汇总到清单和汇总到定额两个值不一样)
-    getTotalFee(baseNodes, excludeNodes){
+    getTotalFee(baseNodes, excludeNodes, adj){
         let rst = 0;
+        const totalFeeType = adj ? 'common.tenderTotalFee' : 'common.totalFee';
         function calcNodes(nodes) {
             for (let node of nodes) {
                 if (!excludeNodes.includes(node)){
@@ -1868,7 +1869,7 @@ class CalcProgram {
                     }
                     else{
                         if (node.sourceType == ModuleNames.bills) {
-                            rst = (rst + calcTools.getFee(node, 'common.totalFee')).toDecimal(decimalObj.decimal("totalPrice", node));
+                            rst = (rst + calcTools.getFee(node, totalFeeType)).toDecimal(decimalObj.decimal("totalPrice", node));
                         };
                     }
                 }
@@ -1878,14 +1879,14 @@ class CalcProgram {
         return rst;
     };
 
-    // 税前工程造价
-    getBeforeTaxTotalFee(excludeNodes){
+    // 税前工程造价 ,adj调价
+    getBeforeTaxTotalFee(excludeNodes, adj){
         let baseNodes = [], me = this;
         baseNodes.push(calcTools.getNodeByFlag(fixedFlag.SUB_ENGINERRING));
         baseNodes.push(calcTools.getNodeByFlag(fixedFlag.MEASURE));
         baseNodes.push(calcTools.getNodeByFlag(fixedFlag.OTHER));
         baseNodes.push(calcTools.getNodeByFlag(fixedFlag.CHARGE));
-        return me.getTotalFee(baseNodes, excludeNodes);
+        return me.getTotalFee(baseNodes, excludeNodes, adj);
     };
 
     clearTenders(){