Browse Source

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

Chenshilong 7 years ago
parent
commit
3895c7ff55

+ 1 - 0
modules/bills_lib/models/bills_lib_schemas.js

@@ -44,6 +44,7 @@ let billsSchema = mongoose.Schema({
         name: String,
         name: String,
         unit: String,
         unit: String,
         ruleText: String,
         ruleText: String,
+        engineering: Number, //工程专业,填计算程序工程专业ID
         Expression: String,
         Expression: String,
         jobs: [],
         jobs: [],
         items: [],
         items: [],

+ 25 - 16
modules/glj/models/glj_list_model.js

@@ -91,14 +91,8 @@ class GLJListModel extends BaseModel {
 
 
             // 整理获取工料机ID list
             // 整理获取工料机ID list
             let gljIdList = [];
             let gljIdList = [];
-            // 整理获取有组成物的项目工料机编码
-            let projectGLJCode = [];
             for(let tmp of gljData) {
             for(let tmp of gljData) {
                 gljIdList.push(tmp.id);
                 gljIdList.push(tmp.id);
-                // 有组成物的类型才入数组
-                if (this.ownCompositionTypes.indexOf(tmp.type)) {
-                    projectGLJCode.push(tmp.code);
-                }
             }
             }
             // 从定额工料机库中获取消耗量
             // 从定额工料机库中获取消耗量
             condition = {
             condition = {
@@ -116,9 +110,15 @@ class GLJListModel extends BaseModel {
                 } else {
                 } else {
                     quantityList[tmp.projectGLJID] += tmp.quantity * tmpNum;
                     quantityList[tmp.projectGLJID] += tmp.quantity * tmpNum;
                 }
                 }
-
             }
             }
-
+            // 整理获取有组成物的项目工料机编码
+            let projectGLJCode = [];
+            for(let tmp of gljData) {
+                // 有组成物的类型且消耗量大于0才查找
+                if (quantityList[tmp.id] !== undefined) {
+                    projectGLJCode.push(tmp.code);
+                }
+            }
             // 查找组成物的消耗量
             // 查找组成物的消耗量
             let totalComposition = {};
             let totalComposition = {};
             let mixRatioData = {};
             let mixRatioData = {};
@@ -145,8 +145,7 @@ class GLJListModel extends BaseModel {
                 }
                 }
             }
             }
             // 组合单价数据
             // 组合单价数据
