Selaa lähdekoodia

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

TonyKang 6 vuotta sitten
vanhempi
commit
a98c860341

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

@@ -1057,7 +1057,7 @@
                 </div>
             </div>
             <div class="modal-footer">
-                <button class="btn btn-primary" id="scope_position_confirm">确定</button>
+                <button class="btn btn-primary" id="scope_position_confirm" data-dismiss="modal">确定</button>
                 <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
             </div>
         </div>

+ 1 - 0
web/building_saas/main/js/models/project_glj.js

@@ -353,6 +353,7 @@ ProjectGLJ.prototype.materialCal = function (id,dataMap) {
     handlingLossRate_n = scMathUtil.roundForObj(handlingLossRate_n,unitPirceDecimal)/100;
     offSiteTransportLossRate_n = scMathUtil.roundForObj(offSiteTransportLossRate_n,unitPirceDecimal)/100;
     totalLoadingTimes = scMathUtil.roundForObj(totalLoadingTimes,unitPirceDecimal) - 1;//(装卸总次数-1)
+    totalLoadingTimes = totalLoadingTimes < 0 ?0:totalLoadingTimes;//(装卸总次数-1) 结果小于0的时候,值设为0
     totalLoadingTimes = scMathUtil.roundForObj(totalLoadingTimes * handlingLossRate_n,process);//(装卸总次数-1)*每增加一次装卸损耗率%
     totalLoadingTimes = scMathUtil.roundForObj(totalLoadingTimes + offSiteTransportLossRate_n,process);//(装卸总次数-1)*每增加一次装卸损耗率%+场外运输损耗率%
     let offSiteTransportLoss = scMathUtil.roundForObj(sum_o_f*totalLoadingTimes,unitPirceDecimal); //场外运输损耗=(原价+单位运费)*((装卸总次数-1)*每增加一次装卸损耗率%+场外运输损耗率%)。

+ 1 - 0
web/building_saas/main/js/models/ration_glj.js

@@ -900,6 +900,7 @@ let ration_glj = {
                 query.specs = oldData.specs;
             }
             for(let d of this.datas){//查询出所有需替换的工料机
+                if(!gljOprObj.scopeSelectedIDMap[d.billsItemID]) continue; //如果不在选中范围的,跳过
                 let tem_index = gljOprObj.getIndex(d, gljKeyArray);
                 if(tem_index == oldIndex){
                     let tem_doc = {};

+ 147 - 0
web/building_saas/main/js/views/glj_col.js

@@ -67,6 +67,144 @@ let gljCol = {
             lockColumns: [0,1,2,3,4,5,6,7]
         }
     },
+    scopeSetting:{
+        "emptyRows":0,
+        "headRows":1,
+        "headRowHeight":[30],
+        "defaultRowHeight": 21,
+        "treeCol": 1,
+        "cols":[
+            {
+                "width":40,
+                "readOnly": true,
+                "head":{
+                    "titleNames":["选择"],
+                    "spanCols":[1],
+                    "spanRows":[1],
+                    "vAlign":[1],
+                    "hAlign":[1],
+                    "font":["Arial"]
+                },
+                "data":{
+                    "field":"selected",
+                    "vAlign":1,
+                    "hAlign":1,
+                    "font":"Arial",
+                    "cellType":function (node) {
+                            return new GC.Spread.Sheets.CellTypes.CheckBox();
+                    }
+                }
+            },
+            {
+                "width":140,
+                "readOnly": true,
+                "head":{
+                    "titleNames":["编号"],
+                    "spanCols":[1],
+                    "spanRows":[1],
+                    "vAlign":[1],
+                    "hAlign":[1],
+                    "font":["Arial"]
+                },
+                "data":{
+                    "field":"code",
+                    "vAlign":1,
+                    "hAlign":0,
+                    "font":"Arial"
+                }
+            },
+            {
+                "width":240,
+                "readOnly": true,
+                "head":{
+                    "titleNames":["名称"],
+                    "spanCols":[1],
+                    "spanRows":[1],
+                    "vAlign":[1],
+                    "hAlign":[1],
+                    "font":["Arial"]
+                },
+                "data":{
+                    "field":"name",
+                    "vAlign":0,
+                    "hAlign":0,
+                    "font":"Arial"
+                }
+            },
+            {
+                "width":70,
+                "readOnly": true,
+                "head":{
+                    "titleNames":["单位"],
+                    "spanCols":[1],
+                    "spanRows":[1],
+                    "vAlign":[1],
+                    "hAlign":[1],
+                    "font":["Arial"]
+                },
+                "data":{
+                    "field":"unit",
+                    "vAlign":1,
+                    "hAlign":1,
+                    "font":"Arial"
+                }
+            },
+            {
+                "width":80,
+                "readOnly": true,
+                "head":{
+                    "titleNames":["工程量"],
+                    "spanCols":[1],
+                    "spanRows":[1],
+                    "vAlign":[1],
+                    "hAlign":[1],
+                    "font":["Arial"]
+                },
+                "data":{
+                    "field":"quantity",
+                    "vAlign":1,
+                    "hAlign":2,
+                    "font":"Arial"
+                }
+            },
+            {
+                "width":80,
+                "readOnly": true,
+                "head":{
+                    "titleNames":["单价"],
+                    "spanCols":[1],
+                    "spanRows":[1],
+                    "vAlign":[1],
+                    "hAlign":[1],
+                    "font":["Arial"]
+                },
+                "data":{
+                    "field":"unitPrice",
+                    "vAlign":1,
+                    "hAlign":2,
+                    "font":"Arial"
+                }
+            },
+            {
+                "width":80,
+                "readOnly": true,
+                "head":{
+                    "titleNames":["金额"],
+                    "spanCols":[1],
+                    "spanRows":[1],
+                    "vAlign":[1],
+                    "hAlign":[1],
+                    "font":["Arial"]
+                },
+                "data":{
+                    "field":"totalPrice",
+                    "vAlign":1,
+                    "hAlign":2,
+                    "font":"Arial"
+                }
+            }
+        ]
+    },
     removeCol:function (dataCode,setting) {
         let colIndex = _.findIndex(setting.header,{'dataCode':dataCode});
         if(colIndex != -1){
@@ -94,6 +232,15 @@ let gljCol = {
         gljOprObj.setting = me.ration_glj_setting;
         projectGljObject.projectGljSetting = me.project_glj_setting;
         projectGljObject.mixRatioSetting = me.mixRatio_Setting;
+        me.setScopeFormater();
+        gljOprObj.scopeSetting = me.scopeSetting;
+    },
+    setScopeFormater:function () {
+        // 综合单价、综合合价,小数部分应补0对齐。  CSL
+        for(let col of this.scopeSetting.cols){
+            if (col.data.field=="totalPrice") col.data.formatter = MainTreeCol.getNumberFormatter(decimalObj.ration.totalPrice, true);
+            if (col.data.field== "unitPrice")  col.data.formatter = MainTreeCol.getNumberFormatter(decimalObj.ration.unitPrice, true);
+        }
     }
 
 };

+ 87 - 9
web/building_saas/main/js/views/glj_view.js

@@ -101,6 +101,11 @@ var gljOprObj = {
         }
     },
     gljLibSheet: null,
+    scopeSetting:{},
+    scopeSpread:null,
+    scopeSheet:null,
+    scopeDatas:[],
+    scopeSelectedIDMap:{},
     initSheet: function (sheet) {
         var me = this;
         me.sheet = sheet;
@@ -1083,7 +1088,6 @@ var gljOprObj = {
         if (me.GLJSelection.length <= 0) {
             return;
         }
-        $("#glj_tree_div").modal('hide');
         $.bootstrapLoading.start();
         project.ration_glj.insertGLJAsRation(me.GLJSelection, selected, function (parentNodeID,nextNodeID,data) {
             let newNode=null;
@@ -1126,7 +1130,6 @@ var gljOprObj = {
             return rg ? false : true;
         })
         if (gljOprObj.GLJSelection.length > 0 && selected && selected.sourceType == ModuleNames.ration) {
-            $("#glj_tree_div").modal('hide');
             project.ration_glj.addGLJByLib(gljOprObj.GLJSelection, selected.data, function (result) {
                 if (result) {
                     selected.data.adjustState = result.adjustState;
@@ -1142,8 +1145,6 @@ var gljOprObj = {
                     });
                 }
             });//doc.rationID=selected.data.ID;
-        } else {
-            $("#glj_tree_div").modal('hide');
         }
     },
     doReplaceGLJ: function () {
@@ -1152,7 +1153,6 @@ var gljOprObj = {
         let project = projectObj.project;
         let selectCode = gljOprObj.GLJSelection[0];
         let selected = projectObj.project.mainTree.selected;
-        $("#glj_tree_div").modal('hide');
         project.ration_glj.replaceGLJ(selectCode, oldData, function (result) {
             if (result) {
                 //result.adjustState;
@@ -1187,7 +1187,6 @@ var gljOprObj = {
         let oldData = me.sheetData[gljContextMenu.selectedRow];
         let project = projectObj.project;
         let selectCode = me.GLJSelection[0];
-        $("#glj_tree_div").modal('hide');
         project.ration_glj.mReplaceGLJ(selectCode, oldData, function (result,updateMap) {
             if(result == null){
                 return;
@@ -1412,8 +1411,72 @@ var gljOprObj = {
                 me.gljTreeSetting.callback.onClick(null, 'gljTree', me.rootNode);
             }
         }
+    },
+    initScopeSpread:function() {
+        if (this.scopeSpread) return this.scopeSpread.repaint();
+        this.scopeSpread = SheetDataHelper.createNewSpread($('#scopeSpread')[0]);
+        sheetCommonObj.spreadDefaultStyle(this.scopeSpread);
+        this.scopeTree = idTree.createNew({id: 'ID', pid: 'ParentID', nid: 'NextSiblingID', rootId: -1, autoUpdate: false});
+        this.scopeTreeController = TREE_SHEET_CONTROLLER.createNew(this.scopeTree, this.scopeSpread.getActiveSheet(), this.scopeSetting);
+        this.scopeSheet = this.scopeSpread.getActiveSheet();
+        this.scopeSpread.bind(GC.Spread.Sheets.Events.ButtonClicked, this.onScopeChecked);
+    },
+    showScopeDatas:function () {
+        this.initScopeSpread();
+        this.scopeDatas =this.getScopeDatas();
+        this.scopeTree.loadDatas(this.scopeDatas);
+        this.scopeTreeController.showTreeData();
+    },
+    getScopeDatas:function () {
+        let controller = projectObj.mainController, project = projectObj.project;
+        let allNodes = [],datas = []
+        for(let rootNode of controller.tree.roots){
+            allNodes.push(rootNode);
+            controller.tree.getAllSubNode(rootNode.source,allNodes);
+        }
+        for(let n of allNodes){
+            let temData = {
+                ID:n.data.ID,
+                NextSiblingID:n.data.NextSiblingID,
+                ParentID:n.data.ParentID,
+                unit : n.data.unit,
+                code : n.data.code,
+                selected:0,
+                name : n.data.name,
+                quantity:calcTools.uiNodeQty(n)?calcTools.uiNodeQty(n):"",
+            };
+            if(n.data.feesIndex && n.data.feesIndex.common){
+                temData.unitPrice = n.data.feesIndex.common.unitFee;
+                temData.totalPrice = n.data.feesIndex.common.totalFee;
+            }
+            datas.push(temData);
+        }
+        return datas;
+    },
+    onScopeChecked:function (e,args) {
+        let me = gljOprObj,nodes = [];
+        var checkboxValue = args.sheet.getCell(args.row, args.col).value();
+        var newval = checkboxValue?0:1;
+        let node = me.scopeTree.items[args.row];
+        setNodeAndChildreSelected(node,newval,nodes);
+        me.scopeTreeController.refreshTreeNode(nodes);
+        
+        function setNodeAndChildreSelected(n,val,arr){
+            n.data.selected = val;
+            nodes.push(n);
+            for(let c of n.children){
+                setNodeAndChildreSelected(c,val,arr)
+            }
+
+        }
+    },
+    setScopeSelection:function () {
+        for(let node of this.scopeTree.items){
+            //挑出选中数,过滤父节点
+            if(node.data.selected == 1 && node.children.length == 0) this.scopeSelectedIDMap[node.data.ID] = true
+        }
     }
-}
+};
 
 $(function () {
     $('#glj_tree_div').on('shown.bs.modal', function (e) {
@@ -1485,6 +1548,13 @@ $(function () {
         }
     });
 
+    $('#mreplace_next_div').on('shown.bs.modal', function (e) {
+        gljOprObj.scopeSelectedIDMap = {};
+        gljOprObj.showScopeDatas();
+    });
+
+
+
     $('#glj_tree_div').on('hidden.bs.modal', function () {
         $('#gljSearchKeyword').val('');
     });
@@ -1540,8 +1610,16 @@ $(function () {
         }else if($('#actionType').val() == 'addMix'){
             projectGljObject.addMixRatio();
         }
-    })
-
+        $("#glj_tree_div").modal('hide');
+    });
+    $('#scope_position_confirm').click(function () {
+        gljOprObj.setScopeSelection();
+        gljOprObj.doMReplaceGLJ();
+    });
+    $('#replace_next_btn').click(function () {
+        $("#glj_tree_div").modal('hide');
+        $("#mreplace_next_div").modal('show');
+    });
     $('#class_selected_conf').click(function () {
         var gljClass = $('#selected_class').val();
         var glj = gljOprObj.selectedGLJClass;

+ 7 - 0
web/building_saas/main/js/views/glj_view_contextMenu.js

@@ -392,6 +392,13 @@ function getGLJData(actionType) {
         $('#modalCon').width($(window).width()*0.5);
         $("input[name='glj']").get(0).checked=true;
         $.bootstrapLoading.end();
+        if(actionType == "m_replace"){
+            $('#glj_selected_conf').hide();
+            $('#replace_next_btn').show();
+        }else {
+            $('#glj_selected_conf').show();
+            $('#replace_next_btn').hide();
+        }
         $("#glj_tree_div").modal({show:true});
         setTimeout(function(){
             gljOprObj.gljLibSpresd?gljOprObj.gljLibSpresd.refresh():'';