Blame view
src/pages/Attendence/teacherAttendence.vue
11.1 KB
687e0b929
|
1 |
<template> |
68d742034
|
2 3 4 5 6 7 8 9 10 11 12 13 14 |
<v-container fluid class="body-color"> <!-- ****** ATTENDENCE TACHERS TABLE ****** --> <v-toolbar color="transparent" flat> <v-btn fab dark class="open-dialog-button hidden-xl-only hidden-md-only hidden-lg-only" small @click="addTeacherAttendenceDialog = true" > <v-icon dark>add</v-icon> </v-btn> <v-btn |
710438de6
|
15 |
v-if="role != 'TEACHER' " |
68d742034
|
16 17 18 19 20 21 22 23 24 25 26 |
round class="open-dialog-button hidden-sm-only hidden-xs-only" dark @click="addTeacherAttendenceDialog = true" > <v-icon class="white--text pr-1" size="20">add</v-icon>Add Teacher Attendence </v-btn> <v-spacer></v-spacer> <v-card-title class="body-1" v-show="show"> <v-btn icon large flat @click="displaySearch"> <v-avatar size="27"> |
aa310d61a
|
27 |
<img src="/static/icon/search.png" alt="icon" /> |
68d742034
|
28 29 30 |
</v-avatar> </v-btn> </v-card-title> |
612b79bb4
|
31 |
<v-flex xs8 sm8 md3 lg2 v-if="showSearch"> |
68d742034
|
32 |
<v-layout> |
8e8d14254
|
33 34 35 36 37 38 39 |
<v-text-field autofocus v-model="search" label="Search" prepend-inner-icon="search" color="primary" ></v-text-field> |
68d742034
|
40 41 42 43 44 45 |
<v-icon @click="closeSearch" color="error">close</v-icon> </v-layout> </v-flex> </v-toolbar> <v-data-table :headers="headers" |
7151b71ec
|
46 |
:items="teachersData" |
68d742034
|
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
:pagination.sync="pagination" :search="search" > <template slot="items" slot-scope="props"> <tr class="tr"> <td class="td td-row">{{ props.index + 1}}</td> <td class="text-xs-center td td-row"> <v-avatar size="40"> <img :src="props.item.profilePicUrl" v-if="props.item.profilePicUrl" /> <img src="/static/icon/user.png" v-else-if="!props.item.profilePicUrl" /> </v-avatar> </td> <td class="td td-row text-xs-center">{{ props.item.name}}</td> <td class="td td-row text-xs-center">{{ props.item.email }}</td> <td class="td td-row text-xs-center">{{ props.item.mobileNo }}</td> <td class="text-xs-center td td-row"> <router-link |
2fe1115d8
|
64 |
:to="{ name:'View Teacher Attendence',params: { teacherId:props.item._id } }" |
68d742034
|
65 66 67 68 69 70 |
> <span> <v-tooltip top> <img slot="activator" style="cursor:pointer; width:25px; height:25px; " |
aa310d61a
|
71 |
src="/static/icon/view.png" |
68d742034
|
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
/> <span>View</span> </v-tooltip> </span> </router-link> </td> </tr> </template> <v-alert slot="no-results" :value="true" color="error" icon="warning" >Your search for "{{ search }}" found no results.</v-alert> </v-data-table> <!-- ****** Add Teachers Attendece****** --> |
8e8d14254
|
88 |
<v-dialog v-model="addTeacherAttendenceDialog" width="1600" v-if="addTeacherAttendenceDialog"> |
68d742034
|
89 90 |
<v-card flat class="pa-2"> <v-layout> |
0cd2fbfba
|
91 |
<v-flex xs12> |
68d742034
|
92 |
<label class="title text-xs-center">Add Teacher Attendence</label> |
8e8d14254
|
93 94 95 96 97 |
<v-icon size="24" class="right" @click="$refs.form.reset();addTeacherAttendenceDialog = false" >cancel</v-icon> |
0cd2fbfba
|
98 |
</v-flex> |
68d742034
|
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 |
</v-layout> <v-flex xs12 class="mt-4"> <v-form ref="form" v-model="valid" lazy-validation> <v-layout wrap> <v-flex xs12 class="px-4"> <v-layout> <v-flex xs6 sm6 lg3 md4> <v-menu ref="menu" :close-on-content-click="false" v-model="menu" :nudge-right="40" lazy transition="scale-transition" offset-y full-width min-width="290px" > <v-text-field slot="activator" v-model="date" label="Select Date" append-icon="event" :rules="dataValid" readonly ></v-text-field> <v-date-picker ref="picker" v-model="date" :max="new Date().toISOString().substr(0, 10)" min="1950-01-01" @change="save" ></v-date-picker> </v-menu> </v-flex> <v-flex xs6 sm6 lg9 md8> <v-btn class="right mt-3 add-button" dark round @click="showTable">Attendence</v-btn> </v-flex> </v-layout> </v-flex> </v-layout> </v-form> </v-flex> <v-flex xs12 v-show="attendeceTable" class> |
0cd2fbfba
|
143 144 145 146 147 148 149 |
<v-data-table :headers="headers" :items="teachersData" :pagination.sync="pagination" :search="search" > <template slot="items" slot-scope="props"> |
68d742034
|
150 151 152 153 154 155 156 157 |
<tr class="tr"> <td class="td td-row">{{ props.index + 1}}</td> <td class="text-xs-center td td-row"> <v-avatar size="40"> <img :src="props.item.profilePicUrl" v-if="props.item.profilePicUrl" /> <img src="/static/icon/user.png" v-else-if="!props.item.profilePicUrl" /> </v-avatar> </td> |
7151b71ec
|
158 159 160 |
<td class="text-xs-center td td-row">{{ props.item.name}}</td> <td class="text-xs-center td td-row">{{ props.item.email }}</td> <td class="text-xs-center td td-row">{{ props.item.mobileNo }}</td> |
68d742034
|
161 162 163 164 165 166 167 168 169 170 171 |
<td class="text-xs-center td td-row"> <v-radio-group v-model="props.item.attendence" :mandatory="false" row> <v-radio v-for="attendences in attendenceType" :key="attendences.value" :label="`${attendences.label}`" :value="attendences.value" ></v-radio> </v-radio-group> </td> </tr> |
0cd2fbfba
|
172 173 |
</template> </v-data-table> |
68d742034
|
174 175 176 177 178 179 |
<v-flex xs12> <v-card-actions> <v-spacer></v-spacer> <v-btn @click="submit()" class="add-button" round dark>Submit</v-btn> </v-card-actions> </v-flex> |
0cd2fbfba
|
180 |
</v-flex> |
68d742034
|
181 182 |
</v-card> </v-dialog> |
0cd2fbfba
|
183 184 185 186 187 188 189 190 |
<v-snackbar :timeout="timeout" :top="y === 'top'" :right="x === 'right'" :vertical="mode === 'vertical'" v-model="snackbar" color="success" >{{ text }}</v-snackbar> |
687e0b929
|
191 192 193 |
<div class="loader" v-if="showLoader"> <v-progress-circular indeterminate color="white"></v-progress-circular> </div> |
68d742034
|
194 |
</v-container> |
687e0b929
|
195 196 197 198 |
</template> <script> import http from "@/Services/http.js"; |
687e0b929
|
199 200 201 202 |
import moment from "moment"; export default { data: () => ({ |
0cd2fbfba
|
203 204 205 |
snackbar: false, y: "top", x: "right", |
710438de6
|
206 |
role: "", |
0cd2fbfba
|
207 |
mode: "", |
68d742034
|
208 |
timeout: 5000, |
0cd2fbfba
|
209 210 211 |
text: "", date: null, menu: false, |
68d742034
|
212 213 214 |
show: true, showSearch: false, addTeacherAttendenceDialog: false, |
0cd2fbfba
|
215 |
attendeceTable: false, |
687e0b929
|
216 |
showLoader: false, |
0cd2fbfba
|
217 |
loading: false, |
687e0b929
|
218 |
search: "", |
0cd2fbfba
|
219 220 221 |
valid: true, isActive: true, newActive: false, |
8e8d14254
|
222 |
dataValid: [(v) => !!v || "Date is required"], |
0cd2fbfba
|
223 224 225 |
attendenceType: [ { label: "Present", |
8e8d14254
|
226 |
value: "present", |
0cd2fbfba
|
227 228 229 |
}, { label: "Late Present With Excuset", |
8e8d14254
|
230 |
value: "latePresentWithExcuse", |
0cd2fbfba
|
231 232 233 |
}, { label: "Late Present", |
8e8d14254
|
234 |
value: "latePresent", |
0cd2fbfba
|
235 236 237 |
}, { label: "Absent", |
8e8d14254
|
238 239 |
value: "absent", }, |
0cd2fbfba
|
240 |
], |
687e0b929
|
241 |
pagination: { |
8e8d14254
|
242 |
rowsPerPage: 8, |
687e0b929
|
243 244 245 246 |
}, headers: [ { text: "No", |
68d742034
|
247 |
align: "", |
687e0b929
|
248 |
sortable: false, |
8e8d14254
|
249 |
value: "No", |
687e0b929
|
250 251 252 253 254 |
}, { text: "Profile Pic", value: "profilePicUrl", sortable: false, |
8e8d14254
|
255 |
align: "center", |
687e0b929
|
256 257 258 |
}, { text: "Name", value: "name", sortable: false, align: "center" }, { text: "Email", value: "email", sortable: false, align: "center" }, |
687e0b929
|
259 260 261 262 |
{ text: "Mobile No", value: "mobileNo", sortable: false, |
8e8d14254
|
263 |
align: "center", |
687e0b929
|
264 |
}, |
8e8d14254
|
265 |
{ text: "Attendance", value: "", sortable: false, align: "center" }, |
687e0b929
|
266 |
], |
0cd2fbfba
|
267 268 |
desserts: [], teachersData: [], |
8e8d14254
|
269 |
addTeachers: {}, |
687e0b929
|
270 |
}), |
0cd2fbfba
|
271 272 273 |
watch: { menu(val) { val && this.$nextTick(() => (this.$refs.picker.activePicker = "DAY")); |
8e8d14254
|
274 275 276 |
}, addTeacherAttendenceDialog: function (val) { if (!val) { |
2f9211c74
|
277 |
// this.teachersData = []; |
8e8d14254
|
278 279 280 281 |
this.date = null; this.menu = false; } }, |
0cd2fbfba
|
282 |
}, |
687e0b929
|
283 |
methods: { |
0cd2fbfba
|
284 285 286 287 288 289 |
save(date) { this.$refs.menu.save(date); }, showTable() { this.attendeceTable = true; this.getTeacherList(); |
687e0b929
|
290 291 292 293 294 295 |
}, getTeacherList() { this.showLoader = true; var token = this.$store.state.token; http() .get("/getTeachersList", { |
8e8d14254
|
296 |
headers: { Authorization: "Bearer " + token }, |
687e0b929
|
297 |
}) |
8e8d14254
|
298 |
.then((response) => { |
0cd2fbfba
|
299 |
this.teachersData = response.data.data; |
7151b71ec
|
300 |
// this.desserts = response.data.data; |
0cd2fbfba
|
301 302 303 304 |
var attendence = ""; for (let i = 0; i < this.teachersData.length; i++) { this.teachersData[i].attendence = "present"; } |
687e0b929
|
305 306 |
this.showLoader = false; // console.log("getTeacherList=====>",this.desserts) |
7151b71ec
|
307 |
// console.log("getTeacherList=====>",this.teachersData) |
687e0b929
|
308 |
}) |
8e8d14254
|
309 |
.catch((error) => { |
687e0b929
|
310 311 312 313 314 315 316 |
this.showLoader = false; if (error.response.status === 401) { this.$router.replace({ path: "/" }); this.$store.dispatch("setToken", null); this.$store.dispatch("Id", null); } }); |
0cd2fbfba
|
317 |
}, |
0cd2fbfba
|
318 319 320 321 322 |
submit() { var teachersAttendence = []; for (var j = 0; j < this.teachersData.length; j++) { teachersAttendence.push({ teacherId: this.teachersData[j]._id, |
8e8d14254
|
323 |
attendanceType: this.teachersData[j].attendence, |
0cd2fbfba
|
324 325 |
}); } |
1c0938369
|
326 327 328 |
if (this.$refs.form.validate()) { let attendanceData = { date: this.date, |
8e8d14254
|
329 |
teachers: teachersAttendence, |
1c0938369
|
330 331 332 |
}; http() .post("/createTeacherAttendance", attendanceData) |
8e8d14254
|
333 |
.then((response) => { |
1c0938369
|
334 335 |
this.snackbar = true; this.text = response.data.message; |
68d742034
|
336 |
this.addTeacherAttendenceDialog = false; |
7efe02762
|
337 |
this.clear(); |
1c0938369
|
338 |
}) |
8e8d14254
|
339 |
.catch((error) => { |
1c0938369
|
340 341 342 343 |
this.snackbar = true; this.text = error.response.data.message; }); } |
0cd2fbfba
|
344 345 346 347 |
}, clear() { this.$refs.form.reset(); this.imageUrl = ""; |
68d742034
|
348 349 350 351 352 353 354 355 356 |
}, displaySearch() { (this.show = false), (this.showSearch = true); }, closeSearch() { this.showSearch = false; this.show = true; this.search = ""; |
8e8d14254
|
357 |
}, |
687e0b929
|
358 359 360 |
}, mounted() { this.getTeacherList(); |
710438de6
|
361 |
this.role = this.$store.state.role; |
8e8d14254
|
362 |
}, |
687e0b929
|
363 |
}; |
68d742034
|
364 |
</script> |