|  | @@ -13,10 +13,11 @@ var feeRateObject={
 | 
	
		
			
				|  |  |      selectionLoad:false,
 | 
	
		
			
				|  |  |      changeInfo:null,
 | 
	
		
			
				|  |  |      feeRateSpreads:null,
 | 
	
		
			
				|  |  | +    editingCell:null,
 | 
	
		
			
				|  |  |      sheetSetting: {
 | 
	
		
			
				|  |  |          header: [
 | 
	
		
			
				|  |  |              {headerName: "专业名称", headerWidth: 200, dataCode: "name", dataType: "String"},
 | 
	
		
			
				|  |  | -            {headerName: "值%", headerWidth: 150, dataCode: "rate", dataType: "String"},
 | 
	
		
			
				|  |  | +            {headerName: "值%", headerWidth: 150, dataCode: "rate", dataType: "String",hAlign: "right"},
 | 
	
		
			
				|  |  |              {headerName: "备注", dataCode: "memo", dataType: "String"}
 | 
	
		
			
				|  |  |          ],
 | 
	
		
			
				|  |  |          view: {
 | 
	
	
		
			
				|  | @@ -114,7 +115,8 @@ var feeRateObject={
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |      createSheet:function(){
 | 
	
		
			
				|  |  | -        feeRateObject.feeRateSpreads=sheetCommonObj.buildSheet($('#fee_rate_sheet')[0], feeRateObject.sheetSetting,30);
 | 
	
		
			
				|  |  | +        var feeRateFile = projectObj.project.FeeRate.getActivateFeeRate();
 | 
	
		
			
				|  |  | +        feeRateObject.feeRateSpreads=sheetCommonObj.buildSheet($('#fee_rate_sheet')[0], feeRateObject.sheetSetting,feeRateFile.rates.length);
 | 
	
		
			
				|  |  |          //gljOprObj.gljLibSpresd.bind(GC.Spread.Sheets.Events.ButtonClicked,gljOprObj.onButtonClick);
 | 
	
		
			
				|  |  |          feeRateObject.feeRateSheet = feeRateObject.feeRateSpreads.getSheet(0);
 | 
	
		
			
				|  |  |          feeRateObject.feeRateSheet.selectionUnit(1)//0 cell,1 row,2 col;
 | 
	
	
		
			
				|  | @@ -123,36 +125,52 @@ var feeRateObject={
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  |      showSelectTree:function () {
 | 
	
		
			
				|  |  |          var sheet= feeRateObject.feeRateSheet;
 | 
	
		
			
				|  |  | +        var setting=feeRateObject.sheetSetting;
 | 
	
		
			
				|  |  | +        var data = projectObj.project.FeeRate.getActivateFeeRate().rates;
 | 
	
		
			
				|  |  | +        var ch = GC.Spread.Sheets.SheetArea.viewport;
 | 
	
		
			
				|  |  | +        var groups=[];
 | 
	
		
			
				|  |  |          sheet.suspendPaint();
 | 
	
		
			
				|  |  |          sheet.suspendEvent();
 | 
	
		
			
				|  |  |          sheet.rowOutlines.direction(GC.Spread.Sheets.Outlines.OutlineDirection.backward);
 | 
	
		
			
				|  |  |          sheet.getRange(-1, 0, -1, 1).cellType(feeRateObject.getTreeNodeCellType());
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        sheet.setValue(0, 0, "Permanent Differences");
 | 
	
		
			
				|  |  | -        sheet.setValue(1, 0, "Permanent Differences");
 | 
	
		
			
				|  |  | -        sheet.setValue(2, 0, "4P01 - Club Dues");
 | 
	
		
			
				|  |  | -        sheet.setValue(3, 0, "4P02 - Business Gifts");
 | 
	
		
			
				|  |  | -        sheet.setValue(4, 0, "4P03 - Int Inc-Muni Borads");
 | 
	
		
			
				|  |  | -        sheet.setValue(5, 0, "4P04 - Lobbying Expense");
 | 
	
		
			
				|  |  | -        sheet.setValue(6, 0, "4P05 - Skybox");
 | 
	
		
			
				|  |  | -        sheet.setValue(7, 0, "4P06 - Stock Options-Perm");
 | 
	
		
			
				|  |  | -        sheet.setValue(8, 0, "4P07 - M&E");
 | 
	
		
			
				|  |  | -        sheet.setValue(9, 0, "Total Permanent Differences");
 | 
	
		
			
				|  |  | -        sheet.setValue(10, 0, "Capital Loss Limitation");
 | 
	
		
			
				|  |  | -        sheet.setValue(11, 0, "Capital Gain/Loss, Sum included in Book income");
 | 
	
		
			
				|  |  | -        sheet.setValue(12, 0, "Capital Loss Disallowed");
 | 
	
		
			
				|  |  | -        sheet.setValue(13, 0, "Charitable Contribution Limitation");
 | 
	
		
			
				|  |  | -        sheet.setValue(14, 0, "Charitable Contributions included in Book income");
 | 
	
		
			
				|  |  | -        sheet.setValue(15, 0, "Demestic production activities deduction included in Book income");
 | 
	
		
			
				|  |  | -        sheet.setValue(16, 0, "Fedeeral Taxable Income Limitation");
 | 
	
		
			
				|  |  | -        sheet.setValue(17, 0, "Limitation percentage");
 | 
	
		
			
				|  |  | -        sheet.setValue(18, 0, "Charitable Contribution limitation");
 | 
	
		
			
				|  |  | -        sheet.setValue(19, 0, "Charitable Contributions disallowed");
 | 
	
		
			
				|  |  | -        sheet.setValue(20, 0, "Federal Taxable Income before Net Operating Loss Deduction");
 | 
	
		
			
				|  |  | -        sheet.rowOutlines.group(1, 10);
 | 
	
		
			
				|  |  | -        sheet.rowOutlines.group(3, 7);
 | 
	
		
			
				|  |  | -        sheet.rowOutlines.group(12, 2);
 | 
	
		
			
				|  |  | +        for (var col = 0; col < setting.header.length; col++) {
 | 
	
		
			
				|  |  | +            var hAlign = "left", vAlign = "center";
 | 
	
		
			
				|  |  | +            if (setting.header[col].hAlign) {
 | 
	
		
			
				|  |  | +                hAlign = setting.header[col].hAlign;
 | 
	
		
			
				|  |  | +            } else if (setting.header[col].dataType !== "String"){
 | 
	
		
			
				|  |  | +                hAlign = "right";
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            vAlign = setting.header[col].vAlign?setting.header[col].vAlign:vAlign;
 | 
	
		
			
				|  |  | +            sheetCommonObj.setAreaAlign(sheet.getRange(-1, col, -1, 1), hAlign, vAlign);
 | 
	
		
			
				|  |  | +            if (setting.header[col].formatter) {
 | 
	
		
			
				|  |  | +                sheet.setFormatter(-1, col, setting.header[col].formatter, GC.Spread.Sheets.SheetArea.viewport);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            for (var row = 0; row < data.length; row++) {
 | 
	
		
			
				|  |  | +                var val = data[row][setting.header[col].dataCode];
 | 
	
		
			
				|  |  | +                if(val&&setting.header[col].dataType === "Number"){
 | 
	
		
			
				|  |  | +                    if(setting.header[col].hasOwnProperty('tofix')){
 | 
	
		
			
				|  |  | +                        val =parseFloat(val).toFixed(setting.header[col].tofix);
 | 
	
		
			
				|  |  | +                    }else {
 | 
	
		
			
				|  |  | +                        val =parseFloat(val).toFixed(2);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                sheet.setValue(row, col, val, ch);
 | 
	
		
			
				|  |  | +                if(col==0){
 | 
	
		
			
				|  |  | +                    feeRateObject.setSheetGroup(data[row],data,groups,row+1);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        //this.lockCells(sheet,setting);
 | 
	
		
			
				|  |  | +        console.log(groups);
 | 
	
		
			
				|  |  | +        _.forEach(groups,function (g) {
 | 
	
		
			
				|  |  | +            for(var k in g){
 | 
	
		
			
				|  |  | +                sheet.rowOutlines.group(parseInt(k), g[k]);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        })
 | 
	
		
			
				|  |  | +     /*   sheet.rowOutlines.group(1, 6);
 | 
	
		
			
				|  |  | +        sheet.rowOutlines.group(8, 6);
 | 
	
		
			
				|  |  |          sheet.rowOutlines.group(15, 6);
 | 
	
		
			
				|  |  | +        sheet.rowOutlines.group(22, 6);*/
 | 
	
		
			
				|  |  |         // sheet.getRange(-1, 0, -1, 1).width(300);
 | 
	
		
			
				|  |  |          sheet.showRowOutline(false);
 | 
	
		
			
				|  |  |          sheet.resumeEvent();
 | 
	
	
		
			
				|  | @@ -224,6 +242,98 @@ var feeRateObject={
 | 
	
		
			
				|  |  |          };
 | 
	
		
			
				|  |  |          return new TreeNodeCellType()
 | 
	
		
			
				|  |  |      },
 | 
	
		
			
				|  |  | +    getFeeRateEditCellType:function () {
 | 
	
		
			
				|  |  | +        var ns = GC.Spread.Sheets;
 | 
	
		
			
				|  |  | +        function FeeRateEditCellType() {
 | 
	
		
			
				|  |  | +            var init=false;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        FeeRateEditCellType.prototype = new ns.CellTypes.Text();
 | 
	
		
			
				|  |  | +        FeeRateEditCellType.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);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if(feeRateObject.editingCell){
 | 
	
		
			
				|  |  | +                if(feeRateObject.editingCell.row==options.row&&feeRateObject.editingCell.col==options.col){
 | 
	
		
			
				|  |  | +                    var image = document.getElementById('f_btn'),imageMagin = 3;
 | 
	
		
			
				|  |  | +                    var imageHeight = h-2*imageMagin;
 | 
	
		
			
				|  |  | +                    var imageWidth = imageHeight* 4/3;
 | 
	
		
			
				|  |  | +                    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();
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        };
 | 
	
		
			
				|  |  | +        FeeRateEditCellType.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
 | 
	
		
			
				|  |  | +            };
 | 
	
		
			
				|  |  | +        };
 | 
	
		
			
				|  |  | +        FeeRateEditCellType.prototype.processMouseDown = function (hitinfo) {
 | 
	
		
			
				|  |  | +            if(feeRateObject.editingCell==null){
 | 
	
		
			
				|  |  | +                feeRateObject.editingCell={
 | 
	
		
			
				|  |  | +                    row:hitinfo.row,
 | 
	
		
			
				|  |  | +                    col:hitinfo.col
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                hitinfo.sheet.invalidateLayout();
 | 
	
		
			
				|  |  | +                hitinfo.sheet.repaint();
 | 
	
		
			
				|  |  | +            }else if(hitinfo.row==feeRateObject.editingCell.row){
 | 
	
		
			
				|  |  | +                var offset=hitinfo.cellRect.x+hitinfo.cellRect.width-6;
 | 
	
		
			
				|  |  | +                var imageMagin=3;
 | 
	
		
			
				|  |  | +                var imageHeight = hitinfo.cellRect.height-2*imageMagin;
 | 
	
		
			
				|  |  | +                var imageWidth = imageHeight* 4/3;
 | 
	
		
			
				|  |  | +                if(hitinfo.x<offset&&hitinfo.x>offset-imageWidth){
 | 
	
		
			
				|  |  | +                    feeRateObject.showSelectModal(hitinfo);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        };
 | 
	
		
			
				|  |  | +        FeeRateEditCellType.prototype.processMouseLeave = function (hitinfo) {
 | 
	
		
			
				|  |  | +            feeRateObject.editingCell=null;
 | 
	
		
			
				|  |  | +            hitinfo.sheet.invalidateLayout();
 | 
	
		
			
				|  |  | +            hitinfo.sheet.repaint();
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return new FeeRateEditCellType();
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    showSelectModal:function (hitinfo) {
 | 
	
		
			
				|  |  | +        $("#fee_rate_tree").modal({show:true});
 | 
	
		
			
				|  |  | +        $('#edit_from').val(hitinfo.sheet.name());
 | 
	
		
			
				|  |  | +        $('#edit_row').val(hitinfo.row);
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    setSheetGroup:function (rate,data,groups,row) {
 | 
	
		
			
				|  |  | +        var me=this;
 | 
	
		
			
				|  |  | +        var group={};
 | 
	
		
			
				|  |  | +        var count=me.getChildrenCount(rate.ID,data);
 | 
	
		
			
				|  |  | +        if(count>0){
 | 
	
		
			
				|  |  | +            group[row]=count;
 | 
	
		
			
				|  |  | +            groups.push(group);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return groups;
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    getChildrenCount:function (id,data) {
 | 
	
		
			
				|  |  | +        var me=this;
 | 
	
		
			
				|  |  | +        var sum=0;
 | 
	
		
			
				|  |  | +        var children=_.filter(data,{'ParentID':id});
 | 
	
		
			
				|  |  | +        if(children&&children.length==0){
 | 
	
		
			
				|  |  | +            return 0;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        for(var i=0;i<children.length;i++){
 | 
	
		
			
				|  |  | +            sum+=me.getChildrenCount(children[i].ID,data);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return children.length+sum;
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  |      createSpreadView:function () {
 | 
	
		
			
				|  |  |          if (this.mainViews) {
 | 
	
		
			
				|  |  |              this.mainViews.destroy();
 | 
	
	
		
			
				|  | @@ -661,5 +771,7 @@ $('#fee_rate_tree').on('hidden.bs.modal', function (e) {
 | 
	
		
			
				|  |  |      if(feeRateObject.feeRateSpreads){
 | 
	
		
			
				|  |  |          feeRateObject.feeRateSpreads.destroy();
 | 
	
		
			
				|  |  |          feeRateObject.feeRateSpreads=null;
 | 
	
		
			
				|  |  | +        $('#edit_from').val('');
 | 
	
		
			
				|  |  | +        $('#edit_row').val('');
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  });
 |