Pārlūkot izejas kodu

Merge branch 'master' into olym

olym 7 gadi atpakaļ
vecāks
revīzija
45795b697f

+ 1 - 2
web/building_saas/main/js/controllers/project_controller.js

@@ -68,8 +68,7 @@ ProjectController = {
 
                 newNode = project.mainTree.insert(selected.getID(), selected.tree.rootID());
             }
-        }
-        else if (selected.sourceType === project.Ration.getSourceType()) {
+        } else if (selected.sourceType === project.Ration.getSourceType()) {
             if (std) {
                 newSource = project.Ration.insertStdRation(selected.source[project.masterField.ration], selected.source, std);
                 project.ration_glj.addRationGLJ(newSource,std);

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

@@ -407,6 +407,7 @@ class CalcProgram {
 
     loadData (datas) {
         this.datas = datas;
+        this.compileAllTemps();
     };
 
     doAfterUpdate (err, data) {

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

@@ -108,6 +108,13 @@ const volumePriceMaps = {
     5: "量设"
 };
 
+const gljTypeMap = {
+   201:'材',
+   4:'主',
+   5:'设'
+}
+
+
 const rationType = {
     ration: 1,
     volumePrice: 2,

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

@@ -48,6 +48,7 @@ var PROJECT = {
                     me.modules[module].setMaxID(counter[module]);
                 }
             }
+
             me._project.loadMainTree();
             //me.test(result[0].data[0]);
             callback(0);
@@ -123,6 +124,17 @@ var PROJECT = {
 
         project.prototype.loadMainTree = function () {
             var that = this;
+            let loadRationGLJNode = function (cacheNode) {
+                var newNode, bj = that.ration_glj.getMainAndEquGLJ(cacheNode.source.ID), i;
+                for(i=0;i<bj.length;i++){
+                    that.ration_glj.transferToNodeData(bj[i]);
+                    newNode = that.mainTree.addNode(cacheNode);
+                    newNode.source = bj[i];
+                    newNode.sourceType = that.ration_glj.getSourceType();
+                    newNode.data = bj[i];
+                }
+            };
+
             var loadRationNode = function (rations, cacheNode) {
                 var newNode, br = that.Ration.getBillsSortRation(cacheNode.source.getID()), i;
                 for (i = 0; i < br.length; i++) {
@@ -130,6 +142,9 @@ var PROJECT = {
                     newNode.source = br[i];
                     newNode.sourceType = that.Ration.getSourceType();
                     newNode.data = br[i];
+                    if(projectInfoObj.projectInfo.property.displaySetting.disPlayMainMateria==true){
+                        loadRationGLJNode(newNode);
+                    }
                 }
             };
 /*            let loadVolumePriceNode = function (cacheNode) {
@@ -141,6 +156,7 @@ var PROJECT = {
                     newNode.data = v;
                 }
             };*/
+
             var loadIdTreeNode = function (nodes, parent) {
                 var newNode, i;
                 for (i = 0; i < nodes.length; i++) {

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

@@ -235,6 +235,7 @@ ProjectGLJ.prototype.getAdjustPrice = function (glj) {
     GLJTypeConst = this.datas.constData.GLJTypeConst !== undefined ? JSON.parse(this.datas.constData.GLJTypeConst) : GLJTypeConst;
     if(glj.unit_price.type==GLJTypeConst.LABOUR||glj.unit_price.type==GLJTypeConst.MACHINE_LABOUR){
         let labour = projectObj.project.calcProgram.compiledLabourCoes[glj.adjCoe];
+        //let labour=1;
         let coe = labour&&labour.coe?labour.coe:1;
         let decimal = getDecimal("glj.unitPrice");
         return scMathUtil.roundTo(parseFloat(coe*glj.unit_price.base_price),-decimal);

+ 10 - 6
web/building_saas/main/js/models/quantity_detail.js

@@ -41,7 +41,6 @@ var quantity_detail = {
             }
         };
         quantity_detail.prototype.refreshAfterSave=function(data){
-            console.log(data);
             var me = this;
             if(data.hasOwnProperty('resort')){
                 this.resortData(data.doc,1);
@@ -108,10 +107,10 @@ var quantity_detail = {
         quantity_detail.prototype.refreshSheetData=function () {
             gljOprObj.showQuantityDetailData();
         };
-        quantity_detail.prototype.saveQuantityDetail=function (args,dataCode) {
+        quantity_detail.prototype.saveQuantityDetail=function (args,dataCode,selected) {
             var me = this;
             var doc={};
-            var selected = projectObj.project.mainTree.selected;
+            var selected = selected?selected:projectObj.project.mainTree.selected;
             if(selected.sourceType==ModuleNames.ration){
                 doc.rationID=selected.data.ID;
             }
@@ -123,6 +122,7 @@ var quantity_detail = {
             doc.seq=args.row;
             if(dataCode=='regex'){
                 if(!this.regexChecking(args.editingText)||!this.referenceChecking(args.editingText,args.row,doc)){
+                    gljOprObj.showQuantityDetailData();
                     return;
                 }
                 doc.refreshQuantity=true;
@@ -147,6 +147,8 @@ var quantity_detail = {
                 }else {
                     data.newRecord?me.refreshAfterSave(data.newRecord):me.refreshAfterSave(data);
                     data.node?gljOprObj.refreshTreeNode(data.node):"";
+                    //gljOprObj.detailSheet.setActiveCell(0,0);
+                    //gljOprObj.detailSheet.clearSelection();
                 }
                 $.bootstrapLoading.end();
             }
@@ -238,13 +240,13 @@ var quantity_detail = {
             let regExp = new RegExp(FindText, "g");
             return str.replace(regExp, RepText);
         };
-        quantity_detail.prototype.updateQuantityDetail=function (args,dataCode,recode) {
+        quantity_detail.prototype.updateQuantityDetail=function (args,dataCode,recode,selected) {
             var doc ={};
             var query={
                 ID:recode.ID,
                 projectID:recode.projectID
             };
-            var selected = projectObj.project.mainTree.selected;
+            var selected = selected?selected:projectObj.project.mainTree.selected;
             doc[dataCode]=args.editingText;
             if (dataCode == 'regex') {
                 if(recode.hasOwnProperty('rationID')){
@@ -256,7 +258,9 @@ var quantity_detail = {
                 if(!selected.data.hasOwnProperty('isFromDetail')||selected.data.isFromDetail==0){
                     var c = confirm("确定要使用工程量明细替换原工程量吗?");
                     if(!c){
-                        query.refreshQuantity=false;
+                        //query.refreshQuantity=false;
+                        this.cleanQuantityDetail(selected,true);
+                        return;
                     }
                 }
                 query.index = args.row;

+ 49 - 7
web/building_saas/main/js/models/ration_glj.js

@@ -112,6 +112,8 @@ var ration_glj = {
                 projectObj.project.ration_glj.datas = neRecodes;
             }
             gljOprObj.showRationGLJSheetData(true);
+            //add to mainTree;
+
             let node = project.mainTree.selected;
             project.calcProgram.calculate(node);
             project.calcProgram.saveNode(node);
@@ -278,14 +280,14 @@ var ration_glj = {
             updateData.push(newobj);
             return updateData;
         };
-        ration_glj.prototype.updateRationGLJByEdit=function (recode,updateField,newval) {
+        ration_glj.prototype.updateRationGLJByEdit=function (recode,updateField,newval,node) {
             var me=this;
             $.bootstrapLoading.start();
             var callback=function (data) {
                 let initShow = false;//是否需要表格初始化显示
                 if(updateField=='customQuantity'){
                     console.log(data);
-                    me.refreshAfterQuantityUpdate(data);
+                    me.refreshAfterQuantityUpdate(data,node);
                 }else {
                     var doc = data.doc;
                     for(var key in doc){
@@ -293,7 +295,7 @@ var ration_glj = {
                     }
                     console.log(data);
                     if(data.hasOwnProperty('adjustState')){//更新定额调整状态
-                        me.updateRationAdjustState(data.adjustState,recode.rationID);
+                        me.updateRationAdjustState(data.adjustState,recode.rationID,node);
                     }
                     if(recode.subList&&recode.subList.length>0){
                         initShow = true;
@@ -320,25 +322,33 @@ var ration_glj = {
             }
             var doc = {};
             doc[updateField]=newval;
+            if(updateField=="type"){
+                doc.shortName = gljTypeMap[newval];
+            }
             CommonAjax.post("/rationGlj/updateRationGLJByEdit",{query:query,doc:doc,priceInfo:priceInfo},callback,function (err) {
                 $.bootstrapLoading.end();
             });
         }
-        ration_glj.prototype.refreshAfterQuantityUpdate=function (data) {
+        ration_glj.prototype.refreshAfterQuantityUpdate=function (data,node) {
             var me=this;
             data.glj_result.forEach(function (item) {
                 me.refreshEachItme(item.doc,item.query);
             })
-            me.updateRationAdjustState(data.adjustState,data.rationID);
+            me.updateRationAdjustState(data.adjustState,data.rationID,node);
         };
-        ration_glj.prototype.updateRationAdjustState=function(adjustState,rationID){
+        ration_glj.prototype.updateRationAdjustState=function(adjustState,rationID,rnode){
+            var nodes=[];
             var node = _.find(projectObj.project.mainTree.items,function (n) {
                 return n.sourceType==ModuleNames.ration&&n.data.ID==rationID;
             })
             if(node){
                 node.data.adjustState=adjustState;
+                nodes.push(node)
             }
-            projectObj.mainController.refreshTreeNode([node]);
+            if(rnode){
+                nodes.push(rnode);
+            }
+            projectObj.mainController.refreshTreeNode(nodes);
         };
         ration_glj.prototype.getGLJData = function(cb){
             CommonAjax.get('/rationGlj/getGLJData', function (data) {
@@ -465,6 +475,38 @@ var ration_glj = {
                 $.bootstrapLoading.end();
             });
         };
+
+        ration_glj.prototype.getMainAndEquGLJ = function (rationID) {
+           var gljList = _.filter(this.datas,function (n) {
+              return n.rationID == rationID&&(n.type==gljType.MAIN_MATERIAL||n.type==gljType.EQUIPMENT)
+           });
+           return gljOprObj.combineWithProjectGlj(gljList);
+        };
+        ration_glj.prototype.transferToNodeData = function (data) {
+            data.subType = data.type;
+            data.marketUnitFee = data.marketPrice;
+        };
+        ration_glj.prototype.updateFromMainSpread=function (value,node,fieldName) {
+            console.log(fieldName);
+            console.log(value);
+            if(node.data[fieldName]===value){
+                return;
+            }
+            if(fieldName=="marketUnitFee"){
+
+            }else {
+                if(value!==undefined&&value!==null){
+                    if(fieldName=="subType"){
+                        node.data.subType = value;
+                        fieldName = "type";//转换成更新工料机类型
+                    }
+                    this.updateRationGLJByEdit(node.data,fieldName,value,node);
+                    return;
+                }
+            }
+           // node.data.subType = value;
+            projectObj.mainController.refreshTreeNode([node]);
+        };
         return new ration_glj(project);
     }
 };

+ 22 - 14
web/building_saas/main/js/views/glj_view.js

@@ -54,8 +54,8 @@ var gljOprObj = {
     assSetting:{
         header:[
             {headerName: "调整名称", headerWidth: 100, dataCode: "name", dataType: "String"},
-            {headerName: "定额值", headerWidth: 120, dataCode: "stdValue", dataType: "String"},
-            {headerName: "实际值", headerWidth: 120, dataCode: "actualValue", dataType: "String"}
+            {headerName: "定额值", headerWidth: 120, dataCode: "stdValue", hAlign: "right", dataType: "String"},
+            {headerName: "实际值", headerWidth: 120, dataCode: "actualValue", hAlign: "right", dataType: "String"}
         ],
         view:{
             lockColumns:[0,1]
@@ -170,8 +170,10 @@ var gljOprObj = {
         var me = this;
         me.detailSheet = sheet;
         sheetCommonObj.initSheet(me.detailSheet, me.detailSetting, 30);
+       // me.detailSheet.selectionUnit(0);//0 cell,1 row,2 col;
         sheet.name('quantity_detail');
         me.bindSheetEvent(sheet);
+
     },
     showCoeData:function(sheet,setting,datas){
         sheet.floatingObjects.remove("customerCoe");
@@ -229,12 +231,18 @@ var gljOprObj = {
         if(args.row==me.detailData.length&&args.editingText==null){
             return;
         }
-       if(args.row==me.detailData.length){
-           projectObj.project.quantity_detail.saveQuantityDetail(args,me.detailSetting.header[args.col].dataCode);
-       }
-        if(args.row<me.detailData.length){
-            projectObj.project.quantity_detail.updateQuantityDetail(args,me.detailSetting.header[args.col].dataCode,me.detailData[args.row]);
-        }
+        var selected = projectObj.project.mainTree.selected;//因为使用了延时方法,所以要先取得选中行;
+        var detailList = me.detailData;
+        args.editingText = args.editingText.replace(/(/g,"(");//替换中文左右括号;
+        args.editingText = args.editingText.replace(/)/g,")");
+        setTimeout(function () {//这里须用延时执行的办法,不然的弹窗确认窗口会和spreadjs 的事件有冲突,造成定额工料机数据不会根据树结点更新的问题
+            if(args.row==detailList.length){
+                projectObj.project.quantity_detail.saveQuantityDetail(args,me.detailSetting.header[args.col].dataCode,selected);
+            }
+            if(args.row<detailList.length){
+                projectObj.project.quantity_detail.updateQuantityDetail(args,me.detailSetting.header[args.col].dataCode,detailList[args.row],selected);
+            }
+        },100);
 
     },
     onEditGLJSheet:function(args){
@@ -348,7 +356,7 @@ var gljOprObj = {
         $('#manual').val(data.coes[1].amount);
         $('#material').val(data.coes[2].amount);
         $('#manchine').val(data.coes[3].amount);
-        $('#main').val(data.coes[4].amount);
+        $('#mainM').val(data.coes[4].amount);
         $('#equipment').val(data.coes[5].amount);
     },
     onInputChange(id,name){
@@ -364,7 +372,7 @@ var gljOprObj = {
                 $('#manual').val(newValue);
                 $('#material').val(newValue);
                 $('#manchine').val(newValue);
-                $('#main').val(newValue);
+                $('#mainM').val(newValue);
                 $('#equipment').val(newValue);
             }else {
                 $('#'+id).val(newValue);
@@ -384,7 +392,7 @@ var gljOprObj = {
         var manual=$('#manual').val();
         var material = $('#material').val();
         var manchine= $('#manchine').val();
-        var main = $('#main').val();
+        var mainM = $('#mainM').val();
         var equipment=$('#equipment').val();
         if(coe_ration!=data.coes[0].amount){
             result.isNeed =true;
@@ -402,9 +410,9 @@ var gljOprObj = {
             result.isNeed =true;
             data.coes[3].amount =manchine;
         }
-        if(main!=data.coes[4].amount){
+        if(mainM!=data.coes[4].amount){
             result.isNeed =true;
-            data.coes[4].amount =main;
+            data.coes[4].amount =mainM;
         }
         if(equipment!=data.coes[5].amount){
             result.isNeed =true;
@@ -495,7 +503,7 @@ var gljOprObj = {
         newString += this.getOneRow('人工',1,'manual');
         newString += this.getOneRow('材料',2,'material');
         newString += this.getOneRow('机械',3,'manchine');
-        newString += this.getOneRow('主材',4,'main');
+        newString += this.getOneRow('主材',4,'mainM');
         newString += this.getOneRow('设备',5,'equipment');
         newString +="</table></form>";
 

+ 10 - 4
web/building_saas/main/js/views/main_tree_col.js

@@ -18,7 +18,7 @@ let MainTreeCol = {
                     return '工料机';     // 这里明细值等张伟城确定
                 }
             } else if (node.sourceType === projectObj.project.ration_glj.getSourceType()) {
-                return '主';
+                return gljTypeMap[node.data.subType];
             }
         },
 
@@ -32,7 +32,7 @@ let MainTreeCol = {
     readOnly: {
         // CSL, 2017-11-28
         subType: function (node){
-            return (node.data.type != 2 && node.data.type != 3);
+            return (node.data.type != 2 && node.data.type != 3&&!MainTreeCol.readOnly.glj(node));
         },
         calcProgramName: function (node) {
             if (
@@ -77,6 +77,9 @@ let MainTreeCol = {
         ration: function (node) {
             return node.sourceType === projectObj.project.Ration.getSourceType();
         },
+        glj: function (node) {
+            return node.sourceType == projectObj.project.ration_glj.getSourceType();
+        },
         volumePrice: function (node) {
             return (node.data.type == rationType.volumePrice || node.data.type == rationType.gljRation);
         },
@@ -110,6 +113,9 @@ let MainTreeCol = {
         },
         forFeeRate:function (node) {
             return MainTreeCol.readOnly.non_bills(node)||MainTreeCol.readOnly.billsParent(node)||MainTreeCol.readOnly.leafBillsWithDetail(node)
+        },
+        forQuantity:function (node) {
+            return MainTreeCol.readOnly.glj(node)||MainTreeCol.readOnly.billsParent(node)
         }
     },
     cellType: {
@@ -146,12 +152,12 @@ let MainTreeCol = {
 
         // CSL, 2017-11-28
         subType: function (node) {
-            if (node.data.type == rationType.volumePrice || node.data.type == rationType.gljRation){
+            if (node.data.type == rationType.volumePrice || node.data.type == rationType.gljRation||node.sourceType === projectObj.project.ration_glj.getSourceType()){
                 let VPType = new GC.Spread.Sheets.CellTypes.ComboBox();
 
                 if (node.data.type == rationType.volumePrice)
                     VPType.items(["人工","材料","机械","主材","设备"])
-                else if (node.data.type == rationType.gljRation)
+                else if (node.data.type == rationType.gljRation||node.sourceType === projectObj.project.ration_glj.getSourceType())
                     VPType.items(["材料","主材","设备"]);
 
                 return VPType;

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

@@ -19,7 +19,7 @@ let decimalObj = Object.create(null);
 
 decimalObj.decimal = function (field, node) {
     if(isDef(field)){
-        if(field === 'feeRate'){
+        if(field === 'feeRate'||field==="quantity_detail"){
             return this[field];
         }
         else if (field.sameText('unitFee')) field = 'unitPrice'

+ 16 - 5
web/building_saas/main/js/views/project_property_display_view.js

@@ -2,21 +2,32 @@
  * Created by Zhong on 2017/11/24.
  */
 let projDisplayView = {
-
-    datas: {},//just for view
-
+    datas: null,//just for view
     init:function () {
         this.datas = projectInfoObj.projectInfo.property.displaySetting;
         this.datas = this.datas === undefined ? { autoHeight: true, disPlayMainMaterial: true } : this.datas;
         $("#autoHeight").attr("checked",this.datas.autoHeight);
         $("#disPlayMainMaterial").attr("checked",this.datas.disPlayMainMaterial);
         //$('#disPlayMainMateria').prop('checked')
-    },
+ },
 
     needUpdate: function(autoHeight, disPlayMainMaterial) {
         return autoHeight !== this.datas.autoHeight || disPlayMainMaterial !== this.datas.disPlayMainMaterial;
-    }
+    },
 
+    updateChecking:function (projectID,properties) {
+        if(this.datas==null){
+            return;
+        }
+        var autoHeight = $('#autoHeight').prop('checked');
+        var disPlayMainMateria = $('#disPlayMainMateria').prop('checked');
+        if(this.datas.autoHeight!==autoHeight||this.datas.disPlayMainMateria!==disPlayMainMateria){
+            this.datas.autoHeight=autoHeight;
+            this.datas.disPlayMainMateria=disPlayMainMateria;
+        }
+        let updateData = {updateType: 'update', updateData: {ID: projectID, 'property.displaySetting':this.datas}};
+        properties.push(updateData);
+    }
 };
 
 $(document).ready(function () {

+ 7 - 14
web/building_saas/main/js/views/project_view.js

@@ -266,7 +266,9 @@ var projectObj = {
     },
     updateCellValue: function (node, value, colSetting) {
         let project = projectObj.project, fieldName = colSetting.data.field;
-        if (value !== calcFees.getFee(node.data, fieldName)) {
+        if(node.sourceType==project.ration_glj.getSourceType()){
+            project.ration_glj.updateFromMainSpread(value,node,fieldName);
+        }else if (value !== calcFees.getFee(node.data, fieldName)) {
             if (fieldName === 'code') {
                 projectObj.updateCode(node, value);
             }
@@ -301,7 +303,6 @@ var projectObj = {
                             projectObj.mainSpread.getActiveSheet().setValue(activeCell.row, activeCell.col, node.data.calcBase? node.data.calcBase: '');
                         }
                     }
-                    $.bootstrapLoading.end();
                     return;
                    // if (value) {value = parseFloat(value).toDecimal(decimalObj.decimal("totalPrice", node))};
                 };
@@ -333,10 +334,8 @@ var projectObj = {
         } else {
             projectObj.mainController.refreshTreeNode([node], false);
         }
-        $.bootstrapLoading.end();
     },
     mainSpreadEditEnded: function (sender, info) {
-        $.bootstrapLoading.start();
         let project = projectObj.project;
         let node = project.mainTree.items[info.row];
         let colSetting = projectObj.mainController.setting.cols[info.col];
@@ -376,7 +375,7 @@ var projectObj = {
 
             if (!err) {
                 that.project.property = projectInfoObj.projectInfo.property;
-                that.project.calcProgram.compileAllTemps();
+                //that.project.calcProgram.compileAllTemps();
                 that.project.calcBase.init(that.project);
                 that.project.calcFields = JSON.parse(JSON.stringify(feeType));
                 // that.project.initCalcFields();
@@ -676,9 +675,6 @@ $('#property_ok').click(function () {
     let properties = [], projectID = parseInt(scUrlUtil.GetQueryString('project'));
     let project = projectObj.project, reCalc= false;
     let b = parseInt($("input[name='calcFlag']:checked").val());
-    // 呈现选项
-    const autoHeight = $("#autoHeight:checked").length > 0;
-    const disPlayMainMaterial = $("#disPlayMainMaterial:checked").length > 0;
     if (b !== project.property.billsCalcMode) {
         let data1 = {updateType: 'update', updateData: {ID: projectID, 'property.billsCalcMode': b}};
         properties.push(data1);
@@ -725,12 +721,9 @@ $('#property_ok').click(function () {
         let updateData = {updateType: 'update', updateData: {ID: projectID, 'property.decimal': updateDecimal}};
         properties.push(updateData);
     }
-    // 呈现选项
-    if (projDisplayView.needUpdate(autoHeight, disPlayMainMaterial)) {
-        const displaySetting = { autoHeight, disPlayMainMaterial };
-        let updateData = {updateType: 'update', updateData: {ID: projectID, 'property.displaySetting': displaySetting}};
-        properties.push(updateData);
-    }
+ // 呈现选项
+    projDisplayView.updateChecking(projectID,properties);
+
     console.log(properties);
     if(properties.length > 0){
         CommonAjax.post('/pm/api/updateProjects', {user_id: userID, updateData: properties}, function (rstData) {