|  | @@ -155,7 +155,8 @@ var projectObj = {
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              return false
 | 
	
		
			
				|  |  |          };
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        setButtonValid(canInsertRationNode(selected), $('#insertRation'));
 | 
	
		
			
				|  |  |          setButtonValid(ifCanDelete(), $('#delete'));
 | 
	
		
			
				|  |  |          setButtonValid(canUpLevel(selected), $('#upLevel'));
 | 
	
		
			
				|  |  |          setButtonValid(canDownLevel(selected), $('#downLevel'));
 | 
	
	
		
			
				|  | @@ -423,7 +424,7 @@ var projectObj = {
 | 
	
		
			
				|  |  |          }  else if(calcTools.isGljRation(node)){
 | 
	
		
			
				|  |  |              gljOprObj.updateRationTypeGLJ(value,node,fieldName,editingText);
 | 
	
		
			
				|  |  |          } else if (value !== calcFees.getFee(node.data, fieldName)||fieldName == 'quantity') {//工程量需要进行转换,所以做特殊处理
 | 
	
		
			
				|  |  | -            if (fieldName === 'code' && !calcTools.isVolumePrice(node)) {
 | 
	
		
			
				|  |  | +            if (fieldName === 'code' && value != '' && !calcTools.isVolumePrice(node)) {
 | 
	
		
			
				|  |  |                  projectObj.updateCode(node, value);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              else if(fieldName ==='feeRate'){
 | 
	
	
		
			
				|  | @@ -520,11 +521,14 @@ var projectObj = {
 | 
	
		
			
				|  |  |          let newV;
 | 
	
		
			
				|  |  |          if(node && node.sourceType === projectObj.project.Ration.getSourceType() && node.data.type === rationType.ration
 | 
	
		
			
				|  |  |              && isDef(node.data.code) && isDef(node.data.prefix) && node.data.prefix !== rationPrefix.none && fieldName === 'code'){
 | 
	
		
			
				|  |  | -            if(node.data.prefix === rationPrefix.complementary){
 | 
	
		
			
				|  |  | -                newV = orgV.replace(new RegExp('补'), '');
 | 
	
		
			
				|  |  | +/*            if(node.data.prefix === rationPrefix.complementary){
 | 
	
		
			
				|  |  | +                newV = orgV.replace(new RegExp(rationPrefix.complementary), '');
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              if(node.data.prefix === rationPrefix.borrow){
 | 
	
		
			
				|  |  | -                newV = orgV.replace(new RegExp('借'), '');
 | 
	
		
			
				|  |  | +                newV = orgV.replace(new RegExp(rationPrefix.borrow), '');
 | 
	
		
			
				|  |  | +            }*/
 | 
	
		
			
				|  |  | +            if(node.data.prefix){
 | 
	
		
			
				|  |  | +                newV = orgV.replace(new RegExp(node.data.prefix), '');
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              info.sheet.setValue(info.row, info.col, newV);
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -541,6 +545,12 @@ var projectObj = {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  | +    onColumnWidthChanged: function (sender, info) {
 | 
	
		
			
				|  |  | +        projectObj.mainSpread.getActiveSheet().setColumnVisible(4, false);
 | 
	
		
			
				|  |  | +        projectObj.mainSpread.getActiveSheet().setColumnVisible(4, true);
 | 
	
		
			
				|  |  | +        projectObj.mainSpread.refresh();
 | 
	
		
			
				|  |  | +        projectObj.mainSpread.repaint();
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  |      mainSpreadEditEnded: function (sender, info) {
 | 
	
		
			
				|  |  |          let project = projectObj.project;
 | 
	
		
			
				|  |  |          let node = project.mainTree.items[info.row];
 | 
	
	
		
			
				|  | @@ -577,7 +587,7 @@ var projectObj = {
 | 
	
		
			
				|  |  |                  let node = project.mainTree.items[changedCell.row];
 | 
	
		
			
				|  |  |                  let colSetting = setting.cols[changedCell.col];
 | 
	
		
			
				|  |  |                  let value = projectObj.checkSpreadEditingText(changedCell.text, colSetting)
 | 
	
		
			
				|  |  | -                if(colSetting.data.field=='code'&& node.sourceType == project.Ration.getSourceType()&&node.data.type==rationType.ration){//如果是更新定额的编码
 | 
	
		
			
				|  |  | +                if(colSetting.data.field=='code' && value != '' && node.sourceType == project.Ration.getSourceType()&&node.data.type==rationType.ration){//如果是更新定额的编码
 | 
	
		
			
				|  |  |                      updateRationCodes.push({'node':node,value:value});
 | 
	
		
			
				|  |  |                  }else {
 | 
	
		
			
				|  |  |                      projectObj.updateCellValue(node, value, colSetting,changedCell.text);
 | 
	
	
		
			
				|  | @@ -686,6 +696,7 @@ var projectObj = {
 | 
	
		
			
				|  |  |                  that.mainController.bind(TREE_SHEET_CONTROLLER.eventName.beforeTreeSelectedChange, that.beforeMainTreeSelectedChange);
 | 
	
		
			
				|  |  |                  that.mainController.bind(TREE_SHEET_CONTROLLER.eventName.treeSelectedChanged, that.treeSelectedChanged);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +                that.bindEnterKey(that.mainSpread, 'mainEnterKey', that.mainSpreadEnterKey);
 | 
	
		
			
				|  |  |                  setTimeout(function () {
 | 
	
		
			
				|  |  |                      that.mainSpread.getActiveSheet().startEdit();//这两句需要挺多时间,而又需要在editend 事件前触发,而这些又不影响计算,所以这里用异步的方法
 | 
	
		
			
				|  |  |                      that.mainSpread.getActiveSheet().endEdit();
 | 
	
	
		
			
				|  | @@ -701,6 +712,7 @@ var projectObj = {
 | 
	
		
			
				|  |  |                  that.mainSpread.bind(GC.Spread.Sheets.Events.ClipboardChanged, that.msClipboardChanged);
 | 
	
		
			
				|  |  |                  that.mainSpread.bind(GC.Spread.Sheets.Events.ButtonClicked, that.onButtonClick);
 | 
	
		
			
				|  |  |                  that.mainSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, that.onCellDoubleClick);
 | 
	
		
			
				|  |  | +                that.mainSpread.bind(GC.Spread.Sheets.Events.ColumnWidthChanged, that.onColumnWidthChanged);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  //let loadOtherStartTime = +new Date();
 | 
	
		
			
				|  |  |                  if(!projectReadOnly){
 | 
	
	
		
			
				|  | @@ -730,6 +742,84 @@ var projectObj = {
 | 
	
		
			
				|  |  |          });
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  | +    mainSpreadEnterKey: function () {
 | 
	
		
			
				|  |  | +        let me = projectObj;
 | 
	
		
			
				|  |  | +        let sheet = me.mainSpread.getActiveSheet();
 | 
	
		
			
				|  |  | +        let orgRow = sheet.getActiveRowIndex();
 | 
	
		
			
				|  |  | +        let orgCol = sheet.getActiveColumnIndex();
 | 
	
		
			
				|  |  | +        let orgField = colSettingObj.getFieldByCol(orgCol);
 | 
	
		
			
				|  |  | +        let selected = me.project.mainTree.items[orgRow];
 | 
	
		
			
				|  |  | +        if(sheet.isEditing()){
 | 
	
		
			
				|  |  | +            sheet.endEdit();
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        //正常情况,焦点应该是在下一行的同一列
 | 
	
		
			
				|  |  | +        let newRow = orgRow + 1, newCol = orgCol;
 | 
	
		
			
				|  |  | +        if(selected){
 | 
	
		
			
				|  |  | +            //在分项/补项的编码单元格回车,焦点应跳动至本行的工程量单元格
 | 
	
		
			
				|  |  | +            if(orgField && orgField === 'code' && selected.sourceType === me.project.Bills.getSourceType() && [billType.FX, billType.BX].includes(selected.data.type)){
 | 
	
		
			
				|  |  | +                let quantityCol = colSettingObj.getColByField('quantity');
 | 
	
		
			
				|  |  | +                let quantityVisible = colSettingObj.getVisible('quantity');
 | 
	
		
			
				|  |  | +                if(quantityCol && quantityVisible){
 | 
	
		
			
				|  |  | +                    newRow = orgRow;
 | 
	
		
			
				|  |  | +                    newCol = quantityCol;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            //在分项/补项的工程量单元格回车,如果其下有定额/量价/人材机,焦点应跳动至其下第一条定额/量价/人材机的工程量;
 | 
	
		
			
				|  |  | +            //如果其下没有定额/量价/人材机,则自动在其下插入一条定额空行,在其后自动插入一条分项空行,焦点跳动至定额空行的编码单元格。
 | 
	
		
			
				|  |  | +            if(orgField && orgField === 'quantity' && selected.sourceType === me.project.Bills.getSourceType() && [billType.FX, billType.BX].includes(selected.data.type)
 | 
	
		
			
				|  |  | +                && selected.children.length === 0){
 | 
	
		
			
				|  |  | +                me.project.Ration.addNewRation(null,rationType.ration, function () {
 | 
	
		
			
				|  |  | +                    newRow = sheet.getActiveRowIndex();
 | 
	
		
			
				|  |  | +                    newCol = sheet.getActiveColumnIndex();
 | 
	
		
			
				|  |  | +                });
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            //在定额/量价/人材机的编码单元格回车,焦点应跳动至本行的工程量单元格
 | 
	
		
			
				|  |  | +            if(orgField && orgField === 'code' && selected.sourceType === me.project.Ration.getSourceType() && []){
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        //设置焦点
 | 
	
		
			
				|  |  | +        sheet.setActiveCell(newRow, newCol);
 | 
	
		
			
				|  |  | +        //触发表格事件
 | 
	
		
			
				|  |  | +        me.mainController.setTreeSelected(me.project.mainTree.items[newRow]);//SelectionChanged
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    //注册自定义回车键事件
 | 
	
		
			
				|  |  | +    bindEnterKey: function (workBook, registerName, operation) {
 | 
	
		
			
				|  |  | +        let me = this;
 | 
	
		
			
				|  |  | +        let sheet = workBook.getActiveSheet();
 | 
	
		
			
				|  |  | +        workBook.commandManager().register(registerName, operation);
 | 
	
		
			
				|  |  | +       /* workBook.commandManager().register(registerName, function(){
 | 
	
		
			
				|  |  | +            operation();
 | 
	
		
			
				|  |  | +           /!* let orgRow = sheet.getActiveRowIndex();
 | 
	
		
			
				|  |  | +            let orgCol = sheet.getActiveColumnIndex();
 | 
	
		
			
				|  |  | +            if(sheet.isEditing()){
 | 
	
		
			
				|  |  | +                sheet.endEdit();
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            let code = sheet.getValue(orgRow, 0);
 | 
	
		
			
				|  |  | +            let newRow, newCol;
 | 
	
		
			
				|  |  | +            if(!me.currentCache[orgRow] && code !== undefined && code !== null && orgCol !== me.setting.header.length - 1){
 | 
	
		
			
				|  |  | +                newRow = orgRow;
 | 
	
		
			
				|  |  | +                newCol = orgCol + 1;
 | 
	
		
			
				|  |  | +                sheet.setActiveCell(newRow, newCol);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            else{
 | 
	
		
			
				|  |  | +                newRow = orgRow + 1;
 | 
	
		
			
				|  |  | +                newCol = me.currentCache[orgRow + 1] ? orgCol : 0;
 | 
	
		
			
				|  |  | +                sheet.setActiveCell(newRow, newCol);
 | 
	
		
			
				|  |  | +            }*!/
 | 
	
		
			
				|  |  | +            //触发事件
 | 
	
		
			
				|  |  | +            /!*me.onLeaveCell({type: 'LeaveCell'}, {sheet: sheet, sheetName: sheet.name(), cancel: false, row: orgRow, col: orgCol});
 | 
	
		
			
				|  |  | +            me.onEnterCell({type: 'EnterCell'}, {sheet: sheet, sheetName: sheet.name(), cancel: false, row: newRow, col: newCol});
 | 
	
		
			
				|  |  | +            let newSels = [{row: newRow, rowCount: 1, col: newCol, colCount: 1}];
 | 
	
		
			
				|  |  | +            let oldSels = [{row: orgRow, rowCount: 1, col: orgRow, colCount: 1}];
 | 
	
		
			
				|  |  | +            me.onSelectionChanged({type: 'SelectionChanged'}, {sheet: sheet, sheetName: sheet.name(), newSelections: newSels, oldSelections: oldSels});*!/
 | 
	
		
			
				|  |  | +        });*/
 | 
	
		
			
				|  |  | +        workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.enter, false, false, false, false);
 | 
	
		
			
				|  |  | +        workBook.commandManager().setShortcutKey(registerName, GC.Spread.Commands.Key.enter, false, false, false, false);
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  |      loadMainSpreadContextMenu: function () {
 | 
	
		
			
				|  |  |          var project = this.project, spread = this.mainSpread, controller = this.mainController;
 | 
	
		
			
				|  |  |          $.contextMenu({
 | 
	
	
		
			
				|  | @@ -861,10 +951,7 @@ var projectObj = {
 | 
	
		
			
				|  |  |                      },
 | 
	
		
			
				|  |  |                      visible: function(key, opt){
 | 
	
		
			
				|  |  |                          var selected = project.mainTree.selected;
 | 
	
		
			
				|  |  | -                        if(selected){
 | 
	
		
			
				|  |  | -                          return canInsertRationNode(selected);
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                       return false;
 | 
	
		
			
				|  |  | +                        return canInsertRationNode(selected);
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  },
 | 
	
		
			
				|  |  |                  "insertLJ": {
 | 
	
	
		
			
				|  | @@ -1994,14 +2081,33 @@ function ifCanDelete() {
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  function canInsertRationNode(selected) {//判断是否能插入定额、量价、定额类型工料机, false 不能,true能
 | 
	
		
			
				|  |  | +    if(!selected)
 | 
	
		
			
				|  |  | +        return false;
 | 
	
		
			
				|  |  |      let project = projectObj.project;
 | 
	
		
			
				|  |  | -    if(selected.sourceType == ModuleNames.bills&&selected.data.type == billType.DXFY){
 | 
	
		
			
				|  |  | +    if(selected.sourceType == ModuleNames.bills && selected.data.type == billType.DXFY){
 | 
	
		
			
				|  |  |          return false
 | 
	
		
			
				|  |  |      }else if(!(project.Bills.isMeasure(selected)||project.Bills.isFBFX(selected))){
 | 
	
		
			
				|  |  |          return false
 | 
	
		
			
				|  |  | -    }else {
 | 
	
		
			
				|  |  | +    }else if(selected.sourceType == ModuleNames.bills && selected.source.children.length > 0){
 | 
	
		
			
				|  |  | +        return false
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    else {
 | 
	
		
			
				|  |  |          return true
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/*    if (selected) {// Vincent, 2018-01-02
 | 
	
		
			
				|  |  | +        if(selected.sourceType === project.Ration.getSourceType()){ // 焦点行是定额/量价/工料机,有效显示。
 | 
	
		
			
				|  |  | +            return false;
 | 
	
		
			
				|  |  | +        }else if(selected.sourceType === project.Bills.getSourceType()){
 | 
	
		
			
				|  |  | +            if(selected.data.type == billType.FX || selected.data.type == billType.BX){//焦点行是分项,有效显示。
 | 
	
		
			
				|  |  | +                return false
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if(selected.data.type == billType.BILL && selected.source.children.length === 0){//焦点行是清单,且没有子项,有效显示。
 | 
	
		
			
				|  |  | +                return false
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    return true;*/
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  //导入类型(09表、广联达)
 |