building-sign/pagesA/overtimeRecord/overtimeRecord.vue

177 lines
5.3 KiB
Vue
Raw Normal View History

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
<!-- 筛选 -->
<view class="screen-box">
<view class="item">
<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>
<view class="item">
<picker class="font24" mode="date" :range="date" @change="beginDateChange" :start="startDate" :end="date">
<view class="name">
<text :class="beginDate==''?'color-99':''">{{beginDate!==''?beginDate.split('-')[0]+'年'+beginDate.split('-')[1]+'月'+beginDate.split('-')[2]+'日':'请选择开始时间'}}</text>
<image src="/static/icon/icon-arrow-02.png" mode="aspectFit"></image>
</view>
</picker>
</view>
<view class="item">
<picker class="font24" mode="date" :range="date" @change="endDateChange" :start="startDate" :end="date">
<view class="name">
<text :class="endDate==''?'color-99':''">{{endDate!==''?endDate.split('-')[0]+'年'+endDate.split('-')[1]+'月'+endDate.split('-')[2]+'日':'请选择截止时间'}}</text>
<image src="/static/icon/icon-arrow-02.png" mode="aspectFit"></image>
</view>
</picker>
</view>
</view>
<!-- 加班记录 -->
<view class="sign-record sign-record-other bg-white">
<view class="item font26" v-for="(item,index) in overtimeList" :key="index">
2022-11-18 10:33:37 +00:00
<view class="info" :class="item.status==-1?'enter-info':''">
2022-11-17 11:40:25 +00:00
<text>工地{{item.worksite_name}}</text>
<text>加班时长{{item.time}}小时</text>
<text>提交时间{{item.create_time}}</text>
</view>
2022-11-18 10:33:37 +00:00
<view class="state color-blue" v-if="item.status==0">{{item.status_text}}</view>
<view class="state" v-if="item.status==1">{{item.status_text}}</view>
<view class="examine-btns font24" v-if="item.status==-1">
<view class="btn color-blue" @tap="editEv(item.id)"></view>
</view>
2022-11-17 11:40:25 +00:00
</view>
</view>
<!-- 加载更多 -->
2022-11-18 10:33:37 +00:00
<view class="more-tips font24">{{overtimeList.length==total?'没有更多数据了':'下滑获取更多'}}</view>
2022-11-16 10:20:26 +00:00
</view>
<!-- 尾部 -->
<tabbar :userType="userType" current="2"></tabbar>
</view>
</template>
<script>
import tabbar from '@/components/tabbar/tabbar';
2022-11-17 11:40:25 +00:00
function getDate(type) {
const date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
if (type === 'start') {
year = year - 10;
}
month = month > 9 ? month : '0' + month;
day = day > 9 ? day : '0' + day;
return `${year}-${month}-${day}`;
}
2022-11-16 10:20:26 +00:00
export default {
components:{
tabbar
},
data() {
return {
statusHeight:uni.getSystemInfoSync().statusBarHeight, //状态栏高度
userType:'worker', //账户类型 工人worker 负责人director
2022-11-17 11:40:25 +00:00
overtimeList:[], //加班列表
page:1,
size:10,
total:0,
worksiteList:[], //工地列表
worksiteIndex:-1, //当前选择
date: getDate({format: true}),
startDate: getDate('start'),
beginDate:'', //开始日期
endDate:'', //结束日期
2022-11-16 10:20:26 +00:00
}
},
onLoad() {
2022-11-17 11:40:25 +00:00
// 获取工地列表
this.getWorksiteList();
// 获取打卡列表
this.getOvertimeList();
2023-01-16 07:13:07 +00:00
},
onShow() {
2022-11-17 11:40:25 +00:00
},
onReachBottom() {
if(this.overtimeList.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.getOvertimeList();
// 关闭下拉刷新
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;
this.isLoding = true;
}
})
},
// 获取加班列表
getOvertimeList(){
let params = {
page:this.page,
size:this.size,
worksite_id:this.worksiteIndex==-1?'':this.worksiteList[this.worksiteIndex].id,
begin_at:this.beginDate,
end_at:this.endDate
}
if(this.page==1) this.overtimeList = [];
this.$requst.post('/api/v1/worker/overtime-list',params).then(res=>{
if(res.code==0){
console.log(res,'加班记录');
this.total = res.data.total;
this.overtimeList = this.overtimeList.concat(res.data.list);
}
})
},
2022-11-18 10:33:37 +00:00
// 再次编辑
editEv(id){
uni.navigateTo({
url:`/pagesA/overtimeEdit/overtimeEdit?id=${id}`
})
},
2022-11-17 11:40:25 +00:00
// 选择工地
bindWorksiteChange(e) {
this.worksiteIndex = e.detail.value;
this.page = 1;
// 获取加班列表
this.getOvertimeList();
},
// 选择开始日期
beginDateChange(e) {
this.beginDate = e.detail.value;
this.page = 1;
// 获取加班列表
this.getOvertimeList();
},
2022-11-16 10:20:26 +00:00
2022-11-17 11:40:25 +00:00
// 选择结束日期
endDateChange(e) {
this.endDate = e.detail.value;
this.page = 1;
// 获取加班列表
this.getOvertimeList();
},
2022-11-16 10:20:26 +00:00
}
}
</script>
<style scoped>
</style>