ce4c83ff
wxy
初始提交
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
<template>
<div class='attence'>
<div class='list-item' v-for="(v,i) in list" :key="i">
<div class='schedule'>
<div class='time'>{{v.schedule_Date}}</div>
<div class='locate'><img src='/static/imgs/community.png'>{{v.comm_Name}}</div>
</div>
<div class='on'>上班
<div class='sign'>
<img v-if='v.first_tsid>0' class='yes' src='/static/imgs/yes.png'>
<img v-else-if='i>0 || beforeCheckIn===false' class='no' src='/static/imgs/no.png'>
</div>
</div>
<div class='off'>下班
<div class='sign'>
<img v-if='v.second_tsid>0' class='yes' src='/static/imgs/yes.png'>
<img v-else-if='i>0 || beforeCheckOff===false' class='no' src='/static/imgs/no.png'>
</div>
</div>
</div>
<NoData v-if='loaded && list.length==0' paddingTop=0 />
</div>
</template>
<script>
import NoData from '@/components/NoData'
const week = ['日','一','二','三','四','五','六']
export default {
components:{NoData},
data() {
return {
list: [],
beforeCheckIn: 'unknown',
beforeCheckOff: 'unknown',
loaded: false
}
},
methods: {
getList() {
this.loaded = false
wx.showLoading({ title: '正在加载' })
wx.request({
url: this.rootUrl + '/TSheet/attence_records',
data: { sessionID: wx.getStorageSync('sessionID') },
success: res => {
if (res.statusCode == '500') {
this.service.getUnionId(this.rootAvatar, this.rootUrl).then(res => {
this.getList()
})
} else {
let dateStr, dateObj
const todayStr = this.service.formatDate(new Date())
const attenceRecords = res.data.response
attenceRecords.forEach(v => {
dateStr = this.service.correctTime(v.schedule_Date)
dateObj = this.service.correctTime(v.schedule_Date,'DateObj')
v.schedule_Date = dateStr + ' (星期' + week[dateObj.getDay()] + ')' + ( dateStr === todayStr ? ' (今天)' : '' )
})
this.list = []
this.list = attenceRecords
if(attenceRecords.length > 0) this.checkDuty()
this.loaded = true
wx.hideLoading()
}
},
fail: res => {
wx.hideLoading()
wx.showToast({ title: '加载失败', icon: 'none' })
}
})
},
checkDuty(){
const tArr = this.list[0].schedule_Date.substring(0,10).split(/-/).map(Number)
const now = new Date()
if (now.getDate() !== tArr[2] || now.getMonth()+1 !== tArr[1] || now.getFullYear() !== tArr[0]){
this.beforeCheckIn = false
this.beforeCheckOff = false
}else{
const CheckFunc = obj=>{
obj.knockOff = this.service.correctTime(obj.knockOff,'DateObj')
const hourEnd = obj.knockOff.getHours()
const minuteEnd = obj.knockOff.getMinutes()
const hour = new Date().getHours()
const minute = new Date().getMinutes()
return hour < hourEnd || hour === hourEnd && minute < minuteEnd
}
wx.request({
url: this.rootUrl + '/ptime/all',
success: res => {
this.beforeCheckIn = CheckFunc(res.data[0])
this.beforeCheckOff = CheckFunc(res.data[1])
}
})
}
}
},
onLoad() {
this.getList()
}
}
</script>
<style lang="stylus" scoped>
.attence
position absolute
Height_Width(100%)
Background()
.list-item
padding 20rpx 30rpx
background white
Border(0, 0, 1rpx, 0)
Flex(flex,flex-end)
.schedule
margin 0 auto 0 0
.time
Font(36rpx)
.locate
margin 25rpx 20rpx 0 0
Flex(flex,,center)
Font(30rpx)
color #666
img
Height_Width(32rpx)
margin-right 10rpx
.on, .off
padding 0 20rpx
Font(32rpx,32rpx,bold)
Flex(flex,space-between,center,column)
.sign
Flex(flex,flex-end,center,column)
.yes
Height_Width(40rpx)
position relative
top 4rpx
.no
Height_Width(32rpx)
.off
padding-right 0
</style>
|