-            this.combineData(gljData, unitPriceList, quantityList, mixRatioData, totalComposition);
-
+            gljData = this.combineData(gljData, unitPriceList, quantityList, mixRatioData, totalComposition);
             // 排序
             // 排序
             gljData.sort(function (a, b) {
             gljData.sort(function (a, b) {
                 a.unit_price = a.unit_price === null ? 0 : a.unit_price;
                 a.unit_price = a.unit_price === null ? 0 : a.unit_price;
@@ -170,7 +169,7 @@ class GLJListModel extends BaseModel {
      * @param {object} quantityList
      * @param {object} quantityList
      * @param {object} mixRatioData 组合物明细数据
      * @param {object} mixRatioData 组合物明细数据
      * @param {object} totalComposition 组合物父工料机统计数据
      * @param {object} totalComposition 组合物父工料机统计数据
-     * @return {void}
+     * @return {Array}
      */
      */
     combineData(gljList, unitPriceList, quantityList = {}, mixRatioData = {}, totalComposition = {}) {
     combineData(gljList, unitPriceList, quantityList = {}, mixRatioData = {}, totalComposition = {}) {
         // 整理组成物消耗量(只有在总列表显示的时候才需用到,获取单项项目工料机内容则忽略)
         // 整理组成物消耗量(只有在总列表显示的时候才需用到,获取单项项目工料机内容则忽略)
@@ -184,8 +183,10 @@ class GLJListModel extends BaseModel {
 
 
             }
             }
         }
         }
+        let result = [];
         // 循环组合数据
         // 循环组合数据
-        for(let glj of gljList) {
+        for(let index in gljList) {
+            let glj = gljList[index];
             if (glj.code === undefined) {
             if (glj.code === undefined) {
                 continue;
                 continue;
             }
             }
@@ -196,13 +197,20 @@ class GLJListModel extends BaseModel {
             }
             }
 
 
             let gljId = glj.glj_id + '';
             let gljId = glj.glj_id + '';
+            let projectGljId = glj.id + '';
+
             // 消耗量赋值
             // 消耗量赋值
-            glj.quantity = quantityList[glj.id] !== undefined ? quantityList[glj.id] : 0;
+            glj.quantity = quantityList[projectGljId] !== undefined ? quantityList[projectGljId] : 0;
             glj.quantity = totalComposition[glj.code] !== undefined ? totalComposition[glj.code] : glj.quantity;
             glj.quantity = totalComposition[glj.code] !== undefined ? totalComposition[glj.code] : glj.quantity;
             glj.quantity = compositionConsumption[gljId] !== undefined ?  glj.quantity + compositionConsumption[gljId] : glj.quantity;
             glj.quantity = compositionConsumption[gljId] !== undefined ?  glj.quantity + compositionConsumption[gljId] : glj.quantity;
 
 
+            // 消耗值为0的数据不显示
+            if (glj.quantity === 0) {
+                delete gljList[index];
+                continue;
+            }
             // 组成物数据
             // 组成物数据
-            glj.ratio_data = mixRatioData[gljId] !== undefined ? mixRatioData[gljId] : [];
+            gljList[index].ratio_data = mixRatioData[gljId] !== undefined ? mixRatioData[gljId] : [];
 
 
             // 计算调整基价
             // 计算调整基价
             switch (glj.unit_price.type + '') {
             switch (glj.unit_price.type + '') {
@@ -218,8 +226,9 @@ class GLJListModel extends BaseModel {
                 default:
                 default:
                     glj.adjust_price = glj.unit_price.base_price;
                     glj.adjust_price = glj.unit_price.base_price;
             }
             }
-
+            result.push(glj);
         }
         }
+        return result;
     }
     }
 
 
     /**
     /**
@@ -540,7 +549,7 @@ class GLJListModel extends BaseModel {
                 unitPriceData[tmp.code + tmp.name] = tmp;
                 unitPriceData[tmp.code + tmp.name] = tmp;
             }
             }
 
 
-            this.combineData(gljData, unitPriceData, [], mixRatioData);
+            gljData = this.combineData(gljData, unitPriceData, [], mixRatioData);
 
 
             // 排序
             // 排序
             gljData.sort(function (a, b) {
             gljData.sort(function (a, b) {

+ 1 - 1
web/building_saas/complementary_glj_lib/html/tools-gongliaoji.html

@@ -85,7 +85,7 @@
           <div class="modal-dialog modal-lg" role="document" id="modalCon">
           <div class="modal-dialog modal-lg" role="document" id="modalCon">
               <div class="modal-content" >
               <div class="modal-content" >
                   <div class="modal-header">
                   <div class="modal-header">
-                    <h5 class="modal-title">内容</h5>
+                    <h5 class="modal-title">选择组成物</h5>
                       <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                       <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                         <span aria-hidden="true">&times;</span>
                         <span aria-hidden="true">&times;</span>
                       </button>
                       </button>

+ 6 - 4
web/building_saas/complementary_glj_lib/js/components.js

@@ -17,7 +17,7 @@ let componentOprObj = {
             {headerName:"编码",headerWidth:80,dataCode:"code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
             {headerName:"编码",headerWidth:80,dataCode:"code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
             {headerName:"名称",headerWidth:120,dataCode:"name", dataType: "String", hAlign: "left", vAlign: "center"},
             {headerName:"名称",headerWidth:120,dataCode:"name", dataType: "String", hAlign: "left", vAlign: "center"},
             {headerName:"规格型号",headerWidth:80,dataCode:"specs", dataType: "String", hAlign: "center", vAlign: "center"},
             {headerName:"规格型号",headerWidth:80,dataCode:"specs", dataType: "String", hAlign: "center", vAlign: "center"},
-            {headerName:"计量单位",headerWidth:80,dataCode:"unit", dataType: "String", hAlign: "center", vAlign: "center"},
+            {headerName:"单位",headerWidth:80,dataCode:"unit", dataType: "String", hAlign: "center", vAlign: "center"},
             {headerName:"单价",headerWidth:80,dataCode:"basePrice", dataType: "Number", formatter: "0.00", hAlign: "right", vAlign: "center"},
             {headerName:"单价",headerWidth:80,dataCode:"basePrice", dataType: "Number", formatter: "0.00", hAlign: "right", vAlign: "center"},
             {headerName:"类型",headerWidth:80,dataCode:"gljType", dataType: "String",  hAlign: "center", vAlign: "center"}
             {headerName:"类型",headerWidth:80,dataCode:"gljType", dataType: "String",  hAlign: "center", vAlign: "center"}
         ]
         ]
@@ -27,11 +27,15 @@ let componentOprObj = {
         me.workBook = sheetOpr.buildSheet(container, me.setting, 30);
         me.workBook = sheetOpr.buildSheet(container, me.setting, 30);
         me.workBook.getSheet(0).setColumnWidth(0, 20, GC.Spread.Sheets.SheetArea.rowHeader);
         me.workBook.getSheet(0).setColumnWidth(0, 20, GC.Spread.Sheets.SheetArea.rowHeader);
         me.workBook.getSheet(0).setFormatter(-1, 1, "@", GC.Spread.Sheets.SheetArea.viewport);
         me.workBook.getSheet(0).setFormatter(-1, 1, "@", GC.Spread.Sheets.SheetArea.viewport);
-        me.workBook.getSheet(0).options.isProtected = true;
+       // me.workBook.getSheet(0).options.isProtected = true;
+        me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditStarting, me.onCellEditStart);
         me.workBook.bind(GC.Spread.Sheets.Events.ButtonClicked, me.onButtonClicked);//复选框点击事件
         me.workBook.bind(GC.Spread.Sheets.Events.ButtonClicked, me.onButtonClicked);//复选框点击事件
         me.componentsBtnOpr($('#componentsConf'));
         me.componentsBtnOpr($('#componentsConf'));
         me.radiosChange();
         me.radiosChange();
     },
     },
+    onCellEditStart: function (sender, args) {
+        args.cancel = true;
+    },
     onButtonClicked: function (sender, args) {
     onButtonClicked: function (sender, args) {
         let me = componentOprObj, re = repositoryGljObj;
         let me = componentOprObj, re = repositoryGljObj;
         let val = args.sheet.getValue(args.row, args.col);
         let val = args.sheet.getValue(args.row, args.col);
@@ -209,9 +213,7 @@ let componentOprObj = {
             }
             }
             sheetOpr.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
             sheetOpr.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
             sheetOpr.showData(me.workBook.getSheet(0), me.setting, cacheSection, re.distTypeTree);
             sheetOpr.showData(me.workBook.getSheet(0), me.setting, cacheSection, re.distTypeTree);
-            me.workBook.getSheet(0).options.isProtected = true;
             me.workBook.getSheet(0).setRowCount(cacheSection.length);
             me.workBook.getSheet(0).setRowCount(cacheSection.length);
-            sheetOpr.setLockCols(me.workBook.getSheet(0), [4], true);
             cacheSection = null;
             cacheSection = null;
         }
         }
     },
     },

+ 49 - 45
web/building_saas/complementary_glj_lib/js/glj.js

@@ -21,7 +21,6 @@ let pageOprObj = {
             repositoryGljObj.getGljTree(stdGljLibId, function () {
             repositoryGljObj.getGljTree(stdGljLibId, function () {
                 repositoryGljObj.getGljItems(me.stdGljLibId, me.userId, me.compilationId);
                 repositoryGljObj.getGljItems(me.stdGljLibId, me.userId, me.compilationId);
             });
             });
-            sheetOpr.shieldAllCells(repositoryGljObj.workBook.getSheet(0), repositoryGljObj.setting);
         });
         });
     }
     }
 };
 };
@@ -101,9 +100,6 @@ let repositoryGljObj = {
                 if(!result.error && callback){
                 if(!result.error && callback){
                     me.distTypeTree = me.getComboData(result.data);
                     me.distTypeTree = me.getComboData(result.data);
                     console.log(me.distTypeTree);
                     console.log(me.distTypeTree);
-                   /* let combo = new GC.Spread.Sheets.CellTypes.ComboBox();
-                    combo.items(me.distTypeTree.comboDatas).editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.text);
-                    me.workBook.getSheet(0).getCell(-1, 5, GC.Spread.Sheets.SheetArea.viewport).cellType(combo).value(me.distTypeTree.comboDatas[0].text);*/
                     callback();
                     callback();
                 }
                 }
             }
             }
