factory_mp_old/pages/my/clock_in.vue

240 lines
5.5 KiB
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="clockInContainer">
<uni-nav-bar @clickLeft="goBack()" height="110rpx" leftWidth="200rpx" leftText="打卡记录" leftIcon="left" border
backgroundColor="#2cade8" color="#fff" fixed statusBar shadow></uni-nav-bar>
<view class="tabbar-title">
<view :class="{'text-title':true, 'active':activeIndex}" @click="changeList(1)">本月</view>
<view style="display: flex;">
<view>选择月份</view>
<picker mode="date" :value="date" fields="month" @change="bindDateChange">
<view class="uni-input">{{date}}</view>
</picker>
</view>
</view>
<view class="content">
<view class="item-wrap" v-for="(val,index) in lists" :key="val.id">
<view class="clock_in_-item">
<view class="center-info">
<view class="info-details">
触发设备:
{{trigger_[val.trigger]}}
</view>
<view class="info-details">触发地点:{{val.detail.deviceName}}</view>
<view class="info-details">打卡时间:{{val.create_time}}</view>
<view class="info-details">考勤推测:
<text v-if="val.type==10" class="nomalState type01">上班打卡</text>
<text v-else-if="val.type==20" class="nomalState type02">下班打卡</text>
<span v-if="(val.type==10 || val.type==20)&&val.exception_type!==null">-</span>
<text v-if="val.exception_type==10" class="nomalState type1">在岗时间短</text>
<text v-else-if="val.exception_type==20" class="nomalState type2">在岗时间长</text>
<text v-else-if="val.exception_type==30" class="nomalState type3">缺卡</text>
<text v-else-if="val.exception_type==40" class="nomalState type4">加班</text>
</view>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
name: 'ticket',
data() {
return {
params: {
employee: '',
page_size: 10,
page: 1,
month: '',
year:''
},
trigger_:{
"door": "门禁",
"location": "定位",
"panel":"面板机"
},
totalNum: 0,
activeIndex:true,//本月
lists: [],
currentMonth:'',
currentYear:'',
date:'选择其他月',
}
},
//上拉加载
onReachBottom() {
const totalPage = Math.ceil(this.totalNum / this.params.page_size);
if (this.params.page < totalPage) {
this.params.page += 1;
this.getLists();
} else {
uni.showToast({
title: "已全部加载",
icon: 'none'
})
}
},
onShow() {
let that = this;
let now = new Date()
var year = now.getFullYear(); // 年
var month = now.getMonth() + 1; // 月
if(month < 10) {
month = '0' + month;
}
that.params.month = that.currentMonth = month;
that.params.year = that.currentYear = year;
that.date = year+'-'+month;
that.$u.api.hrmUserInfo().then(res => {
if(res.err_msg){}else{
that.params.employee = res.id;
that.getLists();
}
})
},
//下拉刷新
onPullDownRefresh() {
this.params.page = 1;
this.lists = [];
this.getLists();
},
methods: {
bindDateChange(e){
let that = this;
that.date = e.target.value;
that.params.month = that.date.split('-')[1];
that.params.year = that.date.split('-')[0];
let current = that.currentYear+'-'+that.currentMonth;
if(that.date==current){
that.activeIndex=true;
}else{
that.activeIndex=false;
}
that.params.page = 1;
that.lists = [];
that.getLists();
},
getLists() {
let that = this;
that.$u.api.hrmClockRecord(that.params).then(res => {
that.lists = that.lists.concat(res.results);
that.totalNum = res.count;
})
},
changeList(index){
let that = this;
that.activeIndex = index;
that.params.month = that.currentMonth;
that.params.year = that.currentYear;
that.params.page = 1;
that.lists = [];
that.getLists();
},
goBack() {
uni.navigateBack({
delta: 1
})
},
}
}
</script>
<style scoped>
.empty-view {
height: 120rpx;
}
>>>.uni-navbar__header,
>>>.uni-status-bar,
.search-wrap {
background-image: linear-gradient(270deg,
#0ca7ee 0%,
#005aff 100%,
#2a8cff 100%,
#54bdff 100%),
linear-gradient(#e60012,
#e60012);
}
.tabbar-title{
display: flex;
justify-content: space-between;
}
.clockInContainer {
background-color: #f3fbff;
}
.clockInContainer>>>.uni-navbar-btn-text text {
font-size: 32rpx !important;
}
.content {
padding: 14rpx;
padding-top: 10upx;
}
.item-wrap {
margin-bottom: 14rpx;
}
.clock_in_-item {
width: 720rpx;
background-color: #ffffff;
border-radius: 10rpx;
margin: 0 auto;
padding: 24rpx 21rpx;
box-sizing: border-box;
}
.info-details {
font-size: 28rpx;
line-height: 40rpx;
color: #5b5b5b;
}
.nomalState {
font-size: 12px;
padding: 0 9px;
height: 24px;
line-height: 23px;
border-radius: 5px;
vertical-align: top;
display: inline-block;
}
.nomalState.type1{
color: #F8DD4E;
background-color: #f9f7e6;
border: 1px solid #f3f0d5;
}
.nomalState.type2{
color: #FF0000;
background-color: #f7e7e7;
border: 1px solid #fbe0e0;
}
.nomalState.type3{
color: #FA8435;
background-color: #fef6ed;
border: 1px solid #fde9cc;
}
.nomalState.type4{
color: #44CEF6;
background-color: #f0f9fb;
border: 1px solid #d2f9ff;
}
.nomalState.type01{
color: #536dfe;
background-color: #edf0fe;
border: 1px solid #dce1fe;
}
.nomalState.type02{
color: #67c23a;
background-color: #f0f9eb;
border: 1px solid #e1f3d8;
}
</style>