代码优化

This commit is contained in:
BianLzhaoMin 2024-10-21 09:44:15 +08:00
parent e388221252
commit 46d723ec72
1 changed files with 61 additions and 22 deletions

View File

@ -31,8 +31,20 @@
src="../../../static/images/img-phase-two/index_img_one_att.png"
mode=""
></image>
<text>在场考勤率{{ ((attPersonNum / einPersonNum) * 100).toFixed(2) }}%</text>
<text>计划考勤率{{ ((planAttNum / planPersonNum) * 100).toFixed(2) }}%</text>
<text>
在场考勤率{{
isNaN(((attPersonNum / einPersonNum) * 100).toFixed(2))
? 0
: ((attPersonNum / einPersonNum) * 100).toFixed(2)
}}%
</text>
<text>
计划考勤率{{
isNaN(((planAttNum / planPersonNum) * 100).toFixed(2))
? 0
: ((planAttNum / planPersonNum) * 100).toFixed(2)
}}%
</text>
<text class="none-box">计划考勤率20%</text>
</view>
</swiper-item>
@ -174,17 +186,27 @@
<view class="person-content">
<view @tap="onJumpColorLight(1)">
<image class="person-img" src="../../../static/images/img-phase-two/index_green_light.png" mode=""></image>
<text class="text-strong">{{ ((greenNum / colorAmount) * 100).toFixed(2) }}%</text>
<text class="text-strong">
{{
isNaN(((greenNum / colorAmount) * 100).toFixed(2)) ? 0 : ((greenNum / colorAmount) * 100).toFixed(2)
}}%
</text>
<text>{{ greenNum }}</text>
</view>
<view @tap="onJumpColorLight(2)">
<image class="person-img" src="../../../static/images/img-phase-two/index_yellow_light.png" mode=""></image>
<text class="text-strong">{{ ((yellowNum / colorAmount) * 100).toFixed(2) }}%</text>
<text class="text-strong">
{{
isNaN(((yellowNum / colorAmount) * 100).toFixed(2)) ? 0 : ((yellowNum / colorAmount) * 100).toFixed(2)
}}%
</text>
<text>{{ yellowNum }}</text>
</view>
<view @tap="onJumpColorLight(3)">
<image class="person-img" src="../../../static/images/img-phase-two/index_red_light.png" mode=""></image>
<text class="text-strong">{{ ((redNum / colorAmount) * 100).toFixed(2) }}%</text>
<text class="text-strong">
{{ isNaN(((redNum / colorAmount) * 100).toFixed(2)) ? 0 : ((redNum / colorAmount) * 100).toFixed(2) }}%
</text>
<text>{{ redNum }}</text>
</view>
</view>
@ -192,7 +214,9 @@
<view class="gender-content">
<view class="man-left">
<view>
<view>{{ ((maleNum / sexAmount) * 100).toFixed(2) }}%</view>
<view>
{{ isNaN(((maleNum / sexAmount) * 100).toFixed(2)) ? 0 : ((maleNum / sexAmount) * 100).toFixed(2) }}%
</view>
<view>({{ maleNum }})</view>
</view>
@ -209,7 +233,11 @@
style="margin-right: 30rpx; background-color: #fc8483"
></view>
<view>
<view>{{ ((femaleNum / sexAmount) * 100).toFixed(2) }}%</view>
<view>
{{
isNaN(((femaleNum / sexAmount) * 100).toFixed(2)) ? 0 : ((femaleNum / sexAmount) * 100).toFixed(2)
}}%
</view>
<view>({{ femaleNum }})</view>
</view>
</view>
@ -246,10 +274,19 @@
<view class="person-proportion">
<text style="color: #04cdfa">
固定占比{{ ((formalPersonNum / (formalPersonNum + temporaryPersonNum)) * 100).toFixed(2) }}%
固定占比{{
isNaN(((formalPersonNum / (formalPersonNum + temporaryPersonNum)) * 100).toFixed(2))
? 0
: ((formalPersonNum / (formalPersonNum + temporaryPersonNum)) * 100).toFixed(2)
}}%
</text>
<text style="color: #fd8d01">
流动占比 {{ ((temporaryPersonNum / (formalPersonNum + temporaryPersonNum)) * 100).toFixed(2) }}%
流动占比
{{
isNaN(((temporaryPersonNum / (formalPersonNum + temporaryPersonNum)) * 100).toFixed(2))
? 0
: ((temporaryPersonNum / (formalPersonNum + temporaryPersonNum)) * 100).toFixed(2)
}}%
</text>
</view>
@ -582,6 +619,8 @@ export default {
const { data: res } = await getHomePageListApi({})
console.log('首页数据', res)
if (!res) return
const { homePageBean, personAtt, workerMsgBean, proMsgBean } = res
const { highRiskNum, mediumRiskNum, lowRiskNum, planPersonNum } = homePageBean
const { buildProNum, prepareProNum, stopProNum, completeProNum } = proMsgBean
@ -702,27 +741,27 @@ export default {
switch (title) {
case '在场考勤率':
params = '在场考勤率'
uni.navigateTo({ url: `/pages/realName/index/pages/personList?isAtt=0` })
uni.navigateTo({ url: `/pages/realName/index/pages/personList?isAtt=0` })
break
case '作业考勤率':
params = '作业考勤率'
uni.navigateTo({ url: '/pages/realName/index/pages/personList?isAtt=0&isPlanWorker=1' })
uni.navigateTo({ url: '/pages/realName/index/pages/personList?isAtt=0&isPlanWorker=1' })
break
case '在场人员(固定)':
params = '在场人员(固定)'
uni.navigateTo({ url: `/pages/realName/index/pages/personList?workerType=1` })
uni.navigateTo({ url: `/pages/realName/index/pages/personList?workerType=1` })
break
case '在场人员(临时)':
uni.navigateTo({ url: `/pages/realName/index/pages/personList?workerType=0` })
uni.navigateTo({ url: `/pages/realName/index/pages/personList?workerType=0` })
params = '在场人员(临时)'
break
case '考勤率(固定人员)':
params = '考勤率(固定人员)'
uni.navigateTo({ url: '/pages/realName/index/pages/personList?isAtt=0&workerType=1' })
uni.navigateTo({ url: '/pages/realName/index/pages/personList?isAtt=0&workerType=1' })
break
case '考勤率(临时人员)':
params = '考勤率(临时人员)'
uni.navigateTo({ url: '/pages/realName/index/pages/personList?isAtt=0&workerType=0' })
uni.navigateTo({ url: '/pages/realName/index/pages/personList?isAtt=0&workerType=0' })
break
}
},
@ -764,31 +803,31 @@ export default {
switch (type) {
case 1:
// params = '绿'
uni.navigateTo({ url: `/pages/realName/index/pages/personList?lightStatus=2` })
uni.navigateTo({ url: `/pages/realName/index/pages/personList?lightStatus=2` })
break
case 2:
params = '黄灯'
uni.navigateTo({ url: `/pages/realName/index/pages/personList?lightStatus=1` })
uni.navigateTo({ url: `/pages/realName/index/pages/personList?lightStatus=1` })
break
case 3:
params = '红灯'
uni.navigateTo({ url: `/pages/realName/index/pages/personList?lightStatus=0` })
uni.navigateTo({ url: `/pages/realName/index/pages/personList?lightStatus=0` })
break
case 4:
params = '男性'
uni.navigateTo({ url: `/pages/realName/index/pages/personList?sex=1` })
uni.navigateTo({ url: `/pages/realName/index/pages/personList?sex=1` })
break
case 5:
params = '女性'
uni.navigateTo({ url: `/pages/realName/index/pages/personList?sex=0` })
uni.navigateTo({ url: `/pages/realName/index/pages/personList?sex=0` })
break
case 6:
params = '固定人员'
uni.navigateTo({ url: `/pages/realName/index/pages/personList?workerType=1` })
uni.navigateTo({ url: `/pages/realName/index/pages/personList?workerType=1` })
break
case 7:
params = '临时人员'
uni.navigateTo({ url: `/pages/realName/index/pages/personList?workerType=0` })
uni.navigateTo({ url: `/pages/realName/index/pages/personList?workerType=0` })
break
}
}