|  | @@ -8,6 +8,8 @@ var gljOprObj = {
 | 
	
		
			
				|  |  |      ration: null,
 | 
	
		
			
				|  |  |      sheetData: [],
 | 
	
		
			
				|  |  |      checkb: null,
 | 
	
		
			
				|  |  | +    rationGljEditObj:null,//编辑定额工料机还没提交的缓存数据
 | 
	
		
			
				|  |  | +    cancelUpdate:true,
 | 
	
		
			
				|  |  |      mainTreeSelectedChange:false,
 | 
	
		
			
				|  |  |      detailSheet: null,
 | 
	
		
			
				|  |  |      detailData: [],
 | 
	
	
		
			
				|  | @@ -106,13 +108,44 @@ var gljOprObj = {
 | 
	
		
			
				|  |  |          subSpread.bind(GC.Spread.Sheets.Events.ButtonClicked, me.onButtonClick);
 | 
	
		
			
				|  |  |          if(!projectReadOnly){
 | 
	
		
			
				|  |  |              gljContextMenu.loadGLJSpreadContextMenu();
 | 
	
		
			
				|  |  | -            //me.bindGLJEnterKey(subSpread,sheet);
 | 
	
		
			
				|  |  | +            me.bindGLJEnterKey(subSpread,sheet);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        sheet.bind(GC.Spread.Sheets.Events.SelectionChanged,function (sender,args) {
 | 
	
		
			
				|  |  | -            let selected = args.newSelections[0] ? args.newSelections[0] : {row: 0, col: 0};
 | 
	
		
			
				|  |  | -            me.sheetInitSelection(selected);
 | 
	
		
			
				|  |  | +        sheet.bind(GC.Spread.Sheets.Events.SelectionChanged,me.onRationGLJSelectionChange);
 | 
	
		
			
				|  |  | +        sheet.bind(GC.Spread.Sheets.Events.CellClick,function () {
 | 
	
		
			
				|  |  | +            //这里主要记录是否点击了sheet以外的地方,如果点击了sheet里的单元格,则将cancelUpdate设置为true不触发提交更新操作
 | 
	
		
			
				|  |  | +            me.cancelUpdate = true;//取消延时任务由selection change 事件处理
 | 
	
		
			
				|  |  |          });
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  | +    onRationGLJSelectionChange:function(sender,args){
 | 
	
		
			
				|  |  | +        let me = gljOprObj;
 | 
	
		
			
				|  |  | +        let selected = args.newSelections[0] ? args.newSelections[0] : {row: 0, col: 0};
 | 
	
		
			
				|  |  | +        console.log("selected changed-------");
 | 
	
		
			
				|  |  | +        //这主要记录是否点击了sheet以外的地方,如果点击了sheet里的单元格,则将cancelUpdate设置为true不触发提交更新操作
 | 
	
		
			
				|  |  | +        me.cancelUpdate = true;//取消延时任务由这里进行判断处理
 | 
	
		
			
				|  |  | +        console.log("change to true");
 | 
	
		
			
				|  |  | +        me.sheetInitSelection(selected,me.setting.style);
 | 
	
		
			
				|  |  | +        if(me.rationGljEditObj){
 | 
	
		
			
				|  |  | +            if(ifNeedUpdate(selected)){
 | 
	
		
			
				|  |  | +                me.updateGljFromCache();
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        function ifNeedUpdate(selected) {
 | 
	
		
			
				|  |  | +            let navigationRightCol = me.setting.navigationRightCol , fieldID = me.setting.header[selected.col].dataCode;
 | 
	
		
			
				|  |  | +            if(me.rationGljEditObj.row == selected.row && navigationRightCol.indexOf(fieldID)!= -1){//如果换行或者超出了三个编辑列,则提交更新
 | 
	
		
			
				|  |  | +                return false;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            return true;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    updateGljFromCache:function () {
 | 
	
		
			
				|  |  | +        let me = this;
 | 
	
		
			
				|  |  | +        if(me.rationGljEditObj){
 | 
	
		
			
				|  |  | +            projectObj.project.ration_glj.submitChange(me.rationGljEditObj.recode, me.rationGljEditObj.doc);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        me.rationGljEditObj = null;
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      bindGLJEnterKey:function (spread,sheet) {
 | 
	
		
			
				|  |  |          let me = this;
 | 
	
	
		
			
				|  | @@ -122,21 +155,24 @@ var gljOprObj = {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          function enterKeyAction(spd,sheeName) {
 | 
	
		
			
				|  |  |              let editRow = sheet.getActiveRowIndex(),orgCol = sheet.getActiveColumnIndex();
 | 
	
		
			
				|  |  | -            if(sheet.isEditing()) sheet.endEdit();
 | 
	
		
			
				|  |  | -             //GC.Spread.Sheets.Commands.commitInputNavigationDown.execute(spd,sheeName);
 | 
	
		
			
				|  |  | -            //sheet.setSelection(editRow,orgCol+1,1,1);
 | 
	
		
			
				|  |  | -            GC.Spread.Sheets.Commands.navigationRight.execute(spd,sheeName);
 | 
	
		
			
				|  |  | -            //sheet.setActiveCell(editRow, orgCol+1)
 | 
	
		
			
				|  |  | +            let fieldID = me.setting.header[orgCol].dataCode;
 | 
	
		
			
				|  |  | +            if(me.setting.navigationRightCol.indexOf(fieldID) != -1){
 | 
	
		
			
				|  |  | +                if(sheet.isEditing()) sheet.endEdit();
 | 
	
		
			
				|  |  | +                GC.Spread.Sheets.Commands.navigationRight.execute(spd,sheeName);
 | 
	
		
			
				|  |  | +            }else {
 | 
	
		
			
				|  |  | +                GC.Spread.Sheets.Commands.commitInputNavigationDown.execute(spd,sheeName);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  | -    sheetInitSelection: function (selected) {
 | 
	
		
			
				|  |  | +    sheetInitSelection: function (selected,style) {
 | 
	
		
			
				|  |  |          let me = gljOprObj;
 | 
	
		
			
				|  |  |          if(selected.row < me.sheetData.length){
 | 
	
		
			
				|  |  | -            me.sheet.setStyle(selected.row, -1, me.getSelStyle(true));
 | 
	
		
			
				|  |  | +            me.sheet.setStyle(selected.row, -1, me.getSelStyle(true,style));
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          me.sheet.repaint();
 | 
	
		
			
				|  |  |          if(me.preGljSelection && me.preGljSelection.row !== selected.row){
 | 
	
		
			
				|  |  | -            me.sheet.setStyle(me.preGljSelection.row, -1, me.getSelStyle(false));
 | 
	
		
			
				|  |  | +            me.sheet.setStyle(me.preGljSelection.row, -1, me.getSelStyle(false,style));
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          me.preGljSelection = selected;
 | 
	
		
			
				|  |  |      },
 | 
	
	
		
			
				|  | @@ -266,8 +302,13 @@ var gljOprObj = {
 | 
	
		
			
				|  |  |          let me = gljOprObj;
 | 
	
		
			
				|  |  |          me.initSelection(args.newSelections.length > 0 ? {row: args.newSelections[0].row} : {row: 0});
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  | -    getSelStyle: function (selected) {
 | 
	
		
			
				|  |  | +    getSelStyle: function (selected,settingStyle) {
 | 
	
		
			
				|  |  |          let style = new GC.Spread.Sheets.Style();
 | 
	
		
			
				|  |  | +        if(settingStyle){
 | 
	
		
			
				|  |  | +            for(let key in settingStyle){
 | 
	
		
			
				|  |  | +                style[key] = settingStyle[key];
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          style.borderLeft = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
 | 
	
		
			
				|  |  |          style.borderTop = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
 | 
	
		
			
				|  |  |          style.borderRight = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
 | 
	
	
		
			
				|  | @@ -453,7 +494,7 @@ var gljOprObj = {
 | 
	
		
			
				|  |  |      showDataIfRationSelect: function (node,selectedNodeId) {
 | 
	
		
			
				|  |  |          var isShow = false;
 | 
	
		
			
				|  |  |          //恢复底色
 | 
	
		
			
				|  |  | -        this.sheet.setStyle(this.sheet.getActiveRowIndex(), -1, this.getSelStyle(false));
 | 
	
		
			
				|  |  | +        this.sheet.setStyle(this.sheet.getActiveRowIndex(), -1, this.getSelStyle(false,this.setting.style));
 | 
	
		
			
				|  |  |          if(projectReadOnly && this.setting.view.lockColumns){
 | 
	
		
			
				|  |  |              this.setting.view.lockColumns = null;
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -524,7 +565,7 @@ var gljOprObj = {
 | 
	
		
			
				|  |  |          sheetCommonObj.showData(this.sheet, this.setting, this.sheetData);
 | 
	
		
			
				|  |  |          //初始选择
 | 
	
		
			
				|  |  |          this.preGljSelection = null;
 | 
	
		
			
				|  |  | -        this.sheetInitSelection({row: this.sheet.getActiveRowIndex(), col: 0});
 | 
	
		
			
				|  |  | +        this.sheetInitSelection({row: this.sheet.getActiveRowIndex(), col: 0},this.setting.style);
 | 
	
		
			
				|  |  |          this.sheet.getRange(-1, 0, -1, this.setting.header.length).locked(true);//锁住定额工料机的所有列
 | 
	
		
			
				|  |  |          this.detailSheet.getRange(-1, 0, -1, this.detailSetting.header.length).locked(true);//锁住工程量明细的所有列
 | 
	
		
			
				|  |  |      },
 | 
	
	
		
			
				|  | @@ -561,7 +602,7 @@ var gljOprObj = {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          //初始选择
 | 
	
		
			
				|  |  |          this.preGljSelection = null;
 | 
	
		
			
				|  |  | -        this.sheetInitSelection({row: this.sheet.getActiveRowIndex(), col: this.sheet.getActiveColumnIndex()});
 | 
	
		
			
				|  |  | +        this.sheetInitSelection({row: this.sheet.getActiveRowIndex(), col: this.sheet.getActiveColumnIndex()},this.setting.style);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |      getUnitPriceCodeMap : function () {//取单价文件中,编码前缀一样的映射表
 | 
	
	
		
			
				|  | @@ -781,7 +822,6 @@ var gljOprObj = {
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  this.setGLJPrice(tem,pg);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |              temRationGLJs.push(tem);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          temRationGLJs = _.sortBy(temRationGLJs, 'code');
 | 
	
	
		
			
				|  | @@ -854,10 +894,27 @@ var gljOprObj = {
 | 
	
		
			
				|  |  |              projectObj.project.projectGLJ.updatePriceFromRG(recode, updateField, newval);
 | 
	
		
			
				|  |  |          }else if(updateField == 'code'){//替换单价文件中已经有的工料机
 | 
	
		
			
				|  |  |              projectObj.project.ration_glj.updateRationGLJByChangeCode(recode, updateField, newval);
 | 
	
		
			
				|  |  | +        }else if(me.setting.navigationRightCol.indexOf(updateField) != -1){//对于名称、规格、单位先跳到下一列,保存至缓存
 | 
	
		
			
				|  |  | +            me.setToEditCache(recode,updateField, newval,args);
 | 
	
		
			
				|  |  |          } else {
 | 
	
		
			
				|  |  |              projectObj.project.ration_glj.updateRationGLJByEdit(recode, updateField, newval);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  | +    setToEditCache:function(recode,updateField,value,args){
 | 
	
		
			
				|  |  | +        let me = this;
 | 
	
		
			
				|  |  | +        if(me.rationGljEditObj == null){
 | 
	
		
			
				|  |  | +            me.rationGljEditObj = {
 | 
	
		
			
				|  |  | +                recode:recode,
 | 
	
		
			
				|  |  | +                doc:{},
 | 
	
		
			
				|  |  | +                row:args.row
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            me.rationGljEditObj.doc[updateField] = value;
 | 
	
		
			
				|  |  | +        }else {
 | 
	
		
			
				|  |  | +            if(me.rationGljEditObj.recode.ID == recode.ID){//确保编辑的是同一条数据
 | 
	
		
			
				|  |  | +                me.rationGljEditObj.doc[updateField] = value;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  |      isRationGLJExit:function (connectKey) {
 | 
	
		
			
				|  |  |          for(let rg of gljOprObj.sheetData){
 | 
	
		
			
				|  |  |              if(rg.isMixRatio == true){
 | 
	
	
		
			
				|  | @@ -1539,6 +1596,20 @@ $(function () {
 | 
	
		
			
				|  |  |          $('#selected_class').val("");
 | 
	
		
			
				|  |  |      })
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    $("#subSpread").focusout(function(e){//当本身或子元素失去焦点时这个事件都会发生,而且不好判断点击的是哪里。
 | 
	
		
			
				|  |  | +        if(gljOprObj.rationGljEditObj){
 | 
	
		
			
				|  |  | +            gljOprObj.cancelUpdate = false;
 | 
	
		
			
				|  |  | +            gljOprObj.timeStamp = e.timeStamp;//设置时间戳,有可能用户在表格上乱点,这个事件被触发多次
 | 
	
		
			
				|  |  | +            setTimeout(function () {//延时执行提交操作,如果点击的是spread里的地方,会把cancelUpdate改成true,这样的话就不执行提交操作
 | 
	
		
			
				|  |  | +                if(gljOprObj.timeStamp == e.timeStamp && gljOprObj.cancelUpdate  !== true){//时间戳要相同
 | 
	
		
			
				|  |  | +                    gljOprObj.updateGljFromCache();
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            },200)
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      function getcmpUpdateData(items) {
 | 
	
		
			
				|  |  |          var data = {
 | 
	
		
			
				|  |  |              "updateItems": [],
 |