Browse Source

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

Chenshilong 7 years ago
parent
commit
6f5ab51c39

+ 1 - 0
web/building_saas/complementary_glj_lib/js/components.js

@@ -237,6 +237,7 @@ let componentOprObj = {
             }
             updateArr.push(re.currentGlj);
             that.updateComponent(updateArr);
+            $('#componentsCacnel').click();
         });
     }
 };

+ 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>

+ 8 - 13
web/building_saas/main/js/models/bills.js

@@ -37,6 +37,9 @@ var Bills = {
                 let uData = JSON.parse(JSON.stringify(data));
                 delete uData.feesIndex;
                 delete uData.flagsIndex;
+                if (uData.quantity) {
+                    uData.quantity = uData.quantity.toFixed(2);
+                }
                 if (uData.fees) {
                     for (let fee of uData.fees) {
                         fee.unitFee = fee.unitFee.toFixed(2);
@@ -85,6 +88,9 @@ var Bills = {
             this.datas = datas;
             // generate Fees & Flags Index, For View & Calculate
             this.datas.forEach(function (data) {
+                if (data.quantity) {
+                    data.quantity = parseFloat(data.quantity);
+                }
                 data.feesIndex = {};
                 if (data.fees) {
                     data.fees.forEach(function (fee) {
@@ -250,25 +256,14 @@ var Bills = {
             } else {
                 data[field] = newValue;
             }
-            updateData.push({'updateType': 'ut_update', 'updateData': data});
+            updateData.push({'updateType': 'ut_update', 'updateData': tools.formatBillsUpdateData(data)});
             this.project.pushNow('updateBills', this.getSourceType(), updateData);
         };
 
         bills.prototype.updateAll = function () {
             let updateData = [];
             for (let data of this.datas) {
-                let uData = JSON.parse(JSON.stringify(data));
-                delete uData.feesIndex;
-                delete uData.flagsIndex;
-                if (uData.fees) {
-                    for (let fee of uData.fees) {
-                        fee.unitFee = fee.unitFee.toFixed(2);
-                        fee.totalFee = fee.totalFee.toFixed(2);
-                        fee.tenderUnitFee = fee.tenderUnitFee.toFixed(2);
-                        fee.tenderTotalFee = fee.tenderTotalFee.toFixed(2);
-                    }
-                }
-                updateData.push({'updateType': 'ut_update', 'updateData': uData});
+                updateData.push({'updateType': 'ut_update', 'updateData': tools.formatBillsUpdateData(data)});
             }
             this.project.pushNow('updateAllBills', this.getSourceType(), updateData);
         };

+ 27 - 1
web/building_saas/main/js/models/ration.js

@@ -160,7 +160,7 @@ var Ration = {
             return newRation;
         };
         ration.prototype.insertStdRation = function (billsID, preRation, std) {
-            var br = this.getBillsSortRation(billsID), updateData = this.getInsertRationData(billsID, preRation), newRation = null;
+            var br = this.getBillsSortRation(billsID), updateData = this.getInsertRationData(billsID, preRation), newRation = null, that = this;
             updateData.forEach(function (data) {
 
                 if (data.updateType === 'ut_create') {
@@ -175,6 +175,8 @@ var Ration = {
                         data.updateData.ruleText = std.chapter.ruleText;
                     }
                     data.updateData.rationAssList =  projectObj.project.ration_ass.CreateNewAss(std);
+                    // calculate ration Quantity
+                    that.CalculateQuantity(data.updateData);
                     newRation = data.updateData;
                 }
             });
@@ -282,6 +284,28 @@ var Ration = {
             }
         };
 
+        ration.prototype.FilterNumberFromUnit = function (unit) {
+            let reg = new RegExp('^[0-9]+');
+            if (reg.test(unit)) {
+                return parseInt(unit.match(reg)[0]);
+            } else {
+                return 1;
+            }
+        };
+
+        ration.prototype.CalculateQuantity = function (ration) {
+            // calculate ration Quantity
+            if (optionsOprObj.getOption(optionsOprObj.optionsTypes.GENERALOPTS, 'rationQuanACToBillsQuan')) {
+                let billsNode = this.project.Bills.tree.findNode(ration[this.project.masterField.ration]);
+                let billsQuantity = billsNode.data.quantity ? billsNode.data.quantity : 0;
+                if (optionsOprObj.getOption(optionsOprObj.optionsTypes.GENERALOPTS, 'rationQuanACToRationUnit')) {
+                    ration.quantity = (billsQuantity / this.FilterNumberFromUnit(ration.unit)).toDecimal(4);
+                } else {
+                    ration.quantity = billsQuantity.toDecimal(4);
+                }
+            }
+        };
+
         ration.prototype.replaceRation = function (ration, std) {
             this.project.beginUpdate('replaceRation');
             
@@ -306,6 +330,8 @@ var Ration = {
                 ration.ruleText = std.chapter.ruleText;
             }
             ration.rationAssList = projectObj.project.ration_ass.CreateNewAss(std);
+            // calculate ration Quantity
+            this.CalculateQuantity(ration);
             updateData.push({updateType: 'ut_update', updateData: ration});
             this.project.push(this.getSourceType(), updateData);
 

+ 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;
+    }
+});

+ 4 - 0
web/building_saas/main/js/views/options_view.js

@@ -56,6 +56,10 @@ let optionsOprObj = {
             }
         }
         return rst;
+    },
+    getOption: function (type, optionName) {
+        let opts = this.getOptsByType(this.options, type);
+        return opts[optionName];
     }
 };
 

+ 1 - 0
web/building_saas/main/js/views/project_view.js

@@ -139,6 +139,7 @@ var projectObj = {
             calcFees.setFee(node.data, fieldName, value);
             calc.calcNode(node, true);
             nodes = getNodes(node);
+            project.Bills.updateNodes(nodes, true);
         } else if (node.sourceType === projectObj.project.VolumePrice.getSourceType()) {
             project.beginUpdate('VolumePrice_QuantityChange');
             project.VolumePrice.updateField(node.source, fieldName, value, false);