Ver código fonte

查找定位工料机为0时也显示bugs

zhangweicheng 6 anos atrás
pai
commit
ce03e2b25a

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

@@ -160,9 +160,9 @@
                           </li>
 
                           <li class="nav-item dropdown">
-                              <a class="nav-link dropdown-toggle more" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false" style="display:none">更多</a>
+                              <a class="nav-link dropdown-toggle more" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false" style="display: none;">更多</a>
                               <div class="dropdown-menu" id="div_more_dropdown_right">
-                                  <!--<a class="dropdown-item  right-nav-link"  href="javascript:void(0)" id = 'locateTab' relaPanel="#locate">查找定位</a>-->
+                                  <a class="dropdown-item  right-nav-link"  href="javascript:void(0)" id = 'locateTab' relaPanel="#locate">查找定位</a>
                                   <!--<a class="dropdown-item" data-toggle="tab" href="#sqpz" role="tab">书签批注</a>-->
                                   <script>
                                       //2018-11-23  zhang 模板库移动到更多下拉框
@@ -334,7 +334,7 @@
                                   <div class="sidebar-tools-bar container-fluid tools-bar-height-y" id="searchPanel">
                                       <div class="p-1 row">
                                           <div class="input-group input-group-sm col-12">
-                                              <input type="text" class="form-control form-control-sm" placeholder="查找内容" value="">
+                                              <input type="text" class="form-control form-control-sm" placeholder="查找内容" id="locateInput" value="">
                                               <div class="input-group-append">
                                                   <button class="btn btn-secondary btn-sm" type="button" id="locate_btn"><i class="fa fa-search" aria-hidden="true"></i></button>
                                               </div>

+ 228 - 14
web/building_saas/main/js/views/locate_view.js

@@ -32,7 +32,7 @@ let locateObject={
         header:[
             {headerName: "编码", headerWidth: 120, dataCode: "code", dataType: "String"},
             {headerName: "名称", headerWidth: 80, dataCode: "name", dataType: "String"},
-            {headerName: "规格型号", headerWidth: 80, dataCode: "code", dataType: "String"},
+            {headerName: "规格型号", headerWidth: 80, dataCode: "specs", dataType: "String"},
             {headerName: "单位", headerWidth: 50, dataCode: "unit", dataType: "String",hAlign: "center"},
             {headerName: "市场价", headerWidth: 65, dataCode: "marketPrice", dataType: "Number", hAlign: "right"}
         ],
@@ -41,6 +41,7 @@ let locateObject={
             colHeaderHeight:30
         }
     },
+    datas:[],
     initMainSpread:function(){
         if(!this.mainSpread){
             this.mainSpread = SheetDataHelper.createNewSpread($("#locate_result")[0],3);
@@ -51,24 +52,24 @@ let locateObject={
         }
     },
     initMainSheet:function () {
-       // this.mainSheet = this.mainSpread .getSheet(0);
-        //this.spread.bind(GC.Spread.Sheets.Events.ButtonClicked, this.onReplaceButtonClick);
-       //初始化清单表格
+        //初始化清单表格
         sheetCommonObj.initSheet(this.mainSpread .getSheet(0),this.bills_setting);
         this.mainSpread .getSheet(0).setRowCount(0);
         //初始化定额表格
         sheetCommonObj.initSheet(this.mainSpread .getSheet(1),this.ration_setting);
         this.mainSpread .getSheet(1).setRowCount(0);
-
         //初始化人材机表格
         sheetCommonObj.initSheet(this.mainSpread.getSheet(2),this.ration_glj_setting);
         this.mainSpread .getSheet(2).setRowCount(0);
+        this.mainSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick,this.onSheetDoubleClick);
+        this.mainSpread .getSheet(2).bind(GC.Spread.Sheets.Events.SelectionChanged,this.gljSelectionChange);
     },
     initSubSpread:function () {
         if(!this.subSpread){
             this.subSpread = SheetDataHelper.createNewSpread($("#locate_sub")[0]);
             sheetCommonObj.spreadDefaultStyle(this.subSpread);
             this.initSubSheet();
+            this.subSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick,this.onSheetDoubleClick);
         }else {
             this.subSpread.refresh();
         }
@@ -85,14 +86,39 @@ let locateObject={
         this.subSheet = this.subSpread .getSheet(0);
         sheetCommonObj.initSheet( this.subSheet, this.ration_setting);
         this.subSheet.setRowCount(0);
-        //this.spread.bind(GC.Spread.Sheets.Events.ButtonClicked, this.onReplaceButtonClick);
         this.subSheet.name('locate_sub');
     },
