Browse Source

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

MaiXinRong 7 years ago
parent
commit
e3961cac92

+ 21 - 5
modules/main/facade/labour_coe_facade.js

@@ -54,13 +54,29 @@ async function getStdLabourCoe(libID) {
 };
 
 // 统一的 getData() 方法供project调用
-function getData (projectID, callback) {
-    projectLabourCoesModel.findOne({projectID: projectID}, '-_id', function(err, datas) {
-            if (!err) {
-                callback(0, projectConsts.LABOUR_COE, datas);
+function getData(projectID, callback) {
+    projectLabourCoesModel.findOne({projectID: projectID}, '-_id', function (err, datas) {
+        if (!err) {
+            // 旧项目没有人工系数文件,默认给它生成一个。
+            if (!datas) {
+                getStdLabourCoe(1).then(function (stdLC) {
+                    let doc = {
+                        ID: uuidV1(),
+                        projectID: projectID,
+                        name: '[旧项目补人工系数文件]',
+                        libID: stdLC.ID,
+                        libName: stdLC.libName,
+                        coes: stdLC.coes
+                    };
+                    projectLabourCoesModel.create(doc);
+                    callback(0, projectConsts.LABOUR_COE, stdLC);
+                });
             } else {
-                callback(1, projectConsts.LABOUR_COE, null);
+                callback(0, projectConsts.LABOUR_COE, datas);
             };
+        } else {
+            callback(1, projectConsts.LABOUR_COE, null);
+        };
     });
 };
 

+ 2 - 1
web/building_saas/css/main.css

@@ -312,4 +312,5 @@ body {
 .gc-column-header-cell{
     text-align: center!important;
 }
-.modal-lg{max-width: 1000px}
+.modal-lg{max-width: 1000px}
+.modal-feeRate {max-width: 550px}

+ 23 - 1
web/building_saas/main/html/main.html

@@ -562,7 +562,7 @@
         <div class="modal-dialog modal-lg" role="document" id="modalCon">
             <div class="modal-content" >
                 <div class="modal-header">
-                    <h5 class="modal-title">内容</h5>
+                    <h5 class="modal-title">请选择工料机</h5>
                     <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                         <span aria-hidden="true">&times;</span>
                     </button>
@@ -601,6 +601,28 @@
             </div>
         </div>
     </div>
+    <!--费率选择窗口-->
+    <div class="modal fade" id="fee_rate_tree" data-backdrop="static">
+        <div class="modal-dialog modal-feeRate" role="document" id="fee_rate_dialog">
+            <div class="modal-content" >
+                <div class="modal-header">
+                    <h5 class="modal-title">费率选择</h5>
+                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                        <span aria-hidden="true">&times;</span>
+                    </button>
+                </div>
+                <div class="modal-body">
+                    <div class="row">
+                        <div class="modal-auto-height col-12" style="overflow: hidden" id="fee_rate_sheet">
+                    </div>
+                </div>
+                <div class="modal-footer">
+                    <button type="button" id="frCacnel" class="btn btn-secondary" data-dismiss="modal">取消</button>
+                    <a href="javascript:void(0);" id="fee_selected_conf" class="btn btn-primary">确定</a>
+                </div>
+            </div>
+        </div>
+    </div>
 
     <!-- JS. -->
     <script type="text/javascript" src="/lib/ztree/jquery.ztree.core.js"></script>

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

@@ -25,7 +25,7 @@ let rationPM = {
             {headerName:"费用名称",headerWidth:200,dataCode:"name", dataType: "String"},
             {headerName:"计算基数",headerWidth:180,dataCode:"dispExpr", dataType: "String"},
             {headerName:"基数说明",headerWidth:300,dataCode:"statement", dataType: "String"},
-            {headerName:"费率",headerWidth:80,dataCode:"feeRate", dataType: "Number"},
+            {headerName:"费率11",headerWidth:80,dataCode:"feeRate", dataType: "Number"},
             {headerName:"字段名称",headerWidth:140,dataCode:"displayFieldName", dataType: "String", hAlign: "center"},
             {headerName:"备注",headerWidth:100,dataCode:"memo", dataType: "String"}
         ],
@@ -56,7 +56,7 @@ 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);
         let mSheet = me.mainSpread.getSheet(0);
         sheetCommonObj.showData(mSheet, me.mainSetting, me.datas);
 
@@ -73,6 +73,10 @@ 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);
     }
 };
 

+ 136 - 0
web/building_saas/main/js/views/fee_rate_view.js

@@ -12,6 +12,18 @@ var feeRateObject={
     needCascadeSet:false,
     selectionLoad:false,
     changeInfo:null,
+    feeRateSpreads:null,
+    sheetSetting: {
+        header: [
+            {headerName: "专业名称", headerWidth: 200, dataCode: "name", dataType: "String"},
+            {headerName: "值%", headerWidth: 150, dataCode: "rate", dataType: "String"},
+            {headerName: "备注", dataCode: "memo", dataType: "String"}
+        ],
+        view: {
+            comboBox: [],
+            lockColumns: [0, 1, 2]
+        }
+    },
     columns: [
         {
             id: 'name',
@@ -101,6 +113,117 @@ var feeRateObject={
 
         }
     },
+    createSheet:function(){
+        feeRateObject.feeRateSpreads=sheetCommonObj.buildSheet($('#fee_rate_sheet')[0], feeRateObject.sheetSetting,30);
+        //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;
+        feeRateObject.feeRateSheet.options.isProtected = true;
+        feeRateObject.feeRateSheet.name('fee_rate');
+    },
+    showSelectTree:function () {
+        var sheet= feeRateObject.feeRateSheet;
+        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);
+        sheet.rowOutlines.group(15, 6);
+       // sheet.getRange(-1, 0, -1, 1).width(300);
+        sheet.showRowOutline(false);
+        sheet.resumeEvent();
+        sheet.resumePaint(false);
+    },
+    getTreeNodeCellType:function () {
+        var ns = GC.Spread.Sheets;
+        function TreeNodeCellType() {
+        }
+        TreeNodeCellType.prototype = new ns.CellTypes.Text();
+        TreeNodeCellType.prototype.paint = function (ctx, value, x, y, w, h, style, options) {
+            var level = options.sheet.rowOutlines.getLevel(options.row);
+            var nlevel = -1;
+            if (options.row < options.sheet.getRowCount() - 1) {
+                nlevel = options.sheet.rowOutlines.getLevel(options.row + 1);
+            }
+            var hoffset = (level + 2) * 12;
+            x += hoffset;
+            w -= hoffset;
+            GC.Spread.Sheets.CellTypes.Base.prototype.paint.apply(this, arguments);
+            if (options.row == options.sheet.getRowCount() - 1) return; //last row
+            if (nlevel > level) {
+                var collapsed = options.sheet.rowOutlines.isCollapsed(options.row + 1);
+                x--;
+                y += h / 2 - 3;
+                ctx.save();
+                ctx.fillStyle = "black";
+                ctx.beginPath();
+                if (collapsed) {
+                    ctx.moveTo(x - 5, y);
+                    ctx.lineTo(x, y + 3);
+                    ctx.lineTo(x - 5, y + 6);
+                } else {
+                    ctx.moveTo(x, y);
+                    ctx.lineTo(x, y + 5);
+                    ctx.lineTo(x - 5, y + 5);
+                }
+                ctx.fill();
+                ctx.restore();
+            }
+            else {
+                x--;
+                y += h / 2 - 3;
+                ctx.save();
+                ctx.restore();
+            }
+        };
+        // override getHitInfo to allow cell type get mouse messages
+        TreeNodeCellType.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
+            };
+        }
+        TreeNodeCellType.prototype.processMouseDown = function (hitinfo) {
+            var level = hitinfo.sheet.rowOutlines.getLevel(hitinfo.row);
+            var hoffset = (level + 2) * 12 + hitinfo.cellRect.x;
+            if (hitinfo.x < hoffset && hitinfo.x > hoffset - 10) {
+                var collapsed = hitinfo.sheet.rowOutlines.isCollapsed(hitinfo.row + 1);
+                hitinfo.sheet.rowOutlines.setCollapsed(hitinfo.row, !collapsed);
+                hitinfo.sheet.invalidateLayout();
+                hitinfo.sheet.repaint();
+            }
+        };
+        return new TreeNodeCellType()
+    },
     createSpreadView:function () {
         if (this.mainViews) {
             this.mainViews.destroy();
@@ -527,3 +650,16 @@ $('#inlineFormCustomSelect').change(function(){
     socket.emit('changeActivateFeeRate',{oldRoom:oldValue,newRoom:selectID});
 })
 
+$('#fee_rate_tree').on('shown.bs.modal', function (e) {
+    if(feeRateObject.feeRateSpreads==null){
+        feeRateObject.createSheet();
+    }
+    feeRateObject.showSelectTree();
+});
+
+$('#fee_rate_tree').on('hidden.bs.modal', function (e) {
+    if(feeRateObject.feeRateSpreads){
+        feeRateObject.feeRateSpreads.destroy();
+        feeRateObject.feeRateSpreads=null;
+    }
+});