<template>
	<view >
		<view>
			<u-cell-group>
				<u-cell icon="setting-fill" :title="v.fullName" size="large" @click="kaoqin(v)" v-for="v in list" :key="v.userId">
					<image slot="icon" src="/static/wjw-user.png" mode="widthFix" style="width: 60rpx;margin-right: 20rpx;"></image>
					<view slot="value" style="font-weight: 500;" :style="{color:v.isSave=='1'?'#19be6b':'#fa3534'}">
						{{v.isSave=='1'?'已打卡':'未打卡'}}
					</view>
				</u-cell>
			</u-cell-group>
		</view>
	</view>
</template>

<script>
	import {getWeekInYear} from "@/utils/wjw.js"
	export default {
		data() {
			return {
				list:[],
				//当前周数
				weekNum:null
			}
		},
		onLoad(){
			this.getPeoList()
			this.weekNum = getWeekInYear(uni.$u.timeFormat(new Date().toLocaleDateString(), 'yyyy-mm-dd'))
		},
		onShow(){
			uni.$once('query', (query) => {
				if(query.a === 1){
					this.getPeoList()
				}
			});
		},
		onPullDownRefresh(){
			this.getPeoList()
		},
		methods: {
			//获取人员列表
			getPeoList(){
				uni.$u.http.get('/oa/attendance/dept/all').then(res=>{
					this.list = res.rows
					setTimeout(()=>{
						uni.stopPullDownRefresh()
					},2000)
				})
			},
			//跳转考勤详情页
			kaoqin(v){
				uni.navigateTo({
					url:`/pages/kqdetail/kqdetail?name=${v.fullName}&id=${v.userId}&weekNumber=${this.weekNum}&deptId=${v.deptId}`
				})
			}
		}
	}
</script>

<style>

</style>
