signInList.vue
4.3 KB
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<template>
<view class="signin_list" :style="vuex_theme">
<mi-calendar :suspensionDateList="suspensionDateList" @change="change" @changeMonth="changeMonth"></mi-calendar>
<view class="steps">
<u-steps current="1" direction="column" v-if="signList.length> 0">
<view v-for="(item, i) in signList" :key="i">
<u-steps-item :title="timeFormat(item.createdTime, 'yyyy-mm-dd hh:MM')" :desc="item.location"
v-if="i == 0">
<u-icon slot="icon" size="38rpx" :name="vuex_baseImgUrl && `${vuex_baseImgUrl}currentTime.png`"></u-icon>
</u-steps-item>
<u-steps-item :title="timeFormat(item.createdTime, 'yyyy-mm-dd hh:MM')" :desc="item.location"
v-else>
<u-icon slot="icon" size="16rpx" :name="vuex_baseImgUrl && `${vuex_baseImgUrl}beforeTime.png`"></u-icon>
</u-steps-item>
</view>
</u-steps>
<view v-else class="no_data">
<c-no-data paddingTop="30"></c-no-data>
</view>
</view>
</view>
</template>
<script>
import {
mapGetters,
mapState,
mapActions
} from 'vuex'
import listMixin from "@/common/mixins/list-mixin.js";
import {
getsignInListApi,
} from '@/config/api.js';
export default {
data() {
const d = new Date();
const year = d.getFullYear();
let month = d.getMonth() + 1;
month = month < 10 ? `0${month}` : month;
const date = this.getZero(d.getDate());
return {
initList: [],
nowTime: `${year}-${month}-${date}`,
suspensionDateList: [],
signList: [],
}
},
onLoad(option) {
this.studentId = option.studentId;
this.planId = option.planId;
getsignInListApi({
studentId: option.studentId,
planId: option.planId,
}).then(data => {
this.initList = data;
if (data && data.length > 0) {
let suspensionDateList = [];
data.map((item, index) => {
let suspensionDate = this.timeFormat(item.signIn)
console.log(suspensionDate, this.nowTime)
suspensionDateList.push(suspensionDate);
})
this.suspensionDateList = suspensionDateList;
this.filterData(data, this.nowTime);
}
})
},
methods: {
timeFormat(timestamp, format = 'yyyy-mm-dd') {
return timestamp > 0 ? uni.$u.timeFormat(timestamp, format) : '--'
},
filterData(data, time) {
let signListArr = data.filter(item => this.timeFormat(item.signIn) == time);
this.signList = signListArr.length > 0 ? signListArr[0].attendanceList : [];
},
change(date) {
console.log(date); // 日期 eg:'2022-01-01'
this.filterData(this.initList, date);
},
getZero(num) {
// 单数前面加0
if (parseInt(num) < 10) {
num = '0' + num;
}
return num;
},
changeMonth(year, month) {
console.log(year, month); // 日期 eg:2022, 6
let monthTime = new Date(year, month - 1);
console.log(monthTime.getTime())
getsignInListApi({
studentId: this.studentId,
time: monthTime.getTime(),
}).then(data => {
this.initList = data;
if (data && data.length > 0) {
let suspensionDateList = [];
data.map((item, index) => {
let suspensionDate = this.timeFormat(item.signIn)
console.log(suspensionDate, this.nowTime)
suspensionDateList.push(suspensionDate);
})
this.suspensionDateList = suspensionDateList;
// let monthFormat = month < 10 ? `${year}-0${month}` : `${year}-${month}`;
// if (this.nowTime.indexOf(monthFormat) != -1) {
// this.filterData(data, this.nowTime);
// }
}
})
},
}
}
</script>
<style lang="scss" scoped>
.signin_list {
width: 100%;
min-height: 100%;
height: auto;
background-color: #F7F7F7;
padding: 5rpx 0 20rpx 0;
.steps {
width: 630rpx;
min-height: 550rpx;
padding: 30rpx;
margin: 20rpx auto 0;
background-color: #fff;
border-radius: 12rpx;
box-shadow: 0 3rpx 32rpx 0rpx rgba(0, 0, 0, 0.1);
}
.steps /deep/ .u-steps-item {
padding-bottom: 40rpx;
.u-steps-item__content {
.u-text {
.u-text__value {
font-size: 28rpx !important;
}
.u-text__value--content {
color: #202131 !important;
}
.u-text__value--tips {
color: #909097 !important;
}
}
}
}
}
</style>