Browse Source

Merge branch 'master' of http://smartcost.f3322.net:3000/SmartCost/ConstructionCost

zhongzewei 7 years ago
parent
commit
64759fc69d

+ 1 - 0
config/gulpConfig.js

@@ -79,6 +79,7 @@ module.exports = {
         'web/building_saas/main/js/models/ration_glj.js',
         'web/building_saas/main/js/models/ration_glj.js',
         'web/building_saas/main/js/models/ration_coe.js',
         'web/building_saas/main/js/models/ration_coe.js',
         'web/building_saas/main/js/models/ration_ass.js',
         'web/building_saas/main/js/models/ration_ass.js',
+        'web/building_saas/main/js/models/ration_installation',
         // 'web/building_saas/main/js/models/volume_price.js',
         // 'web/building_saas/main/js/models/volume_price.js',
         'web/building_saas/main/js/models/labour_coe.js',
         'web/building_saas/main/js/models/labour_coe.js',
         'web/building_saas/main/js/models/installation_fee.js',
         'web/building_saas/main/js/models/installation_fee.js',

+ 50 - 2
modules/main/facade/ration_facade.js

@@ -11,10 +11,12 @@ let ration_coe = mongoose.model('ration_coe');
 let ration_model = require('../models/ration');
 let ration_model = require('../models/ration');
 let bill_model = require('../models/bills');
 let bill_model = require('../models/bills');
 let decimal_facade = require('./decimal_facade');
 let decimal_facade = require('./decimal_facade');
+import installationFeeModel from "../models/installation_fee";
+import rationInstallationModel from "../models/ration_installation";
 const uuidV1 = require('uuid/v1');
 const uuidV1 = require('uuid/v1');
 let std_glj_lib_gljList_model = mongoose.model('std_glj_lib_gljList');
 let std_glj_lib_gljList_model = mongoose.model('std_glj_lib_gljList');
 let coeMolde = mongoose.model('std_ration_lib_coe_list');
 let coeMolde = mongoose.model('std_ration_lib_coe_list');
-
+let _= require('lodash');
 
 
 module.exports = {
 module.exports = {
     replaceRations: replaceRations,
     replaceRations: replaceRations,
@@ -113,8 +115,54 @@ async function addRationSubList(stdRation,newRation) {
     let ration_gljs = await addRationGLJ(stdRation,newRation);
     let ration_gljs = await addRationGLJ(stdRation,newRation);
     let ration_coes = await addRationCoe(stdRation,newRation);
     let ration_coes = await addRationCoe(stdRation,newRation);
     //todo  添加增加安装费
     //todo  添加增加安装费
+    let ration_installs =  await addRationInstallFee(stdRation,newRation);
+    return {ration:newRation,ration_gljs:ration_gljs,ration_coes:ration_coes,ration_installs:ration_installs};
+}
+
+async function addRationInstallFee(std,newRation) {
+    let install_fee_list = [];
+    if(std.hasOwnProperty('rationInstList') && std.rationInstList.length > 0){
+        let installFee = await installationFeeModel.findOne({'projectID': newRation.projectID});
+        for(let ri of std.rationInstList){
+            let feeItem = _.find(installFee.installFeeItem,{'ID':ri.feeItemId});
+            let section = _.find(installFee.installSection,{'ID':ri.sectionId});
+            if(feeItem&&section){
+                let tem_r_i = {
+                    libID:installFee.libID,
+                    projectID:newRation.projectID,
+                    rationID:newRation.ID,
+                    feeItemId:feeItem.ID,
+                    sectionId:section.ID,
+                    itemName:feeItem.feeItem,
+                    feeType:feeItem.feeType,
+                    sectionName:section.name,
+                    unifiedSetting:1
+                };
+                if(section.feeRuleId&&section.feeRuleId!=''){
+                    let feeRule = _.find(installFee.feeRule,{'ID':section.feeRuleId});
+                    if(feeRule){
+                        tem_r_i.ruleId = feeRule.ID;
+                        tem_r_i.code = feeRule.code;
+                        tem_r_i.rule = feeRule.rule;
+                        tem_r_i.base = feeRule.base;
+                        tem_r_i.feeRate = feeRule.feeRate;
+                        tem_r_i.labour = feeRule.labour;
+                        tem_r_i.material = feeRule.material;
+                        tem_r_i.machine = feeRule.machine;
+                        tem_r_i.position = feeRule.position;
+                        tem_r_i.billID = feeRule.billID;
+                    }
+                }
+                tem_r_i.ID = uuidV1();
+                install_fee_list.push(tem_r_i);
+            }
+        }
+        if(install_fee_list.length>0){
+            await rationInstallationModel.insertMany(install_fee_list);
+        }
+    }
 
 
-    return {ration:newRation,ration_gljs:ration_gljs,ration_coes:ration_coes};
+    return install_fee_list;
 }
 }
 
 
 async function addRationCoe(std,newRation) {
 async function addRationCoe(std,newRation) {

+ 21 - 0
modules/main/facade/ration_installation_facade.js

@@ -0,0 +1,21 @@
+/**
+ * Created by zhang on 2018/2/24.
+ */
+
+import rationInstallationModel from "../models/ration_installation";
+let consts = require('../models/project_consts');
+let projectConsts = consts.projectConst;
+
+module.exports={
+    getData:getData
+};
+
+function getData(projectID, callback) {
+    rationInstallationModel.find({'projectID': projectID}, (err, datas) => {
+        if (err) {
+            callback(1, '', null);
+        } else {
+            callback(0, consts.projectConst.RATION_INSTALLATION, datas);
+        }
+    })
+}

+ 2 - 0
modules/main/models/project.js

@@ -7,6 +7,7 @@ var GLJData = require('./glj');
 var ration_glj_data = require('../../ration_glj/facade/ration_glj_facade');
 var ration_glj_data = require('../../ration_glj/facade/ration_glj_facade');
 var ration_coe_data = require('../../ration_glj/facade/ration_coe_facade');
 var ration_coe_data = require('../../ration_glj/facade/ration_coe_facade');
 var ration_ass_data = require('../../ration_glj/facade/ration_ass_facade');
 var ration_ass_data = require('../../ration_glj/facade/ration_ass_facade');
+let ration_installation = require('../facade/ration_installation_facade');
 var quantity_detail_data = require('../facade/quantity_detail_facade');
 var quantity_detail_data = require('../facade/quantity_detail_facade');
 var fee_rate_data = require('../../fee_rates/facade/fee_rates_facade');
 var fee_rate_data = require('../../fee_rates/facade/fee_rates_facade');
 let projCounter = require('./proj_counter_model');
 let projCounter = require('./proj_counter_model');
@@ -33,6 +34,7 @@ moduleMap[projectConsts.RATION] = rationData;
 moduleMap[projectConsts.RATION_GLJ] = ration_glj_data;
 moduleMap[projectConsts.RATION_GLJ] = ration_glj_data;
 moduleMap[projectConsts.RATION_COE] = ration_coe_data;
 moduleMap[projectConsts.RATION_COE] = ration_coe_data;
 moduleMap[projectConsts.RATION_ASS] = ration_ass_data;
 moduleMap[projectConsts.RATION_ASS] = ration_ass_data;
+moduleMap[projectConsts.RATION_INSTALLATION] = ration_installation;
 moduleMap[projectConsts.QUANTITY_DETAIL] = quantity_detail_data;
 moduleMap[projectConsts.QUANTITY_DETAIL] = quantity_detail_data;
 moduleMap[projCounter.collectionName] = projCounter;
 moduleMap[projCounter.collectionName] = projCounter;
 moduleMap[projSetting.collectionName] = projSetting;
 moduleMap[projSetting.collectionName] = projSetting;

+ 1 - 0
modules/main/models/project_consts.js

@@ -8,6 +8,7 @@ let projectConst = {
     RATION_GLJ:'ration_glj',
     RATION_GLJ:'ration_glj',
     RATION_COE:'ration_coe',
     RATION_COE:'ration_coe',
     RATION_ASS:'ration_ass',
     RATION_ASS:'ration_ass',
+    RATION_INSTALLATION:'ration_installation',
     QUANTITY_DETAIL:'quantity_detail',
     QUANTITY_DETAIL:'quantity_detail',
     PROJECTGLJ: 'projectGLJ',
     PROJECTGLJ: 'projectGLJ',
     GLJLIST: 'GLJList',
     GLJLIST: 'GLJList',

+ 7 - 2
modules/main/models/ration_installation.js

@@ -14,6 +14,7 @@ var ration_installation = new Schema({
     feeItemId:String,
     feeItemId:String,
     ruleId:String,
     ruleId:String,
     itemName:String,
     itemName:String,
+    sectionName:String,
     code: String,
     code: String,
     rule: String,
     rule: String,
     base: String,
     base: String,
@@ -21,8 +22,12 @@ var ration_installation = new Schema({
     labour: Number,
     labour: Number,
     material: Number,
     material: Number,
     machine: Number,
     machine: Number,
+    feeType: String, //费用类型
     position: String,//记取位置
     position: String,//记取位置
-    billID:String//记取位置对应的清单ID
+    billID:String,//记取位置对应的清单ID
+    unifiedSetting:{type: Number,default:1},//0:false 1:true  按统一设置
 },{versionKey:false});
 },{versionKey:false});
 
 
-mongoose.model('ration_installation', ration_installation);
+let rationInstallationModel = mongoose.model('ration_installation', ration_installation,"ration_installation");
+
+export{ rationInstallationModel as default}

+ 10 - 8
web/building_saas/glj/js/project_glj_spread.js

@@ -38,7 +38,7 @@ ProjectGLJSpread.prototype.init = function () {
     }
     }
     let selectBox = new GC.Spread.Sheets.CellTypes.ComboBox();
     let selectBox = new GC.Spread.Sheets.CellTypes.ComboBox();
     selectBox.items(supplySelect);
     selectBox.items(supplySelect);
-    selectBox.editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.text);
+    selectBox.editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.value);
     let header = [
     let header = [
         {name: '编码', field: 'code', visible: true,width:80},
         {name: '编码', field: 'code', visible: true,width:80},
         {name: '名称', field: 'name', visible: true,width:160},
         {name: '名称', field: 'name', visible: true,width:160},
@@ -214,7 +214,7 @@ ProjectGLJSpread.prototype.updateProjectGLJField = function(info, callback) {
 
 
     // 如果是供货方式则需要处理数据
     // 如果是供货方式则需要处理数据
     if (field === 'supply') {
     if (field === 'supply') {
-        value = this.supplyType.indexOf(value);
+        // value = this.supplyType.indexOf(value);
         extend.supply_quantity = this.getSupplyQuantity(value, activeSheet, info);
         extend.supply_quantity = this.getSupplyQuantity(value, activeSheet, info);
     }
     }
     if(field === 'supply_quantity'){//修改数量需做4舍5入
     if(field === 'supply_quantity'){//修改数量需做4舍5入
@@ -311,11 +311,11 @@ ProjectGLJSpread.prototype.specialColumn = function (sourceData) {
             activeSheet.getCell(rowCounter, supplyColumn,  GC.Spread.Sheets.SheetArea.viewport).locked(true);
             activeSheet.getCell(rowCounter, supplyColumn,  GC.Spread.Sheets.SheetArea.viewport).locked(true);
         }
         }
         // 如果为部分甲供则甲供数量需要可编辑
         // 如果为部分甲供则甲供数量需要可编辑
-        if (data.supply === 1) {
+        if (data.supply == 1) {
             activeSheet.getCell(rowCounter, supplyQuantity,  GC.Spread.Sheets.SheetArea.viewport).locked(false);
             activeSheet.getCell(rowCounter, supplyQuantity,  GC.Spread.Sheets.SheetArea.viewport).locked(false);
         }
         }
         //供货方式为完全甲供时设置甲供数量为总消耗量
         //供货方式为完全甲供时设置甲供数量为总消耗量
-        if (data.supply === 2) {
+        if (data.supply == 2) {
             activeSheet.setValue(rowCounter, supplyQuantity,  data.quantity);
             activeSheet.setValue(rowCounter, supplyQuantity,  data.quantity);
         }
         }
         // 供货方式数据
         // 供货方式数据
@@ -323,6 +323,7 @@ ProjectGLJSpread.prototype.specialColumn = function (sourceData) {
         supplyIndex = isNaN(supplyIndex) ? 0 : supplyIndex;
         supplyIndex = isNaN(supplyIndex) ? 0 : supplyIndex;
         let supplyText = this.supplyType[supplyIndex] !== undefined ? this.supplyType[supplyIndex] : '自行采购';
         let supplyText = this.supplyType[supplyIndex] !== undefined ? this.supplyType[supplyIndex] : '自行采购';
         activeSheet.setValue(rowCounter, supplyColumn, supplyText);
         activeSheet.setValue(rowCounter, supplyColumn, supplyText);
+        // activeSheet.setValue(rowCounter, supplyColumn, supplyIndex);
 
 
         // 如果类型为混凝土、砂浆、配合比、机械,则市场单价和供货方式不能修改
         // 如果类型为混凝土、砂浆、配合比、机械,则市场单价和供货方式不能修改
         if (canNotChangeTypeId.indexOf(data.unit_price.type) >= 0) {
         if (canNotChangeTypeId.indexOf(data.unit_price.type) >= 0) {
@@ -474,13 +475,14 @@ ProjectGLJSpread.prototype.priceCalculate = function(info) {
  * @return {void}
  * @return {void}
  */
  */
 ProjectGLJSpread.prototype.changeSupplyType = function(info) {
 ProjectGLJSpread.prototype.changeSupplyType = function(info) {
-    let supply = info.newValue;
-    let supplyNumber = this.supplyType.indexOf(supply) > -1 ? this.supplyType.indexOf(supply) : 0;
+    // let supply = info.newValue;
+    // let supplyNumber = this.supplyType.indexOf(supply) > -1 ? this.supplyType.indexOf(supply) : 0;
+    let supplyNumber = info.newValue;
     let supplyQuantityColumn = this.sheetObj.getFieldColumn('supply_quantity');
     let supplyQuantityColumn = this.sheetObj.getFieldColumn('supply_quantity');
     let activeSheet = this.sheetObj.getSheet();
     let activeSheet = this.sheetObj.getSheet();
 
 
     // 部分甲供时可更改甲供数量数据,其余则只读
     // 部分甲供时可更改甲供数量数据,其余则只读
-    let locked = supplyNumber === 1 ? false : true;
+    let locked = supplyNumber == 1 ? false : true;
     activeSheet.getCell(info.row, supplyQuantityColumn,  GC.Spread.Sheets.SheetArea.viewport).locked(locked);
     activeSheet.getCell(info.row, supplyQuantityColumn,  GC.Spread.Sheets.SheetArea.viewport).locked(locked);
 
 
     let supplyQuantity = this.getSupplyQuantity(supplyNumber, activeSheet, info);
     let supplyQuantity = this.getSupplyQuantity(supplyNumber, activeSheet, info);
@@ -500,7 +502,7 @@ ProjectGLJSpread.prototype.getSupplyQuantity = function(supplyType, activeSheet,
     // 获取总消耗量
     // 获取总消耗量
     let quantity = activeSheet.getValue(info.row, quantityColumn);
     let quantity = activeSheet.getValue(info.row, quantityColumn);
     // 自行采购和甲定乙供则把甲供数量设置为0,其余情况则设置为当前总消耗量
     // 自行采购和甲定乙供则把甲供数量设置为0,其余情况则设置为当前总消耗量
-    let supplyQuantity = supplyType === 0 || supplyType === 3 ? 0 : quantity;
+    let supplyQuantity = supplyType == 0 || supplyType == 3 ? 0 : quantity;
     supplyQuantity = parseFloat(supplyQuantity);
     supplyQuantity = parseFloat(supplyQuantity);
 
 
     return supplyQuantity;
     return supplyQuantity;

+ 20 - 3
web/building_saas/main/html/main.html

@@ -1019,9 +1019,6 @@
         <script src="/lib/spreadjs/views/plugins/gc.spread.views.gridlayout.10.0.0.min.js" type="text/javascript"></script>
         <script src="/lib/spreadjs/views/plugins/gc.spread.views.gridlayout.10.0.0.min.js" type="text/javascript"></script>
         <script>GC.Spread.Sheets.LicenseKey = "559432293813965#A0y3iTOzEDOzkjMyMDN9UTNiojIklkI1pjIEJCLi4TPB9mM5AFNTd4cvZ7SaJUVy3CWKtWYXx4VVhjMpp7dYNGdx2ia9sEVlZGOTh7NRlTUwkWR9wEV4gmbjBDZ4ElR8N7cGdHVvEWVBtCOwIGW0ZmeYVWVr3mI0IyUiwCMzETN8kzNzYTM0IicfJye&Qf35VfiEzRwEkI0IyQiwiIwEjL6ByUKBCZhVmcwNlI0IiTis7W0ICZyBlIsIyNyMzM5ADI5ADNwcTMwIjI0ICdyNkIsIibj9SbvNmL4N7bjRnch56ciojIz5GRiwiI8+Y9sWY9QmZ0Jyp96uL9v6L0wap9biY9qiq95q197Wr9g+89iojIh94Wiqi";</script>
         <script>GC.Spread.Sheets.LicenseKey = "559432293813965#A0y3iTOzEDOzkjMyMDN9UTNiojIklkI1pjIEJCLi4TPB9mM5AFNTd4cvZ7SaJUVy3CWKtWYXx4VVhjMpp7dYNGdx2ia9sEVlZGOTh7NRlTUwkWR9wEV4gmbjBDZ4ElR8N7cGdHVvEWVBtCOwIGW0ZmeYVWVr3mI0IyUiwCMzETN8kzNzYTM0IicfJye&Qf35VfiEzRwEkI0IyQiwiIwEjL6ByUKBCZhVmcwNlI0IiTis7W0ICZyBlIsIyNyMzM5ADI5ADNwcTMwIjI0ICdyNkIsIibj9SbvNmL4N7bjRnch56ciojIz5GRiwiI8+Y9sWY9QmZ0Jyp96uL9v6L0wap9biY9qiq95q197Wr9g+89iojIh94Wiqi";</script>
         <script>GC.Spread.Views.LicenseKey = "559432293813965#A0y3iTOzEDOzkjMyMDN9UTNiojIklkI1pjIEJCLi4TPB9mM5AFNTd4cvZ7SaJUVy3CWKtWYXx4VVhjMpp7dYNGdx2ia9sEVlZGOTh7NRlTUwkWR9wEV4gmbjBDZ4ElR8N7cGdHVvEWVBtCOwIGW0ZmeYVWVr3mI0IyUiwCMzETN8kzNzYTM0IicfJye&Qf35VfiEzRwEkI0IyQiwiIwEjL6ByUKBCZhVmcwNlI0IiTis7W0ICZyBlIsIyNyMzM5ADI5ADNwcTMwIjI0ICdyNkIsIibj9SbvNmL4N7bjRnch56ciojIz5GRiwiI8+Y9sWY9QmZ0Jyp96uL9v6L0wap9biY9qiq95q197Wr9g+89iojIh94Wiqi";</script>
         <script>GC.Spread.Views.LicenseKey = "559432293813965#A0y3iTOzEDOzkjMyMDN9UTNiojIklkI1pjIEJCLi4TPB9mM5AFNTd4cvZ7SaJUVy3CWKtWYXx4VVhjMpp7dYNGdx2ia9sEVlZGOTh7NRlTUwkWR9wEV4gmbjBDZ4ElR8N7cGdHVvEWVBtCOwIGW0ZmeYVWVr3mI0IyUiwCMzETN8kzNzYTM0IicfJye&Qf35VfiEzRwEkI0IyQiwiIwEjL6ByUKBCZhVmcwNlI0IiTis7W0ICZyBlIsIyNyMzM5ADI5ADNwcTMwIjI0ICdyNkIsIibj9SbvNmL4N7bjRnch56ciojIz5GRiwiI8+Y9sWY9QmZ0Jyp96uL9v6L0wap9biY9qiq95q197Wr9g+89iojIh94Wiqi";</script>
-
-
-
         <!-- inject:js -->
         <!-- inject:js -->
         <!--<script type="text/javascript" src="/test/tmp_data/test_ration_calc/ration_calc_base.js"></script>-->
         <!--<script type="text/javascript" src="/test/tmp_data/test_ration_calc/ration_calc_base.js"></script>-->
         <script type="text/javascript" src="/web/building_saas/main/js/models/main_consts.js"></script>
         <script type="text/javascript" src="/web/building_saas/main/js/models/main_consts.js"></script>
@@ -1077,6 +1074,7 @@
         <script type="text/javascript" src="/web/building_saas/main/js/models/ration_glj.js"></script>
         <script type="text/javascript" src="/web/building_saas/main/js/models/ration_glj.js"></script>
         <script type="text/javascript" src="/web/building_saas/main/js/models/ration_coe.js"></script>
         <script type="text/javascript" src="/web/building_saas/main/js/models/ration_coe.js"></script>
         <script type="text/javascript" src="/web/building_saas/main/js/models/ration_ass.js"></script>
         <script type="text/javascript" src="/web/building_saas/main/js/models/ration_ass.js"></script>
+        <script type="text/javascript" src="/web/building_saas/main/js/models/ration_installation.js"></script>
         <!--<script type="text/javascript" src="/web/building_saas/main/js/models/volume_price.js"></script>-->
         <!--<script type="text/javascript" src="/web/building_saas/main/js/models/volume_price.js"></script>-->
         <script type="text/javascript" src="/web/building_saas/main/js/models/labour_coe.js"></script>
         <script type="text/javascript" src="/web/building_saas/main/js/models/labour_coe.js"></script>
         <script type="text/javascript" src="/web/building_saas/main/js/models/calc_program.js"></script>
         <script type="text/javascript" src="/web/building_saas/main/js/models/calc_program.js"></script>
@@ -1186,9 +1184,28 @@
 //                count();
 //                count();
 //            }
 //            }
 
 
+
             $(document).ready(function(){
             $(document).ready(function(){
                 //createTree();
                 //createTree();
 
 
+
+
+              /*  document.onkeydown=keydown;
+                function keydown(e){
+                   alert('aa');
+                   e.preventDefault();
+                   e.stopPropagation()
+
+                }*/
+
+              /*  $(document).keypress(function(e) {
+                    var code = (e.keyCode ? e.keyCode : e.which);
+                    if (code == 40) {
+                        alert("down pressed");
+                    } else if (code == 38) {
+                        alert("up pressed");
+                    }
+                });*/
                 /*            $("#tab_calc_program").click(function(){
                 /*            $("#tab_calc_program").click(function(){
                  location.href = '/web/building_saas/main/html/calc_program.html';
                  location.href = '/web/building_saas/main/html/calc_program.html';
                  });*/
                  });*/

+ 1 - 1
web/building_saas/main/js/models/calc_program.js

@@ -434,7 +434,7 @@ let calcTools = {
         else if (baseName == calcBaseNames.JGSBF || baseName == calcBaseNames.JDSBF){
         else if (baseName == calcBaseNames.JGSBF || baseName == calcBaseNames.JDSBF){
             gljT = [gljType.EQUIPMENT];
             gljT = [gljType.EQUIPMENT];
         };
         };
-
+        // alert(JSON.stringify(projectGLJ.testGLJs()));
         let supplyProjectGLJs = projectGLJ.getGLJsBySupply(supplyT, gljT);
         let supplyProjectGLJs = projectGLJ.getGLJsBySupply(supplyT, gljT);
         if (supplyProjectGLJs.length == 0) return 0;
         if (supplyProjectGLJs.length == 0) return 0;
 
 

+ 1 - 0
web/building_saas/main/js/models/main_consts.js

@@ -10,6 +10,7 @@ const ModuleNames = {
     ration_glj:'ration_glj',
     ration_glj:'ration_glj',
     ration_coe:'ration_coe',
     ration_coe:'ration_coe',
     ration_ass:'ration_ass',
     ration_ass:'ration_ass',
+    ration_installation:'ration_installation',
     quantity_detail:'quantity_detail',
     quantity_detail:'quantity_detail',
     labour_coe: 'labour_coe',
     labour_coe: 'labour_coe',
     calc_program: 'calc_program',
     calc_program: 'calc_program',

+ 1 - 0
web/building_saas/main/js/models/project.js

@@ -79,6 +79,7 @@ var PROJECT = {
             this.ration_glj = ration_glj.createNew(this);
             this.ration_glj = ration_glj.createNew(this);
             this.ration_coe = ration_coe.createNew(this);
             this.ration_coe = ration_coe.createNew(this);
             this.ration_ass = ration_ass.createNew(this);
             this.ration_ass = ration_ass.createNew(this);
+            this.ration_installation = ration_installation.createNew(this);
             this.quantity_detail = quantity_detail.createNew(this);
             this.quantity_detail = quantity_detail.createNew(this);
             this.installation_fee = installation_fee.createNew(this);
             this.installation_fee = installation_fee.createNew(this);
             this.FeeRate = FeeRate.createNew(this);
             this.FeeRate = FeeRate.createNew(this);

+ 32 - 1
web/building_saas/main/js/models/project_glj.js

@@ -70,11 +70,42 @@ ProjectGLJ.prototype.getDataByID = function (ID) {//根据项目工料机ID取
 
 
 // CSL, 2018-02-08 甲供、甲定。
 // CSL, 2018-02-08 甲供、甲定。
 ProjectGLJ.prototype.getGLJsBySupply = function (supplyTypeArr, gljTypeArr) {
 ProjectGLJ.prototype.getGLJsBySupply = function (supplyTypeArr, gljTypeArr) {
+    // 项目工料机采用了内部绑定数据源方式,能够双向同步,但同时带来难干预控制问题。supply值存在混杂情况,如:“2”和“部分甲供”同时存在。
+    // 所以这里要合并处理。
+    let mixSupply = [];
+    for (let s of supplyTypeArr){
+        switch (s) {
+            case 1:
+                mixSupply.push('部分甲供');
+                break;
+            case 2:
+                mixSupply.push('完全甲供');
+                break;
+            case 3:
+                mixSupply.push('甲定乙供');
+                break;
+            default:
+                mixSupply.push('自行采购');
+        }
+    };
+    mixSupply = mixSupply.concat(supplyTypeArr);
+
     return _.filter(this.datas.gljList, function (glj) {
     return _.filter(this.datas.gljList, function (glj) {
-        return supplyTypeArr.includes(glj.supply) && gljTypeArr.includes(glj.type);
+        return mixSupply.includes(glj.supply) && gljTypeArr.includes(glj.type);
     });
     });
 };
 };
 
 
+ProjectGLJ.prototype.testGLJs = function () {
+    let gljs = [];
+    for (let glj of this.datas.gljList){
+         let o = new Object();
+         o.name = glj.name;
+         o.supply = glj.supply;
+         gljs.push(o);
+    };
+    return gljs;
+};
+
 /**
 /**
  * 修改工料机数据
  * 修改工料机数据
  *
  *

+ 1 - 1
web/building_saas/main/js/models/ration.js

@@ -448,7 +448,7 @@ var Ration = {
                 $.bootstrapLoading.start();
                 $.bootstrapLoading.start();
                 CommonAjax.post("/ration/addNewRation",{itemQuery:itemQuery,newData:newData,calQuantity:calQuantity,brUpdate:brUpdate},function (data) {
                 CommonAjax.post("/ration/addNewRation",{itemQuery:itemQuery,newData:newData,calQuantity:calQuantity,brUpdate:brUpdate},function (data) {
                     //更新缓存
                     //更新缓存
-
+                    console.log(data);
                     me.datas.push(data.ration);
                     me.datas.push(data.ration);
                     project.ration_glj.addDatasToList(data.ration_gljs);
                     project.ration_glj.addDatasToList(data.ration_gljs);
                     project.ration_coe.addDatasToList(data.ration_coes);
                     project.ration_coe.addDatasToList(data.ration_coes);

+ 28 - 0
web/building_saas/main/js/models/ration_installation.js

@@ -0,0 +1,28 @@
+/**
+ * Created by zhang on 2018/2/24.
+ */
+let ration_installation = {
+    createNew: function (project) {
+        // 用户定义private方法
+        var tools = {};
+
+        // 所有通过this访问的属性,都不应在此单元外部进行写入操作
+        var ration_installation = function (proj) {
+            // this.project = proj;
+            this.datas = [];
+
+            var sourceType = ModuleNames.ration_installation;
+            this.getSourceType = function () {
+                return sourceType;
+            }
+            proj.registerModule(ModuleNames.ration_installation, this);
+        };
+
+        // prototype用于定义public方法
+        ration_installation.prototype.loadData = function (datas) {
+            this.datas = datas;
+        };
+
+        return new ration_installation(project);
+    }
+};

+ 8 - 2
web/building_saas/main/js/views/glj_view.js

@@ -413,8 +413,11 @@ var gljOprObj = {
         if(selected.sourceType == ModuleNames.ration_glj){//选中的是工料机时不可编辑
         if(selected.sourceType == ModuleNames.ration_glj){//选中的是工料机时不可编辑
             return ;
             return ;
         }
         }
-        var checkboxValue = args.sheet.getCell(args.row, args.col).value();
-        var newval = 0;
+        let checkboxValue = args.sheet.getCell(args.row, args.col).value();
+        if(args.sheetName == 'rationInstallSheet' && checkboxValue){
+            return;
+        }
+        let newval = 0;
         if (checkboxValue) {
         if (checkboxValue) {
             newval = 0;
             newval = 0;
             args.sheet.getCell(args.row, args.col).value(newval);
             args.sheet.getCell(args.row, args.col).value(newval);
@@ -716,6 +719,7 @@ var gljOprObj = {
                     this.showRationGLJData(node);
                     this.showRationGLJData(node);
                     this.showRationCoeData(node);
                     this.showRationCoeData(node);
                     this.showRationAssData(node);
                     this.showRationAssData(node);
+                    installationFeeObj.showRationInstallationData(node);
                 }
                 }
                 isShow = true;
                 isShow = true;
             }
             }
@@ -1039,10 +1043,12 @@ var gljOprObj = {
         sheetCommonObj.showData(this.sheet, this.setting, []);
         sheetCommonObj.showData(this.sheet, this.setting, []);
         sheetCommonObj.showData(this.coeSheet, this.coeSetting, []);
         sheetCommonObj.showData(this.coeSheet, this.coeSetting, []);
         sheetCommonObj.showData(this.assSheet, this.assSetting, []);
         sheetCommonObj.showData(this.assSheet, this.assSetting, []);
+        sheetCommonObj.showData(installationFeeObj.rationInstallSheet, installationFeeObj.rationInstallSetting, []);
         //  sheetCommonObj.showData(this.detailSheet,this.detailSetting,[]);
         //  sheetCommonObj.showData(this.detailSheet,this.detailSetting,[]);
         this.sheetData = [];
         this.sheetData = [];
         this.coeSheetData = [];
         this.coeSheetData = [];
         this.assSheetData = [];
         this.assSheetData = [];
+        installationFeeObj.rationInstallData = [];
         //this.detailData=[];
         //this.detailData=[];
     },
     },
     /*   lockRationGLJCell:function(){
     /*   lockRationGLJCell:function(){

+ 25 - 10
web/building_saas/main/js/views/installation_fee_view.js

@@ -5,20 +5,22 @@ let installationFeeObj={
     rationInstallSheet:null,
     rationInstallSheet:null,
     rationInstallData:null,
     rationInstallData:null,
     rationInstallSetting:{
     rationInstallSetting:{
-   /*     header: [
-            {headerName: "分册章节", headerWidth: 150, dataCode: "name", dataType: "String"},
-            {headerName: "费用规则", headerWidth: 220, dataCode: "rule", hAlign: "left", dataType: "String",getText:'forRule'},
+        header: [
+            {headerName: "按统一设置", headerWidth: 80, dataCode: "unifiedSetting", dataType: "String",cellType: "checkBox"},
+            {headerName: "费用项", headerWidth: 160, dataCode: "itemName", dataType: "String"},
+            {headerName: "费用规则", headerWidth: 300, dataCode: "rule", hAlign: "left", dataType: "String"/*,getText:'forRule'*/},
             {headerName: "编码", headerWidth: 70, dataCode: "code", hAlign: "left", dataType: "String"},
             {headerName: "编码", headerWidth: 70, dataCode: "code", hAlign: "left", dataType: "String"},
-            {headerName: "基数", headerWidth: 80, dataCode: "base", hAlign: "left", dataType: "String",cellType:'comboBox',options:installSectionBase},
+            {headerName: "基数", headerWidth: 150, dataCode: "base", hAlign: "left", dataType: "String",cellType:'comboBox',options:installSectionBase},
             {headerName: "费率(%)", headerWidth: 80, dataCode: "feeRate", hAlign: "right", dataType: "String"},
             {headerName: "费率(%)", headerWidth: 80, dataCode: "feeRate", hAlign: "right", dataType: "String"},
             {headerName: "其中人工(%)", headerWidth: 100, dataCode: "labour", hAlign: "right", dataType: "String"},
             {headerName: "其中人工(%)", headerWidth: 100, dataCode: "labour", hAlign: "right", dataType: "String"},
             {headerName: "其中材料(%)", headerWidth: 100, dataCode: "material", hAlign: "right", dataType: "String"},
             {headerName: "其中材料(%)", headerWidth: 100, dataCode: "material", hAlign: "right", dataType: "String"},
             {headerName: "其中机械(%)", headerWidth: 100, dataCode: "machine", hAlign: "right", dataType: "String"},
             {headerName: "其中机械(%)", headerWidth: 100, dataCode: "machine", hAlign: "right", dataType: "String"},
+            {headerName: "费用类型", headerWidth: 100, dataCode: "feeType", hAlign: "center", dataType: "String",cellType:'comboBox',options:installFeeType},
             {headerName: "记取位置", headerWidth: 100, dataCode: "position", hAlign: "left", dataType: "String",cellType:'selectButton'}
             {headerName: "记取位置", headerWidth: 100, dataCode: "position", hAlign: "left", dataType: "String",cellType:'selectButton'}
         ],
         ],
         view: {
         view: {
             lockColumns: [0, 2]
             lockColumns: [0, 2]
-        }*/
+        }
     },
     },
     feeItemSpread:null,
     feeItemSpread:null,
     feeItemSheet:null,
     feeItemSheet:null,
@@ -209,8 +211,6 @@ let installationFeeObj={
        this.feeDetailSheet.setRowCount(0);
        this.feeDetailSheet.setRowCount(0);
     },
     },
     onFeeItemSelectionChange:function (e, info) {
     onFeeItemSelectionChange:function (e, info) {
-        console.log('fee item selection change');
-        console.log(info);
         let me = installationFeeObj;
         let me = installationFeeObj;
         let newSelections = info.newSelections;
         let newSelections = info.newSelections;
         let row = newSelections[0].row;
         let row = newSelections[0].row;
@@ -229,7 +229,6 @@ let installationFeeObj={
                 me.showFeeDetailData();
                 me.showFeeDetailData();
             }
             }
         }
         }
-       // me.feeItemSheet.repaint();
     },
     },
     onFeeDetailSelectionChange:function (e,info) {
     onFeeDetailSelectionChange:function (e,info) {
         console.log('detail selection change');
         console.log('detail selection change');
@@ -323,6 +322,16 @@ let installationFeeObj={
         this.moreFeeRuleSheet.setRowCount(this.moreFeeRuleData.length);
         this.moreFeeRuleSheet.setRowCount(this.moreFeeRuleData.length);
         this.moreFeeRuleSheet.clearSelection();
         this.moreFeeRuleSheet.clearSelection();
     },
     },
+    showRationInstallationData:function (node) {
+        var installationList = [];
+        var ration_installation = projectObj.project.ration_installation;
+        var ration = node.data;
+        if (ration_installation.datas && ration_installation.datas.length > 0) {
+            installationList = _.filter(ration_installation.datas, {'projectID': ration.projectID, 'rationID': ration.ID})
+        }
+        this.rationInstallData = installationList;
+        sheetCommonObj.showData(this.rationInstallSheet, this.rationInstallSetting,this.rationInstallData);
+    },
     refreshFeeDetailRow:function (row) {
     refreshFeeDetailRow:function (row) {
         let detail = this.feeDetailData[row];
         let detail = this.feeDetailData[row];
         let section = projectObj.project.installation_fee.getInstallSectionByID(detail.libID,detail.ID);
         let section = projectObj.project.installation_fee.getInstallSectionByID(detail.libID,detail.ID);
@@ -369,7 +378,7 @@ let installationFeeObj={
             feeItemShowArray.push(tem_Lib);
             feeItemShowArray.push(tem_Lib);
             if(d.installFeeItem && d.installFeeItem.length > 0){
             if(d.installFeeItem && d.installFeeItem.length > 0){
                 for(let t_if of d.installFeeItem){
                 for(let t_if of d.installFeeItem){
-                    t_if.installFeeID = d.ID,
+                    t_if.installFeeID = d.ID;
                     t_if.libID = d.libID;
                     t_if.libID = d.libID;
                     t_if.isMixRatio = true;
                     t_if.isMixRatio = true;
                     t_if.displayPosition = this.getDisplayText(t_if);
                     t_if.displayPosition = this.getDisplayText(t_if);
@@ -385,7 +394,6 @@ let installationFeeObj={
             if(node){
             if(node){
                 return node.data.code +" "+node.data.name;
                 return node.data.code +" "+node.data.name;
             }
             }
-
         }
         }
         return  item.position;
         return  item.position;
     },
     },
@@ -406,6 +414,8 @@ let installationFeeObj={
         let feeRules =  projectObj.project.installation_fee.getFeeRuleByFeeItem(feeItem);
         let feeRules =  projectObj.project.installation_fee.getFeeRuleByFeeItem(feeItem);
         return feeRules;
         return feeRules;
     },
     },
+
+
     getDetailRowDataBySection(is,libID){
     getDetailRowDataBySection(is,libID){
         let me = this;
         let me = this;
         let tem_detail = {
         let tem_detail = {
@@ -453,6 +463,11 @@ let installationFeeObj={
         this.moreFeeRuleSheet.selectionUnit(1);//0 cell,1 row,2 col;
         this.moreFeeRuleSheet.selectionUnit(1);//0 cell,1 row,2 col;
         this.moreFeeRuleSheet.name('moreFeeRuleSheet');
         this.moreFeeRuleSheet.name('moreFeeRuleSheet');
     },
     },
+    initRationInstallSheet:function (sheet) {
+        this.rationInstallSheet = sheet;
+        this.initSheet( this.rationInstallSheet,this.rationInstallSetting);
+        this.rationInstallSheet.name("rationInstallSheet");
+    },
     onFeeRuleDoubleClick:function (e,info) {
     onFeeRuleDoubleClick:function (e,info) {
         if(info.row!=undefined||info!=null){
         if(info.row!=undefined||info!=null){
             installationFeeObj.updateFeeRuleToSection(info.row);
             installationFeeObj.updateFeeRuleToSection(info.row);

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

@@ -46,9 +46,9 @@ var projectObj = {
                 projectObj.testDisplay('结果', rst);*/
                 projectObj.testDisplay('结果', rst);*/
 
 
         // 基数
         // 基数
-/*        node.data.isSubcontract = true;
-        node.data.gljList = project.ration_glj.getGljArrByRation(node.data.ID);
-        let bname = '甲定额基价材料费';
+        // node.data.isSubcontract = true;
+        /*node.data.gljList = project.ration_glj.getGljArrByRation(node.data.ID);
+        let bname = '甲定额基价材料费';
         projectObj.testDisplay(bname, rationCalcBases[bname](node));*/
         projectObj.testDisplay(bname, rationCalcBases[bname](node));*/
 
 
     },
     },
@@ -320,7 +320,8 @@ var projectObj = {
         if (node.sourceType === project.Bills.getSourceType()) {
         if (node.sourceType === project.Bills.getSourceType()) {
             this.updateBillsCode(node, value);   // 新清单不适合实时计算,下面套什么还不能确定,无数量计算也无意义
             this.updateBillsCode(node, value);   // 新清单不适合实时计算,下面套什么还不能确定,无数量计算也无意义
         } else if (node.sourceType === project.Ration.getSourceType()) {
         } else if (node.sourceType === project.Ration.getSourceType()) {
-            this.updateRationCode(node, value);  // 新套定额适合实时计算
+            project.Ration.updateRationCodes([{'node':node,value:value}]);
+          //  this.updateRationCode(node, value);  // 新套定额适合实时计算
             // 这里因异步问题暂时缺少工料机价格。该过程移到:ration_glj.js的refreshAfterSave方法中。
             // 这里因异步问题暂时缺少工料机价格。该过程移到:ration_glj.js的refreshAfterSave方法中。
             /*project.calcProgram.calcAndSave(node);
             /*project.calcProgram.calcAndSave(node);
             if (activeSubSheetIs(subSheetIndex.ssiCalcProgram)) {
             if (activeSubSheetIs(subSheetIndex.ssiCalcProgram)) {

+ 18 - 0
web/building_saas/main/js/views/sub_view.js

@@ -31,6 +31,9 @@ SheetDataHelper.protectdSheet(subSpread.getSheet(1));
 gljOprObj.initDetailSheet(subSpread.getSheet(3));
 gljOprObj.initDetailSheet(subSpread.getSheet(3));
 SheetDataHelper.protectdSheet(subSpread.getSheet(3));
 SheetDataHelper.protectdSheet(subSpread.getSheet(3));
 
 
+//安装增加费
+installationFeeObj.initRationInstallSheet(subSpread.getSheet(5));
+SheetDataHelper.protectdSheet(subSpread.getSheet(5));
 
 
 $("#linkGLJ").click(function(){
 $("#linkGLJ").click(function(){
     $("#subItems").children().hide();//控制显示subSpread,隐藏特征及内容spread
     $("#subItems").children().hide();//控制显示subSpread,隐藏特征及内容spread
@@ -68,6 +71,21 @@ $("#linkFZTJ").click(function(){
     //subSpread.getActiveSheet().setValue(0, 0, "附注条件");
     //subSpread.getActiveSheet().setValue(0, 0, "附注条件");
 });
 });
 
 
+
+
+$("#linkAZZJF").click(function(){
+    $("#subItems").children().hide();
+    $("#subSpread").show();
+    pageCCOprObj.active = false;
+    refreshSubSpread();
+    subSpread.setActiveSheetIndex(5);
+    $.contextMenu( 'destroy', "#subSpread" );
+    //gljContextMenu.loadQuantityDetailMenu();
+    gljOprObj.activeTab='#linkAZZJF';
+    // for test
+    //subSpread.getActiveSheet().setValue(0, 0, "安装增加费");
+});
+
 $("#linkGCLMX").click(function(){
 $("#linkGCLMX").click(function(){
     $("#subItems").children().hide();
     $("#subItems").children().hide();
     $("#subSpread").show();
     $("#subSpread").show();