Selaa lähdekoodia

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

Conflicts:
	web/building_saas/main/js/views/project_glj_view.js
zhangweicheng 7 vuotta sitten
vanhempi
commit
6209c68914

+ 2 - 0
modules/all_models/project_glj.js

@@ -89,6 +89,8 @@ let modelSchema = {
     mix_ratio_id: Number,
     // 显示关联父级工料机code(组合物用)
     connect_code: String,
+    materialType: Number,   //三材类别
+    materialCoe: Number,    //三材系数
     ratio_data: Schema.Types.Mixed
 };
 mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false}));

+ 1 - 1
modules/glj/controllers/glj_controller.js

@@ -82,7 +82,7 @@ class GLJController extends BaseController {
         try {
             // 可编辑的字段
             let editableField = ['is_evaluate', 'unit_price.market_price', 'is_adjust_price', 'mix_ratio.consumption',
-                'supply', 'supply_quantity'];
+                'supply', 'supply_quantity','delivery_address','delivery','materialType','materialCoe'];
             if (editableField.indexOf(field) < 0) {
                 throw '对应字段不能编辑';
             }

+ 3 - 1
modules/glj/models/glj_list_model.js

@@ -596,7 +596,9 @@ class GLJListModel extends BaseModel {
                 unit: tmp.unit === undefined ? '' : tmp.unit,
                 type: tmp.gljType,
                 adjCoe:tmp.adjCoe,
-                original_code:tmp.code
+                original_code:tmp.code,
+                materialType: tmp.materialType,   //三材类别
+                materialCoe: tmp.materialCoe
             };
             gljInsertData.push(gljData);
 

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

@@ -269,6 +269,8 @@ async function addRationGLJ(std,newRation) {
                 newGLJ.type = std_glj.gljType;
                 newGLJ.repositoryId = std_glj.repositoryId;
                 newGLJ.adjCoe = std_glj.adjCoe;
+                newGLJ.materialType = std_glj.materialType;
+                newGLJ.materialCoe = std_glj.materialCoe;
                 let info = await  ration_glj_facade.getInfoFromProjectGLJ(newGLJ,unitPriceFileId);
                 newGLJ = ration_glj_facade.createNewRecord(info);
                 newRationGLJList.push(newGLJ);

+ 1 - 0
modules/pm/models/project_property_template.js

@@ -9,6 +9,7 @@ const defaultDecimal = {
     glj: {quantity: 3, unitPrice: 2},
     feeRate: 2,
     quantity_detail: 4,
+    material:5,//三材系数
     process: 6
 };
 const displaySetting = {

+ 2 - 0
modules/ration_glj/facade/ration_glj_facade.js

@@ -578,6 +578,8 @@ function getGLJSearchInfo(ration_glj) {
         market_price: ration_glj.basePrice,
         repositoryId: ration_glj.repositoryId,
         adjCoe: ration_glj.adjCoe,
+        materialType:ration_glj.materialType,
+        materialCoe:ration_glj.materialCoe,
         from: ration_glj.from ? ration_glj.from : 'std'//std:标准工料机库, cpt:补充工料机库
     };
     let glj_type_object = glj_type_util.getStdGljTypeCacheObj();

+ 8 - 0
web/building_saas/main/js/models/calc_program.js

@@ -579,6 +579,14 @@ let calcTools = {
         for (let rID of rationIDs){
             rationNodes.push(nodes['id_' + rID]);
         };
+
+        // 工料机形式的定额
+        let items = projectObj.project.mainTree.items;
+        for (let item of items){
+            if (item.data.projectGLJID == PGLJID)
+                rationNodes.push(item);
+        };
+
         return rationNodes;
     },
     getNodesByProgramID(programID){

+ 5 - 3
web/building_saas/main/js/models/composition.js

@@ -112,7 +112,8 @@ Composition.prototype.updateConsumptionInCache = function (pid,recode,updateData
         //乘以父工料机的消耗量得到该组成物总消耗量的改变量
         changValue = operationWithRound(parentGlj.quantity,changValue,"glj.quantity","*");
         let oldQuantity =  scMathUtil.roundForObj(mglj.quantity,decimal);
-        mglj.quantity = scMathUtil.roundToString(oldQuantity+changValue,decimal);
+        mglj.quantity = scMathUtil.roundForObj(oldQuantity+changValue,decimal);
+        projectObj.project.projectGLJ.quantityChangeMap[mglj.id] = mglj.quantity;
         let p_key = gljOprObj.getIndex(parentGlj,gljKeyArray);
         let m_list = projectObj.project.projectGLJ.datas.mixRatioMap[p_key];
         if(operation == 'delete'){//如果是删除
@@ -132,6 +133,7 @@ Composition.prototype.updateConsumptionInCache = function (pid,recode,updateData
         // 设置父级3个价格
         parentGlj.unit_price.market_price =  updateData.market_price;
         parentGlj.unit_price.base_price =  updateData.base_price;
+        return mglj.id;
     }
 }
 
@@ -142,9 +144,9 @@ Composition.prototype.updateConsumption = function (updateData,recode,pid,callba
     $.bootstrapLoading.start();
     CommonAjax.specialPost( '/glj/update',updateData,function (result) {
         //更新缓存
-        me.updateConsumptionInCache(pid,recode,updateData);
+       let sid = me.updateConsumptionInCache(pid,recode,updateData);
         if(callback){
-            callback();
+            callback(sid);
         }
         $.bootstrapLoading.end();
     })

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

@@ -209,6 +209,13 @@ const materialType = {
     4: '水泥',
     5: '标准砖'
 };
+const materialTypeMap = {
+    GC: 1,
+    GJ: 2,
+    MC: 3,
+    SN: 4,
+    SZ: 5
+}
 
 //清单固定行
 const fixedFlag = {
@@ -340,4 +347,11 @@ const blockType ={
 const installFeeType = ['子目费用','分项费用','措施费用'];
 const installSectionBase = ['分别按人材机乘系数','人工','材料','机械'];
 const supplyComboMap = [{text:"自行采购",value:0},{text:"完全甲供",value:2},{text:"部分甲供",value:1},{text:"甲定乙供",value:3}];//后来调整了下拉选项的顺序,为了不改之前的业务逻辑,这里的值对换了一下
+const materialComboMap = [
+    {text:materialType[materialTypeMap.GC],value:materialTypeMap.GC},
+    {text:materialType[materialTypeMap.GJ],value:materialTypeMap.GJ},
+    {text:materialType[materialTypeMap.MC],value:materialTypeMap.MC},
+    {text:materialType[materialTypeMap.SN],value:materialTypeMap.SN},
+    {text:materialType[materialTypeMap.SZ],value:materialTypeMap.SZ}
+];
 

+ 26 - 4
web/building_saas/main/js/models/project_glj.js

@@ -8,6 +8,7 @@
 function ProjectGLJ() {
     this.datas = null;
     this.isLoading = false;
+    this.quantityChangeMap=null;
 }
 
 /**
@@ -690,15 +691,16 @@ ProjectGLJ.prototype.getShortNameByID = function (ID) {
     return gljTypeMap["typeId" + ID].shortName;
 };
 
-ProjectGLJ.prototype.calcQuantity  = function (){
+ProjectGLJ.prototype.calcQuantity  = function (init=false){
     let project_gljs = this.datas.gljList;
     let mixRatioConnectData = this.datas.mixRatioConnectData;
     let mixRatioMap = this.datas.mixRatioMap;
     let rations = projectObj.project.Ration.datas;
     let rationMap = _.indexBy(rations,'ID');
-    let quantityMap={};
+    let quantityMap={},changeArray=[];
     let rationGljGroup = _.groupBy(projectObj.project.ration_glj.datas,'projectGLJID')
     let q_decimal = getDecimal("glj.quantity");
+    console.log(init);
     for(let pglj of project_gljs ){
         let pg_index = gljOprObj.getIndex(pglj,gljKeyArray);
         pglj.subdivisionQuantity = 0;
@@ -709,7 +711,6 @@ ProjectGLJ.prototype.calcQuantity  = function (){
         pglj.subdivisionQuantity = result.subdivisionQuantity;
         pglj.techQuantity = result.techQuantity;
         pglj.quantity = result.quantity;
-
         quantityMap[pg_index] = pglj;
     }
     //计算做为组成物的消耗量
@@ -729,8 +730,29 @@ ProjectGLJ.prototype.calcQuantity  = function (){
             }
         }
     }
+    if(init == true || this.quantityChangeMap == null){//如果是初始化,建立一个映射表
+        this.quantityChangeMap = {};
+        for(let pglj of project_gljs){
+            this.quantityChangeMap[pglj.id] = pglj.quantity;
+        }
+    }else if(this.quantityChangeMap != null){
+        for(let pglj of project_gljs){
+            if(this.quantityChangeMap[pglj.id] != undefined|| this.quantityChangeMap[pglj.id] != null){
+                if(this.quantityChangeMap[pglj.id] !=  pglj.quantity){
+                    changeArray.push(pglj);
+                    this.quantityChangeMap[pglj.id] = pglj.quantity;
+                }
+            }else { //映射表没有,说明是新添加的项目工料机
+                changeArray.push(pglj);
+                this.quantityChangeMap[pglj.id] = pglj.quantity;
+            }
+        }
+    }
+    changeArray.length > 0 && projectGljObject.calcPartASupplyFeeByProjectGLJs ?projectGljObject.calcPartASupplyFeeByProjectGLJs(changeArray):'';
 
-}
+
+
+};
 
 ProjectGLJ.prototype.getQuantityPerGLJ = function (ration_glj_list,rations,rationMap,pglj) {
     let billIDs =   projectObj.project.Bills.getSubdivisionProjectLeavesID();//取分部分项上的所有叶子清单ID

+ 11 - 2
web/building_saas/main/js/models/ration_glj.js

@@ -532,6 +532,8 @@ var ration_glj = {
                         serialNo: serialNo,
                         GLJID: glj.ID,
                         adjCoe: glj.adjCoe,
+                        materialType:glj.materialType,
+                        materialCoe:glj.materialCoe,
                         repositoryId: glj.repositoryId
                     }
                     if (glj.hasOwnProperty("compilationId")) {
@@ -608,6 +610,8 @@ var ration_glj = {
                     type: glj.gljType,
                     adjCoe: glj.adjCoe,
                     createType: 'add',
+                    materialType:ration_glj.materialType,
+                    materialCoe:ration_glj.materialCoe,
                     repositoryId: glj.repositoryId
                 }
                 if (glj.hasOwnProperty("compilationId")) {
@@ -645,6 +649,8 @@ var ration_glj = {
             oldData.specs = glj.specs;
             oldData.basePrice = glj.basePrice;
             oldData.repositoryId = glj.repositoryId;
+            oldData.materialType = glj.materialType;
+            oldData. materialCoe =  glj.materialCoe;
             if (glj.hasOwnProperty("compilationId")) {
                 oldData.from = "cpt";
                 if (glj.code.indexOf('-') != -1) {//这条工料机是用户通过修改包称、规格、型号等保存到补充工料机库的
@@ -690,6 +696,8 @@ var ration_glj = {
                 type: glj.gljType,
                 basePrice: glj.basePrice,
                 repositoryId: glj.repositoryId,
+                materialType: glj.materialType,   //三材类别
+                materialCoe: glj.materialCoe,
                 projectID: oldData.projectID
             }
             if (oldData.createType == 'replace') {
@@ -795,10 +803,11 @@ var ration_glj = {
             return false
         };
         ration_glj.prototype.findGLJNodeByID = function (ID) {
-            let node = _.find(projectObj.project.mainTree.items, function (n) {//找到对应的树节点
+           return projectObj.project.mainTree.findNode(ID);
+          /*  let node = _.find(projectObj.project.mainTree.items, function (n) {//找到对应的树节点
                 return n.sourceType == ModuleNames.ration_glj && n.data.ID == ID;
             });
-            return node;
+            return node;*/
         };
         ration_glj.prototype.findRationNodeByID = function (ID) {
             let node = _.find(projectObj.project.mainTree.items, function (n) {//找到对应定额的树节点

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

@@ -1527,7 +1527,7 @@ var gljOprObj = {
                     if (project.ration_glj.needShowToTree(t)) {//如果是造价书中的树节点,则也须刷新
                         project.ration_glj.transferToNodeData(t);
                         var node = project.ration_glj.findGLJNodeByID(t.ID);
-                        nodes.push(node);
+                        node ? nodes.push(node):'';
                     }
                 }
             })

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

@@ -348,7 +348,7 @@ function getGLJData(actionType) {
         console.log(+new Date());
         $("#glj_tree_div").modal({show:true});
         setTimeout(function(){
-            gljOprObj.gljLibSpresd.refresh();
+            gljOprObj.gljLibSpresd?gljOprObj.gljLibSpresd.refresh():'';
         }, 200);
     })
 }

+ 12 - 2
web/building_saas/main/js/views/project_glj_view.js

@@ -426,9 +426,9 @@ projectGljObject={
             }
             info.sheet.resumeEvent();
             info.sheet.resumePaint();
-            if (dataCode === 'supply' || dataCode === 'supply_quantity'){
+            if (dataCode === 'supply' || dataCode === 'supply_quantity'){    // basePrice、marketPrice 有自己的计算代码,无需走这里重复计算
                 let rations = calcTools.getRationsByProjectGLJ(recode.id);
-                projectObj.project.calcProgram.calcRationsAndSave(rations, function () {
+                projectObj.project.calcProgram.calcNodesAndSave(rations, function () {
                     projectObj.mainController.refreshTreeNode(projectObj.project.mainTree.roots);
                 });
             }
@@ -523,6 +523,16 @@ projectGljObject={
             socket.emit('changeNewRoom',data);
             socketObject.roomInfo.unitFile = socketObject.getUnitFileRoomID();
         }
+    },
+    calcPartASupplyFeeByProjectGLJs: function (projectGLJsArr) {
+        for (let pGLJ of projectGLJsArr){
+              if (pGLJ.supply == supplyType.BFJG){
+                  let rations = calcTools.getRationsByProjectGLJ(pGLJ.id);
+                  projectObj.project.calcProgram.calcNodesAndSave(rations, function () {
+                      projectObj.mainController.refreshTreeNode(projectObj.project.mainTree.roots);
+                  });
+              }
+        };
     }
 };
 

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

@@ -595,7 +595,7 @@ var projectObj = {
             let mTime = +new Date();
             console.log(`get data时间——${mTime - startTime}`);
             if (!err) {
-                that.project.projectGLJ.calcQuantity();//计算分部分项和技术措施项目消耗量;
+                that.project.projectGLJ.calcQuantity(true);//计算分部分项和技术措施项目消耗量;
                 let quantityTime = +new Date();
                 console.log(`计算quantity时间——${quantityTime - mTime}`);
                 that.project.property = projectInfoObj.projectInfo.property;