소스 검색

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

Chenshilong 7 년 전
부모
커밋
224c95b39c

+ 1 - 1
config/gulpConfig.js

@@ -93,7 +93,7 @@ module.exports = {
         'web/building_saas/main/js/models/quantity_detail.js',
         'web/building_saas/main/js/views/glj_view_contextMenu.js',
         'web/building_saas/main/js/views/calc_program_view.js',
-        'web/building_saas/main/js/views/confirm_modal.js'
+        'web/building_saas/main/js/views/confirm_modal.js',
         'public/web/treeDataHelper.js',
         'public/web/ztree_common.js',
         'public/web/rpt_tpl_def.js',

+ 3 - 0
web/building_saas/main/html/calc_program_manage.html

@@ -8,6 +8,9 @@
 </head>
 
 <body>
+<div style="">
+    <img id="f_btn" src="/web/dest/css/img/feeRate_btn.jpg" alt="" />
+</div>
     <div class="toolsbar px-1">
     </div>
     <div class="container-fluid">

+ 5 - 3
web/building_saas/main/html/main.html

@@ -541,15 +541,15 @@
     </div>
     <!--弹出清单单位选择设置-->
     <div class="modal fade" id="std_bills_unit" data-backdrop="static">
-        <div class="modal-dialog modal-lg" role="document">
+        <div class="modal-dialog" role="document">
             <div class="modal-content">
                 <div class="modal-header">
-                    <h5 class="modal-title"><i class="fa fa-table"></i> 请选择清单计量单位</h5>
+                    <h5 class="modal-title"><i class="fa fa-superscript"></i> 请选择清单计量单位</h5>
                     <button type="button" class="close" id='std_bills_unit_close' aria-label="Close">
                         <span aria-hidden="true">&times;</span>
                     </button>
                 </div>
-                <div class="modal-body modal-auto-height" id="std_bills_unit_spread" style="height: 200px; overflow: hidden;">
+                <div class="modal-body modal-auto-height" id="std_bills_unit_spread" style="height: 200px; width: 500px; overflow: hidden;">
                 </div>
                 <div class="modal-footer">
                     <a href="javascript:void(0);" id="std_bills_unit_ok" class="btn btn-primary">确定</a>
@@ -631,6 +631,8 @@
                     </button>
                 </div>
                 <div class="modal-body">
+                    <input type="hidden" id="edit_from">
+                    <input type="hidden" id="edit_row">
                     <div class="row">
                         <div class="modal-auto-height col-12" style="overflow: hidden" id="fee_rate_sheet">
                     </div>

+ 14 - 0
web/building_saas/main/js/controllers/project_controller.js

@@ -82,6 +82,20 @@ ProjectController = {
             this.syncDisplayNewNode(sheetController, newNode);
         }
     },
+    replaceRation: function (project, sheetController, std) {
+        if (!project || !sheetController) { return; }
+
+        let selected = project.mainTree.selected, newSource = null, newNode = null;
+        if (selected === null) { return; }
+
+        if (selected.sourceType === project.Ration.getSourceType()) {
+            project.Ration.replaceRation(selected.source, std);
+            project.ration_glj.addRationGLJ(selected.source, std);
+            sheetController.refreshTreeNode([selected], false);
+        } else {
+            alert('当前焦点行不是定额,无法替换。');
+        }
+    },
     addVolumePrice: function (project, sheetController) {
         if (!project || !sheetController) { return null; }
 

+ 6 - 8
web/building_saas/main/js/views/calc_program_manage.js

@@ -25,13 +25,13 @@ let rationPM = {
             {headerName:"费用名称",headerWidth:200,dataCode:"name", dataType: "String"},
             {headerName:"计算基数",headerWidth:180,dataCode:"dispExpr", dataType: "String"},
             {headerName:"基数说明",headerWidth:300,dataCode:"statement", dataType: "String"},
-            {headerName:"费率11",headerWidth:80,dataCode:"feeRate", dataType: "Number"},
+            {headerName:"费率",headerWidth:80,dataCode:"feeRate", dataType: "Number",hAlign: "left"},
             {headerName:"字段名称",headerWidth:140,dataCode:"displayFieldName", dataType: "String", hAlign: "center"},
             {headerName:"备注",headerWidth:100,dataCode:"memo", dataType: "String"}
         ],
         view:{
             comboBox:[],
-            lockColumns:[0,1,2,3,4,6]
+            lockColumns:[0,1,2,3,6]
         }
     },
 
@@ -56,14 +56,16 @@ let rationPM = {
 
         me.mainSpread.getSheet(0).bind(GC.Spread.Sheets.Events.EnterCell, me.onMainEnterCell);
         me.detailSpread.getSheet(0).bind(GC.Spread.Sheets.Events.CellChanged, me.onDetailCellChanged);
-        me.detailSpread.getSheet(0).bind(GC.Spread.Sheets.Events.CellDoubleClick, me.onCellClick);
+        //me.detailSpread.getSheet(0).bind(GC.Spread.Sheets.Events.CellClick, me.onCellClick);
         let mSheet = me.mainSpread.getSheet(0);
         sheetCommonObj.showData(mSheet, me.mainSetting, me.datas);
 
         let dSheet = me.detailSpread.getSheet(0);
+        dSheet.getRange(-1, 4, -1, 1).cellType(feeRateObject.getFeeRateEditCellType());
+        dSheet.name('calc_detail');
         sheetCommonObj.showData(dSheet, me.detailSetting, me.datas[0].calcItems);
-    },
 
