Blame view
src/pages/Section/section.vue
18.9 KB
76f4f9c78
|
1 |
<template> |
68d742034
|
2 |
<v-container fluid class="body-color"> |
db965de89
|
3 |
<v-dialog v-model="editSectionDialog" max-width="460px" persistent> |
68d742034
|
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 |
<v-card flat class="card-style pa-2" dark> <v-layout> <v-flex xs12> <label class="title text-xs-center">Edit Section</label> <v-icon size="24" class="right" @click="editSectionDialog = false">cancel</v-icon> </v-flex> </v-layout> <v-container fluid> <v-layout wrap justify-center> <v-flex xs12 sm12> <v-form> <v-layout> <v-flex xs5 sm4 class="pt-4 subheading"> <label class="right">Class :</label> </v-flex> <v-flex xs7 sm8> <v-autocomplete :items="addclass" :label="editedItem.classData.classNum" v-model="editItem.classId" item-text="classNum" item-value="_id" class="ml-2" ></v-autocomplete> </v-flex> </v-layout> <v-layout> <v-flex xs5 sm4 class="pt-4 subheading"> <h5 class="right my-1 hidden-xs-only hidden-sm-only">Section Name :</h5> <h5 class="right my-1 hidden-lg-only hidden-md-only hidden-xl-only">Name :</h5> </v-flex> <v-flex xs7 sm8> <v-autocomplete v-model="editedItem.name" placeholder="fill your Section Name" :items="SectionName" class="ml-2" ></v-autocomplete> </v-flex> </v-layout> <v-layout> <v-flex xs5 sm4 class="pt-4 subheading"> <h5 class="right my-1 hidden-xs-only hidden-sm-only">Incharge :</h5> <h5 class="right my-1 hidden-lg-only hidden-md-only hidden-xl-only">Incharge :</h5> </v-flex> <v-flex xs7 sm8> <v-select :items="teacherList" v-model="editedItem.classInchargeId" :label="editedItem.teacherData[0].name" item-text="name" item-value="_id" class="ml-2" ></v-select> </v-flex> </v-layout> <v-flex xs12> <v-card-actions> <v-btn round dark @click.native="closeSectionDialog" class="add-button">Cancel</v-btn> <v-spacer></v-spacer> <v-btn round dark @click="save" :loading="editLoading" class="add-button">Save</v-btn> </v-card-actions> |
aa8fc5033
|
66 |
</v-flex> |
68d742034
|
67 68 69 70 71 72 |
</v-form> </v-flex> </v-layout> </v-container> </v-card> </v-dialog> |
26ec38b66
|
73 |
|
68d742034
|
74 |
<!-- ****** PROFILE VIEW SECTION DATA ****** --> |
76f4f9c78
|
75 |
|
db965de89
|
76 |
<v-dialog v-model="viewSectionDialog" max-width="500px" persistent> |
68d742034
|
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
<v-card flat class="card-style pa-3" dark> <v-layout> <v-flex xs12> <label class="title text-xs-center">View Section</label> <v-icon size="24" class="right" @click="viewSectionDialog = false">cancel</v-icon> </v-flex> </v-layout> <v-card-text> <v-container grid-list-md> <v-layout wrap> <v-flex> <v-layout> <v-flex xs7 sm6> <h5 class="right my-1 hidden-xs-only hidden-sm-only"> <b>Class Name :</b> </h5> <h5 class="right my-1 hidden-lg-only hidden-md-only hidden-xl-only"> <b>Class :</b> </h5> </v-flex> <v-flex sm6 xs5> <h5 class="my-1">{{ editedItem.classData.classNum }}</h5> |
5f1d4b444
|
99 |
</v-flex> |
26ec38b66
|
100 |
</v-layout> |
68d742034
|
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 xs7 sm6> <h5 class="right my-1"> <b>Section Name :</b> </h5> </v-flex> <v-flex sm6 xs5> <h5 class="my-1">{{ editedItem.name }}</h5> </v-flex> </v-layout> <v-layout> <v-flex xs7 sm6> <h5 class="right my-1 hidden-xs-only hidden-sm-only"> <b>Class Incharge :</b> </h5> <h5 class="right my-1 hidden-lg-only hidden-md-only hidden-xl-only"> <b>Incharge :</b> </h5> </v-flex> <v-flex sm6 xs5> <h5 class="my-1">{{ editedItem.teacherData[0].name }}</h5> </v-flex> </v-layout> <v-layout> <v-flex xs7 sm6> <h5 class="right my-1"> <b>Session :</b> </h5> </v-flex> <v-flex sm6 xs5> <h5 class="my-1">{{ editedItem.session }}</h5> |
26ec38b66
|
132 133 |
</v-flex> </v-layout> |
68d742034
|
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 |
</v-flex> </v-layout> </v-container> </v-card-text> </v-card> </v-dialog> <!-- ****** Section 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="addSectionDialog = true" > <v-icon dark>add</v-icon> </v-btn> <v-btn round class="open-dialog-button hidden-sm-only hidden-xs-only" dark @click="addSectionDialog = true" > <v-icon class="white--text pr-1" size="20">add</v-icon>Add Section </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
|
163 |
<img src="/static/icon/search.png" alt="icon" /> |
68d742034
|
164 165 166 |
</v-avatar> </v-btn> </v-card-title> |
612b79bb4
|
167 |
<v-flex xs8 v-if="showSearch"> |
68d742034
|
168 169 |
<v-layout> <v-text-field |
8e8d14254
|
170 |
autofocus |
68d742034
|
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
v-model="search" label="Search" prepend-inner-icon="search" color="primary" style="transition: 0.8s cubic-bezier(0.25, 0.8, 0.25, 1); !important" ></v-text-field> <v-icon @click="closeSearch" color="error">close</v-icon> </v-layout> </v-flex> </v-toolbar> <v-data-table :headers="headers" :items="sectionList" :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">{{ props.item.classData.classNum }}</td> <td class="text-xs-center td td-row">{{ props.item.name }}</td> <td class="text-xs-center td td-row">{{ props.item.session }}</td> <td class="text-xs-center td td-row"> <span> <v-tooltip top> <img slot="activator" style="cursor:pointer; width:25px; height:25px;" class="mr-3" @click="profile(props.item)" |
aa310d61a
|
201 |
src="/static/icon/view.png" |
68d742034
|
202 203 204 205 206 207 208 209 210 |
/> <span>View</span> </v-tooltip> <v-tooltip top> <img slot="activator" style="cursor:pointer; width:20px; height:18px; " class="mr-3" @click="editItem(props.item)" |
aa310d61a
|
211 |
src="/static/icon/edit.png" |
68d742034
|
212 213 214 |
/> <span>Edit</span> </v-tooltip> |
b039d39fb
|
215 |
<!-- <v-tooltip top> |
68d742034
|
216 217 218 219 |
<img slot="activator" style="cursor:pointer; width:20px; height:20px; " @click="deleteItem(props.item)" |
aa310d61a
|
220 |
src="/static/icon/delete.png" |
68d742034
|
221 222 223 |
class="mr-3" /> <span>Delete</span> |
8e8d14254
|
224 |
</v-tooltip>--> |
68d742034
|
225 226 227 228 229 230 231 232 233 234 235 236 |
</span> </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> <!-- </v-tab-item> --> |
7efe02762
|
237 |
<!-- DIALOG BOX - ADD Students Dialog box --> |
db965de89
|
238 |
<v-dialog v-model="addSectionDialog" max-width="400px" v-if="addSectionDialog" persistent> |
68d742034
|
239 240 241 |
<v-card flat class="card-style pa-2" dark> <v-layout> <v-flex xs12> |
8c3acf4a9
|
242 |
<label class="title text-xs-center">Add Section</label> |
8e8d14254
|
243 244 245 246 247 |
<v-icon size="24" class="right" @click="$refs.form.reset();addSectionDialog = false" >cancel</v-icon> |
26ec38b66
|
248 |
</v-flex> |
68d742034
|
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
</v-layout> <v-container fluid fill-height> <v-layout align-center> <v-flex xs12> <v-form ref="form" v-model="valid" lazy-validation> <v-layout> <v-flex xs4 class="pt-4 subheading"> <label class="right">Section :</label> </v-flex> <v-flex xs8 class="ml-3"> <v-autocomplete v-model="sectionData.name" placeholder="fill your Section Name" :items="SectionName" :rules="nameRules" required ></v-autocomplete> </v-flex> </v-layout> <v-layout> <v-flex xs4 class="pt-4 subheading"> <label class="right">Class :</label> </v-flex> <v-flex xs8 class="ml-3"> <v-select :items="addclass" label="Select Class" v-model="sectionData.classNum" item-text="classNum" item-value="_id" name="Select Class" :rules="classRules" required ></v-select> </v-flex> </v-layout> <v-layout> <v-flex xs4 class="pt-4 subheading"> <label class="right">Incharge :</label> </v-flex> <v-flex xs8 class="ml-3"> <v-select :items="teacherList" label="Select Incharge" v-model="sectionData.sectionId" item-text="name" item-value="_id" name="Select Class" :rules="inchargeRules" required ></v-select> </v-flex> </v-layout> <v-layout> <v-flex xs4 class="pt-4 subheading"> <label class="right">Session:</label> </v-flex> <v-flex xs8 class="ml-3"> <v-text-field v-model="sectionData.session" placeholder="fill your Session" name="name" type="text" :rules="sessionRules" required ></v-text-field> </v-flex> </v-layout> <v-layout> <v-flex xs12 sm12> <v-card-actions> |
f31c3fd76
|
320 |
<v-btn @click="clear" class="clear-button" round dark>Clear</v-btn> |
68d742034
|
321 322 323 324 325 326 327 328 |
<v-spacer></v-spacer> <v-btn @click="submit" class="add-button" round dark :loading="loading">Add</v-btn> </v-card-actions> </v-flex> </v-layout> </v-form> </v-flex> </v-layout> |
26ec38b66
|
329 |
</v-container> |
68d742034
|
330 331 332 333 334 335 336 337 338 339 |
</v-card> </v-dialog> <v-snackbar :timeout="timeout" :top="y === 'top'" :right="x === 'right'" :vertical="mode === 'vertical'" v-model="snackbar" :color="color" >{{ text }}</v-snackbar> |
26ec38b66
|
340 |
<div class="loader" v-if="showLoader"> |
76f4f9c78
|
341 |
<v-progress-circular indeterminate color="white"></v-progress-circular> |
26ec38b66
|
342 |
</div> |
68d742034
|
343 |
</v-container> |
76f4f9c78
|
344 345 346 347 |
</template> <script> import http from "@/Services/http.js"; |
29ac0dbb2
|
348 349 |
// import { apiCollection } from "@/schoolApi/apiCollection"; // const getSectionData = apiCollection.get("posts"); |
76f4f9c78
|
350 351 352 353 354 355 356 |
export default { data: () => ({ snackbar: false, y: "top", x: "right", mode: "", |
68d742034
|
357 |
timeout: 5000, |
76f4f9c78
|
358 |
text: "", |
68d742034
|
359 360 361 |
color: "", show: true, showSearch: false, |
26ec38b66
|
362 |
showLoader: false, |
76f4f9c78
|
363 |
loading: false, |
26ec38b66
|
364 365 |
date: null, search: "", |
68d742034
|
366 367 |
editSectionDialog: false, viewSectionDialog: false, |
76f4f9c78
|
368 |
valid: true, |
26ec38b66
|
369 |
validEdit: true, |
68d742034
|
370 |
addSectionDialog: false, |
dc4d6088a
|
371 |
editLoading: false, |
76f4f9c78
|
372 |
details: [], |
76f4f9c78
|
373 |
pagination: { |
8e8d14254
|
374 |
rowsPerPage: 10, |
76f4f9c78
|
375 |
}, |
8e8d14254
|
376 377 378 379 |
nameRules: [(v) => !!v || " Section Name is required"], classRules: [(v) => !!v || " Class Name is required"], sessionRules: [(v) => !!v || " Session is required"], inchargeRules: [(v) => !!v || " Incharge Name is required"], |
26ec38b66
|
380 |
SectionName: ["A", "B", "C", "D", "E", "F"], |
76f4f9c78
|
381 382 383 |
headers: [ { text: "No", |
68d742034
|
384 |
align: "", |
76f4f9c78
|
385 |
sortable: false, |
8e8d14254
|
386 |
value: "No", |
76f4f9c78
|
387 |
}, |
26ec38b66
|
388 389 390 391 |
{ text: "Class Name", value: "classData.classNum", sortable: false, |
8e8d14254
|
392 |
align: "center", |
26ec38b66
|
393 |
}, |
55f72b7d7
|
394 |
{ text: "Section Name", value: "name", sortable: false, align: "center" }, |
5f1d4b444
|
395 |
{ text: "Session", value: "session", sortable: false, align: "center" }, |
8e8d14254
|
396 |
{ text: "Action", value: "", sortable: false, align: "center" }, |
76f4f9c78
|
397 |
], |
68d742034
|
398 |
sectionList: [], |
26ec38b66
|
399 400 401 402 403 |
addclass: [], teacherList: [], select: "", selectId: "", token: "", |
76f4f9c78
|
404 405 |
editedIndex: -1, editedItem: { |
26ec38b66
|
406 |
classData: { |
8e8d14254
|
407 |
classNum: "", |
76f4f9c78
|
408 |
}, |
caa79cee0
|
409 410 |
teacherData: [ { |
8e8d14254
|
411 412 413 |
name: "", }, ], |
d9bb52b5b
|
414 415 |
// name: "", // session: new Date().getFullYear() |
76f4f9c78
|
416 |
}, |
26ec38b66
|
417 |
sectionData: { |
8e8d14254
|
418 419 |
session: new Date().getFullYear(), }, |
76f4f9c78
|
420 |
}), |
8e8d14254
|
421 422 423 424 425 426 427 |
watch: { addSectionDialog: function (val) { if (!val) { this.sectionData = []; } }, }, |
55f72b7d7
|
428 |
methods: { |
dc4d6088a
|
429 |
getSectionList() { |
29ac0dbb2
|
430 |
// const { data } = await getSectionData.get(); |
76f4f9c78
|
431 |
this.showLoader = true; |
dc4d6088a
|
432 |
http() |
26ec38b66
|
433 |
.get("/getAllSections", { |
8e8d14254
|
434 |
headers: { Authorization: "Bearer " + this.token }, |
26ec38b66
|
435 |
}) |
8e8d14254
|
436 |
.then((response) => { |
68d742034
|
437 |
this.sectionList = response.data.data; |
76f4f9c78
|
438 439 |
this.showLoader = false; // console.log("getAllSections=====>",response.data.data) |
76f4f9c78
|
440 |
}) |
8e8d14254
|
441 |
.catch((error) => { |
76f4f9c78
|
442 |
this.showLoader = false; |
00e4bc4e1
|
443 |
if (error.response.status === 401) { |
a17c68a03
|
444 445 446 447 |
this.$router.replace({ path: "/" }); this.$store.dispatch("setToken", null); this.$store.dispatch("Id", null); } |
76f4f9c78
|
448 449 450 |
}); }, editItem(item) { |
68d742034
|
451 |
this.editedIndex = this.sectionList.indexOf(item); |
76f4f9c78
|
452 |
this.editedItem = Object.assign({}, item); |
68d742034
|
453 |
this.editSectionDialog = true; |
76f4f9c78
|
454 455 |
}, profile(item) { |
68d742034
|
456 |
this.editedIndex = this.sectionList.indexOf(item); |
76f4f9c78
|
457 |
this.editedItem = Object.assign({}, item); |
68d742034
|
458 |
this.viewSectionDialog = true; |
76f4f9c78
|
459 460 461 |
}, deleteItem(item) { let deleteStudent = { |
8e8d14254
|
462 |
sectionId: item._id, |
76f4f9c78
|
463 464 |
}; http() |
26ec38b66
|
465 466 467 |
.delete( "/deleteSection", confirm("Are you sure you want to delete this?") && { |
8e8d14254
|
468 |
params: deleteStudent, |
26ec38b66
|
469 470 |
} ) |
8e8d14254
|
471 |
.then((response) => { |
d9bb52b5b
|
472 |
this.snackbar = true; |
68d742034
|
473 474 |
this.text = response.data.message; this.color = "green"; |
76f4f9c78
|
475 476 |
this.getSectionList(); }) |
8e8d14254
|
477 |
.catch((error) => { |
68d742034
|
478 479 480 |
this.snackbar = true; this.text = error.response.data.message; this.color = "green"; |
76f4f9c78
|
481 482 |
}); }, |
68d742034
|
483 484 |
closeSectionDialog() { this.editSectionDialog = false; |
76f4f9c78
|
485 |
}, |
68d742034
|
486 487 |
closeviewSectionDialog() { this.viewSectionDialog = false; |
76f4f9c78
|
488 489 |
}, submit() { |
26ec38b66
|
490 491 492 493 494 |
if (this.$refs.form.validate()) { let addSection = { name: this.sectionData.name, classId: this.sectionData.classNum, session: this.sectionData.session, |
8e8d14254
|
495 |
classInchargeId: this.sectionData.sectionId, |
76f4f9c78
|
496 |
}; |
5f1d4b444
|
497 |
this.loading = true; |
76f4f9c78
|
498 499 |
http() .post("/createSection", addSection) |
8e8d14254
|
500 |
.then((response) => { |
2b0e316ee
|
501 |
this.getSectionList(); |
d9bb52b5b
|
502 |
this.snackbar = true; |
68d742034
|
503 |
this.color = "green"; |
d9bb52b5b
|
504 |
this.text = "New Section added successfully"; |
26ec38b66
|
505 |
this.clear(); |
68d742034
|
506 |
this.addSectionDialog = false; |
26ec38b66
|
507 |
this.loading = false; |
76f4f9c78
|
508 |
}) |
8e8d14254
|
509 |
.catch((error) => { |
d9bb52b5b
|
510 |
this.snackbar = true; |
68d742034
|
511 |
this.color = "error"; |
d9bb52b5b
|
512 |
this.text = error.response.data.message; |
26ec38b66
|
513 |
this.loading = false; |
76f4f9c78
|
514 515 516 |
}); } }, |
76f4f9c78
|
517 518 519 520 |
clear() { this.$refs.form.reset(); }, save() { |
a17c68a03
|
521 |
this.editedItem.sectionId = this.editedItem._id; |
dc4d6088a
|
522 |
this.editLoading = true; |
76f4f9c78
|
523 |
http() |
caa79cee0
|
524 |
.put("/updateSection", this.editedItem) |
8e8d14254
|
525 |
.then((response) => { |
dc4d6088a
|
526 |
this.editLoading = false; |
d9bb52b5b
|
527 |
this.snackbar = true; |
68d742034
|
528 529 |
this.color = "green"; this.text = response.data.message; |
26ec38b66
|
530 |
this.getSectionList(); |
68d742034
|
531 |
this.closeSectionDialog(); |
76f4f9c78
|
532 |
}) |
8e8d14254
|
533 |
.catch((error) => { |
dc4d6088a
|
534 |
this.editLoading = false; |
68d742034
|
535 536 |
this.snackbar = true; this.color = "error"; |
26ec38b66
|
537 |
this.text = error.response.data.message; |
76f4f9c78
|
538 |
}); |
76f4f9c78
|
539 |
}, |
26ec38b66
|
540 541 542 |
getAllTeacher() { http() .get("/getTeachersList", { |
8e8d14254
|
543 |
headers: { Authorization: "Bearer " + this.token }, |
26ec38b66
|
544 |
}) |
8e8d14254
|
545 |
.then((response) => { |
26ec38b66
|
546 547 548 |
this.teacherList = response.data.data; this.showLoader = false; }) |
8e8d14254
|
549 |
.catch((err) => { |
26ec38b66
|
550 551 552 553 554 555 556 |
// console.log("err====>", err); this.showLoader = false; }); }, getAllClasses() { http() .get("/getClassesList", { |
8e8d14254
|
557 |
headers: { Authorization: "Bearer " + this.token }, |
26ec38b66
|
558 |
}) |
8e8d14254
|
559 |
.then((response) => { |
76f4f9c78
|
560 |
this.addclass = response.data.data; |
76f4f9c78
|
561 |
}) |
8e8d14254
|
562 |
.catch((err) => { |
76f4f9c78
|
563 |
// console.log("err====>", err); |
a17c68a03
|
564 |
// this.$router.replace({ path: "/" }); |
76f4f9c78
|
565 |
}); |
68d742034
|
566 567 568 569 570 571 572 573 |
}, displaySearch() { (this.show = false), (this.showSearch = true); }, closeSearch() { this.showSearch = false; this.show = true; this.search = ""; |
8e8d14254
|
574 |
}, |
26ec38b66
|
575 576 577 578 579 580 |
}, mounted() { this.token = this.$store.state.token; this.getSectionList(); this.getAllClasses(); this.getAllTeacher(); |
8e8d14254
|
581 |
}, |
76f4f9c78
|
582 583 |
}; </script> |