321 lines
8.1 KiB
Vue
321 lines
8.1 KiB
Vue
<template>
|
||
<view class="page">
|
||
<u-navbar class="u-navbar" title="考勤统计" placeholder @leftClick="leftClick" leftIconColor="#fff" bgColor="#00337A" :titleStyle="{ color: '#FFF', fontSize: '32rpx' }"/>
|
||
<view class="view-box">
|
||
<view style="font-size: 24rpx;">{{proName}}</view>
|
||
</view>
|
||
<view class="view-box">
|
||
<view style="width: 96%;height: auto;padding: 10rpx auto;display: flex;align-items: center;margin-bottom: 20rpx;">
|
||
<u-search shape="square" placeholder="人员姓名" v-model="keyword" :showAction="false"></u-search>
|
||
<view class="searchBtn" @click="searchList">搜索</view>
|
||
</view>
|
||
<view style="width: 96%;height: auto;padding: 10rpx auto;display: flex;align-items: center;">
|
||
<uni-datetime-picker v-model="range" type="daterange" rangeSeparator="至"/>
|
||
<view class="resetBtn" @click="resetSearch">重置</view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 列表 -->
|
||
<view class="list-box">
|
||
|
||
<u-list @scrolltolower="scrolltolower" height="72vh" >
|
||
<u-list-item v-for="(item, index) in listData" :key="index">
|
||
<view class="list-item" @click="goDetailList(item)">
|
||
<view class="content-box">
|
||
<view class="item-text" >
|
||
<text class="label" style="font-weight: bold;">姓名:</text>
|
||
<text class="info">{{item.name}}</text>
|
||
<!-- <text class="info-right" style="color: green;" v-if="item.lightStatus==2">绿灯</text>
|
||
<text class="info-right" style="color: yellow;" v-if="item.lightStatus==1">黄灯</text>
|
||
<text class="info-right" style="color: red;" v-if="item.lightStatus==0">红灯</text> -->
|
||
</view>
|
||
<view class="item-text">
|
||
<text class="label" style="font-weight: bold;">身份证:</text>
|
||
<text class="info">{{item.idNumber}}</text>
|
||
</view>
|
||
<view class="item-text">
|
||
<text class="label"style="font-weight: bold;">上班天数:</text>
|
||
<text class="info">{{item.countDay}}</text>
|
||
</view>
|
||
<view class="item-text">
|
||
<text class="label"style="font-weight: bold;">缺勤天数:</text>
|
||
<text class="info">{{item.queQinDay}}</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</u-list-item>
|
||
</u-list>
|
||
</view>
|
||
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import config from '@/config'
|
||
export default {
|
||
data() {
|
||
return {
|
||
proName:"",
|
||
proId:uni.getStorageSync('realNameUser').proId,
|
||
range:[],
|
||
keyword:'',
|
||
listData:[],
|
||
page:1,
|
||
pageSize:5,
|
||
total:0
|
||
|
||
}
|
||
},
|
||
onLoad() {
|
||
this.getPro()
|
||
// 获取当前时间戳
|
||
const currentTimestamp = Math.floor(Date.now() / 1000);
|
||
// 计算上个月的时间戳
|
||
const lastMonthTimestamp = currentTimestamp - 30 * 24 * 60 * 60;
|
||
this.range[0]=this.timeFormat(lastMonthTimestamp,'yyyy-mm-dd');
|
||
this.range[1]=this.timeFormat(currentTimestamp,'yyyy-mm-dd');
|
||
this.loadmore()
|
||
},
|
||
onShow() {
|
||
|
||
},
|
||
methods: {
|
||
getPro(){
|
||
let param={
|
||
id:this.proId,
|
||
subId:-1
|
||
}
|
||
uni.request({
|
||
url: config.realAppUrl + '/offLine/getPro',
|
||
method: 'post',
|
||
data: param,
|
||
header: {
|
||
'Content-Type': 'application/x-www-form-urlencoded',
|
||
Authorization: uni.getStorageSync('realNameToken')
|
||
},
|
||
success: res => {
|
||
res = res.data;
|
||
if(res.code==200){
|
||
console.log(res)
|
||
this.proName = res.data[0].abbreviation||"";
|
||
}
|
||
},
|
||
fail: err => {
|
||
console.log(err)
|
||
}
|
||
})
|
||
},
|
||
resetSearch(){
|
||
this.keyword="";
|
||
// 获取当前时间戳
|
||
const currentTimestamp = Math.floor(Date.now() / 1000);
|
||
// 计算上个月的时间戳
|
||
const lastMonthTimestamp = currentTimestamp - 30 * 24 * 60 * 60;
|
||
this.range[0]=this.timeFormat(lastMonthTimestamp,'yyyy-mm-dd');
|
||
this.range[1]=this.timeFormat(currentTimestamp,'yyyy-mm-dd');
|
||
this.searchList()
|
||
},
|
||
//搜索
|
||
searchList(value){
|
||
this.page = 1;
|
||
this.pageSize = 5;
|
||
this.listData=[]
|
||
this.loadmore()
|
||
},
|
||
//滚动下拉1
|
||
scrolltolower() {
|
||
this.page=this.page+1;
|
||
this.pageSize=this.page*5;
|
||
if(this.pageSize<=this.total){
|
||
this.loadmore()
|
||
}else if(this.pageSize>this.total){
|
||
if((this.pageSize-this.total)<5){
|
||
this.loadmore()
|
||
}else{
|
||
uni.showToast({
|
||
title:"没有更多了",
|
||
icon: 'none'
|
||
})
|
||
}
|
||
}
|
||
|
||
},
|
||
loadmore(){
|
||
let param={
|
||
pageNo:0,
|
||
pageSize:this.pageSize,
|
||
proId:this.proId,
|
||
name:this.keyword,
|
||
startDay:this.range[0],
|
||
endDay:this.range[1]
|
||
}
|
||
console.log(param)
|
||
uni.request({
|
||
url: config.realAppUrl+'/faceContrast/getFaceContrastList',
|
||
method: 'post',
|
||
data: param,
|
||
header: {
|
||
'Content-Type': 'application/x-www-form-urlencoded',
|
||
Authorization: uni.getStorageSync('realNameToken')
|
||
},
|
||
success: res => {
|
||
console.log(res)
|
||
res = res.data;
|
||
if(res.code==200){
|
||
this.listData=res.data.result;
|
||
this.total=res.data.totalCount;
|
||
}else{
|
||
uni.showToast({
|
||
title: res.msg,
|
||
icon: 'none'
|
||
})
|
||
}
|
||
},
|
||
fail: err => {
|
||
console.log(err)
|
||
}
|
||
})
|
||
},
|
||
goDetailList(item){
|
||
console.log(item)
|
||
uni.navigateTo({
|
||
url: `/pages/realName/workAttendance/statistics/detail?idNumber=${item.idNumber}&proId=${item.proId}&startDay=${this.range[0]}&endDay=${this.range[1]}`
|
||
})
|
||
},
|
||
// 返回
|
||
leftClick() {
|
||
console.log('返回')
|
||
uni.navigateBack({
|
||
delta: 1 // 返回
|
||
});
|
||
},
|
||
timeFormat(dateTime = null, formatStr = 'yyyy-mm-dd') {
|
||
let date
|
||
// 若传入时间为假值,则取当前时间
|
||
if (!dateTime) {
|
||
date = new Date()
|
||
}
|
||
// 若为unix秒时间戳,则转为毫秒时间戳(逻辑有点奇怪,但不敢改,以保证历史兼容)
|
||
else if (/^\d{10}$/.test(dateTime?.toString().trim())) {
|
||
date = new Date(dateTime * 1000)
|
||
}
|
||
// 若用户传入字符串格式时间戳,new Date无法解析,需做兼容
|
||
else if (typeof dateTime === 'string' && /^\d+$/.test(dateTime.trim())) {
|
||
date = new Date(Number(dateTime))
|
||
}
|
||
// 处理平台性差异,在Safari/Webkit中,new Date仅支持/作为分割符的字符串时间
|
||
// 处理 '2022-07-10 01:02:03',跳过 '2022-07-10T01:02:03'
|
||
else if (typeof dateTime === 'string' && dateTime.includes('-') && !dateTime.includes('T')) {
|
||
date = new Date(dateTime.replace(/-/g, '/'))
|
||
}
|
||
// 其他都认为符合 RFC 2822 规范
|
||
else {
|
||
date = new Date(dateTime)
|
||
}
|
||
|
||
const timeSource = {
|
||
'y': date.getFullYear().toString(), // 年
|
||
'm': (date.getMonth() + 1).toString().padStart(2, '0'), // 月
|
||
'd': date.getDate().toString().padStart(2, '0'), // 日
|
||
'h': date.getHours().toString().padStart(2, '0'), // 时
|
||
'M': date.getMinutes().toString().padStart(2, '0'), // 分
|
||
's': date.getSeconds().toString().padStart(2, '0') // 秒
|
||
// 有其他格式化字符需求可以继续添加,必须转化成字符串
|
||
}
|
||
|
||
for (const key in timeSource) {
|
||
const [ret] = new RegExp(`${key}+`).exec(formatStr) || []
|
||
if (ret) {
|
||
// 年可能只需展示两位
|
||
const beginIndex = key === 'y' && ret.length === 2 ? 2 : 0
|
||
formatStr = formatStr.replace(ret, timeSource[key].slice(beginIndex))
|
||
}
|
||
}
|
||
return formatStr
|
||
}
|
||
},
|
||
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss">
|
||
.searchBtn{
|
||
width: 120rpx;
|
||
height:60rpx;
|
||
line-height: 60rpx;
|
||
text-align: center;
|
||
border-radius: 10rpx;
|
||
background-color: #00337A;
|
||
color: #FFF;
|
||
margin-left: 20rpx;
|
||
}
|
||
.resetBtn{
|
||
width: 120rpx;
|
||
height:60rpx;
|
||
line-height: 60rpx;
|
||
text-align: center;
|
||
border-radius: 10rpx;
|
||
background-color: #fff;
|
||
color: #000;
|
||
margin-left: 20rpx;
|
||
border: 1rpx solid #00337A;
|
||
}
|
||
.view-box{
|
||
width: 94%;
|
||
margin: 20rpx auto;
|
||
background-color: #FFF;
|
||
border-radius: 10rpx;
|
||
padding:20rpx;
|
||
}
|
||
.page {
|
||
width: 100vw;
|
||
height: 100vh;
|
||
background-color: #f8f8f8;
|
||
box-sizing: border-box;
|
||
// padding: 0 20px;
|
||
.list-box{
|
||
width: 90%;
|
||
height: auto;
|
||
// border: 1px solid #000;
|
||
margin: 0rpx auto;
|
||
|
||
.list-item{
|
||
width: 100%;
|
||
height: auto;
|
||
background-color: #fff;
|
||
border-radius: 20rpx;
|
||
margin: 20rpx 0;
|
||
|
||
.content-box{
|
||
width: 100%;
|
||
height: auto;
|
||
padding: 10rpx 0;
|
||
border-bottom: 1rpx solid #eee;
|
||
|
||
.item-text{
|
||
width: 95%;
|
||
margin-left: 20rpx;
|
||
margin-top: 15rpx;
|
||
// display: flex;
|
||
align-items: center;
|
||
position: relative;
|
||
.label{
|
||
color: #999;
|
||
font-weight: 500;
|
||
}
|
||
.info-right{
|
||
position: absolute;
|
||
top: 0rpx;
|
||
right: 40rpx;
|
||
}
|
||
.info{
|
||
color: #000;
|
||
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
</style>
|