+    },
     onMainEnterCell: function(sender, args) {
         var me = rationPM;
         var row = args.sheet.getActiveRowIndex();
@@ -73,10 +75,6 @@ let rationPM = {
         var dData = me.datas[row].calcItems;
         sheetCommonObj.showData(dSheet, me.detailSetting, dData);
         me.detailSpread.resumePaint();
-    },
-    onCellClick:function (sender,args) {
-        $("#fee_rate_tree").modal({show:true});
-        console.log(args);
     }
 };
 

+ 4 - 3
web/building_saas/main/js/views/confirm_modal.js

@@ -74,8 +74,9 @@ let ConfirmModal = {
         },
         check: function (std, okCallBack, cancelCallBack) {
             if (!this.spread) {
-                this.spread = SheetDataHelper.createNewSpread($('#std_bills_unit_spread')[0]);
-                SheetDataHelper.loadSheetHeader(this.setting, ConfirmModal.stdBillsUnit.spread.getActiveSheet());
+                this.spread = SheetDataHelper.createNewSpread($('#std_bills_unit_spread')[0], {sheetCount: 1});
+                this.spread.options.showScrollTip = GC.Spread.Sheets.ShowScrollTip.vertical;
+                SheetDataHelper.loadSheetHeader(this.setting, this.spread.getActiveSheet());
             }
             let sheet = ConfirmModal.stdBillsUnit.spread.getActiveSheet();
             let modalObj = this.modalObj;
@@ -102,7 +103,7 @@ let ConfirmModal = {
                 datas.push({'code': std.code, 'name': std.name, 'unit': unit});
             }
             SheetDataHelper.loadSheetData(this.setting, sheet, datas);
-            this.modalObj.modal({backdrop: false, keyboard: false});  
+            this.modalObj.modal('show');  
             ConfirmModal.stdBillsUnit.spread.refresh();  
         }
     }

+ 139 - 27
web/building_saas/main/js/views/fee_rate_view.js

@@ -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('');
     }
 });

+ 3 - 3
web/building_saas/main/js/views/glj_view.js

@@ -526,6 +526,7 @@ var gljOprObj = {
         }
     },
     showRationGLJSheetData:function () {
+        this.sheetData=_.sortBy(this.sheetData,'type');
         sheetCommonObj.showData(this.sheet,this.setting,this.sheetData);
     },
     filterGljByRation:function (ration,datas) {
@@ -536,9 +537,8 @@ var gljOprObj = {
         return gljList;
     },
     showInSheet:function(gljList){
-        gljList=this.combineWithProjectGlj(gljList);
-        sheetCommonObj.showData(this.sheet,this.setting,gljList);
-        this.sheetData=gljList;
+        this.sheetData=this.combineWithProjectGlj(gljList);
+        this.showRationGLJSheetData();
     },
     combineWithProjectGlj:function (ration_gljs) {
         var projectGljs = projectObj.project.projectGLJ.datas.gljList;

+ 39 - 0
web/building_saas/main/js/views/std_ration_lib.js

@@ -86,6 +86,44 @@ var rationLibObj = {
             });
         }
     },
+    loadStdRationContextMenu: function () {
+        let rationSpread = rationLibObj.sectionRationsSpread, rationSheet = rationSpread.getActiveSheet();
+        $.contextMenu({
+            selector: '#stdSectionRations',
+            build: function ($trigger, e) {
+                let target = SheetDataHelper.safeRightClickSelection($trigger, e, rationSpread);
+                return target.hitTestType === GC.Spread.Sheets.SheetArea.viewport || target.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
+            },
+            items: {
+                "insertStdRation": {
+                    name: "插入定额",
+                    icon: 'fa-sign-in',
+                    callback: function (key, opt) {
+                        let select = $('#stdRationLibSelect'), rationSelect = rationSheet.getSelections();
+                        let rationCode = rationSelect.length > 0 ? rationSheet.getText(rationSelect[0].row, 0) : '';
+                        if (rationCode !== '') {
+                            CommonAjax.postRationLib('/rationRepository/api/getRationItem', {user_id: userID, rationLibId: select.val(), code: rationCode}, function (data) {
+                                ProjectController.addRation(projectObj.project, projectObj.mainController, data);
+                            });
+                        }
+                    }
+                },
+                "replaceStdRation": {
+                    name: "替换定额",
+                    icon: 'fa-sign-in',
+                    callback: function (key, opt) {
+                        let select = $('#stdRationLibSelect'), rationSelect = rationSheet.getSelections();
+                        let rationCode = rationSelect.length > 0 ? rationSheet.getText(rationSelect[0].row, 0) : '';
+                        if (rationCode !== '') {
+                            CommonAjax.postRationLib('/rationRepository/api/getRationItem', {user_id: userID, rationLibId: select.val(), code: rationCode}, function (data) {
+                                ProjectController.replaceRation(projectObj.project, projectObj.mainController, data);
+                            });
+                        }
+                    }
+                },
+            }
+        });
+    },
     rationChapterTreeSetting: {
         "emptyRows":0,
         "headRows":1,
@@ -195,6 +233,7 @@ $('#stdRationTab').bind('click', function () {
     rationLibObj.checkSpread();
     if (select[0].options.length === 0) {
         rationLibObj.loadStdRationLibs();
+        rationLibObj.loadStdRationContextMenu();
     };
 });
 $('#stdRationLibSelect').change(function () {

BIN
web/dest/css/img/feeRate_btn.jpg