Compare commits

...

2 Commits

Author SHA1 Message Date
BianLzhaoMin 46d723ec72 代码优化 2024-10-21 09:44:15 +08:00
BianLzhaoMin e388221252 请求地址更换 2024-10-21 09:24:11 +08:00
6 changed files with 229 additions and 29 deletions

View File

@ -1,4 +1,5 @@
import request from '@/utils/request_new'
import request_yn from '@/utils/request_new_yn'
// 获取首页数据
export function getHomePageListApi(data) {
@ -18,7 +19,7 @@ export function getHomePageSelectApi() {
}
// 首页二级页面--作业计划详情-作业计划列表
export function getWorkPlanDetailsApi(data) {
return request({
return request_yn({
url: '/ynPlan/home/getjhxxq',
method: 'post',
data
@ -26,7 +27,7 @@ export function getWorkPlanDetailsApi(data) {
}
// 首页二级页面--作业计划详情-作业人员及持证信息
export function getWorkPersonnelApi(data) {
return request({
return request_yn({
url: '/ynPlan/home/getDayUser',
method: 'post',
data
@ -34,7 +35,7 @@ export function getWorkPersonnelApi(data) {
}
// 首页二级页面--作业计划详情-作业票、站班会照片
export function getStandGuardImgApi(data) {
return request({
return request_yn({
url: '/ynPlan/home/getZbhPhotos',
method: 'post',
data
@ -42,7 +43,7 @@ export function getStandGuardImgApi(data) {
}
// 首页二级页面--作业计划详情-持证信息详情
export function getHoldCardInfoApi(data) {
return request({
return request_yn({
url: '/ynPlan/home/getDayUserCZ',
method: 'post',
data

View File

@ -26,6 +26,8 @@ module.exports = {
realBmwUrl: 'http://192.168.0.14:1911/bmw',
//实名制移动端 -- 新
realNewBmwUrl: 'http://192.168.0.14:1911',
//实名制移动端 -- 新
realNewYnUrl: 'http://192.168.0.14:1918',
// 应用信息
appInfo: {

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
}
}

View File

@ -225,7 +225,7 @@ export default {
const response = await getStandGuardImgApi(params)
this.workPersonList = res.data
console.log('人员信息---', res.data)
console.log('人员信息---', res)
this.holdCardList = res.datac
this.standGuardList = response.data

View File

@ -18,10 +18,19 @@
class="uni-calendar--hook"
:range="true"
:showMonth="false"
:selected="info.selected"
@change="change"
@monthSwitch="monthSwitch"
/>
>
<template v-slot:day="{ date, lunar, extraInfo }">
<view class="custom-day">
<text class="day-number">{{ date.day }}</text>
<text v-if="extraInfo" class="custom-info" :class="getInfoClass(extraInfo)">
{{ extraInfo }}
</text>
<!-- <view v-if="hasEvent(date)" class="event-dot"></view> -->
</view>
</template>
</uni-calendar>
</view>
</view>
</template>
@ -38,10 +47,35 @@ export default {
range: true,
insert: false,
selected: []
},
customInfo: {
'2024-10-01': '重要',
'2024-10-15': '假期'
},
events: {
'2024-10-01': { type: 'important', text: '重要' },
'2024-10-15': { type: 'holiday', text: '假期' },
'2024-10-20': { type: 'birthday', text: '生日' }
}
}
},
methods: {
onChange(e) {
console.log('选择的日期变化:', e)
},
onMonthSwitch(e) {
console.log('月份切换:', e)
},
hasEvent(date) {
const dateString = `${date.year}-${String(date.month).padStart(2, '0')}-${String(date.day).padStart(2, '0')}`
return !!this.events[dateString]
},
getInfoClass(info) {
if (info === '重要') return 'info-important'
if (info === '假期') return 'info-holiday'
if (info === '生日') return 'info-birthday'
return ''
},
change() {
console.log('日期变化---')
},
@ -89,4 +123,43 @@ export default {
display: flex;
align-items: center;
}
.custom-day {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
position: relative;
}
.day-number {
font-size: 14px;
}
.custom-info {
font-size: 10px;
margin-top: 2px;
}
.info-important {
color: #ff4d4f;
}
.info-holiday {
color: #52c41a;
}
.info-birthday {
color: #1890ff;
}
.event-dot {
width: 4px;
height: 4px;
border-radius: 50%;
background-color: #1890ff;
position: absolute;
bottom: 2px;
}
</style>

85
utils/request_new_yn.js Normal file
View File

@ -0,0 +1,85 @@
import store from '@/store'
import config from '@/config'
import { getToken, setToken } from '@/utils/auth'
import errorCode from '@/utils/errorCode'
import { toast, showConfirm, tansParams } from '@/utils/common'
let timeout = 60000
const baseUrl = config.realNewYnUrl
console.log('baseUrl-请求', baseUrl)
const request = config => {
// 是否需要设置 token
const isToken = (config.headers || {}).isToken === false
config.header = config.header || {}
if (getToken() && !isToken) {
config.header['Authorization'] = 'Bearer ' + getToken()
}
// get请求映射params参数
if (config.params) {
let url = config.url + '?' + tansParams(config.params)
url = url.slice(0, -1)
config.url = url
}
if (config.method === 'post') {
config.header = {
...config.header,
'Content-Type': 'application/x-www-form-urlencoded'
}
// config.data = JSON.stringify(config.data);
}
return new Promise((resolve, reject) => {
uni
.request({
method: config.method || 'get',
timeout: config.timeout || timeout,
url: baseUrl + config.url,
data: config.data,
header: config.header,
dataType: 'json'
})
.then(response => {
// console.log(response)
let [error, res] = response
if (error) {
toast('后端接口连接异常')
reject('后端接口连接异常')
return
}
const code = res.data.code || 200
const msg = errorCode[code] || res.data.msg || errorCode['default']
if (code === 401) {
showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
if (res.confirm) {
store.dispatch('LogOut').then(res => {
uni.reLaunch({ url: '/pages/login' })
})
}
})
reject('无效的会话,或者会话已过期,请重新登录。')
} else if (code === 500) {
toast(msg)
reject(msg)
} else if (code !== 200) {
toast(msg)
reject(msg)
}
resolve(res.data)
})
.catch(error => {
let { message } = error
if (message === 'Network Error') {
message = '后端接口连接异常'
} else if (message.includes('timeout')) {
message = '系统接口请求超时'
} else if (message.includes('Request failed with status code')) {
message = '系统接口' + message.substr(message.length - 3) + '异常'
}
toast(message)
reject(error)
})
})
}
export default request