Jelajahi Sumber

接口联调 记录滚动条高度

wenmenghao321 2 tahun lalu
induk
melakukan
e887dc3deb

+ 2 - 0
src/jfw/modules/app/src/web/staticres/jyapp/big-member/js/report_analysis.js

@@ -308,6 +308,7 @@ var vm = new Vue({
         if (this.rid) {
           this.getReportResult()
         }
+        
       } else {
         this.$nextTick(this.calcOffsetTop)
         if (utils.isIos) {
@@ -320,6 +321,7 @@ var vm = new Vue({
   },
   methods: {
     gotable () {
+      this.saveState()
       window.location.href='/jyapp/big/page/report_table?source=analysis'+'&flag=3'+'&rid='+this.rid+'&header=客户类型分布详情'
     },
     showLoading: function () {

+ 42 - 3
src/jfw/modules/app/src/web/staticres/jyapp/big-member/js/report_detail_month.js

@@ -5,6 +5,7 @@ var vNode = {
       monthReportExample: monthReportExample,
     },
     data: {
+        scrollTop:0,
         barChart: barChart,
         keywords:'',
         keyTip: '',
@@ -162,9 +163,46 @@ var vNode = {
         if (this.$refs['chartRegCount']) {
           this.$refs['chartRegCount'].echarts.resize()
         }
+        setTimeout(() => {
+            this.reStoreState()
+        
+        }, 500);
+        utils.iosBackRefresh()
     },
     methods: {
+      saveScrollTop: function () {
+        var wrapper = document.querySelector('.j-container .j-main')
+        if (wrapper.scrollTop) {
+          this.scrollTop = parseInt(wrapper.scrollTop)
+        }
+        var $data = {
+          scrollTop: this.scrollTop, 
+        }
+        sessionStorage.setItem('$data_month', JSON.stringify($data))
+      },
+      reStoreState: function () {
+        var $data = sessionStorage.getItem('$data_month')
+        if ($data) {
+          $data = JSON.parse($data)
+          this.scrollTop = $data.scrollTop
+        
+          setTimeout(function () {
+            // 恢复滚动高度
+            this.setScrollTop(this.scrollTop)
+          }.bind(this), 0)
+  
+          sessionStorage.removeItem('$data_month')
+        } 
+  
+      },
+      setScrollTop: function (scrollTop) {
+        this.$nextTick(function () {
+          var wrapper = document.querySelector('.j-container .j-main')
+          wrapper.scrollTop = scrollTop
+        })
+      },
         goTable (type) {
+          this.saveScrollTop()
           if(type =='curMonthCountTop'){ // 本月项目数量采购行业排行榜
             window.location.href='/jyapp/big/page/report_table?source=curMonthCountTop&type='+utils.getParam("type")+'&start='+utils.getParam('start')+'&end='+utils.getParam('end')+'&header=本月项目数量采购行业排行榜'
             
@@ -411,8 +449,9 @@ var vNode = {
                         // 本月项目数量TOP10采购行业 7
                         if(res.data.project_buyerclass_count && res.data.project_buyerclass_count.length > 0) {
                             // that.curMonthCountTop.list = that.formatterWinData(res.data.project_buyerclass_count,'count')
+                            
                             var pro_count_list = res.data.project_buyerclass_count.filter(function (item, index) {
-                              return item[buyerclass] != '其它'
+                              return item['buyerclass'] != '其它'
                              })
                             that.curMonthCountTop.list = that.formatterWinData(pro_count_list,'count')
                             that.isShow.show_7 = true;
@@ -425,7 +464,7 @@ var vNode = {
                             // that.curMonthScaleTop.list = that.formatterWinData(data,'scale')
                             var data = res.data.project_buyerclass_bidamount;
                             var pro_bidamount_list = data.filter(function (item, index) {
-                              return item[buyerclass] != '其它'
+                              return item['buyerclass'] != '其它'
                              })
                             that.curMonthScaleTop.list = that.formatterWinData(pro_bidamount_list,'scale')
                             that.isShow.show_8 = true;
@@ -438,7 +477,7 @@ var vNode = {
                             // that.averageScaleTop.list = that.formatterWinData(d,'average')
                             var d = res.data.project_buyerclass_average_bidamount;
                             var pro_average_list = d.filter(function (item, index) {
-                              return item[buyerclass] != '其它'
+                              return item['buyerclass'] != '其它'
                              })
                             that.averageScaleTop.list = that.formatterWinData(pro_average_list,'average')
                             that.isShow.show_9 = true;

+ 43 - 20
src/jfw/modules/app/src/web/templates/big-member/page_report_table.html

@@ -221,7 +221,7 @@
             <tr><th v-for="(item,index) in head_list" :class="{'sort_': index==0,'long_': index==1 ,'middle':index==2||index==3}" v-html="item"></th></tr>
           </thead>
            <tbody>
-            <tr v-for="(item,index) in data_list" v-show="item.total==0 && item.amount==0">
+            <tr v-for="(item,index) in data_list" >
             <td class="sort_">${index + 1}</td>
             <td class="long_">${item.buyclass}</td>
             <td class="t_right middle">${item.total}</td>
@@ -248,7 +248,7 @@
             <tr><th v-for="(item,index) in head_list" :class="{'sort': index==0,'long': index==1 || index==2}" v-html="item"></th></tr>
           </thead>
             <tbody>
-            <tr v-for="(item,index) in data_list" v-show="item.value == 0">
+            <tr v-for="(item,index) in data_list" >
             <td class="sort">${index + 1}</td>
             <td class="long">${item.buyerclass}</td>
             <td class="t_right long">${item.value}</td>
@@ -356,10 +356,15 @@
           if (res && res.error_code === 0 && res.data) {
             let data_ = res.data.customer_scale
             data_.forEach(ele => {
-              ele.amount=ele.amount.toFixed(2)  
+              if(ele.amount){
+                ele.amount=ele.amount.toFixed(2)  
+              } 
             });
             data_.sort(function(a,b){return b.total-a.total});
-            this_.data_list=data_
+            let newarr = data_.filter(function (item, index) {
+              return !(item['amount'] ==0 && item['total'] ==0 )
+            })
+            this_.data_list=newarr
             if(res.data.customer_scale_other){
               this_.analysis_num=res.data.customer_scale_other.total
               this_.analysis_price=res.data.customer_scale_other.amount.toFixed(2)
@@ -383,51 +388,69 @@
                 success:function(res) {
                     // console.log(res)
                     if(res.error_code == 0 && res.data) {
+                      console.log(that.parm)
                        if(that.parm=='curMonthCountTop'){ //数量
                         let others=[]
                         let data_ =res.data.project_buyerclass_count
+                        // data_.push({buyerclass:'其它',count:12})
                         data_.forEach(ele => {
-                          ele.value=ele.count 
-                          if(ele.buyclass=='其它'){
+                          if(ele.count){
+                            ele.value=ele.count 
+                          }
+                          if(ele.buyerclass=='其它'){
                             others.push(ele)
                           }
                         });
 
                         let newarr = data_.filter(function (item, index) {
-                              return item[buyerclass] != '其它'
+                              return (item['buyerclass'] != '其它' && item['count']!=0)
                         })
-
                         that.data_list=newarr
-                        that.num=others[0].count
-
-                       }else if(this.parm=='curMonthScaleTop'){ //规模排行
+                        
+                        if(others.length!=0){
+                          that.num=others[0].count
+                        }
+                        
+                       }else if(that.parm=='curMonthScaleTop'){ //规模排行
                         let data_ =res.data.project_buyerclass_bidamount
                         let others=[]
+                        // data_.push({buyerclass:'其它',bidamount:12})
                         data_.forEach(ele => {
-                          ele.value=ele.bidamount.toFixed(2) 
-                          if(ele.buyclass=='其它'){
+                          if(ele.bidamount){
+                            ele.value=ele.bidamount.toFixed(2) 
+                          }
+                          if(ele.buyerclass=='其它'){
                             others.push(ele)
                           }
                         });
                         let newarr = data_.filter(function (item, index) {
-                              return item[buyerclass] != '其它'
+                              return (item['buyerclass'] != '其它' && item['bidamount']!=0)
                         })
+                        console.log(newarr)
                         that.data_list=newarr
-                        that.num=others[0].bidamount
-                       }else if(this.parm=='averageScaleTop'){ //平均规模排行
+                        if(others.length!=0){
+                          that.num=others[0].bidamount
+                        }
+                       }else if(that.parm=='averageScaleTop'){ //平均规模排行
                         let data_ =res.data.project_buyerclass_average_bidamount
                         let others=[]
+                        // data_.push({buyerclass:'其它',average:12})
                         data_.forEach(ele => {
-                          ele.value=ele.average.toFixed(2) 
-                          if(ele.buyclass=='其它'){
+                          if(ele.average){
+                            ele.value=ele.average.toFixed(2) 
+
+                          }
+                          if(ele.buyerclass=='其它'){
                             others.push(ele)
                           }
                         });
                         let newarr = data_.filter(function (item, index) { 
-                              return item[buyerclass] != '其它'
+                              return (item['buyerclass'] != '其它' && item['average']!=0)
                         })
                         that.data_list=newarr
-                        that.num=others[0].average
+                        if(others.length!=0){
+                          that.num=others[0].average
+                        }
                        }    
 
                     }else{

+ 42 - 4
src/web/staticres/big-member/js/report_detail_month.js

@@ -5,6 +5,7 @@ var vNode = {
       monthReportExample: monthReportExample,
     },
     data: {
+        scrollTop:0,
         barChart: barChart,
         keywords:'',
         keyTip: '',
@@ -162,9 +163,46 @@ var vNode = {
         if (this.$refs['chartRegCount']) {
           this.$refs['chartRegCount'].echarts.resize()
         }
+        setTimeout(() => {
+          this.reStoreState()
+      
+      }, 500);
+      utils.iosBackRefresh()
     },
     methods: {
+      saveScrollTop: function () {
+        var wrapper = document.querySelector('.j-container .j-main')
+        if (wrapper.scrollTop) {
+          this.scrollTop = parseInt(wrapper.scrollTop)
+        }
+        var $data = {
+          scrollTop: this.scrollTop, 
+        }
+        sessionStorage.setItem('$data_month', JSON.stringify($data))
+      },
+      reStoreState: function () {
+        var $data = sessionStorage.getItem('$data_month')
+        if ($data) {
+          $data = JSON.parse($data)
+          this.scrollTop = $data.scrollTop
+        
+          setTimeout(function () {
+            // 恢复滚动高度
+            this.setScrollTop(this.scrollTop)
+          }.bind(this), 0)
+  
+          sessionStorage.removeItem('$data_month')
+        } 
+  
+      },
+      setScrollTop: function (scrollTop) {
+        this.$nextTick(function () {
+          var wrapper = document.querySelector('.j-container .j-main')
+          wrapper.scrollTop = scrollTop
+        })
+      },
       goTable (type) {
+        this.saveScrollTop()
         if(type =='curMonthCountTop'){ // 本月项目数量采购行业排行榜
           window.location.href='/big/wx/page/report_table?source=curMonthCountTop&type='+utils.getParam("type")+'&start='+utils.getParam('start')+'&end='+utils.getParam('end')+'&header=本月项目数量采购行业排行榜'
           
@@ -177,7 +215,7 @@ var vNode = {
 
       }, 
 
-      },
+    
         goCollect: function(source) {
           location.href = '/weixin/frontPage/bigmember/free/perfect_info?source=' + source
         },
@@ -413,7 +451,7 @@ var vNode = {
                         // 本月项目数量TOP10采购行业 7
                         if(res.data.project_buyerclass_count && res.data.project_buyerclass_count.length > 0) {
                             var pro_count_list = res.data.project_buyerclass_count.filter(function (item, index) {
-                            return item[buyerclass] != '其它'
+                            return item['buyerclass'] != '其它'
                            })
                             that.curMonthCountTop.list = that.formatterWinData(pro_count_list,'count')
                             that.isShow.show_7 = true;
@@ -424,7 +462,7 @@ var vNode = {
                         if(res.data.project_buyerclass_bidamount && res.data.project_buyerclass_bidamount.length > 0) {
                             var data = res.data.project_buyerclass_bidamount;
                             var pro_bidamount_list = data.filter(function (item, index) {
-                              return item[buyerclass] != '其它'
+                              return item['buyerclass'] != '其它'
                              })
                             that.curMonthScaleTop.list = that.formatterWinData(pro_bidamount_list,'scale')
                             that.isShow.show_8 = true;
@@ -435,7 +473,7 @@ var vNode = {
                         if(res.data.project_buyerclass_average_bidamount && res.data.project_buyerclass_average_bidamount.length > 0) {
                             var d = res.data.project_buyerclass_average_bidamount;
                             var pro_average_list = d.filter(function (item, index) {
-                              return item[buyerclass] != '其它'
+                              return item['buyerclass'] != '其它'
                              })
                             that.averageScaleTop.list = that.formatterWinData(pro_average_list,'average')
                             that.isShow.show_9 = true;

+ 44 - 21
src/web/templates/big-member/wx/page_report_table.html

@@ -220,7 +220,7 @@
             <tr><th v-for="(item,index) in head_list" :class="{'sort_': index==0,'long_': index==1 ,'middle':index==2||index==3}" v-html="item"></th></tr>
           </thead>
            <tbody>
-            <tr v-for="(item,index) in data_list" v-show="item.total==0 && item.amount==0">
+            <tr v-for="(item,index) in data_list" >
             <td class="sort_">${index + 1}</td>
             <td class="long_">${item.buyclass}</td>
             <td class="t_right middle">${item.total}</td>
@@ -247,7 +247,7 @@
             <tr><th v-for="(item,index) in head_list" :class="{'sort': index==0,'long': index==1 || index==2}" v-html="item"></th></tr>
           </thead>
             <tbody>
-            <tr v-for="(item,index) in data_list" v-show="item.value == 0">
+            <tr v-for="(item,index) in data_list" >
             <td class="sort">${index + 1}</td>
             <td class="long">${item.buyerclass}</td>
             <td class="t_right long">${item.value}</td>
@@ -265,7 +265,7 @@
 <script src=//cdn-common.jianyu360.com/cdn/lib/zepto/1.2.0/zepto.min.js></script>
 <script src='{{Msg "seo" "cdn"}}/big-member/js/utils.js?v={{Msg "seo" "version"}}'></script>
 <script>
- var vNode_ = {
+  var vNode_ = {
     delimiters: ['${', '}'],
     el: '#report_table',
     components: {
@@ -347,10 +347,15 @@
           if (res && res.error_code === 0 && res.data) {
             let data_ = res.data.customer_scale
             data_.forEach(ele => {
-              ele.amount=ele.amount.toFixed(2)  
+              if(ele.amount){
+                ele.amount=ele.amount.toFixed(2)  
+              } 
             });
             data_.sort(function(a,b){return b.total-a.total});
-            this_.data_list=data_
+            let newarr = data_.filter(function (item, index) {
+              return !(item['amount'] ==0 && item['total'] ==0 )
+            })
+            this_.data_list=newarr
             if(res.data.customer_scale_other){
               this_.analysis_num=res.data.customer_scale_other.total
               this_.analysis_price=res.data.customer_scale_other.amount.toFixed(2)
@@ -374,51 +379,69 @@
                 success:function(res) {
                     // console.log(res)
                     if(res.error_code == 0 && res.data) {
+                      console.log(that.parm)
                        if(that.parm=='curMonthCountTop'){ //数量
                         let others=[]
                         let data_ =res.data.project_buyerclass_count
+                        // data_.push({buyerclass:'其它',count:12})
                         data_.forEach(ele => {
-                          ele.value=ele.count 
-                          if(ele.buyclass=='其它'){
+                          if(ele.count){
+                            ele.value=ele.count 
+                          }
+                          if(ele.buyerclass=='其它'){
                             others.push(ele)
                           }
                         });
 
                         let newarr = data_.filter(function (item, index) {
-                              return item[buyerclass] != '其它'
+                              return (item['buyerclass'] != '其它' && item['count']!=0)
                         })
-
                         that.data_list=newarr
-                        that.num=others[0].count
-
-                       }else if(this.parm=='curMonthScaleTop'){ //规模排行
+                        
+                        if(others.length!=0){
+                          that.num=others[0].count
+                        }
+                        
+                       }else if(that.parm=='curMonthScaleTop'){ //规模排行
                         let data_ =res.data.project_buyerclass_bidamount
                         let others=[]
+                        // data_.push({buyerclass:'其它',bidamount:12})
                         data_.forEach(ele => {
-                          ele.value=ele.bidamount.toFixed(2) 
-                          if(ele.buyclass=='其它'){
+                          if(ele.bidamount){
+                            ele.value=ele.bidamount.toFixed(2) 
+                          }
+                          if(ele.buyerclass=='其它'){
                             others.push(ele)
                           }
                         });
                         let newarr = data_.filter(function (item, index) {
-                              return item[buyerclass] != '其它'
+                              return (item['buyerclass'] != '其它' && item['bidamount']!=0)
                         })
+                        console.log(newarr)
                         that.data_list=newarr
-                        that.num=others[0].bidamount
-                       }else if(this.parm=='averageScaleTop'){ //平均规模排行
+                        if(others.length!=0){
+                          that.num=others[0].bidamount
+                        }
+                       }else if(that.parm=='averageScaleTop'){ //平均规模排行
                         let data_ =res.data.project_buyerclass_average_bidamount
                         let others=[]
+                        // data_.push({buyerclass:'其它',average:12})
                         data_.forEach(ele => {
-                          ele.value=ele.average.toFixed(2) 
-                          if(ele.buyclass=='其它'){
+                          if(ele.average){
+                            ele.value=ele.average.toFixed(2) 
+
+                          }
+                          if(ele.buyerclass=='其它'){
                             others.push(ele)
                           }
                         });
                         let newarr = data_.filter(function (item, index) { 
-                              return item[buyerclass] != '其它'
+                              return (item['buyerclass'] != '其它' && item['average']!=0)
                         })
                         that.data_list=newarr
-                        that.num=others[0].average
+                        if(others.length!=0){
+                          that.num=others[0].average
+                        }
                        }    
 
                     }else{