@@ -195,6 +191,7 @@ let repositoryGljObj = {
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EnterCell, me.onEnterCell);
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EnterCell, me.onEnterCell);
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.SelectionChanged, me.onSelectionChanged);
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.SelectionChanged, me.onSelectionChanged);
+        me.workBook.bind(GC.Spread.Sheets.Events.ButtonClicked, me.onButtonClicked);//复选框点击事件
     },
     },
     getCurrentComponent: function (gljComponent) {
     getCurrentComponent: function (gljComponent) {
         let me = repositoryGljObj, rst = [];
         let me = repositoryGljObj, rst = [];
@@ -285,11 +282,7 @@ let repositoryGljObj = {
         //混凝土202、砂浆203、配合比204、机械3
         //混凝土202、砂浆203、配合比204、机械3
         if(typeof info.oldSelections || info.oldSelections.length === 0 && info.newSelections.length > 0 || info.oldSelections[0].row !== info.newSelections[0].row){
         if(typeof info.oldSelections || info.oldSelections.length === 0 && info.newSelections.length > 0 || info.oldSelections[0].row !== info.newSelections[0].row){
             let row = info.newSelections[0].row;
             let row = info.newSelections[0].row;
-            sheetOpr.lockCells(that.workBook.getSheet(0), that.setting);
-            that.workBook.getSheet(0).getRange(-1, 0 , -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(true);
-            that.workBook.getSheet(0).getRange(-1, 4 , -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(true);
             that.isLocked = true;
             that.isLocked = true;
-            //that.workBook.getSheet(0).options.isProtected = true;
             sheetOpr.cleanSheet(that.workBook.getSheet(0), that.setting, -1);
             sheetOpr.cleanSheet(that.workBook.getSheet(0), that.setting, -1);
             me.workBook.focus(true);
             me.workBook.focus(true);
             me.currentComponent = [];
             me.currentComponent = [];
@@ -298,8 +291,6 @@ let repositoryGljObj = {
                 //标记当前工料机
                 //标记当前工料机
                 me.currentGlj = me.currentCache[row];
                 me.currentGlj = me.currentCache[row];
                 if(me.allowComponent.indexOf(me.currentCache[row].gljType) !== -1){
                 if(me.allowComponent.indexOf(me.currentCache[row].gljType) !== -1){
-                    //that.workBook.getSheet(0).getRange(-1, 0 , -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(false);
-                    that.workBook.getSheet(0).getRange(-1, 4 , -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(false);
                     that.isLocked = false;
                     that.isLocked = false;
                     //展示数据
                     //展示数据
                     if(me.currentGlj.component.length > 0){
                     if(me.currentGlj.component.length > 0){
@@ -359,24 +350,13 @@ let repositoryGljObj = {
                 }
                 }
                 else {
                 else {
                     $('#gljAlertBtn').click();
                     $('#gljAlertBtn').click();
-                    //me.workBook.getSheet(0).options.isProtected = true;
-                    sheetOpr.lockAllCells(args.sheet);
                     $('#aleConfBtn').click(function () {
                     $('#aleConfBtn').click(function () {
-                        // me.workBook.getSheet(0).options.isProtected = false;
-                        sheetOpr.unLockAllCells(args.sheet);
-                        sheetOpr.reLockSomeCodes(args.sheet, 0, repositoryGljObj.currentCache.length);
                         me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, focusToCol);
                         me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, focusToCol);
                     });
                     });
                     $('#gljAleClose').click(function () {
                     $('#gljAleClose').click(function () {
-                        // me.workBook.getSheet(0).options.isProtected = false;
-                        sheetOpr.unLockAllCells(args.sheet);
-                        sheetOpr.reLockSomeCodes(args.sheet, 0, repositoryGljObj.currentCache.length);
                         me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, focusToCol);
                         me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, focusToCol);
                     });
                     });
                     $('#aleCanceBtn').click(function () {
                     $('#aleCanceBtn').click(function () {
-                        // me.workBook.getSheet(0).options.isProtected = false;
-                        sheetOpr.unLockAllCells(args.sheet);
-                        sheetOpr.reLockSomeCodes(args.sheet, 0, repositoryGljObj.currentCache.length);
                         me.addGljObj = null;
                         me.addGljObj = null;
                         me.workBook.getSheet(0).suspendPaint();
                         me.workBook.getSheet(0).suspendPaint();
                         me.workBook.getSheet(0).suspendEvent();
                         me.workBook.getSheet(0).suspendEvent();
@@ -394,21 +374,31 @@ let repositoryGljObj = {
             }
             }
         }
         }
     },
     },
+    onButtonClicked: function (sender, args) {
+        let me = repositoryGljObj;
+        if(args.col === 6 && args.row < me.currentCache.length){
+            args.sheet.setValue(args.row, args.col, true);
+        }
+    },
     onCellEditStart: function(sender, args) {
     onCellEditStart: function(sender, args) {
         let me = repositoryGljObj;
         let me = repositoryGljObj;
         let rObj = sheetOpr.combineRowData(me.workBook.getSheet(0), me.setting, args.row);
         let rObj = sheetOpr.combineRowData(me.workBook.getSheet(0), me.setting, args.row);
         me.currentEditingGlj = rObj;
         me.currentEditingGlj = rObj;
         me.orgCode = me.workBook.getSheet(0).getValue(args.row, 0);
         me.orgCode = me.workBook.getSheet(0).getValue(args.row, 0);
-        let cacheSection = me.complementaryGljList;
-        if (cacheSection) {
-            for (let j = 0; j < cacheSection.length; j++) {
-                if (cacheSection[j][me.setting.header[0].dataCode] && cacheSection[j][me.setting.header[0].dataCode] == rObj[me.setting.header[0].dataCode]) {
-                    rObj["ID"] = cacheSection[j]["ID"];
-                    rObj.gljClass = cacheSection[j].gljClass;
-                    break;
-                }
+        if(args.row < me.currentCache.length){
+            me.currentGlj = me.currentCache[args.row];
+            if(args.col === 0 || (args.col === 4 && me.allowComponent.indexOf(me.currentGlj.gljType) !== -1)
+                || args.col === 6){
+                args.cancel = true;
+            }
+            else {
+                rObj.ID = me.currentGlj.ID;
+                rObj.gljClass = me.currentGlj.gljClass;
             }
             }
         }
         }
+        else {
+            me.currentGlj = null;
+        }
     },
     },
     onCellEditEnd: function(sender, args) {
     onCellEditEnd: function(sender, args) {
         let me = repositoryGljObj, that = gljComponentOprObj,
         let me = repositoryGljObj, that = gljComponentOprObj,
@@ -531,7 +521,6 @@ let repositoryGljObj = {
         }
         }
         if(updateArr.length >0 || addArr.length >0){
         if(updateArr.length >0 || addArr.length >0){
             me.currentEditingGlj = null;
             me.currentEditingGlj = null;
-            //me.workBook.getSheet(0).setValue(11, 5, "人工");
             me.mixUpdateRequest(updateArr, addArr, []);
             me.mixUpdateRequest(updateArr, addArr, []);
         }
         }
     },
     },
@@ -605,12 +594,9 @@ let repositoryGljObj = {
                                 }
                                 }
                                 $('#alertText').text(text + "不可为空!");
                                 $('#alertText').text(text + "不可为空!");
                                 $('#codeAlertBtn').click();
                                 $('#codeAlertBtn').click();
-                                sheet.options.isProtected = true;
                                 $('#codAleConfBtn').click(function () {
                                 $('#codAleConfBtn').click(function () {
-                                    sheetOpr.lockSomeCodes(sheet, 0, cacheSection.length);
                                 });
                                 });
                                 $('#codAleClose').click(function () {
                                 $('#codAleClose').click(function () {
-                                    sheetOpr.lockSomeCodes(sheet, 0, cacheSection.length);
                                 });
                                 });
                             }
                             }
                         }
                         }
@@ -780,11 +766,39 @@ let repositoryGljObj = {
         pasteObj.gljClass = me.gljCurTypeId;
         pasteObj.gljClass = me.gljCurTypeId;
         return true;
         return true;
     },
     },
+    canPasted: function (info) {
+        let rst = true;
+        let me = repositoryGljObj;
+        if(me.gljCurTypeId < 0){
+            return false;
+        }
+        if(info.cellRange.col + info.cellRange.colCount - 1 > me.setting.header.length - 2){
+            return false;
+        }
+        if(info.cellRange.row < me.currentCache.length){
+            if(info.cellRange.col === 0){
+                return false;
+            }
+            else if(info.cellRange.col <= 4 && info.cellRange.col + info.cellRange.colCount - 1 >= 4){
+                for(let i = 0, len = info.cellRange.rowCount; i < len; i++){
+                    let row = i + info.cellRange.row;
+                    if(row < me.currentCache.length){
+                        if(me.allowComponent.indexOf(me.currentCache[row].gljType) !== -1){
+                            rst = false;
+                        }
+                    }
+                    else {
+                        break;
+                    }
+                }
+            }
+        }
+        return rst;
+    },
     onClipboardPasting: function(sender, args) {
     onClipboardPasting: function(sender, args) {
         let me = repositoryGljObj;
         let me = repositoryGljObj;
         let maxCol = args.cellRange.col + args.cellRange.colCount - 1;
         let maxCol = args.cellRange.col + args.cellRange.colCount - 1;
-        //复制的列数超过正确的列数,不可复制
-        if (me.gljCurTypeId < 0 || maxCol >= me.setting.header.length -1) {
+        if (!me.canPasted(args)) {
             args.cancel = true;
             args.cancel = true;
         }
         }
     },
     },
@@ -955,9 +969,6 @@ let repositoryGljObj = {
                     }
                     }
                     else{
                     else{
                         me.currentCache = me.getCache();
                         me.currentCache = me.getCache();
-                        //sheetOpr.unLockAllCells(me.workBook.getSheet(0));
-                        sheetOpr.reLockSomeCodes(me.workBook.getSheet(0), 0, me.currentCache.length);
-                        //sheetOpr.lockSomeCodes(me.workBook.getSheet(0), 0, me.currentCache.length);
                     }
                     }
                     me.showGljItems(me.complementaryGljList, me.gljCurTypeId);
                     me.showGljItems(me.complementaryGljList, me.gljCurTypeId);
                 }
                 }
