Blame view
src/pages/Section/section.vue
18.5 KB
76f4f9c78
|
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 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-container fluid class="body-color"> <v-dialog v-model="editSectionDialog" max-width="460px"> <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 |
|
68d742034
|
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
<v-dialog v-model="viewSectionDialog" max-width="500px"> <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 167 168 169 170 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 |
</v-avatar> </v-btn> </v-card-title> <v-flex xs8 v-show="showSearch"> <v-layout> <v-text-field 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
|
200 |
src="/static/icon/view.png" |
68d742034
|
201 202 203 204 205 206 207 208 209 |
/> <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
|
210 |
src="/static/icon/edit.png" |
68d742034
|
211 212 213 214 215 216 217 218 |
/> <span>Edit</span> </v-tooltip> <v-tooltip top> <img slot="activator" style="cursor:pointer; width:20px; height:20px; " @click="deleteItem(props.item)" |
aa310d61a
|
219 |
src="/static/icon/delete.png" |
68d742034
|
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
class="mr-3" /> <span>Delete</span> </v-tooltip> </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> --> <!-- ****** ADD Students Dialog box****** --> <v-dialog v-model="addSectionDialog" max-width="400px"> <v-card flat class="card-style pa-2" dark> <v-layout> <v-flex xs12> <label class="title text-xs-center">Add Class</label> <v-icon size="24" class="right" @click="addSectionDialog = false">cancel</v-icon> |
26ec38b66
|
244 |
</v-flex> |
68d742034
|
245 246 247 248 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 320 321 322 323 324 |
</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> <v-btn @click="clear" class="add-button" round dark>Clear</v-btn> <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
|
325 |
</v-container> |
68d742034
|
326 327 328 329 330 331 332 333 334 335 |
</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
|
336 |
<div class="loader" v-if="showLoader"> |
76f4f9c78
|
337 |
<v-progress-circular indeterminate color="white"></v-progress-circular> |
26ec38b66
|
338 |
</div> |
68d742034
|
339 |
</v-container> |
76f4f9c78
|
340 341 342 343 |
</template> <script> import http from "@/Services/http.js"; |
29ac0dbb2
|
344 345 |
// import { apiCollection } from "@/schoolApi/apiCollection"; // const getSectionData = apiCollection.get("posts"); |
76f4f9c78
|
346 347 348 349 350 351 352 |
export default { data: () => ({ snackbar: false, y: "top", x: "right", mode: "", |
68d742034
|
353 |
timeout: 5000, |
76f4f9c78
|
354 |
text: "", |
68d742034
|
355 356 357 |
color: "", show: true, showSearch: false, |
26ec38b66
|
358 |
showLoader: false, |
76f4f9c78
|
359 |
loading: false, |
26ec38b66
|
360 361 |
date: null, search: "", |
68d742034
|
362 363 |
editSectionDialog: false, viewSectionDialog: false, |
76f4f9c78
|
364 |
valid: true, |
26ec38b66
|
365 |
validEdit: true, |
68d742034
|
366 |
addSectionDialog: false, |
dc4d6088a
|
367 |
editLoading: false, |
76f4f9c78
|
368 |
details: [], |
76f4f9c78
|
369 |
pagination: { |
68d742034
|
370 |
rowsPerPage: 10 |
76f4f9c78
|
371 372 |
}, nameRules: [v => !!v || " Section Name is required"], |
26ec38b66
|
373 374 375 376 |
classRules: [v => !!v || " Class Name is required"], sessionRules: [v => !!v || " Session is required"], inchargeRules: [v => !!v || " Incharge Name is required"], SectionName: ["A", "B", "C", "D", "E", "F"], |
76f4f9c78
|
377 378 379 |
headers: [ { text: "No", |
68d742034
|
380 |
align: "", |
76f4f9c78
|
381 382 383 |
sortable: false, value: "No" }, |
26ec38b66
|
384 385 386 387 388 389 |
{ text: "Class Name", value: "classData.classNum", sortable: false, align: "center" }, |
55f72b7d7
|
390 |
{ text: "Section Name", value: "name", sortable: false, align: "center" }, |
5f1d4b444
|
391 |
{ text: "Session", value: "session", sortable: false, align: "center" }, |
76f4f9c78
|
392 393 |
{ text: "Action", value: "", sortable: false, align: "center" } ], |
68d742034
|
394 |
sectionList: [], |
26ec38b66
|
395 396 397 398 399 |
addclass: [], teacherList: [], select: "", selectId: "", token: "", |
76f4f9c78
|
400 401 |
editedIndex: -1, editedItem: { |
26ec38b66
|
402 403 |
classData: { classNum: "" |
76f4f9c78
|
404 |
}, |
caa79cee0
|
405 406 407 408 |
teacherData: [ { name: "" } |
d9bb52b5b
|
409 410 411 |
] // name: "", // session: new Date().getFullYear() |
76f4f9c78
|
412 |
}, |
26ec38b66
|
413 414 |
sectionData: { session: new Date().getFullYear() |
687e0b929
|
415 |
} |
76f4f9c78
|
416 |
}), |
55f72b7d7
|
417 |
methods: { |
dc4d6088a
|
418 |
getSectionList() { |
29ac0dbb2
|
419 |
// const { data } = await getSectionData.get(); |
76f4f9c78
|
420 |
this.showLoader = true; |
dc4d6088a
|
421 |
http() |
26ec38b66
|
422 423 424 |
.get("/getAllSections", { headers: { Authorization: "Bearer " + this.token } }) |
76f4f9c78
|
425 |
.then(response => { |
68d742034
|
426 |
this.sectionList = response.data.data; |
76f4f9c78
|
427 428 |
this.showLoader = false; // console.log("getAllSections=====>",response.data.data) |
76f4f9c78
|
429 |
}) |
37150e7c1
|
430 |
.catch(error => { |
76f4f9c78
|
431 |
this.showLoader = false; |
00e4bc4e1
|
432 |
if (error.response.status === 401) { |
a17c68a03
|
433 434 435 436 |
this.$router.replace({ path: "/" }); this.$store.dispatch("setToken", null); this.$store.dispatch("Id", null); } |
76f4f9c78
|
437 438 439 |
}); }, editItem(item) { |
68d742034
|
440 |
this.editedIndex = this.sectionList.indexOf(item); |
76f4f9c78
|
441 |
this.editedItem = Object.assign({}, item); |
68d742034
|
442 |
this.editSectionDialog = true; |
76f4f9c78
|
443 444 |
}, profile(item) { |
68d742034
|
445 |
this.editedIndex = this.sectionList.indexOf(item); |
76f4f9c78
|
446 |
this.editedItem = Object.assign({}, item); |
68d742034
|
447 |
this.viewSectionDialog = true; |
76f4f9c78
|
448 449 450 451 452 453 |
}, deleteItem(item) { let deleteStudent = { sectionId: item._id }; http() |
26ec38b66
|
454 455 456 457 458 459 |
.delete( "/deleteSection", confirm("Are you sure you want to delete this?") && { params: deleteStudent } ) |
76f4f9c78
|
460 |
.then(response => { |
d9bb52b5b
|
461 |
this.snackbar = true; |
68d742034
|
462 463 |
this.text = response.data.message; this.color = "green"; |
76f4f9c78
|
464 465 466 |
this.getSectionList(); }) .catch(error => { |
68d742034
|
467 468 469 |
this.snackbar = true; this.text = error.response.data.message; this.color = "green"; |
76f4f9c78
|
470 471 |
}); }, |
68d742034
|
472 473 |
closeSectionDialog() { this.editSectionDialog = false; |
76f4f9c78
|
474 |
}, |
68d742034
|
475 476 |
closeviewSectionDialog() { this.viewSectionDialog = false; |
76f4f9c78
|
477 478 |
}, submit() { |
26ec38b66
|
479 480 481 482 483 |
if (this.$refs.form.validate()) { let addSection = { name: this.sectionData.name, classId: this.sectionData.classNum, session: this.sectionData.session, |
d9bb52b5b
|
484 |
classInchargeId: this.sectionData.sectionId |
76f4f9c78
|
485 |
}; |
5f1d4b444
|
486 |
this.loading = true; |
76f4f9c78
|
487 488 489 |
http() .post("/createSection", addSection) .then(response => { |
2b0e316ee
|
490 |
this.getSectionList(); |
d9bb52b5b
|
491 |
this.snackbar = true; |
68d742034
|
492 |
this.color = "green"; |
d9bb52b5b
|
493 |
this.text = "New Section added successfully"; |
26ec38b66
|
494 |
this.clear(); |
68d742034
|
495 |
this.addSectionDialog = false; |
26ec38b66
|
496 |
this.loading = false; |
76f4f9c78
|
497 498 |
}) .catch(error => { |
d9bb52b5b
|
499 |
this.snackbar = true; |
68d742034
|
500 |
this.color = "error"; |
d9bb52b5b
|
501 |
this.text = error.response.data.message; |
26ec38b66
|
502 |
this.loading = false; |
76f4f9c78
|
503 504 505 |
}); } }, |
76f4f9c78
|
506 507 508 509 |
clear() { this.$refs.form.reset(); }, save() { |
a17c68a03
|
510 |
this.editedItem.sectionId = this.editedItem._id; |
dc4d6088a
|
511 |
this.editLoading = true; |
76f4f9c78
|
512 |
http() |
caa79cee0
|
513 |
.put("/updateSection", this.editedItem) |
76f4f9c78
|
514 |
.then(response => { |
dc4d6088a
|
515 |
this.editLoading = false; |
d9bb52b5b
|
516 |
this.snackbar = true; |
68d742034
|
517 518 |
this.color = "green"; this.text = response.data.message; |
26ec38b66
|
519 |
this.getSectionList(); |
68d742034
|
520 |
this.closeSectionDialog(); |
76f4f9c78
|
521 522 |
}) .catch(error => { |
dc4d6088a
|
523 |
this.editLoading = false; |
68d742034
|
524 525 |
this.snackbar = true; this.color = "error"; |
26ec38b66
|
526 |
this.text = error.response.data.message; |
76f4f9c78
|
527 |
}); |
76f4f9c78
|
528 |
}, |
26ec38b66
|
529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 |
getAllTeacher() { http() .get("/getTeachersList", { headers: { Authorization: "Bearer " + this.token } }) .then(response => { this.teacherList = response.data.data; this.showLoader = false; }) .catch(err => { // console.log("err====>", err); this.showLoader = false; }); }, getAllClasses() { http() .get("/getClassesList", { headers: { Authorization: "Bearer " + this.token } }) |
76f4f9c78
|
548 549 |
.then(response => { this.addclass = response.data.data; |
76f4f9c78
|
550 551 552 |
}) .catch(err => { // console.log("err====>", err); |
a17c68a03
|
553 |
// this.$router.replace({ path: "/" }); |
76f4f9c78
|
554 |
}); |
68d742034
|
555 556 557 558 559 560 561 562 |
}, displaySearch() { (this.show = false), (this.showSearch = true); }, closeSearch() { this.showSearch = false; this.show = true; this.search = ""; |
26ec38b66
|
563 564 565 566 567 568 569 |
} }, mounted() { this.token = this.$store.state.token; this.getSectionList(); this.getAllClasses(); this.getAllTeacher(); |
76f4f9c78
|
570 571 572 |
} }; </script> |