-    showMainData:function () {
-        let datas = [];
-        //sheetCommonObj.showData(this.mainSheet,this.mainSettiong,datas);
+    initOutstanding:function () {
+        if(!projectObj.project.property.locateSetting) return;
+        let outstd = projectObj.project.property.locateSetting;
+        $("#outstanding").prop("checked",outstd.outstanding);
+        $("#outInp").val(parseFloat(outstd.outInp));
+    },
+    showMainData:function (datas,setting) {
+        sheetCommonObj.showData(this.mainSpread.getActiveSheet(),setting,datas);
         this.mainSpread.getActiveSheet().setRowCount(datas.length);
     },
+    showSubRateDatas:function () {
+        this.subRationDatas = this.getSubRationDatas();
+        sheetCommonObj.showData(this.subSheet,this.ration_setting,this.subRationDatas);
+        this.subSheet.setRowCount(this.subRationDatas.length);
+    },
+
+    getSubRationDatas:function () {
+        let datas = [];
+        let sheet = this.mainSpread.getActiveSheet();
+        let oldSel = sheet.getSelections()[0];
+        if(this.gljDatas && this.gljDatas.length > 0){
+            let glj = this.gljDatas[oldSel.row];
+            if(!glj) return datas;
+            let  nodes = projectObj.project.projectGLJ.getImpactRationNodes([glj.reference]);
+            for(let n of nodes){
+                datas.push(this.getShowRationDatas(n.data));
+            }
+        }
+        return datas;
+    },
+
     refreshView: function (options, refreshWorkBook) {
         let me = this;
         let mainHeight = $(window).height()-$(".header").height()-$(".toolsbar").height()-$("#searchPanel").height();
@@ -118,28 +144,200 @@ let locateObject={
             me.refreshView(options, false);
             me.initMainSpread();
             me.initSubSpread();
-            me.showMainData();
         };
+        if(options == "bills") me.initOutstanding();
         options == "bills"?$("#outstandingOptions").show(0,callback):$("#outstandingOptions").hide(0,callback);
 
     },
     findRecodes:function () {
-
+        let options = $("input[name='content_type']:checked").val();
+        let keyword = $("#locateInput").val();
+        switch (options){
+            case "bills":
+                this.billsDatas = this.findBills(keyword);
+                this.showMainData(this.billsDatas,this.bills_setting);
+                break;
+            case "ration":
+                this.rationDatas = this.findRations(keyword);
+                this.showMainData(this.rationDatas,this.ration_setting);
+                break;
+            case "ration_glj":
+                this.gljDatas = this.findGLJs(keyword);
+                this.showMainData(this.gljDatas,this.ration_glj_setting);
+                this.showSubRateDatas();
+                break;
+        }
     },
     onshow:function () {
         locateObject.init();
+    },
+    matchItem:function (keyword,i) {//true 匹配上,false匹配失败
+        let match = false;
+        if(keyword && keyword !="") {//如果keyword为空,匹配所有
+            if (i.code && i.code.indexOf(keyword) != -1) match = true;
+            if (i.name && i.name.indexOf(keyword) != -1) match = true;
+            if(match == false) return false
+        }
+        return true;
+    },
+    findGLJs:function(keyword){
+        let datas = [];
+        let gljList = projectObj.project.projectGLJ.datas.gljList;
+        gljList =  sortProjectGLJ(gljList);
+        for(let glj of gljList){
+            // if(glj.quantity == 0 || glj.quantity == '0') continue;  2019-07-01 需求改成消耗量为0也显示
+            let match = this.matchItem(keyword,glj);
+            if(match == false) continue;
+            let data = getGLJDatas(glj);
+            gljOprObj.setGLJPrice(data,glj);
+            datas.push(data);
+        }
+        return datas;
+        function getGLJDatas(tem) {
+            return{
+                ID:tem.id,
+                name:tem.name,
+                code:tem.code,
+                unit:tem.unit,
+                specs:tem.specs,
+                reference:tem
+            }
+        }
+
+    },
+    findRations:function (keyword) {
+        let datas = [];
+        let items = projectObj.project.mainTree.items;
+        for(let  i of items){
+            if(i.sourceType == ModuleNames.ration){
+                let match = this.matchItem(keyword,i.data);
+                if(match == false) continue;
+                let bills = this.getShowRationDatas(i.data);
+                datas.push(bills);
+            }
+        }
+        return datas;
+    },
+    getShowRationDatas:function(data){
+        return{
+            ID:data.ID,
+            name:data.name,
+            code:data.code,
+            unit:data.unit,
+            quantity:data.quantity
+        }
+    },
+    findBills:function(keyword){
+        let datas = [],priceMap={};
+        let items = projectObj.project.mainTree.items;
+        for(let  i of items){
+            if(i.sourceType == ModuleNames.bills){
+                let match = this.matchItem(keyword,i.data);
+                if(match == false) continue;
+                let bills = getBillData(i.data);
+                priceMap = setPriceMap(bills,priceMap);
+                datas.push(bills);
+            }
+        }
+        setBgColour(datas,priceMap);
+        datas =  _.sortByAll(datas,['code']);
+        return datas;
+
+
+        function setBgColour(bills,map) {
+            let outStd = $("#outstanding").prop("checked");
+            let outInp = $("#outInp").val();
+            if(outStd == true && outInp && outInp!=""){
+                for(let b of bills){
+                    if(b.code && b.code.length >= 9){
+                        let key = b.code.substr(0,9);
+                        if(map[key] && map[key].count > 1){
+                            let avg = map[key].total/map[key].count;
+                            let unitPrice = b.unitPrice?parseFloat(b.unitPrice):0;
+                            if(unitPrice ==0 ) continue;
+                            if(Math.abs(unitPrice - avg)/avg * 100  >= parseFloat(outInp)) b.bgColour = "#FFFACD"
+                        }
+                    }
+                }
+            }
+        }
+        function setPriceMap (bills,map) {
+            if(bills.code && bills.code.length >= 9){
+                let key = bills.code.substr(0,9);
+                let unitPrice = bills.unitPrice?parseFloat(bills.unitPrice):0;
+                if(map[key]){
+                    map[key].total += unitPrice;
+                    map[key].count ++;
+                }else {
+                    map[key] = {total:unitPrice,count:1}
+                }
+
+            }
+
+            return map;
+        }
+
+        function getBillData(data) {
+            return{
+                ID:data.ID,
+                name:data.name,
+                code:data.code,
+                unit:data.unit,
+                quantity:data.quantity,
+                unitPrice:data.feesIndex&&data.feesIndex.common?data.feesIndex.common.unitFee:"",
+                totalPrice:data.feesIndex&&data.feesIndex.common?data.feesIndex.common.totalFee:"",
+                bgColour:"white"
+            }
+        }
+    },
+    onSheetDoubleClick:function (e,args) {
+        let me = locateObject;
+        let options = $("input[name='content_type']:checked").val();
+        let sheetName = args.sheet.name()
+        if(options == "ration_glj"&&sheetName != "locate_sub" ) return;
+        let datas = options == "bills"? me.billsDatas:me.rationDatas;
+        if( args.sheet.name() == "locate_sub") datas = me.subRationDatas;
+        me.locateNode(datas[args.row].ID);
+    },
+    gljSelectionChange:function (e,args) {
+        let me = locateObject;
+        let newSel = args.newSelections[0];
+        let oldSel = args.oldSelections?args.oldSelections[0]:{};
+        if(newSel.row != oldSel.row){
+            me.showSubRateDatas();
+        }
+    },
+    locateNode:function (ID) {
+        let node =  projectObj.project.mainTree.findNode(ID);
+        if(node) projectObj.loadFocusLocation(node.serialNo(),1);
+    },
+    updateOutStanding:function (outstanding,outInp) {
+        let outstd = {outstanding:outstanding,outInp:outInp};
+        let updateData = {type:ModuleNames.project,data:{'ID' : projectObj.project.ID(),'property.locateSetting':outstd}};
+        projectObj.project.updateNodes([updateData],function () {
+            projectObj.project.property.locateSetting = outstd;
+        });
     }
-}
+
+};
 
 
 $("#locate_btn").click(function () {
     locateObject.findRecodes();
 });
 
