YNUtdPlatform/pages/realName/workAttendance/tempClock/tempPeopleList.vue

306 lines
8.4 KiB
Vue
Raw Permalink Normal View History

<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="width: 98%;height: auto;padding: 10rpx auto;display: flex;align-items: center;margin-bottom: 20rpx;">
<uni-data-select v-model="isToWork" :localdata="range" :clear="false" style="width: 32%;margin-right: 20rpx;"></uni-data-select>
<uni-data-select v-model="isTrain" :localdata="range1" :clear="false" style="width: 32%;margin-right: 20rpx;"></uni-data-select>
<uni-data-select v-model="isOver" :localdata="range2" :clear="false" style="width: 32%;"></uni-data-select>
</view>
<view style="width: 96%;height: auto;padding: 10rpx auto;display: flex;align-items: center;">
<u-search shape="square" placeholder="人员姓名" v-model="keyword" :showAction="false" bgColor="#FFF" borderColor="#ccc"></u-search>
<view class="searchBtn" @click="searchList">搜索</view>
</view>
</view>
<view style="padding-left: 40rpx;">
<text style="font-size: 24rpx;color: #5193FE;">已查询{{number}}条数据</text>
</view>
<!-- 列表 -->
<view class="list-box">
<u-list height="78vh" >
<u-list-item v-for="(item, index) in listData" :key="index">
<view class="list-item">
<view class="content-box">
<view class="item-text" >
<view class="sortBox">{{index+1}}</view>
<text class="info">{{item.name}}{{item.idNumber}}</text>
<text style="color: red;position: absolute;right: 20rpx;top: 10rpx;" v-if="item.isToWork==0"> 未考勤</text>
<text style="color: #06E7A3;position: absolute;right: 20rpx;top: 10rpx;" v-if="item.isToWork!=0"> 已考勤</text>
</view>
<view class="item-text">
<text class="info">所在工程</text>
<text class="label">{{item.proName}}</text>
</view>
<view class="item-text">
<text class="info" >安全培训考试</text>
<text style="color: red;position: absolute;right: 20rpx;" v-if="item.isTrain==0"> 未完成</text>
<text style="color: #06E7A3;position: absolute;right: 20rpx;" v-if="item.isTrain==1"> 已完成</text>
</view>
<view class="item-text">
<text class="info">{{item.einTime}}入场</text>
<text style="color: red;position: absolute;right: 20rpx;" v-if="item.attDayNum>7"> 已超7天</text>
</view>
</view>
</view>
</u-list-item>
</u-list>
</view>
</view>
</template>
<script>
import config from '@/config'
export default {
data() {
return {
proId:uni.getStorageSync('realNameUser').proId,
keyword:'',
listData:[],
number:0,
isToWork: 0,//是否考勤
range: [
{ value: 0, text: "全部" },
{ value: 1, text: "已考勤" },
{ value: 2, text: "未考勤" },
],
isTrain: 0,//是否培训
range1: [
{ value: 0, text: "全部" },
{ value: 1, text: "已培训" },
{ value: 2, text: "未培训" },
],
isOver: 0,//是否超过
range2: [
{ value: 0, text: "全部" },
{ value: 1, text: "超七天" },
{ value: 2, text: "未超七天" },
],
}
},
onLoad(option) {
if(option.isOver){
this.isOver=Number(option.isOver);
this.$forceUpdate()
}
this.loadmore()
},
onShow() {
},
methods: {
//搜索
searchList(){
this.listData=[]
this.number=0
this.loadmore()
},
loadmore(){
let param={
proId:this.proId
}
console.log(param)
uni.request({
url: config.realAppUrl+'/BasePerson/downloadTemporaryWorkPerson',
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;
if(this.keyword!=""){
this.listData = this.listData.filter(obj => obj.name.indexOf(this.keyword) >= 0);
}
console.log(this.isToWork)
if(this.isToWork==1){//已考勤 item.isToWork==0
this.listData = this.listData.filter(obj => obj.isToWork != 0);
}else if(this.isToWork==2){//未考勤
this.listData = this.listData.filter(obj => obj.isToWork == 0);
}else{
this.listData = this.listData
}
console.log(this.isTrain)
if(this.isTrain==1){//已培训
this.listData = this.listData.filter(obj => obj.isTrain == 1);
}else if(this.isTrain==2){//未培训
this.listData = this.listData.filter(obj => obj.isTrain == 0);
}else{
this.listData = this.listData
}
console.log(this.isOver)
if(this.isOver==1){//已超过7天
this.listData = this.listData.filter(obj => obj.attDayNum > 7);
}else if(this.isOver==2){//未超过7天
this.listData = this.listData.filter(obj => obj.attDayNum <= 7);
}else{
this.listData = this.listData
}
this.number=this.listData.length;
}else{
uni.showToast({
title: res.msg,
icon: 'none'
})
}
},
fail: err => {
console.log(err)
}
})
},
// 返回
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;
2024-09-29 10:19:21 +08:00
background-color: #EFEFEF;
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;
.sortBox{
display: inline-block;
width: 12%;
text-align: center;
height: 60rpx;
line-height: 60rpx;
color: #FFF;
margin-right: 20rpx;
background: url('../../../../static/realName/serial.png') no-repeat;
background-size: 100% 100%;
}
.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>