Browse Source

update project glj view

zhangweicheng 7 years ago
parent
commit
65d4d46e6a
1 changed files with 37 additions and 12 deletions
  1. 37 12
      web/building_saas/main/js/views/project_glj_view.js

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

@@ -19,12 +19,14 @@ projectGljObject={
             {headerName: "是否暂估", headerWidth: 60, dataCode: "is_evaluate", hAlign: "center", dataType: "String",cellType:'checkBox'},
             {headerName: "供货方式", headerWidth: 80, dataCode: "supply", hAlign: "center", dataType: "String",cellType:'comboBox',editorValueType:true,options:supplyComboMap},
             {headerName: "甲供数量", headerWidth: 100, dataCode: "supply_quantity", hAlign: "right", dataType: "Number",validator:"number"},
+            {headerName: "三材类别", headerWidth: 80, dataCode: "materialType", hAlign: "center", dataType: "String",cellType:'comboBox',editorValueType:true,options:materialComboMap},
+            {headerName: "三材系数", headerWidth: 100, dataCode: "materialCoe", hAlign: "right", dataType: "Number",decimalField:'material'},
             {headerName: "交货方式", headerWidth: 90, dataCode: "delivery", hAlign: "left", dataType: "String"},
             {headerName: "送达地点", headerWidth: 100, dataCode: "delivery_address", hAlign: "left", dataType: "String"},
             {headerName: "不调价", headerWidth: 55, dataCode: "is_adjust_price", dataType: "String",cellType: "checkBox"}
         ],
         view: {
-            lockColumns: [0,1,2,3,4,5,7,12,13]
+            lockColumns: [0,1,2,3,4,5,7]
         }
     },
     projectGljSpread:null,
@@ -98,8 +100,9 @@ projectGljObject={
             me.mixRatioSheet.setValue(0, consumptionCol, '消耗量', GC.Spread.Sheets.SheetArea.colHeader);
         }
         let sel = me.projectGljSheet.getSelections()[0];