@@ -1050,20 +1061,13 @@ let gljTypeTreeOprObj = {
         me.addGljObj = null;
         me.addGljObj = null;
         //me.currentCache = me.getCache();
         //me.currentCache = me.getCache();
         sheetOpr.cleanData(that.workBook.getSheet(0), that.setting, 5);
         sheetOpr.cleanData(that.workBook.getSheet(0), that.setting, 5);
-        that.workBook.getSheet(0).getRange(-1, 0 , -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(true);
-        that.workBook.getSheet(0).getRange(-1, 4 , -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(true);
-        me.workBook.getSheet(0).getRange(-1, 6 , -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(true);
-        //that.workBook.getSheet(0).options.isProtected = true;
         if (me.parentNodeIds["_pNodeId_" + treeNode.ID]) {
         if (me.parentNodeIds["_pNodeId_" + treeNode.ID]) {
             me.currentOprParent = 1;
             me.currentOprParent = 1;
             me.currentCache = me.getParentCache(me.parentNodeIds["_pNodeId_" + treeNode.ID]);
             me.currentCache = me.getParentCache(me.parentNodeIds["_pNodeId_" + treeNode.ID]);
-            sheetOpr.lockCodeCells(me.workBook.getSheet(0), me.currentCache.length);
             me.workBook.getSheet(0).setRowCount(me.currentCache.length);
             me.workBook.getSheet(0).setRowCount(me.currentCache.length);
         } else {
         } else {
             me.currentOprParent = 0;
             me.currentOprParent = 0;
             me.currentCache = me.getCache();
             me.currentCache = me.getCache();
-            sheetOpr.unLockAllCells(me.workBook.getSheet(0));
-            sheetOpr.reLockSomeCodes(me.workBook.getSheet(0), 0, me.currentCache.length);
         }
         }
         me.showGljItems(me.complementaryGljList, gljTypeId);
         me.showGljItems(me.complementaryGljList, gljTypeId);
     }
     }

+ 17 - 9
web/building_saas/complementary_glj_lib/js/gljComponent.js

@@ -9,12 +9,12 @@ let gljComponentOprObj = {
         header:[
         header:[
             {headerName:"编码",headerWidth:80,dataCode:"code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
             {headerName:"编码",headerWidth:80,dataCode:"code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
             {headerName:"名称",headerWidth:110,dataCode:"name", dataType: "String", hAlign: "left", vAlign: "center"},
             {headerName:"名称",headerWidth:110,dataCode:"name", dataType: "String", hAlign: "left", vAlign: "center"},
-            {headerName:"计量单位",headerWidth:80,dataCode:"unit", dataType: "String", hAlign: "center", vAlign: "center"},
+            {headerName:"单位",headerWidth:80,dataCode:"unit", dataType: "String", hAlign: "center", vAlign: "center"},
             {headerName:"单价",headerWidth:80,dataCode:"basePrice", dataType: "Number", formatter: "0.00", hAlign: "right", vAlign: "center"},
             {headerName:"单价",headerWidth:80,dataCode:"basePrice", dataType: "Number", formatter: "0.00", hAlign: "right", vAlign: "center"},
             {headerName:"消耗量",headerWidth:80,dataCode:"consumeAmt", dataType: "Number", formatter: "0.000", hAlign: "right", vAlign: "center"}
             {headerName:"消耗量",headerWidth:80,dataCode:"consumeAmt", dataType: "Number", formatter: "0.000", hAlign: "right", vAlign: "center"}
         ],
         ],
         view: {
         view: {
-            lockedCells:[0, 1, 2, 3]
+            lockedCols:[0, 1, 2, 3]
         }
         }
     },
     },
     buildSheet: function(container) {
     buildSheet: function(container) {
@@ -22,7 +22,6 @@ let gljComponentOprObj = {
         me.workBook = sheetOpr.buildSheet(container, me.setting, 30);
         me.workBook = sheetOpr.buildSheet(container, me.setting, 30);
         me.workBook.getSheet(0).setColumnWidth(0, 20, GC.Spread.Sheets.SheetArea.rowHeader);
         me.workBook.getSheet(0).setColumnWidth(0, 20, GC.Spread.Sheets.SheetArea.rowHeader);
         me.workBook.getSheet(0).setFormatter(-1, 0, "@", GC.Spread.Sheets.SheetArea.viewport);
         me.workBook.getSheet(0).setFormatter(-1, 0, "@", GC.Spread.Sheets.SheetArea.viewport);
-        me.workBook.getSheet(0).options.isProtected = true;
         sheetOpr.cleanData(me.workBook.getSheet(0), me.setting, -1);
         sheetOpr.cleanData(me.workBook.getSheet(0), me.setting, -1);
 
 
         me.onContextmenuOpr();//右键菜单
         me.onContextmenuOpr();//右键菜单
@@ -31,11 +30,6 @@ let gljComponentOprObj = {
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);
         me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
         me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
         me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
         me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
-        /*me.gljComponentDelOpr();
-        me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
-        me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
-        me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditStarting, me.onCellEditStart);
-        me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);*/
 
 
     },
     },
     getRowData: function (sheet, row, setting) {
     getRowData: function (sheet, row, setting) {
@@ -82,6 +76,9 @@ let gljComponentOprObj = {
                         callback: function(){},
                         callback: function(){},
                         items: {
                         items: {
                             "insert": {name: "插入", disabled: insertDis, icon: "fa-sign-in", callback: function (key, opt) {
                             "insert": {name: "插入", disabled: insertDis, icon: "fa-sign-in", callback: function (key, opt) {
+                                //getCurrentGlj
+                                let thatRow = that.workBook.getSheet(0).getSelections()[0].row;
+                                that.currentGlj = thatRow < that.currentCache.length ? that.currentCache[thatRow] : null;
                                 //默认radio所有工料机
                                 //默认radio所有工料机
                                 co.initRadio();
                                 co.initRadio();
                                 co.gljCurTypeId = null;
                                 co.gljCurTypeId = null;
@@ -209,6 +206,17 @@ let gljComponentOprObj = {
         let me = gljComponentOprObj, that = repositoryGljObj;
         let me = gljComponentOprObj, that = repositoryGljObj;
         let rObj = me.getRowData(args.sheet, args.row, me.setting);
         let rObj = me.getRowData(args.sheet, args.row, me.setting);
         me.currentEditingComponent = rObj;
         me.currentEditingComponent = rObj;
+        let thatRow = that.workBook.getSheet(0).getSelections()[0].row;
+        if(thatRow < that.currentCache.length){
+            that.currentGlj = that.currentCache[thatRow];
+            if(me.setting.view.lockedCols.indexOf(args.col) !== -1 || that.allowComponent.indexOf(that.currentGlj.gljType) === -1 ||
+                (args.col === 4 && (!that.currentComponent|| args.row >= that.currentComponent.length))){
+                args.cancel = true;
+            }
+        }
+        else {
+            args.cancel = true;
+        }
     },
     },
     onCellEditEnd: function (sender, args) {
     onCellEditEnd: function (sender, args) {
         let me = gljComponentOprObj, that = repositoryGljObj, updateBasePrc = [];
         let me = gljComponentOprObj, that = repositoryGljObj, updateBasePrc = [];
@@ -340,7 +348,7 @@ let gljComponentOprObj = {
         let me = gljComponentOprObj;
         let me = gljComponentOprObj;
         let maxCol = info.cellRange.col + info.cellRange.colCount - 1;
         let maxCol = info.cellRange.col + info.cellRange.colCount - 1;
         //复制的列数超过正确的列数,不可复制
         //复制的列数超过正确的列数,不可复制
-        if(maxCol >= me.setting.header.length){
+        if(info.cellRange.col !== 4 || info.cellRange.colCount > 1){
             args.cancel = true;
             args.cancel = true;
         }
         }
     },
     },

+ 0 - 37
web/building_saas/complementary_glj_lib/js/sheetOpr.js

@@ -119,11 +119,6 @@ let sheetOpr = {
         else{
         else{
             sheet.setRowCount(typeof repositoryGljObj !== 'undefined' && repositoryGljObj.currentOprParent === 1 ? data.length : data.length + 10);
             sheet.setRowCount(typeof repositoryGljObj !== 'undefined' && repositoryGljObj.currentOprParent === 1 ? data.length : data.length + 10);
         }
         }
-        if(data.length === 0){
-            for(let i = 0; i < sheet.getRowCount(); i++){
-                sheet.getCell(i, 4, GC.Spread.Sheets.SheetArea.viewport).locked(false);
-            }
-        }
         for (var col = 0; col < setting.header.length; col++) {
         for (var col = 0; col < setting.header.length; col++) {
             var hAlign = "left", vAlign = "center";
             var hAlign = "left", vAlign = "center";
             if (setting.header[col].hAlign) {
             if (setting.header[col].hAlign) {
@@ -137,23 +132,13 @@ let sheetOpr = {
                 sheet.setFormatter(-1, col, setting.header[col].formatter, GC.Spread.Sheets.SheetArea.viewport);
                 sheet.setFormatter(-1, col, setting.header[col].formatter, GC.Spread.Sheets.SheetArea.viewport);
             }
             }
             for (var row = 0; row < data.length; row++) {
             for (var row = 0; row < data.length; row++) {
-                //var cell = sheet.getCell(row, col, GC.Spread.Sheets.SheetArea.viewport);
                 if(setting.header[col].dataCode === 'gljType' && data[row].gljType){
                 if(setting.header[col].dataCode === 'gljType' && data[row].gljType){
-                    if(typeof repositoryGljObj !== 'undefined' && typeof repositoryGljObj.allowComponent !== 'undefined' && repositoryGljObj.allowComponent.indexOf(data[row].gljType) !== -1){
-                        sheet.getCell(row, 4, GC.Spread.Sheets.SheetArea.viewport).locked(true);
-                    }
-                    else if(typeof repositoryGljObj !== 'undefined' && typeof repositoryGljObj.allowComponent !== 'undefined' && repositoryGljObj.allowComponent.indexOf(data[row].gljType) === -1){
-                        sheet.getCell(row, 4, GC.Spread.Sheets.SheetArea.viewport).locked(false);
-                    }
                     let distTypeVal =  distTypeTree.distTypes[distTypeTree.prefix + data[row].gljType].data.fullName;
                     let distTypeVal =  distTypeTree.distTypes[distTypeTree.prefix + data[row].gljType].data.fullName;
                     sheet.setValue(row, col, distTypeVal, ch);
                     sheet.setValue(row, col, distTypeVal, ch);
                 }
                 }
                 else {
                 else {
                     sheet.setValue(row, col, data[row][setting.header[col].dataCode], ch);
                     sheet.setValue(row, col, data[row][setting.header[col].dataCode], ch);
                     sheet.setTag(row, 0, data[row].ID, ch);
                     sheet.setTag(row, 0, data[row].ID, ch);
-                    if(typeof setting.owner === 'undefined'){
-                        sheet.getCell(row, 0, GC.Spread.Sheets.SheetArea.viewport).locked(true);
-                    }
                 }
                 }
                 //复选框
                 //复选框
                 if(setting.header[col].dataCode === 'isComplementary'){
                 if(setting.header[col].dataCode === 'isComplementary'){
@@ -163,7 +148,6 @@ let sheetOpr = {
                 //新增组成物表,选择复选框
                 //新增组成物表,选择复选框
                 if(setting.header[col].dataCode === 'select'){
                 if(setting.header[col].dataCode === 'select'){
                     sheet.setCellType(row, col, checkBoxType)
                     sheet.setCellType(row, col, checkBoxType)
-                    sheet.getCell(row, col, GC.Spread.Sheets.SheetArea.viewport).locked(false);
                     if(data[row].isChecked === true){
                     if(data[row].isChecked === true){
                         sheet.getCell(row, col).value(1);
                         sheet.getCell(row, col).value(1);
                     }
                     }
@@ -171,7 +155,6 @@ let sheetOpr = {
             }
             }
             for(let i = data.length; i < sheet.getRowCount(); i++){
             for(let i = data.length; i < sheet.getRowCount(); i++){
                 sheet.setCellType(i, 6, null);
                 sheet.setCellType(i, 6, null);
-                sheet.getCell(i, 4, GC.Spread.Sheets.SheetArea.viewport).locked(false);
             }
             }
         }
         }
         sheet.resumeEvent();
         sheet.resumeEvent();
@@ -228,28 +211,18 @@ let sheetOpr = {
                         isExist = false;
                         isExist = false;
                     for(let i=0; i< stdGljList.length; i++){
                     for(let i=0; i< stdGljList.length; i++){
                         if(stdGljList[i].code == sheet.getValue(row, col) && sheet.getValue(row, col)!== orgCode){
                         if(stdGljList[i].code == sheet.getValue(row, col) && sheet.getValue(row, col)!== orgCode){
-                            me.lockAllCells(sheet);
                             $('#alertText').text("输入的编号已存在,请重新输入!");
                             $('#alertText').text("输入的编号已存在,请重新输入!");
                             $('#codeAlertBtn').click();
                             $('#codeAlertBtn').click();
                             $('#codAleConfBtn').click(function () {
                             $('#codAleConfBtn').click(function () {
-                                // me.reLockSomeCodes(sheet, 0, repositoryGljObj.currentCache.length);
-                                me.unLockAllCells(sheet);
-                                me.reLockSomeCodes(sheet, 0, repositoryGljObj.currentCache.length);
-                                //sheet.setText(row, 0, '');
                                 sheet.getCell(row, 0).formatter("@");
                                 sheet.getCell(row, 0).formatter("@");
                                 sheet.getCell(row, 0).text("");
                                 sheet.getCell(row, 0).text("");
                                 sheet.setActiveCell(row, 0);
                                 sheet.setActiveCell(row, 0);
                             });
                             });
                             $('#codAleClose').click(function () {
                             $('#codAleClose').click(function () {
-                                //me.reLockSomeCodes(sheet, 0, repositoryGljObj.currentCache.length);
-                                me.unLockAllCells(sheet);
-                                me.reLockSomeCodes(sheet, 0, repositoryGljObj.currentCache.length);
-                                //sheet.setText(row, 0, '');
                                 sheet.getCell(row, 0).formatter("@");
                                 sheet.getCell(row, 0).formatter("@");
                                 sheet.getCell(row, 0).text("");
                                 sheet.getCell(row, 0).text("");
                                 sheet.setActiveCell(row, 0);
                                 sheet.setActiveCell(row, 0);
                             });
                             });
-                            // sheet.setValue(row, col, orgCode);
                             isExist = true
                             isExist = true
                             break;
                             break;
                         }
                         }
@@ -257,28 +230,18 @@ let sheetOpr = {
                     if(!isExist){
                     if(!isExist){
                         for(let i=0; i< complementaryGljList.length; i++){
                         for(let i=0; i< complementaryGljList.length; i++){
                             if(complementaryGljList[i].code == sheet.getValue(row, col) && sheet.getValue(row, col)!== orgCode){
                             if(complementaryGljList[i].code == sheet.getValue(row, col) && sheet.getValue(row, col)!== orgCode){
-                                me.lockAllCells(sheet);
                                 $('#alertText').text("输入的编号已存在,请重新输入!");
                                 $('#alertText').text("输入的编号已存在,请重新输入!");
                                 $('#codeAlertBtn').click();
                                 $('#codeAlertBtn').click();
                                 $('#codAleConfBtn').click(function () {
                                 $('#codAleConfBtn').click(function () {
-                                    // me.reLockSomeCodes(sheet, 0, repositoryGljObj.currentCache.length);
-                                    me.unLockAllCells(sheet);
-                                    me.reLockSomeCodes(sheet, 0, repositoryGljObj.currentCache.length);
-                                    //sheet.setText(row, 0, '');
                                     sheet.getCell(row, 0).formatter("@");
                                     sheet.getCell(row, 0).formatter("@");
                                     sheet.getCell(row, 0).text("");
                                     sheet.getCell(row, 0).text("");
                                     sheet.setActiveCell(row, 0);
                                     sheet.setActiveCell(row, 0);
                                 });
                                 });
                                 $('#codAleClose').click(function () {
                                 $('#codAleClose').click(function () {
-                                    //me.reLockSomeCodes(sheet, 0, repositoryGljObj.currentCache.length);
-                                    me.unLockAllCells(sheet);
-                                    me.reLockSomeCodes(sheet, 0, repositoryGljObj.currentCache.length);
-                                    //sheet.setText(row, 0, '');
                                     sheet.getCell(row, 0).formatter("@");
                                     sheet.getCell(row, 0).formatter("@");
                                     sheet.getCell(row, 0).text("");
                                     sheet.getCell(row, 0).text("");
                                     sheet.setActiveCell(row, 0);
                                     sheet.setActiveCell(row, 0);
                                 });
                                 });
-                                // sheet.setValue(row, col, orgCode);
                                 isExist = true
                                 isExist = true
                                 break;
                                 break;
                             }
                             }

+ 23 - 21
web/building_saas/glj/js/project_glj.js

@@ -199,32 +199,34 @@ $(document).ready(function () {
  * @return {void|boolean}
  * @return {void|boolean}
  */
  */
 function init() {
 function init() {
-    // 加载工料机数据
-    let data = projectObj.project.projectGLJ === null ? null : projectObj.project.projectGLJ.datas;
-    if (data === null) {
-        return false;
-    }
-    // 赋值
-    jsonData = data.gljList !== undefined && data.gljList.length > 0 ? data.gljList : [];
-    mixRatioConnectData = data.mixRatioConnectData !== undefined ? data.mixRatioConnectData : mixRatioConnectData;
+    projectObj.project.projectGLJ.loadData(function(data) {
+        if (jsonData.length <= 0) {
+            // 赋值
+            jsonData = data.gljList !== undefined && data.gljList.length > 0 ? data.gljList : [];
+            mixRatioConnectData = data.mixRatioConnectData !== undefined ? data.mixRatioConnectData : mixRatioConnectData;
+
+            host = data.constData.hostname !== undefined ? data.constData.hostname : '';
+            materialIdList = data.constData.materialIdList !== undefined ? data.constData.materialIdList : materialIdList;
+            roomId = data.constData.roomId !== undefined ? data.constData.roomId : roomId;
+            canNotChangeTypeId = data.constData.ownCompositionTypes !== undefined ?
+                data.constData.ownCompositionTypes : canNotChangeTypeId;
+            GLJTypeConst = data.constData.GLJTypeConst !== undefined ? JSON.parse(data.constData.GLJTypeConst) : GLJTypeConst;
 
 
-    host = data.constData.hostname !== undefined ? data.constData.hostname : '';
-    materialIdList = data.constData.materialIdList !== undefined ? data.constData.materialIdList : materialIdList;
-    roomId = data.constData.roomId !== undefined ? data.constData.roomId : roomId;
-    canNotChangeTypeId = data.constData.ownCompositionTypes !== undefined ?
-        data.constData.ownCompositionTypes : canNotChangeTypeId;
-    GLJTypeConst = data.constData.GLJTypeConst !== undefined ? JSON.parse(data.constData.GLJTypeConst) : GLJTypeConst;
+            let usedTenderList = data.usedTenderList !== undefined ? data.usedTenderList : [];
+            usedUnitPriceInfo = data.constData.usedUnitPriceInfo !== undefined ?
+                data.constData.usedUnitPriceInfo : {};
 
 
-    let usedTenderList = data.usedTenderList !== undefined ? data.usedTenderList : [];
-    usedUnitPriceInfo = data.constData.usedUnitPriceInfo !== undefined ?
-        data.constData.usedUnitPriceInfo : {};
+            // 连接socket服务器
+            socketInit();
 
 
-    // 连接socket服务器
-    socketInit();
+            unitPriceFileInit(usedUnitPriceInfo.name, usedTenderList);
 
 
-    unitPriceFileInit(usedUnitPriceInfo.name, usedTenderList);
+            setTimeout(spreadInit, 1);
+        } else {
+            projectObj.project.projectGLJ.loadCacheData();
+        }
 
 
-    setTimeout(spreadInit, 1);
+    });
 }
 }
 
 
 /**
 /**

+ 1 - 1
web/building_saas/glj/js/project_glj_spread.js

@@ -106,7 +106,7 @@ ProjectGLJSpread.prototype.init = function () {
     this.sheetObj.setColumnEditable(marketPriceColumn);
     this.sheetObj.setColumnEditable(marketPriceColumn);
     this.sheetObj.setColumnEditable(isEvaluateColumn);
     this.sheetObj.setColumnEditable(isEvaluateColumn);
     this.sheetObj.setColumnEditable(isAdjustPriceColumn);
     this.sheetObj.setColumnEditable(isAdjustPriceColumn);
-    this.sheetObj.setColumnEditable(11);
+    this.sheetObj.setColumnEditable(supplyColumn);
     this.sheetObj.setData(sourceData);
     this.sheetObj.setData(sourceData);
     // 取消正在加载字符提示
     // 取消正在加载字符提示
     $("#project-glj > p").hide();
     $("#project-glj > p").hide();

+ 32 - 14
web/building_saas/main/js/calc/bills_calc.js

@@ -237,9 +237,8 @@ let baseCalcField = [
 class BillsCalcHelper {
 class BillsCalcHelper {
     constructor (project, calcFlag) {
     constructor (project, calcFlag) {
         this.project = project;
         this.project = project;
-        this.InitFields(this.project.calcFields);
+        this.InitFields(project.calcFields);
     };
     };
-
     getBillsGLjs (node) {
     getBillsGLjs (node) {
         let rations = this.project.Ration.getBillsSortRation(node.source.getID());
         let rations = this.project.Ration.getBillsSortRation(node.source.getID());
         let gljs = this.project.ration_glj.getGatherGljArrByRations(rations);
         let gljs = this.project.ration_glj.getGatherGljArrByRations(rations);
@@ -248,7 +247,7 @@ class BillsCalcHelper {
         }
         }
         return gljs;
         return gljs;
     };
     };
-    calcRationLeaf (node, fields) {
+    calcRationLeaf (node, fields, isIncre) {
         nodeCalcObj.node = node;
         nodeCalcObj.node = node;
         nodeCalcObj.digit = this.project.Decimal.unitFee;
         nodeCalcObj.digit = this.project.Decimal.unitFee;
         calcFees.checkFields(node.data, fields);
         calcFees.checkFields(node.data, fields);
@@ -277,47 +276,50 @@ class BillsCalcHelper {
                 default:
                 default:
                     node.data.feesIndex[field.type].unitFee = 0;
                     node.data.feesIndex[field.type].unitFee = 0;
             }
             }
+            let value = 0;
             switch (field.totalFeeFlag) {
             switch (field.totalFeeFlag) {
                 case sumTotalFeeFlag:
                 case sumTotalFeeFlag:
-                    node.data.feesIndex[field.type].totalFee = nodeCalcObj.sumTotalFee().toDecimal(this.project.Decimal.common.totalFee);
+                    value = nodeCalcObj.sumTotalFee().toDecimal(this.project.Decimal.common.totalFee);
                     break;
                     break;
                 case totalFeeFlag:
                 case totalFeeFlag:
-                    node.data.feesIndex[field.type].totalFee = nodeCalcObj.totalFee().toDecimal(this.project.Decimal.common.totalFee);
+                    value = nodeCalcObj.totalFee().toDecimal(this.project.Decimal.common.totalFee);
                     break;
                     break;
                 default:
                 default:
-                    node.data.feesIndex[field.type].totalFee = 0;
+                    value = 0;
             }
             }
+            this.setTotalFee(node, field, value, isIncre);
         }
         }
     };
     };
-    calcVolumePriceLeaf (node, fields) {
+    calcVolumePriceLeaf (node, fields, isIncre) {
         let total = 0;
         let total = 0;
         for (let child of this.node.children) {
         for (let child of this.node.children) {
             total += this.getFee(child.data, 'feesIndex.common.totalFee');
             total += this.getFee(child.data, 'feesIndex.common.totalFee');
         }
         }
     };
     };
-    calcParent (node, fields) {
+    calcParent (node, fields, isIncre) {
         nodeCalcObj.node = node;
         nodeCalcObj.node = node;
         calcFees.checkFields(node.data, fields);
         calcFees.checkFields(node.data, fields);
         for (let field of fields) {
         for (let field of fields) {
             nodeCalcObj.field = field;
             nodeCalcObj.field = field;
-            node.data.feesIndex[field.type].totalFee = nodeCalcObj.sumTotalFee().toDecimal(this.project.Decimal.common.totalFee);
+            let value = nodeCalcObj.sumTotalFee().toDecimal(this.project.Decimal.common.totalFee);
+            this.setTotalFee(node, field, value, isIncre);
         }
         }
     };
     };
-    calcNode(node) {
+    calcNode(node, isIncre) {
         if (node.source.children.length > 0) {
         if (node.source.children.length > 0) {
-            this.calcParent(node, this.project.calcFields);
+            this.calcParent(node, this.project.calcFields, isIncre);
         } else {
         } else {
             if (node.children.length > 0) {
             if (node.children.length > 0) {
                 if (node.firstChild().sourceType === this.project.Ration.getSourceType()) {
                 if (node.firstChild().sourceType === this.project.Ration.getSourceType()) {
-                    this.calcRationLeaf(node, this.project.calcFields);
+                    this.calcRationLeaf(node, this.project.calcFields, isIncre);
                 } else {
                 } else {
-                    this.calcVolumePriceLeaf(node, this.project.calcFields);
+                    this.calcVolumePriceLeaf(node, this.project.calcFields, isIncre);
                 }
                 }
             } else {
             } else {
 
 
             }
             }
         }
         }
-    }
+    };
     calcNodes (nodes) {
     calcNodes (nodes) {
         for (let node of nodes) {
         for (let node of nodes) {
             if (node.sourceType !== this.project.Bills.getSourceType()) {
             if (node.sourceType !== this.project.Bills.getSourceType()) {
@@ -329,6 +331,22 @@ class BillsCalcHelper {
             this.calcNode(node);
             this.calcNode(node);
         }
         }
     };
     };
+    updateParent (parent, field, Incre) {
+        if (parent && parent.sourceType === this.project.Bills.getSourceType()) {
+            calcFees.checkFields(parent.data, [field]);
+            parent.data.feesIndex[field.type].totalFee = (parent.data.feesIndex[field.type].totalFee + Incre).toDecimal(this.project.Decimal.common.totalFee);
+            this.updateParent(parent.parent, field, Incre);
+        }
+    };
+    setTotalFee (node, field, value, isIncre) {
+        if (isIncre) {
+            let incre = value - node.data.feesIndex[field.type].totalFee;
+            node.data.feesIndex[field.type].totalFee = value;
+            this.updateParent(node.parent, field, incre);
+        } else {
+            node.data.feesIndex[field.type].totalFee = value;
+        }
+    };
     converseCalc (node) {
     converseCalc (node) {
         if (node && node.sourceType === this.project.Bills.getSourceType()) {
         if (node && node.sourceType === this.project.Bills.getSourceType()) {
             this.calcNode(node);
             this.calcNode(node);

+ 24 - 2
web/building_saas/main/js/models/bills.js

@@ -32,6 +32,20 @@ var Bills = {
                     updateDatas.push(updateData);
                     updateDatas.push(updateData);
                 });
                 });
                 return updateDatas;
                 return updateDatas;
+            },
+            formatBillsUpdateData: function (data) {
+                let uData = JSON.parse(JSON.stringify(data));
+                delete uData.feesIndex;
+                delete uData.flagsIndex;
+                if (uData.fees) {
+                    for (let fee of uData.fees) {
+                        fee.unitFee = fee.unitFee.toFixed(2);
+                        fee.totalFee = fee.totalFee.toFixed(2);
+                        fee.tenderUnitFee = fee.tenderUnitFee.toFixed(2);
+                        fee.tenderTotalFee = fee.tenderTotalFee.toFixed(2);
+                    }
+                }
+                return uData;
             }
             }
         };
         };
 
 
@@ -254,10 +268,18 @@ var Bills = {
                         fee.tenderTotalFee = fee.tenderTotalFee.toFixed(2);
                         fee.tenderTotalFee = fee.tenderTotalFee.toFixed(2);
                     }
                     }
                 }
                 }
-                updateData.push({'updateType': 'ut_update', 'updateData': data});
+                updateData.push({'updateType': 'ut_update', 'updateData': uData});
             }
             }
             this.project.pushNow('updateAllBills', this.getSourceType(), updateData);
             this.project.pushNow('updateAllBills', this.getSourceType(), updateData);
-        }
+        };
+
+        bills.prototype.updateNodes = function (nodes) {
+            let updateData = [];
+            for (let node of nodes) {
+                updateData.push({'updateType': 'ut_update', 'updateData': tools.formatBillsUpdateData(node.data)});
+            }
+            this.project.pushNow('updateBills', this.getSourceType(), updateData);
+        };
 
 
         return new bills(project);
         return new bills(project);
     }
     }

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

@@ -306,7 +306,9 @@ var projectObj = {
                 "spr2":'--------',
                 "spr2":'--------',
                 "calculateAll_RationContent": {
                 "calculateAll_RationContent": {
                     name: '造价计算',
                     name: '造价计算',
-                    callback: projectObj.calculateAll
+                    callback: function () {
+                        projectObj.calculateAll();
+                    }
                 }
                 }
             }
             }
         });
         });
@@ -314,13 +316,14 @@ var projectObj = {
     // 计算node及node的所有父项
     // 计算node及node的所有父项
     converseCalculateBills: function (node) {
     converseCalculateBills: function (node) {
         let calc = new BillsCalcHelper(this.project);
         let calc = new BillsCalcHelper(this.project);
-        calc.converseCalc(node, this.project.calcFields);
+        calc.calcNode(node, true);
         let cur = node, nodes = [];
         let cur = node, nodes = [];
         while (cur) {
         while (cur) {
             nodes.push(cur);
             nodes.push(cur);
             cur = cur.parent;
             cur = cur.parent;
         }
         }
         this.mainController.refreshTreeNode(nodes, false);
         this.mainController.refreshTreeNode(nodes, false);
+        this.project.Bills.updateNodes(nodes);
         calc = null;
         calc = null;
     },
     },
     // 计算全部清单
     // 计算全部清单