Blame view
src/pages/Attendence/teacherAttendence.vue
10.6 KB
687e0b929
|
1 |
<template> |
68d742034
|
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
<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 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
|
26 |
<img src="/static/icon/search.png" alt="icon" /> |
68d742034
|
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 |
</v-avatar> </v-btn> </v-card-title> <v-flex xs8 sm8 md3 lg2 v-show="showSearch"> <v-layout> <v-text-field v-model="search" label="Search" prepend-inner-icon="search" color="primary"></v-text-field> <v-icon @click="closeSearch" color="error">close</v-icon> </v-layout> </v-flex> </v-toolbar> <v-data-table :headers="headers" :items="desserts" :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
|
57 |
:to="{ name:'View Teacher Attendence',params: { teacherId:props.item._id } }" |
68d742034
|
58 59 60 61 62 63 |
> <span> <v-tooltip top> <img slot="activator" style="cursor:pointer; width:25px; height:25px; " |
aa310d61a
|
64 |
src="/static/icon/view.png" |
68d742034
|
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
/> <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****** --> <v-dialog v-model="addTeacherAttendenceDialog" width="1600"> <v-card flat class="pa-2"> <v-layout> |
0cd2fbfba
|
84 |
<v-flex xs12> |
68d742034
|
85 86 |
<label class="title text-xs-center">Add Teacher Attendence</label> <v-icon size="24" class="right" @click="addTeacherAttendenceDialog = false">cancel</v-icon> |
0cd2fbfba
|
87 |
</v-flex> |
68d742034
|
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 |
</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
|
132 133 134 135 136 137 138 |
<v-data-table :headers="headers" :items="teachersData" :pagination.sync="pagination" :search="search" > <template slot="items" slot-scope="props"> |
68d742034
|
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
<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="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> <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
|
161 162 |
</template> </v-data-table> |
68d742034
|
163 164 165 166 167 168 |
<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
|
169 |
</v-flex> |
68d742034
|
170 171 |
</v-card> </v-dialog> |
0cd2fbfba
|
172 173 174 175 176 177 178 179 |
<v-snackbar :timeout="timeout" :top="y === 'top'" :right="x === 'right'" :vertical="mode === 'vertical'" v-model="snackbar" color="success" >{{ text }}</v-snackbar> |
687e0b929
|
180 181 182 |
<div class="loader" v-if="showLoader"> <v-progress-circular indeterminate color="white"></v-progress-circular> </div> |
68d742034
|
183 |
</v-container> |
687e0b929
|
184 185 186 187 |
</template> <script> import http from "@/Services/http.js"; |
687e0b929
|
188 189 190 191 |
import moment from "moment"; export default { data: () => ({ |
0cd2fbfba
|
192 193 194 195 |
snackbar: false, y: "top", x: "right", mode: "", |
68d742034
|
196 |
timeout: 5000, |
0cd2fbfba
|
197 198 199 |
text: "", date: null, menu: false, |
68d742034
|
200 201 202 |
show: true, showSearch: false, addTeacherAttendenceDialog: false, |
0cd2fbfba
|
203 |
attendeceTable: false, |
687e0b929
|
204 |
showLoader: false, |
0cd2fbfba
|
205 |
loading: false, |
687e0b929
|
206 |
search: "", |
0cd2fbfba
|
207 208 209 |
valid: true, isActive: true, newActive: false, |
1c0938369
|
210 |
dataValid: [v => !!v || "Date is required"], |
0cd2fbfba
|
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
attendenceType: [ { label: "Present", value: "present" }, { label: "Late Present With Excuset", value: "latePresentWithExcuse" }, { label: "Late Present", value: "latePresent" }, { label: "Absent", value: "absent" } ], |
687e0b929
|
229 |
pagination: { |
68d742034
|
230 |
rowsPerPage: 8 |
687e0b929
|
231 232 233 234 |
}, headers: [ { text: "No", |
68d742034
|
235 |
align: "", |
687e0b929
|
236 237 238 239 240 241 242 243 244 245 246 |
sortable: false, value: "No" }, { text: "Profile Pic", value: "profilePicUrl", sortable: false, align: "center" }, { text: "Name", value: "name", sortable: false, align: "center" }, { text: "Email", value: "email", sortable: false, align: "center" }, |
687e0b929
|
247 248 249 250 251 252 |
{ text: "Mobile No", value: "mobileNo", sortable: false, align: "center" }, |
0cd2fbfba
|
253 |
{ text: "Attendance", value: "", sortable: false, align: "center" } |
687e0b929
|
254 |
], |
0cd2fbfba
|
255 256 257 |
desserts: [], teachersData: [], addTeachers: {} |
687e0b929
|
258 |
}), |
0cd2fbfba
|
259 260 261 262 263 |
watch: { menu(val) { val && this.$nextTick(() => (this.$refs.picker.activePicker = "DAY")); } }, |
687e0b929
|
264 |
methods: { |
0cd2fbfba
|
265 266 267 268 269 270 |
save(date) { this.$refs.menu.save(date); }, showTable() { this.attendeceTable = true; this.getTeacherList(); |
687e0b929
|
271 272 273 274 275 276 277 278 279 |
}, getTeacherList() { this.showLoader = true; var token = this.$store.state.token; http() .get("/getTeachersList", { headers: { Authorization: "Bearer " + token } }) .then(response => { |
0cd2fbfba
|
280 |
this.teachersData = response.data.data; |
687e0b929
|
281 |
this.desserts = response.data.data; |
0cd2fbfba
|
282 283 284 285 |
var attendence = ""; for (let i = 0; i < this.teachersData.length; i++) { this.teachersData[i].attendence = "present"; } |
687e0b929
|
286 287 288 289 290 291 292 293 294 295 296 |
this.showLoader = false; // console.log("getTeacherList=====>",this.desserts) }) .catch(error => { this.showLoader = false; if (error.response.status === 401) { this.$router.replace({ path: "/" }); this.$store.dispatch("setToken", null); this.$store.dispatch("Id", null); } }); |
0cd2fbfba
|
297 |
}, |
0cd2fbfba
|
298 299 300 301 302 303 304 305 |
submit() { var teachersAttendence = []; for (var j = 0; j < this.teachersData.length; j++) { teachersAttendence.push({ teacherId: this.teachersData[j]._id, attendanceType: this.teachersData[j].attendence }); } |
1c0938369
|
306 307 308 309 310 311 312 313 314 315 |
if (this.$refs.form.validate()) { let attendanceData = { date: this.date, teachers: teachersAttendence }; http() .post("/createTeacherAttendance", attendanceData) .then(response => { this.snackbar = true; this.text = response.data.message; |
68d742034
|
316 |
this.addTeacherAttendenceDialog = false; |
1c0938369
|
317 318 319 320 321 322 |
}) .catch(error => { this.snackbar = true; this.text = error.response.data.message; }); } |
0cd2fbfba
|
323 324 325 326 |
}, clear() { this.$refs.form.reset(); this.imageUrl = ""; |
68d742034
|
327 328 329 330 331 332 333 334 335 |
}, displaySearch() { (this.show = false), (this.showSearch = true); }, closeSearch() { this.showSearch = false; this.show = true; this.search = ""; |
687e0b929
|
336 337 338 339 |
} }, mounted() { this.getTeacherList(); |
687e0b929
|
340 341 |
} }; |
68d742034
|
342 |
</script> |