2022-11-16 10:20:26 +00:00
|
|
|
|
<template>
|
|
|
|
|
<view class="pad-x120">
|
|
|
|
|
<!-- 头部 -->
|
|
|
|
|
<status-nav navBarTitle="打卡记录"></status-nav>
|
|
|
|
|
<view class="content" :style="{'padding-top':statusHeight+50+'px'}">
|
2022-11-17 11:40:25 +00:00
|
|
|
|
<!-- 筛选 -->
|
2023-01-15 07:31:11 +00:00
|
|
|
|
<view class="screen-box screen-box-other" v-if="ifShow">
|
2023-01-14 03:15:59 +00:00
|
|
|
|
<view class="item" :class="userType=='director'?'width-all':''">
|
2022-11-17 11:40:25 +00:00
|
|
|
|
<picker class="font24" mode="selector" :range="worksiteList" @change="bindWorksiteChange" :value="worksiteIndex" :range-key="'name'">
|
|
|
|
|
<view class="name">
|
|
|
|
|
<text class="clips1" :class="worksiteIndex==-1?'color-99':''">{{worksiteIndex!==-1?worksiteList[worksiteIndex].name:'请选择工地'}}</text>
|
|
|
|
|
<image src="/static/icon/icon-arrow-02.png" mode="aspectFit"></image>
|
|
|
|
|
</view>
|
|
|
|
|
</picker>
|
|
|
|
|
</view>
|
2023-01-15 07:31:11 +00:00
|
|
|
|
<view class="item font26 color-blue" @tap="showCard=true">
|
2022-12-09 09:56:41 +00:00
|
|
|
|
<view class="name" style="justify-content: center;">补卡操作</view>
|
2022-11-17 11:40:25 +00:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2022-12-09 09:56:41 +00:00
|
|
|
|
<!-- 打卡日历 -->
|
|
|
|
|
<view class="sign-calendar">
|
2023-01-12 11:47:46 +00:00
|
|
|
|
<sign-calendar ref="signCalendar" @getDate="getDate"></sign-calendar>
|
2022-12-09 09:56:41 +00:00
|
|
|
|
</view>
|
|
|
|
|
<!-- 时间 -->
|
2023-01-12 11:47:46 +00:00
|
|
|
|
<view class="sign-record-date font26">{{curDate.substr(0,4)+'年'+curDate.substr(5,2)+'月'+curDate.substr(8,2)+'日'}} 打卡情况</view>
|
2022-11-17 11:40:25 +00:00
|
|
|
|
<!-- 打卡记录 -->
|
|
|
|
|
<view class="sign-record sign-record-other bg-white">
|
|
|
|
|
<view class="item font26" v-for="(item,index) in signList" :key="index">
|
|
|
|
|
<view class="info">
|
2023-01-14 03:15:59 +00:00
|
|
|
|
<text>{{item.type_text}}打卡:{{item.is_replenish==1?'补打卡':item.created_at.substr(item.created_at.length-8)}}</text>
|
|
|
|
|
<text v-if="item.role!==0">打卡工地:{{item.worksite_name}}</text>
|
2022-11-17 11:40:25 +00:00
|
|
|
|
</view>
|
2023-01-14 03:15:59 +00:00
|
|
|
|
<view class="state" v-if="item.role!==0&&item.status==1">{{item.status_text}}</view>
|
|
|
|
|
<view class="state color-blue" v-if="item.role!==0&&item.status==0">{{item.status_text}}</view>
|
|
|
|
|
<view class="state color-red" v-if="item.role!==0&&item.status==-1">{{item.status_text}}</view>
|
2022-11-17 11:40:25 +00:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<!-- 加载更多 -->
|
2023-01-14 03:15:59 +00:00
|
|
|
|
<view class="more-tips font24" v-if="signList.length==0">当日没有打卡记录</view>
|
2022-11-16 10:20:26 +00:00
|
|
|
|
</view>
|
2022-12-09 09:56:41 +00:00
|
|
|
|
<!-- 补卡弹窗 -->
|
|
|
|
|
<view class="pop-up-bg" v-if="showCard">
|
|
|
|
|
<view class="sign-cate bg-white">
|
|
|
|
|
<view class="title font34">请选择补卡时间</view>
|
|
|
|
|
<view class="txt font28">
|
|
|
|
|
<view class="radio-item" @tap="changeSignType(index)" v-for="(item,index) in radioList" :key="index">
|
|
|
|
|
<view :class="radioIndex==index?'checked':''"></view>
|
2023-01-12 11:47:46 +00:00
|
|
|
|
<view>{{item.title}}</view>
|
2022-12-09 09:56:41 +00:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<!-- 审核按钮 -->
|
|
|
|
|
<view class="sign-cate-btns color-white font30">
|
|
|
|
|
<view class="btn" @tap="showCard=false,radioIndex=0">取消</view>
|
|
|
|
|
<view class="btn" @tap="submitEv">确认</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2022-11-16 10:20:26 +00:00
|
|
|
|
<!-- 尾部 -->
|
2022-12-22 09:36:10 +00:00
|
|
|
|
<tabbar :userType="userType" current="2"></tabbar>
|
2022-11-16 10:20:26 +00:00
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
<script>
|
2022-12-09 09:56:41 +00:00
|
|
|
|
import signCalendar from '@/components/sign-calendar/sign-calendar';
|
2022-11-16 10:20:26 +00:00
|
|
|
|
import tabbar from '@/components/tabbar/tabbar';
|
|
|
|
|
export default {
|
|
|
|
|
components:{
|
2022-12-09 09:56:41 +00:00
|
|
|
|
signCalendar,
|
2022-11-16 10:20:26 +00:00
|
|
|
|
tabbar
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
statusHeight:uni.getSystemInfoSync().statusBarHeight, //状态栏高度
|
2022-12-22 08:47:05 +00:00
|
|
|
|
userType:'', //账户类型 工人:worker 负责人:director
|
2022-11-17 11:40:25 +00:00
|
|
|
|
signList:[], //打卡列表
|
2022-12-09 09:56:41 +00:00
|
|
|
|
radioList:[
|
2023-01-12 11:47:46 +00:00
|
|
|
|
{title:'上午上班',type:'morning_on'},
|
|
|
|
|
{title:'上午下班',type:'morning_off'},
|
|
|
|
|
{title:'下午上班',type:'afternoon_on'},
|
|
|
|
|
{title:'下午下班',type:'afternoon_off'}
|
2022-12-09 09:56:41 +00:00
|
|
|
|
],//打卡类型
|
|
|
|
|
radioIndex:0, //当前选择
|
2023-01-12 11:47:46 +00:00
|
|
|
|
curDate:'', //当前日期
|
2022-11-17 11:40:25 +00:00
|
|
|
|
page:1,
|
|
|
|
|
size:10,
|
|
|
|
|
total:0,
|
|
|
|
|
worksiteList:[], //工地列表
|
|
|
|
|
worksiteIndex:-1, //当前选择
|
2022-12-09 09:56:41 +00:00
|
|
|
|
showCard:false, //是否显示补卡
|
2023-01-15 07:31:11 +00:00
|
|
|
|
ifShow:uni.getStorageSync('worker_role')==1?true:false,
|
2022-11-16 10:20:26 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
2022-12-22 08:47:05 +00:00
|
|
|
|
onLoad(op) {
|
2023-01-12 11:47:46 +00:00
|
|
|
|
if(op.userType){
|
2022-12-22 08:47:05 +00:00
|
|
|
|
this.userType = op.userType;
|
|
|
|
|
}
|
2023-01-12 11:47:46 +00:00
|
|
|
|
if(op.date){
|
|
|
|
|
// 获取选择日期
|
|
|
|
|
this.curDate = op.date;
|
|
|
|
|
}else{
|
|
|
|
|
let year = new Date().getFullYear();
|
|
|
|
|
let month = new Date().getMonth() + 1;
|
|
|
|
|
let day = new Date().getDate();
|
|
|
|
|
this.curDate = `${year}-${month<10?'0'+month:month}-${day<10?'0'+day:day}`;
|
|
|
|
|
}
|
2022-11-17 11:40:25 +00:00
|
|
|
|
// 获取工地列表
|
|
|
|
|
this.getWorksiteList();
|
|
|
|
|
},
|
|
|
|
|
onShow() {
|
2023-01-14 08:13:24 +00:00
|
|
|
|
setTimeout(()=>{
|
|
|
|
|
// 获取打卡列表
|
|
|
|
|
this.getSignList();
|
|
|
|
|
},200)
|
2022-11-17 11:40:25 +00:00
|
|
|
|
},
|
|
|
|
|
onReachBottom() {
|
|
|
|
|
if(this.signList.length<this.total){
|
|
|
|
|
this.page++;
|
|
|
|
|
// 获取打卡列表
|
|
|
|
|
this.getSignList();
|
|
|
|
|
}
|
2022-11-16 10:20:26 +00:00
|
|
|
|
},
|
2022-11-28 06:26:17 +00:00
|
|
|
|
onPullDownRefresh() {
|
|
|
|
|
this.page = 1;
|
|
|
|
|
// 获取打卡列表
|
|
|
|
|
this.getSignList();
|
|
|
|
|
// 关闭下拉刷新
|
|
|
|
|
uni.stopPullDownRefresh();
|
|
|
|
|
},
|
2022-11-16 10:20:26 +00:00
|
|
|
|
methods: {
|
2022-11-17 11:40:25 +00:00
|
|
|
|
// 获取工地列表
|
|
|
|
|
getWorksiteList(){
|
|
|
|
|
this.$requst.get('/api/v1/common/worksite-list').then(res=>{
|
|
|
|
|
if(res.code==0){
|
|
|
|
|
this.worksiteList = res.data.list;
|
2023-01-12 11:47:46 +00:00
|
|
|
|
if(uni.getStorageSync('worksite_id')){
|
|
|
|
|
this.worksiteIndex = this.worksiteList.findIndex(item=> item.id === uni.getStorageSync('worksite_id'));
|
2023-01-14 05:57:57 +00:00
|
|
|
|
}else if(uni.getStorageSync('baseWorksiteId')!==0){
|
2023-01-12 11:47:46 +00:00
|
|
|
|
this.worksiteIndex = this.worksiteList.findIndex(item=> item.id === uni.getStorageSync('baseWorksiteId'));
|
2023-01-14 05:57:57 +00:00
|
|
|
|
}else{
|
|
|
|
|
this.worksiteIndex = -1;
|
2023-01-12 11:47:46 +00:00
|
|
|
|
}
|
2022-11-17 11:40:25 +00:00
|
|
|
|
this.isLoding = true;
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
2022-12-09 09:56:41 +00:00
|
|
|
|
// 改变上下班打卡
|
|
|
|
|
changeSignType(index){
|
|
|
|
|
if(this.radioIndex !== index){
|
|
|
|
|
this.radioIndex = index;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2023-01-12 11:47:46 +00:00
|
|
|
|
// 获取选择时间
|
|
|
|
|
getDate(date){
|
2023-01-14 03:15:59 +00:00
|
|
|
|
if(date!==this.curDate){
|
|
|
|
|
this.curDate = date;
|
|
|
|
|
// 获取打卡列表
|
|
|
|
|
this.getSignList();
|
|
|
|
|
}
|
2023-01-12 11:47:46 +00:00
|
|
|
|
},
|
|
|
|
|
|
2022-12-09 09:56:41 +00:00
|
|
|
|
// 确认补卡
|
|
|
|
|
submitEv(){
|
2023-01-12 11:47:46 +00:00
|
|
|
|
let params = {
|
|
|
|
|
day:this.curDate,
|
2023-01-14 05:57:57 +00:00
|
|
|
|
worksite_id:this.worksiteIndex!==-1?this.worksiteList[this.worksiteIndex].id:0,
|
2023-01-12 11:47:46 +00:00
|
|
|
|
type:this.radioList[this.radioIndex].type
|
|
|
|
|
}
|
2023-01-14 05:46:19 +00:00
|
|
|
|
this.$requst.post('/api/v1/user/replenish',params).then(res=>{
|
2023-01-12 11:47:46 +00:00
|
|
|
|
if(res.code==0){
|
|
|
|
|
this.$toolAll.tools.showToast('补卡成功');
|
|
|
|
|
this.showCard = false;
|
|
|
|
|
// 获取状态列表
|
2023-01-14 08:13:24 +00:00
|
|
|
|
this.$refs.signCalendar.getStatusObj(this.worksiteList[this.worksiteIndex].id);
|
2023-01-14 05:46:19 +00:00
|
|
|
|
}else{
|
|
|
|
|
this.$toolAll.tools.showToast(res.msg);
|
2023-01-12 11:47:46 +00:00
|
|
|
|
}
|
|
|
|
|
})
|
2022-12-09 09:56:41 +00:00
|
|
|
|
},
|
|
|
|
|
|
2022-11-17 11:40:25 +00:00
|
|
|
|
// 获取打卡列表
|
|
|
|
|
getSignList(){
|
2023-01-15 07:31:11 +00:00
|
|
|
|
let params = {};
|
|
|
|
|
if(uni.getStorageSync('worker_role')==0){
|
|
|
|
|
params = {
|
|
|
|
|
day:this.curDate,
|
|
|
|
|
worksite_id:0
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
params = {
|
|
|
|
|
day:this.curDate,
|
|
|
|
|
worksite_id:this.worksiteIndex!==-1?this.worksiteList[this.worksiteIndex].id:0
|
|
|
|
|
}
|
2023-01-14 08:13:24 +00:00
|
|
|
|
}
|
|
|
|
|
this.$requst.get('/api/v1/user/sign-today',params).then(res=>{
|
2023-01-14 03:15:59 +00:00
|
|
|
|
if(res.code == 0){
|
2022-11-17 11:40:25 +00:00
|
|
|
|
console.log(res,'打卡记录');
|
2023-01-14 03:15:59 +00:00
|
|
|
|
// 获取打卡状态
|
|
|
|
|
this.buttonColor = res.data.buttonColor;
|
|
|
|
|
// 获取打卡记录列表
|
|
|
|
|
this.signList = res.data.list;
|
2022-11-17 11:40:25 +00:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 选择工地
|
|
|
|
|
bindWorksiteChange(e) {
|
|
|
|
|
this.worksiteIndex = e.detail.value;
|
|
|
|
|
this.page = 1;
|
|
|
|
|
// 获取打卡列表
|
|
|
|
|
this.getSignList();
|
2023-01-14 08:13:24 +00:00
|
|
|
|
// 获取状态列表
|
|
|
|
|
this.$refs.signCalendar.getStatusObj(this.worksiteList[this.worksiteIndex].id);
|
2022-11-17 11:40:25 +00:00
|
|
|
|
},
|
2022-11-16 10:20:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
|
|
|
|
</style>
|