Explorar o código

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

chenshilong %!s(int64=7) %!d(string=hai) anos
pai
achega
3170d04017

+ 1 - 0
config/gulpConfig.js

@@ -141,6 +141,7 @@ module.exports = {
         'web/building_saas/main/js/views/tender_price_view.js',
         'web/building_saas/main/js/views/sub_view.js',
         'web/building_saas/main/js/views/fee_rate_view.js',
+        'web/building_saas/main/js/views/quantity_edit_view.js',
         'web/building_saas/main/js/views/sub_fee_rate_views.js',
         'web/building_saas/main/js/views/calc_base_view.js',
         'web/building_saas/main/js/views/project_property_labour_coe_view.js',

+ 40 - 18
public/web/sheet/sheet_common.js

@@ -545,26 +545,48 @@ var sheetCommonObj = {
         workBook.commandManager().setShortcutKey('myEnter', GC.Spread.Commands.Key.enter, false, false, false, false);
     },
     //解决esc后触发了编辑结束的保存事件,显示与实际数据不同问题
-    bindEscKey: function (workBook, editStarting = null, editEnded = null) {
-        let sheet = workBook.getActiveSheet();
+    bindEscKey: function (workBook, sheets) {
+        function isDef(v){
+            return typeof v !== 'undefined' && v !== null;
+        }
         workBook.commandManager().register('myEsc', function () {
-            sheet.unbind(GC.Spread.Sheets.Events.EditStarting);
-            sheet.unbind(GC.Spread.Sheets.Events.EditEnded);
-            let row = sheet.getActiveRowIndex();
-            let col = sheet.getActiveColumnIndex();
-            let orgV = sheet.getValue(row, col);
-            if(!isDef(orgV)){
-                orgV = '';
-            }
-            if(sheet.isEditing()){
-                sheet.endEdit();
-                sheet.setValue(row, col, orgV);
-            }
-            if(editStarting){
-                sheet.bind(GC.Spread.Sheets.Events.EditStarting, editStarting);
+            let activeSheet = workBook.getActiveSheet();
+            let hasTheSheet = false;
+            for(let sheetObj of sheets){
+                let sheet = sheetObj.sheet;
+                if(sheet === activeSheet){
+                    hasTheSheet = true;
+                    let editStarting = sheetObj.editStarting;
+                    let editEnded = sheetObj.editEnded;
+                    if(editStarting){
+                        sheet.unbind(GC.Spread.Sheets.Events.EditStarting);
+                    }
+                    if(editEnded){
+                        sheet.unbind(GC.Spread.Sheets.Events.EditEnded);
+                    }
+                    let row = sheet.getActiveRowIndex();
+                    let col = sheet.getActiveColumnIndex();
+                    let orgV = sheet.getValue(row, col);
+                    if(!isDef(orgV)){
+                        orgV = '';
+                    }
+                    if(sheet.isEditing()){
+                        sheet.endEdit();
+                        sheet.setValue(row, col, orgV);
+                    }
+                    if(editStarting){
+                        sheet.bind(GC.Spread.Sheets.Events.EditStarting, editStarting);
+                    }
+                    if(editEnded){
+                        sheet.bind(GC.Spread.Sheets.Events.EditEnded, editEnded);
+                    }
+                }
             }
-            if(editEnded){
-                sheet.bind(GC.Spread.Sheets.Events.EditEnded, editEnded);
+            //容错处理,以防没把所有工作簿的表格信息传入参数
+            if(!hasTheSheet){
+                if(activeSheet.isEditing()){
+                    activeSheet.endEdit();
+                }
             }
         });
         workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.esc, false, false, false, false);

+ 8 - 1
web/building_saas/complementary_ration_lib/html/dinge.html

@@ -553,9 +553,16 @@
 
         rationCoeOprObj.buildSheet(rdSpread.getSheet(2));
 
+        rationInstObj.buildSheet(rdSpread.getSheet(3));
         rationInstObj.getInstallation(parseInt(getQueryString("repository")), function () {
-            rationInstObj.buildSheet(rdSpread.getSheet(3));
+            //rationInstObj.buildSheet(rdSpread.getSheet(3));
         });
+        let rdSpreadEscSheets = [];
+        rdSpreadEscSheets.push({sheet: rdSpread.getSheet(0), editStarting: rationGLJOprObj.onEditStarting, editEnded: rationGLJOprObj.onCellEditEnd});
+        rdSpreadEscSheets.push({sheet: rdSpread.getSheet(1), editStarting: rationAssistOprObj.onEditStarting, editEnded: rationAssistOprObj.onEditEnded});
+        rdSpreadEscSheets.push({sheet: rdSpread.getSheet(2), editStarting: rationCoeOprObj.onEditStarting, editEnded: rationCoeOprObj.onEditEnded});
+        rdSpreadEscSheets.push({sheet: rdSpread.getSheet(3), editStarting: rationInstObj.onEditStarting, editEnded: rationInstObj.onEditEnded});
+        sheetCommonObj.bindEscKey(rdSpread, rdSpreadEscSheets);
         pageOprObj.initPage();
 
         $("#linkGLJ").click(function(){

+ 1 - 0
web/building_saas/complementary_ration_lib/js/ration.js

@@ -41,6 +41,7 @@ let rationOprObj = {
         let rationRepId = getQueryString("repository");
         let me = rationOprObj;
         me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30);
+        sheetCommonObj.bindEscKey(me.workBook, [{sheet: me.workBook.getSheet(0), editStarting: me.onCellEditStart, editEnded: me.onCellEditEnd}]);
         me.getRationsCodes(rationRepId);
         me.onContextmenuOpr();
         me.rationDelOpr();

+ 1 - 0
web/building_saas/complementary_ration_lib/js/section_tree.js

@@ -143,6 +143,7 @@ let sectionTreeObj = {
     buildSheet: function () {
         if(!this.isDef(this.workBook)){
             this.workBook = new GC.Spread.Sheets.Workbook($('#sectionSpread')[0], {sheetCount: 1});
+            sheetCommonObj.bindEscKey(this.workBook, [{sheet: this.workBook.getSheet(0), editStarting: this.onEditStarting, editEnded: this.onEditEnded}]);
             this.sheet = this.workBook.getSheet(0);
             this.bindEvents(this.sheet);
             this.setOptions(this.workBook, this.setting.options);

+ 4 - 0
web/building_saas/js/global.js

@@ -129,3 +129,7 @@ function getFeeIndex(fees) {
     return feesIndex;
 }
 
+function replaceAll(FindText, RepText,str) {
+    let regExp = new RegExp(FindText, "g");
+    return str.replace(regExp, RepText);
+};

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 39 - 0
web/building_saas/main/html/main.html


+ 1 - 1
web/building_saas/main/js/controllers/block_controller.js

@@ -565,7 +565,7 @@ let BlockController = {
                 billsQuantity?ration.contain = scMathUtil.roundForObj(ration.quantity/billsQuantity,getDecimal("process")):ration.contain = 0;
             } else {//如果定额的工程量是通过计算出来的,则应该重新计算。
                 let tem_contain = scMathUtil.roundForObj(ration.contain,getDecimal("process"));
-                let tem_quantity = scMathUtil.roundForObj(billsQuantity*tem_contain,getDecimal("ration.quantity")); //this.autoTransformQuantity(tem_quantity,rationNode);
+                let tem_quantity = scMathUtil.roundForObj(billsQuantity*tem_contain,getDecimal("ration.quantity"));
                 ration.quantity = tem_quantity;
             }
         }else {//GCLMXHJ

+ 23 - 23
web/building_saas/main/js/models/quantity_detail.js

@@ -288,8 +288,9 @@ var quantity_detail = {
             me.commonUpdate("/quantity_detail/swapRow",update_task);
         };
         quantity_detail.prototype.replaceAll=function(FindText, RepText,str) {
-            let regExp = new RegExp(FindText, "g");
-            return str.replace(regExp, RepText);
+            /*let regExp = new RegExp(FindText, "g");
+            return str.replace(regExp, RepText);*/
+            return replaceAll(FindText, RepText,str);
         };
 
         quantity_detail.prototype.calcResult = function (doc) {//return false 代表输入有误
@@ -376,14 +377,16 @@ var quantity_detail = {
             var selected = selected?selected:projectObj.project.mainTree.selected;
             doc[dataCode]=args.editingText;
             if (dataCode == 'regex') {
-                if(this.checkAndCalcResult(args.editingText,args.row,doc) === false){
-                    gljOprObj.showQuantityDetailData();
-                    return;
-                }
                 if(recode.hasOwnProperty('rationID')){
                     query.rationID=recode.rationID;
+                    doc.rationID=recode.rationID;
                 }else {
-                    query.billID = recode.billID
+                    query.billID = recode.billID;
+                    doc.billID=recode.billID;
+                }
+                if(this.checkAndCalcResult(args.editingText,args.row,doc) === false){
+                    gljOprObj.showQuantityDetailData();
+                    return;
                 }
                 query.refreshQuantity=true;
                 if(!selected.data.hasOwnProperty('isFromDetail')||selected.data.isFromDetail==0){
@@ -651,14 +654,15 @@ var quantity_detail = {
         quantity_detail.prototype.autoTransformQuantity = function(value,node){//根据单位转换定额工程量
             let data = node.data;
             let option = optionsOprObj.getOption(optionsOprObj.optionsTypes.GENERALOPTS,'rationQuanACToRationUnit');
-            if(node.data.quantityEXP=='GCLMXHJ'||(option==true&&node.sourceType === project.Ration.getSourceType()&&data.unit)) {//还需加入判读是否转换,如果是来自工程量明细的话,默认都进行转换
+            if(node.data.quantityEXP=='GCLMXHJ'||node.data.quantityEXP.indexOf('QDL')!=-1||(option==true&&node.sourceType === project.Ration.getSourceType()&&data.unit)) {
+                //还需加入判读是否转换,如果是来自工程量明细或者包含了表达式中包含了清单量的话,默认都进行转换
                 let times = parseInt(data.unit);
                 if (isNaN(times)) {
                     times = 1
                 }
                 value = value / times;
             }
-            let EXPString=node.data.quantityEXP+"";
+      /*      let EXPString=node.data.quantityEXP+""; 这里现在都没用到了
             if(option==false&&node.sourceType === project.Ration.getSourceType()&&EXPString!='GCLMXHJ'&&EXPString.indexOf("QDL")==-1&&data.unit){//勾选不根据单位转换工程量,且定额是手输的,
                 let times = parseInt(data.unit);
                 if(!isNaN(times)){///如果定额单位可以做转换
@@ -675,7 +679,7 @@ var quantity_detail = {
                        billQuantity!=0?node.data.contain = scMathUtil.roundForObj(temValue/billQuantity,getDecimal("process")):'';
                     }
                 }
-            }
+            }*/
             return value;
         };
         quantity_detail.prototype.reverseQuantity = function (value,node) {//根据单位反向运算出工程量
@@ -729,25 +733,21 @@ var quantity_detail = {
             if(node.children.length>0){//如果有子项
                 for(let rationNode of node.children){
                     let EXPString = rationNode.data.quantityEXP+"";
-                    if(EXPString.indexOf("QDL")!=-1){
-                        if(EXPString=="QDL"){//定额的工程量是直接通过清单量填进来的;
+                    if(EXPString.indexOf("QDL")!=-1){//包含了清单量的定额才要再重新计算
+                        let ration_value = quantityEditObj.evalQuantityExp(EXPString,rationNode);
+                        if(ration_value !== 'evalError'){
                             let times = parseInt(rationNode.data.unit);
                             if(isNaN(times)){
                                 times = 1;
                             }
-                            rationNode.data.quantity = scMathUtil.roundForObj(value / times,getDecimal("quantity",rationNode));
+                            rationNode.data.quantity = scMathUtil.roundForObj(ration_value / times,getDecimal("quantity",rationNode));
                             rationNode.data.contain = scMathUtil.roundForObj(rationNode.data.quantity/value,getDecimal("process"));
-                        }else {//如果定额的工程量是通过计算出来的,则应该重新计算。
-                            let tem_contain = scMathUtil.roundForObj(rationNode.data.contain,getDecimal("process"));
-                            let tem_quantity = scMathUtil.roundForObj(value*tem_contain,getDecimal("quantity",rationNode)); //this.autoTransformQuantity(tem_quantity,rationNode);
-                            rationNode.data.quantity = tem_quantity;
-                        }
-                        rationNode.changed = true;
-                        needUpdateChildren.push(rationNode);
-                        if (rationNode.children.length>0){//如果有子工料机
-                            gljNodes = gljNodes.concat(rationNode.children);
+                            needUpdateChildren.push(rationNode);
+                            if (rationNode.children.length>0){//如果有子工料机
+                                gljNodes = gljNodes.concat(rationNode.children);
+                            }
                         }
-                    }else {
+                    }else {//如果不是通过清单量计算得来的定额工程量,则重新计算含量
                         let tem_contain=0;
                         if(value&&value!=0){
                            let children_quantity = scMathUtil.roundForObj(rationNode.data.quantity,getDecimal("quantity",rationNode));

+ 6 - 5
web/building_saas/main/js/views/installation_fee_view.js

@@ -589,16 +589,17 @@ let installationFeeObj={
         me.modifyFeeRuleSheet.bind(GC.Spread.Sheets.Events.EditStarting, this.onModifyFeeRuleEditStarting);
         this.modifyFeeRuleSheet.name('modifyFeeRuleSheet');
     },
+    rationInstSheeteditChecking: function (sender, args) {
+        if(args.row>=installationFeeObj.rationInstallData.length){
+            args.cancel = true;
+        }
+    },
     initRationInstallSheet:function (sheet) {
         let me = this;
         this.rationInstallSheet = sheet;
         this.initSheet( this.rationInstallSheet,this.rationInstallSetting);
         sheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.onRationSheetSelectionChange);
-        sheet.bind(GC.Spread.Sheets.Events.EditStarting, function (sender, args) {
-           if(args.row>=me.rationInstallData.length){
-               args.cancel = true;
-           }
-        });
+        sheet.bind(GC.Spread.Sheets.Events.EditStarting, this.rationInstSheeteditChecking);
         this.rationInstallSheet.name("rationInstallSheet");
     },
     onRationSheetSelectionChange: function (sender, args) {

+ 5 - 1
web/building_saas/main/js/views/main_tree_col.js

@@ -230,7 +230,11 @@ let MainTreeCol = {
         feeRate: function () {
             return feeRateObject.getFeeRateEditCellType();
         },
-
+        quantity:function (node) {
+            if(!MainTreeCol.readOnly.forQuantity(node)){
+              return  quantityEditObj.getQuantityEditCellType();
+            }
+        },
         calcBase: function () {
             return calcBaseView.getCalcBaseCellType('bills');
         },

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

@@ -44,6 +44,10 @@ var projectObj = {
             pageCCOprObj.mainActiveCell = projectObj.mainSpread.getActiveSheet().getSelections()[0];//mainSpread焦点单元格
             pageCCOprObj.setCacheAndShow(node);
         }
+
+        let acSheet = subSpread.getActiveSheet();
+
+        console.log(acSheet.name());
         // for test interface.  CSLAAAAA
         // projectObj.testDisplay('前四项累计值排除当前选中项' + projectObj.project.calcProgram.getBeforeTaxTotalFee([node]));
 
@@ -204,7 +208,7 @@ var projectObj = {
         return value;
     },
     checkSpreadEditingText: function (editingText, colSetting) {
-        if (colSetting.data.field === 'quantity'||colSetting.data.field === 'contain') {
+        if (colSetting.data.field === 'contain') {//colSetting.data.field === 'quantity'
             return this.checkFormulaValidField(editingText, colSetting);
         }
         else if (colSetting.data.field === 'programID') {
@@ -441,7 +445,8 @@ var projectObj = {
             else if (fieldName === 'quantity' || fieldName === 'marketUnitFee' || fieldName === 'feesIndex.common.unitFee' || fieldName === 'programID' ||
                 fieldName === 'subType' || fieldName === 'calcBase' || fieldName === 'isSubcontract'){
                 if (fieldName === 'quantity') {
-                    project.quantity_detail.editMainTreeNodeQuantity(value,node,fieldName,editingText);
+                    quantityEditObj.checkingAndUpdate(editingText,node);
+                   // project.quantity_detail.editMainTreeNodeQuantity(value,node,fieldName,editingText);
                     return;
                 }
                 else if (fieldName === 'marketUnitFee' || fieldName === 'feesIndex.common.unitFee') {
@@ -537,6 +542,9 @@ var projectObj = {
             }
             info.sheet.setValue(info.row, info.col, newV);
         }
+        if(node&&fieldName =='quantity'&&(node.data.quantityEXP !==null||node.data.quantityEXP !==undefined)){
+            info.sheet.setValue(info.row, info.col, node.data.quantityEXP);
+        }
     },
     onCellDoubleClick: function (sender, info){
         let project = projectObj.project;
@@ -548,7 +556,6 @@ var projectObj = {
                 return;
             }
         }
-
     },
     onColumnWidthChanged: function (sender, info) {
         projectObj.mainSpread.getActiveSheet().setColumnVisible(4, false);
@@ -703,17 +710,17 @@ var projectObj = {
                 if(!projectReadOnly){
                     sheetCommonObj.bindEnterKey(that.mainSpread, that.mainSpreadEnterKey);
                 }
-                sheetCommonObj.bindEscKey(that.mainSpread, that.mainSpreadEditStarting, that.mainSpreadEditEnded);
+                sheetCommonObj.bindEscKey(that.mainSpread, [{sheet: that.mainSpread.getSheet(0), editStarting: that.mainSpreadEditStarting, editEnded: that.mainSpreadEditEnded}]);
                 setTimeout(function () {
                     that.mainSpread.getActiveSheet().startEdit();//这两句需要挺多时间,而又需要在editend 事件前触发,而这些又不影响计算,所以这里用异步的方法
                     that.mainSpread.getActiveSheet().endEdit();
 
                     that.mainSpread.bind(GC.Spread.Sheets.Events.EditEnded, that.mainSpreadEditEnded);
+                    that.mainSpread.bind(GC.Spread.Sheets.Events.EditStarting, that.mainSpreadEditStarting);
                 },100);
                 that.mainSpread.bind(GC.Spread.Sheets.Events.SelectionChanged, that.amountAreaNumber);//选中统计专用,节点相关操作在treeSelectedChanged里些
                 that.mainSpread.bind(GC.Spread.Sheets.Events.LeaveCell, that.mainSpreadLeaveCell);
                 that.mainSpread.bind(GC.Spread.Sheets.Events.EnterCell, that.mainSpreadEnterCell);
-                that.mainSpread.bind(GC.Spread.Sheets.Events.EditStarting, that.mainSpreadEditStarting);
 
                 that.mainSpread.bind(GC.Spread.Sheets.Events.RangeChanged, that.mainSpreadRangeChanged);
                 that.mainSpread.bind(GC.Spread.Sheets.Events.ClipboardChanged, that.msClipboardChanged);

+ 247 - 0
web/building_saas/main/js/views/quantity_edit_view.js

@@ -0,0 +1,247 @@
+/**
+ * Created by zhang on 2018/7/20.
+ */
+let quantityEditObj = {
+    spread:null,
+    datas:[],
+    setting:{
+        header:[
+            {headerName: "基数名称", headerWidth: 250, dataCode: "name", dataType: "String"},
+            {headerName: "代码", headerWidth: 150, dataCode: "code", dataType: "String"},
+        ],
+        view: {
+            lockColumns: [0,1]
+        }
+    },
+    initSpread:function () {
+        if(!this.spread){
+            this.spread = SheetDataHelper.createNewSpread($("#quantityEditSpread")[0]);
+            this.initSheet();
+        }
+        this.showData();
+    },
+    initSheet:function () {
+        this.sheet = this.spread .getSheet(0);
+        sheetCommonObj.initSheet( this.sheet, this.setting, 30);
+        this.sheet.bind(GC.Spread.Sheets.Events.CellDoubleClick,this.onCellDoubleClick);
+        this.sheet.name('quantityEdit');
+        // console.log(cell.value());
+    },
+    showData:function () {
+        this.datas = [];//{name:'工程量明细合计',code:'GCLMXHJ'}这里暂时只有清单量一个选项
+        let selected = projectObj.project.mainTree.selected;
+        if(selected.sourceType == ModuleNames.ration){
+            this.datas.push({name:'清单量',code:'QDL'});
+        }
+        sheetCommonObj.showData(this.sheet, this.setting,this.datas);
+        this.sheet.setRowCount(this.datas.length);
+
+    },
+    onCellDoubleClick:function (e,info) {
+        if(quantityEditObj.datas[info.row]){
+            let oldVal = $("#quantityEXPValue").val();
+            $("#quantityEXPValue").val(oldVal+quantityEditObj.datas[info.row].code);
+            $("#quantityEXPValue").focus();
+        }
+    },
+    getQuantityEditCellType:function () {
+        var ns = GC.Spread.Sheets;
+        function QuantityEditCellType() {
+            var init=false;
+        }
+        QuantityEditCellType.prototype = new ns.CellTypes.Text();
+        QuantityEditCellType.prototype.paint = function (ctx, value, x, y, w, h, style, options) {
+            // if(value!=null){
+            // ctx.fillText(value,x+3+ctx.measureText(value).width,y+h-3);
+            // }
+            GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, arguments);
+            if(quantityEditObj.editingCell && !projectReadOnly){
+                if(quantityEditObj.editingCell.row==options.row&&quantityEditObj.editingCell.col==options.col){
+                    var image = document.getElementById('f_btn'),imageMagin = 3;
+                    var imageHeight = h-2*imageMagin;
+                    var imageWidth = w*2/7;
+                    var imageX = x + w - imageWidth- imageMagin, imageY = y + h / 2 - imageHeight / 2;
+                    ctx.save();
+                    ctx.drawImage(image, imageX, imageY,imageWidth,imageHeight);
+                    ctx.beginPath();
+                    ctx.arc(imageX+imageWidth/2,imageY+imageHeight/2,1,0,360,false);
+                    ctx.arc(imageX+imageWidth/2-4,imageY+imageHeight/2,1,0,360,false);
+                    ctx.arc(imageX+imageWidth/2+4,imageY+imageHeight/2,1,0,360,false);
+                    ctx.fillStyle="black";//填充颜色,默认是黑色
+                    ctx.fill();//画实心圆
+                    ctx.closePath();
+                    ctx.restore();
+                }
+            }
+
+        };
+        QuantityEditCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
+            return {
+                x: x,
+                y: y,
+                row: context.row,
+                col: context.col,
+                cellStyle: cellStyle,
+                cellRect: cellRect,
+                sheetArea: context.sheetArea
+            };
+        };
+        QuantityEditCellType.prototype.processMouseDown = function (hitinfo) {
+            var me=quantityEditObj;
+            me.pmLeave = false;
+            if(me.editingCell==null){
+                var showSelectBtn = true;
+                if(showSelectBtn){
+                    me.editingCell={
+                        row:hitinfo.row,
+                        col:hitinfo.col
+                    }
+                    hitinfo.sheet.invalidateLayout();
+                    hitinfo.sheet.repaint();
+                }
+            }else if(hitinfo.row==me.editingCell.row){
+                var offset=hitinfo.cellRect.x+hitinfo.cellRect.width-6;
+                var imageMagin=3;
+                var imageHeight = hitinfo.cellRect.height-2*imageMagin;
+                var imageWidth = hitinfo.cellRect.width*2/7;
+                if(hitinfo.x<offset&&hitinfo.x>offset-imageWidth){
+                    if(!projectReadOnly){
+                        me.showSelectModal(hitinfo);
+                    }
+                }
+            }
+        };
+        QuantityEditCellType.prototype.processMouseEnter = function (hitinfo) {
+            let text = hitinfo.sheet.getText(hitinfo.row, hitinfo.col);
+            let tag = hitinfo.sheet.getTag(hitinfo.row, hitinfo.col);
+            let dataField = "quantity";
+
+            if(hitinfo.sheet.getCell(hitinfo.row,hitinfo.col).wordWrap()==true){
+                return;
+            }
+            if(dataField=="quantity"){
+                text = tag;
+            }else if(tag !== undefined && tag) {
+                text = tag;
+            }
+            if (text && text !== '') {
+                if (!this._toolTipElement) {
+                    let div = $('#autoTip')[0];
+                    if (!div) {
+                        div = document.createElement("div");
+                        $(div).css("position", "absolute")
+                            .css("border", "1px #C0C0C0 solid")
+                            .css("box-shadow", "1px 2px 5px rgba(0,0,0,0.4)")
+                            .css("font", "9pt Arial")
+                            .css("background", "white")
+                            .css("padding", 5)
+                            .attr("id", 'autoTip');
+                        $(div).hide();
+                        document.body.insertBefore(div, null);
+                    }
+                    this._toolTipElement = div;
+                    $(this._toolTipElement).text(text);
+                    let cellRect =  hitinfo.sheet.getCellRect(hitinfo.row,hitinfo.col);
+                    $(this._toolTipElement).css("top", cellRect.y+$('#main').offset().top+cellRect.height).css("left",  hitinfo.x );//
+
+                    $(this._toolTipElement).show("fast");
+                    TREE_SHEET_HELPER.tipDiv = 'show';//做个标记
+                }
+            }
+        };
+        QuantityEditCellType.prototype.processMouseLeave = function (hitinfo) {
+            if(!quantityEditObj.pmLeave){
+                quantityEditObj.editingCell=null;
+                hitinfo.sheet.invalidateLayout();
+                hitinfo.sheet.repaint();
+                quantityEditObj.pmLeave = true;
+            }
+            let me = this;
+            TREE_SHEET_HELPER.tipDiv = 'hide';
+            if (me._toolTipElement) {
+                $(me._toolTipElement).hide();
+                me._toolTipElement = null;
+            };
+            TREE_SHEET_HELPER.tipDivCheck();//延时检查:当tips正在show的时候,就调用了hide方法,会导致tips一直存在,所以设置一个超时处理
+        };
+        return new QuantityEditCellType();
+    },
+    showSelectModal:function (hitinfo) {
+        //锁定的清单不显示
+        let project = projectObj.project;
+        if(project.isBillsLocked() && project.withinBillsLocked(project.mainTree.selected)){
+            return;
+        }
+        $("#quantityEXPEdit").modal({show:true});
+    },
+    checkingAndUpdate(quantityEXP,node){
+        let me = this;
+        quantityEXP = quantityEXP.toUpperCase();
+        if(quantityEXP === node.data.quantityEXP){ //没有变化,不做任何操作
+            projectObj.mainController.refreshTreeNode([node]);
+            return;
+        }
+        let value = me.evalQuantityExp(quantityEXP,node);
+        if(value!=='evalError'){
+            if(node.data.hasOwnProperty('isFromDetail')&&node.data.isFromDetail==1){
+                hintBox.infoBox('操作确认', '已有工程量明细,是否清空明细表,采用手工输入的表达式?', 2, function () {
+                    node.data.isFromDetail=0;
+                    me.updateQuantityEXP(value,quantityEXP,node);
+                }, function () {
+                    projectObj.mainController.refreshTreeNode([node]);
+                },['确定','取消'],false);
+                return;
+            }
+            me.updateQuantityEXP(value,quantityEXP,node);
+        }else {
+            projectObj.mainController.refreshTreeNode([node]);
+        }
+    },
+    evalQuantityExp(quantityEXP,node){
+        let evalString = quantityEXP;
+        if( node.sourceType == ModuleNames.ration && quantityEXP.indexOf('QDL')!=-1){
+            let billNode = node.parent;
+            let bQuantity = billNode.data.quantity?scMathUtil.roundForObj(billNode.data.quantity,getDecimal("quantity",billNode)):0;
+            evalString = replaceAll("QDL","("+bQuantity+")",evalString);
+        }
+        try {
+            let value = eval(evalString);
+            return value;
+        }catch (error){
+            alert("输入的表达式有误,请重新输入!");
+            return "evalError"
+        }
+    },
+    updateQuantityEXP:function (value,quantityEXP,node) {
+        let quantity_detail = projectObj.project.quantity_detail;
+        quantity_detail.cleanQuantityDetail(node,true);
+        if(node.sourceType === ModuleNames.bills){
+            quantity_detail.updateBillQuantity(value,node,quantityEXP,quantityEXP);
+            //me.updateBillQuantity(value,node,null,editingText);
+        }else {
+            quantity_detail.updateRationQuantity(value,node,quantityEXP,quantityEXP);
+        }
+    }
+
+};
+$(function(){
+    $('#quantityEXPEdit').on('shown.bs.modal', function (e) {
+        let selected = projectObj.project.mainTree.selected;
+        $("#quantityEXPValue").val(selected.data.quantityEXP);
+        quantityEditObj.initSpread();
+    });
+
+    $('#operation_p').children("button").bind('click',function (){
+        let oldVal = $("#quantityEXPValue").val();
+        $("#quantityEXPValue").val(oldVal+$(this).text());
+        $("#quantityEXPValue").focus();
+    })
+
+    $("#quantityEditConf").bind('click',function () {
+        let selected = projectObj.project.mainTree.selected;
+        quantityEditObj.checkingAndUpdate($("#quantityEXPValue").val(),selected);
+        $("#quantityEXPEdit").modal('hide');
+    })
+
+
+});

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

@@ -11,7 +11,9 @@ let subSpread = null;
 let subObj = {
     initSubSpread:function () {
         contentOprObj.buildSheet($("#jobSpread")[0]);
+        sheetCommonObj.bindEscKey(contentOprObj.workBook, [{sheet: contentOprObj.workBook.getSheet(0), editStarting: contentOprObj.onEditStart, editEnded: contentOprObj.onEditEnded}]);
         characterOprObj.buildSheet($("#itemSpread")[0]);
+        sheetCommonObj.bindEscKey(characterOprObj.workBook, [{sheet: characterOprObj.workBook.getSheet(0), editStarting: characterOprObj.onEditStart, editEnded: characterOprObj.onEditEnded}]);
         $("#tzjnrCon").hide();
         $("#subSpread").show();
         subSpread = sheetCommonObj.createSpread($("#subSpread")[0], 4);
@@ -40,6 +42,13 @@ let subObj = {
         installationFeeObj.initRationInstallSheet(subSpread.getSheet(3));
         SheetDataHelper.protectdSheet(subSpread.getSheet(3));
 
+        //绑定esc
+        let subEscSheets = [];
+        subEscSheets.push({sheet: subSpread.getSheet(0), editStarting: gljOprObj.editChecking, editEnded: gljOprObj.onEditEnded});//定额工料机
+        subEscSheets.push({sheet: subSpread.getSheet(1), editStarting: gljOprObj.editChecking, editEnded: gljOprObj.onEditEnded});//工程量明细
+        subEscSheets.push({sheet: subSpread.getSheet(3), editStarting: installationFeeObj.rationInstSheeteditChecking, editEnded: null});//定额安装增加费
+        sheetCommonObj.bindEscKey(subSpread, subEscSheets);
+
         if(projectReadOnly){
             disableSpread(subSpread);
             disableSpread(contentOprObj.workBook);