building-sign/pagesB/worker/worker.vue

226 lines
6.1 KiB
Vue
Raw Normal View History

2022-11-18 10:33:37 +00:00
<template>
<view class="pad-x120">
<!-- 头部 -->
2022-12-21 08:26:21 +00:00
<status-nav navBarTitle="工人列表"></status-nav>
2022-11-18 10:33:37 +00:00
<view class="content" :style="{'padding-top':statusHeight+50+'px'}">
<!-- 工人列表 -->
2022-12-21 08:26:21 +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="radio" :class="item.ifcheck?'checked':''" @tap="chooseEv(index)" v-if="status==0"></view>
<view class="info" :class="status==0?'hide':''">
<text>姓名{{item.worker_name}}</text>
<text>{{item.type_text}}打卡{{item.created_at}}</text>
<text>打卡工地{{item.worksite_name}}</text>
2022-11-28 06:26:17 +00:00
</view>
2022-12-21 08:26:21 +00:00
<!-- 待确认 -->
<view class="examine-btns font24" v-if="item.status==0">
<view class="btn color-blue" @tap="submitEv(item.id,1)"></view>
<view class="btn color-99" @tap="submitEv(item.id,0)">退</view>
2022-11-28 06:26:17 +00:00
</view>
2022-12-21 08:26:21 +00:00
<!-- 已确认 -->
<view class="state" :class="item.status==-1?'color-red':''" v-if="item.status==1 || item.status==-1">{{item.status_text}}</view>
2022-11-18 10:33:37 +00:00
</view>
2022-12-21 08:26:21 +00:00
<!-- 加载更多 -->
<view class="more-tips font24">{{signList.length==total?'没有更多数据了':'下滑获取更多'}}</view>
2022-12-08 10:07:45 +00:00
</view>
2022-11-18 10:33:37 +00:00
</view>
<!-- 工人评定弹窗 -->
<view class="pop-up-bg" v-if="showEvaluate">
<view class="sign-cate bg-white">
<view class="title font34">工人评定</view>
<view class="txt evaluate-txt font28">
<view class="evaluate-tips">请根据工人本月的表现情况进行评定</view>
<view class="evaluate-stars" v-for="(item,index) in allStars" :key="index">
<image @tap="changeStars(index)" :src="index<=curStars-1?'/static/icon/icon-stars-active.png':'/static/icon/icon-stars.png'" mode="widthFix"></image>
</view>
</view>
<!-- 审核按钮 -->
<view class="sign-cate-btns color-white font30">
<view class="btn" @tap="showEvaluate=false,curStars=0"></view>
<view class="btn" @tap="submitEv"></view>
</view>
</view>
</view>
2022-11-18 10:33:37 +00:00
<!-- 尾部 -->
<tabbar :userType="userType" current="2"></tabbar>
2022-11-18 10:33:37 +00:00
</view>
</template>
<script>
import tabbar from '@/components/tabbar/tabbar';
export default {
components:{
tabbar
},
data() {
return {
statusHeight:uni.getSystemInfoSync().statusBarHeight, //状态栏高度
userType:'director', //账户类型 工人worker 负责人director
2022-12-21 08:26:21 +00:00
signList:[], //打卡列表
page:1,
size:10,
status:0,
total:0,
isAll:false, //是否全选
ids:'', //选中的id
showEvaluate:false,//是否显示评定弹窗
allStars:5, //总共几星
curStars:0, //选择几星
2022-11-18 10:33:37 +00:00
}
},
2022-12-21 08:26:21 +00:00
onLoad() {
2022-11-18 10:33:37 +00:00
},
onShow() {
2022-12-21 08:26:21 +00:00
// 获取打卡列表
this.getSignList();
},
onReachBottom() {
if(this.signList.length<this.total){
this.page++;
// 获取打卡列表
this.getSignList();
}
},
onPullDownRefresh() {
this.page = 1;
// 获取打卡列表
this.getSignList();
// 关闭下拉刷新
uni.stopPullDownRefresh();
2022-12-08 10:07:45 +00:00
},
onShareAppMessage(res) {
let shareObj = {
title:'工地打卡',
path: '/pages/pagehome/pagehome',
imageUrl:'/static/share-logo.jpg',
}
// 返回shareObj
return shareObj;
2022-11-18 10:33:37 +00:00
},
methods: {
// 选择几星
changeStars(index){
if(index!==this.curStars-1){
this.curStars = index+1;
}
},
2022-12-21 08:26:21 +00:00
// 选择栏目
changeEv(index){
this.status = index;
this.page = 1;
// 获取打卡列表
this.getSignList();
},
// 选中事件
chooseEv(index) {
this.signList[index].ifcheck = !this.signList[index].ifcheck;
let exit = this.signList.filter(item=>item.ifcheck==false);
if(exit.length>0){
this.isAll = false;
} else {
this.isAll = true;
}
let idsTemparr = this.signList.filter(item=>{return item.ifcheck==true})
let idsArr = [];
idsTemparr.forEach(item=>{
idsArr.push(item.id)
2022-11-18 10:33:37 +00:00
})
2022-12-21 08:26:21 +00:00
// 选中的id
this.ids = idsArr.join(',');
2022-11-18 10:33:37 +00:00
},
2022-12-21 08:26:21 +00:00
// 全选事件
chooseAll(){
let exit = this.signList.filter(item=>item.ifcheck==false);
if(exit.length>0){
this.isAll = true;
this.signList.forEach(item=>item.ifcheck = true);
} else {
this.isAll = false;
this.signList.forEach(item=>{item.ifcheck = false});
2022-12-08 10:07:45 +00:00
}
2022-12-21 08:26:21 +00:00
let idsTemparr = this.signList.filter(item=>{return item.ifcheck==true})
let idsArr = [];
idsTemparr.forEach(item=>{
idsArr.push(item.id)
})
// 选中的id
this.ids = idsArr.join(',');
2022-12-08 10:07:45 +00:00
},
2022-12-21 08:26:21 +00:00
// 确认&退回事件
submitEv(id,type){
let params = {
id:id,
type:type
}
this.$requst.post('/api/v1/manager/check-clock',params).then(res=>{
if(res.code==0){
2022-12-08 10:07:45 +00:00
if(type==0){
this.$toolAll.tools.showToast('已退回');
}else{
this.$toolAll.tools.showToast('已确认');
}
2022-12-21 08:26:21 +00:00
// 获取打卡列表
this.getSignList();
2022-12-08 10:07:45 +00:00
}
})
},
2022-12-21 08:26:21 +00:00
// 批量确认&退回事件
submitAll(type){
let params = {
id:this.ids,
type:type
}
this.$requst.post('/api/v1/manager/check-clock',params).then(res=>{
if(res.code==0){
if(type==0){
this.$toolAll.tools.showToast('已退回');
}else{
this.$toolAll.tools.showToast('已确认');
}
// 获取打卡列表
this.getSignList();
}
})
},
// 获取打卡列表
getSignList(){
let params = {
page:this.page,
size:this.size,
status:this.status
}
if(this.page==1) this.signList = [];
this.$requst.post('/api/v1/manager/clock-list',params).then(res=>{
if(res.code==0){
console.log(res,'打卡列表');
this.total = res.data.total;
let signArr = [];
res.data.list.forEach(item=>{
let obj = {
id:item.id,
created_at:item.created_at,
status:item.status,
status_text:item.status_text,
worksite_name:item.worksite_name,
worker_name:item.worker_name,
type_text:item.type_text,
is_statistic:item.is_statistic,
ifcheck:false,
}
signArr.push(obj);
})
this.signList = this.signList.concat(signArr);
}
})
},
2022-11-18 10:33:37 +00:00
}
}
</script>
<style scoped>
</style>