From 69e964a86fe6be63e1c3e6cfafc1bd252a34b155 Mon Sep 17 00:00:00 2001 From: lancer <1905818361@qq.com> Date: Fri, 27 Aug 2021 17:20:14 +0800 Subject: [PATCH] init --- pages/center/Piabodata/Groupcontrast.vue | 38 ++++++++++++++---- pages/center/Piabodata/Theteamcompared.vue | 46 +++++++++++++++++----- 2 files changed, 68 insertions(+), 16 deletions(-) diff --git a/pages/center/Piabodata/Groupcontrast.vue b/pages/center/Piabodata/Groupcontrast.vue index d68e3d9..5859ba7 100644 --- a/pages/center/Piabodata/Groupcontrast.vue +++ b/pages/center/Piabodata/Groupcontrast.vue @@ -32,7 +32,7 @@ {{item.name.substring(0, 4)}} - + {{item.zxl==null?0:item.zxl}} @@ -56,7 +56,7 @@ {{item.name.substring(0, 4)}} - + {{item.zxl==null?0:item.zxl}} @@ -89,7 +89,7 @@ {{item.name.substring(0, 4)}} - + {{item.zxl==null?0:item.zxl}} @@ -122,7 +122,7 @@ {{item.name.substring(0, 4)}} - + {{item.zxl==null?0:item.zxl}} @@ -370,14 +370,17 @@ // 当为全部时 this['newlisttabinfo'+index]=[] // 当选择全部时 - + let arr=[] // 当两个都选择的时候 result.map(item=>{ let obj={} obj.name=item.houseName obj.zxl=item.data - this['newlisttabinfo'+index].push(obj) + arr.push(obj) + }) + arr=this.dealData(arr) + this['newlisttabinfo'+index]=arr }) }, // 获取销奖能力 @@ -431,7 +434,28 @@ uni.navigateTo({ url: `/pages/center/Piabodata/selectGroup?ids=${this.houseId}` }); - } + }, + // 定义一个公共方法对数据进行处理 + dealData(arr){ + // 获取最大值 + let num=Math.max.apply(Math, arr.map(function (o) { return o.zxl })) //结果:3 + // console.log(num) + if(num>100){ + // 获取最大值的下标 + // let idx=arr.findIndex(item=>item.zxl==num) + // console.log(idx,123) + arr.map(item=>{ + item.zxl1=Math.floor(item.zxl/num*100) + }) + // console.log(arr) + return arr + }else{ + arr.map(item=>{ + item.zxl1=item.zxl + }) + return arr + } + }, } }; diff --git a/pages/center/Piabodata/Theteamcompared.vue b/pages/center/Piabodata/Theteamcompared.vue index 413973d..375f034 100644 --- a/pages/center/Piabodata/Theteamcompared.vue +++ b/pages/center/Piabodata/Theteamcompared.vue @@ -74,7 +74,7 @@ {{item.name.substring(0, 4)}} - + {{item.zxl==null?0:item.zxl}} @@ -120,7 +120,7 @@ {{item.name.substring(0, 4)}} - + {{item.zxl==null?0:item.zxl}} @@ -166,7 +166,7 @@ {{item.name.substring(0, 4)}} - + {{item.zxl==null?0:item.zxl}} @@ -795,6 +795,7 @@ // 先处理牌名数据,需要进行判断全部还是单个 // 当为全部时 this['newlisttabinfo'+index]=[] + let arr=[] // 当选择全部时 if(!this.staff1.value&&!this.staff2.value){ // console.log(1) @@ -802,8 +803,11 @@ let obj={} obj.name=item.deptName obj.zxl=item.data - this['newlisttabinfo'+index].push(obj) + arr.push(obj) + }) + arr=this.dealData(arr) + this['newlisttabinfo'+index]=arr } // 当选择只有一个时 else if(this.staff1.value&&!this.staff2.value){ @@ -812,7 +816,7 @@ let obj={} obj.name=item.deptName obj.zxl=item.data - this['newlisttabinfo'+index].push(obj) + arr.push(obj) }) // 判断是否显示平均 // 如果显示对比 @@ -821,9 +825,11 @@ let obj={} obj.name='平均' obj.zxl=item.data - this['newlisttabinfo'+index].push(obj) + arr.push(obj) }) } + arr=this.dealData(arr) + this['newlisttabinfo'+index]=arr }else{ // console.log(3) // 当两个都选择的时候 @@ -831,14 +837,16 @@ let obj={} obj.name=item.deptName obj.zxl=item.data - this['newlisttabinfo'+index].push(obj) + arr.push(obj) }) result[1].map(item=>{ let obj={} obj.name=item.deptName obj.zxl=item.data - this['newlisttabinfo'+index].push(obj) + arr.push(obj) }) + arr=this.dealData(arr) + this['newlisttabinfo'+index]=arr } }else{ // 当选择趋势时 @@ -1002,7 +1010,27 @@ this.$forceUpdate() }) }, - + // 定义一个公共方法对数据进行处理 + dealData(arr){ + // 获取最大值 + let num=Math.max.apply(Math, arr.map(function (o) { return o.zxl })) //结果:3 + // console.log(num) + if(num>100){ + // 获取最大值的下标 + // let idx=arr.findIndex(item=>item.zxl==num) + // console.log(idx,123) + arr.map(item=>{ + item.zxl1=Math.floor(item.zxl/num*100) + }) + // console.log(arr) + return arr + }else{ + arr.map(item=>{ + item.zxl1=item.zxl + }) + return arr + } + }, } };