-        if(me.projectGljSheetData.length>sel.row){
-            gljId = me.projectGljSheetData[sel.row].id;
+        let srow = sel.row == -1?0:sel.row;
+        if(me.projectGljSheetData.length>srow){
+            gljId = me.projectGljSheetData[srow].id;
         }
         projectObj.project.projectGLJ.getRatioData(gljId,function (data) {
             let rationList =[];
@@ -138,10 +141,16 @@ projectGljObject={
             args.cancel = true;
         }
     },
-    projectGljEditChecking:function (row,col) {//return false表示不能编
+    projectGljEditChecking:function (row,col) {//return false表示不能编
         let me = projectGljObject;
         let data = me.projectGljSheetData[row];
         let dataCode = me.projectGljSetting.header[col].dataCode;
+        let lockColumns = me.projectGljSetting.view.lockColumns;
+
+        if(lockColumns.indexOf(col)!= -1){
+            return false;
+        }
+
         if(dataCode=='is_adjust_price'||dataCode=='is_evaluate'){
             return false;
         }
@@ -170,6 +179,14 @@ projectGljObject={
         let me = projectGljObject;
         let changeInfo=[];
         let canChange = true;
+        if(me.projectGljEditChecking(info.row,info.col) == false){
+            canChange = false;
+        }else if (info.action == GC.Spread.Sheets.RangeChangedAction.clear) {
+            info.newValue = null;
+            me.onProjectGLJValueChange(sender,info);
+            return ;
+        }
+
         for(let c of info.changedCells){
             let value=  info.sheet.getCell(c.row, c.col).text();
             changeInfo.push({row:c.row,col:c.col,value:value});
@@ -182,7 +199,6 @@ projectGljObject={
             }
         }
         if(canChange == false){//恢复原来的值
-            console.log('1');
             me.showProjectGljData();
         }else {
              me.batchUpdatePrice(changeInfo);
@@ -200,6 +216,7 @@ projectGljObject={
 
 
     showProjectGljData:function () {
+        let sel = this.projectGljSheet.getSelections()[0];
         let projectGljSheetData = [];
         let gljList = projectObj.project.projectGLJ.datas.gljList;
         gljList = this.filterProjectGLJ(gljList);
@@ -211,6 +228,7 @@ projectGljObject={
         this.projectGljSheet.setRowCount(0);
         sheetCommonObj.showData(this.projectGljSheet, this.projectGljSetting,this.projectGljSheetData);
         this.projectGljSheet.setRowCount(this.projectGljSheetData.length);
+        this.projectGljSheet.setSelection(sel.row,sel.col,sel.rowCount,sel.colCount);
     },
     filterProjectGLJ:function (gljList) {
         let me = projectGljObject;
@@ -245,6 +263,8 @@ projectGljObject={
             quantity:glj.quantity,
             supply:glj.supply,
             supply_quantity:glj.supply_quantity,
+            materialType:glj.materialType,
+            materialCoe:glj.materialCoe,
             delivery:glj.delivery,
             delivery_address:glj.delivery_address,
             is_adjust_price:glj.is_adjust_price,
@@ -312,16 +332,16 @@ projectGljObject={
         let updateData ={id: recode.mix_ratio_id, field: 'mix_ratio.' + dataCode, value: value, market_price: parentMarketPrice, base_price: parentBasePrice};
         let prow= projectGljObject.projectGljSheet.getActiveRowIndex();//取父机械或组成物的下标
         let prowData = projectGljObject.projectGljSheetData[prow];
-        composition.updateConsumption(updateData,recode,prowData.id,function () {
-           me.refreshParentData(prow,prowData.id);
+        composition.updateConsumption(updateData,recode,prowData.id,function (sid) {
+           me.refreshParentData(prow,prowData.id,sid);
         });
     },
-    refreshParentData:function (row,pid) {
+    refreshParentData:function (row,pid,sid) {
         let me = this;
         me.refreshProjectGljRow(row);
         // 更新组成物缓存
         projectObj.project.composition.loadData();
-        //查找使用了父项目工料机的定额工料机
+        //查找使用了父项目工料机的定额工料机
         let updateNodes=[];
         let ration_gljs = _.filter(projectObj.project.ration_glj.datas,{'projectGLJID':pid});
         for(let rg of ration_gljs){
@@ -339,8 +359,14 @@ projectGljObject={
                 updateNodes.push(r_node);
             }
         }
+        if(sid){
+            let subRations = calcTools.getRationsByProjectGLJ(sid);
+            updateNodes = updateNodes.concat(subRations);
+        }
         if(updateNodes.length>0){
-            projectObj.project.calcProgram.calcRationsAndSave(updateNodes);
+            projectObj.project.calcProgram.calcRationsAndSave(updateNodes,function () {
+                projectObj.mainController.refreshTreeNode(projectObj.project.mainTree.roots);
+            });
         }
         gljOprObj.refreshView();
     },
@@ -377,7 +403,7 @@ projectGljObject={
         parentBasePrice = parentBasePrice.toDecimal(getDecimal("glj.unitPrice"));
         return [parentMarketPrice, parentBasePrice];
     },
-    onProjectGLJValueChange:function (e,info) {
+    onProjectGLJValueChange:function (e,info) {//me.projectGljSetting
         let projectGLJ = projectObj.project.projectGLJ;
         let me = projectGljObject,row = info.row, col = info.col;
         let dataCode = me.projectGljSetting.header[col].dataCode;
@@ -400,7 +426,6 @@ projectGljObject={
             }
             info.sheet.resumeEvent();
             info.sheet.resumePaint();
-
             if (dataCode === 'supply' || dataCode === 'supply_quantity'){
                 let rations = calcTools.getRationsByProjectGLJ(recode.id);
                 projectObj.project.calcProgram.calcRationsAndSave(rations, function () {