+//回车键搜索
+$('#locateInput').bind('keypress', function (event) {
+    if(event.keyCode === 13){
+        $(this).blur();
+        locateObject.findRecodes();
+    }
+});
+
 $("input[name='content_type']").each(function(){
     $(this).click(function(){
-        let optins = $(this).val();
-        switch (optins){
+        let options = $(this).val();
+        switch (options){
             case "bills":
                 locateObject.mainSpread.setActiveSheetIndex(0);
                 break;
@@ -153,3 +351,19 @@ $("input[name='content_type']").each(function(){
         locateObject.init();
     });
 });
+
+
+$('#outInp').change(function(){
+    let me = locateObject;
+    let process = getDecimal('process');
+    var newVal = $(this).val();
+    let outInp = scMathUtil.roundForObj(newVal,process);
+    let outStd = $("#outstanding").prop("checked");
+    me.updateOutStanding(outStd,outInp);
+});
+$('#outstanding').change(function(){
+    let me = locateObject;
+    let outInp = $("#outInp").val();
+    let outStd = $("#outstanding").prop("checked");
+    me.updateOutStanding(outStd,scMathUtil.roundForObj(outInp,getDecimal('process')));
+});

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

@@ -1567,10 +1567,10 @@ var projectObj = {
     },
 
     // 获取上次退出时的焦点位置
-    loadFocusLocation: function() {
+    loadFocusLocation: function(orow,ocol) {
         const projectId = scUrlUtil.GetQueryString('project');
-        let row = getLocalCache('lastRow:' + projectId);
-        let col = getLocalCache('lastCol:' + projectId);
+        let row = gljUtil.isDef(orow)?orow:getLocalCache('lastRow:' + projectId);
+        let col = gljUtil.isDef(ocol)?ocol:getLocalCache('lastCol:' + projectId);
         if(row == null || col == null){
             //默认焦点定位到造价书的第一行“分项”。
             col = 1;