Blame view

src/pages/Report/studentReport.vue 15.8 KB
006544386   Neeraj Sharma   implement task
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  <template>
    <v-app id="pages-dasboard">
      <v-snackbar
        :timeout="timeout"
        :top="y === 'top'"
        :right="x === 'right'"
        :vertical="mode === 'vertical'"
        v-model="snackbar"
        color="success"
      >{{ text }}</v-snackbar>
  
      <!-- ******  Student Report TABLE****** -->
      <v-card flat>
        <v-card-actions>
          <v-layout>
            <h4 class="right mt-2 ml-2">Student Report</h4>
          </v-layout>
          <v-spacer></v-spacer>
        </v-card-actions>
      </v-card>
79583580d   Neeraj Sharma   implement task ma...
21
      <v-card flat class="elevation-0">
006544386   Neeraj Sharma   implement task
22
23
24
25
26
        <v-form ref="form" v-model="valid" lazy-validation>
          <v-flex xs12 sm12 lg12>
            <v-layout wrap>
              <v-flex xs12 sm12 lg4>
                <v-layout>
495e4037c   Neeraj Sharma   update
27
                  <v-flex xs4 sm4 lg3 class="subheading mt-4">
006544386   Neeraj Sharma   implement task
28
29
                    <label class="right">Report For :</label>
                  </v-flex>
495e4037c   Neeraj Sharma   update
30
                  <v-flex xs7 sm6 lg8 class="ml-2">
006544386   Neeraj Sharma   implement task
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
                    <v-select
                      v-model="report.form"
                      label="Select your report for"
                      :items="formList"
                      item-text="name"
                      item-value="value"
                      @change="getReport(report.form)"
                      :rules="formRules"
                      required
                    ></v-select>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12 sm12 lg4 v-if="bloodGroup">
                <v-layout>
495e4037c   Neeraj Sharma   update
46
                  <v-flex xs4 sm4 lg4 class="subheading mt-4">
006544386   Neeraj Sharma   implement task
47
48
                    <label class="right">Blood Group :</label>
                  </v-flex>
495e4037c   Neeraj Sharma   update
49
                  <v-flex xs7 sm6 lg8 class="ml-2">
006544386   Neeraj Sharma   implement task
50
51
52
53
54
55
56
57
58
59
60
61
                    <v-select
                      v-model="report.bloodGroup"
                      label="Select your Blood Group "
                      :items="bloodGroupList"
                      :rules="bloodGroupRules"
                      required
                    ></v-select>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12 sm12 lg4 v-if="genderShow">
                <v-layout>
495e4037c   Neeraj Sharma   update
62
                  <v-flex xs4 sm4 lg4 class="subheading mt-4">
006544386   Neeraj Sharma   implement task
63
64
                    <label class="right">Gender:</label>
                  </v-flex>
495e4037c   Neeraj Sharma   update
65
                  <v-flex xs7 sm6 lg8 class="ml-2">
006544386   Neeraj Sharma   implement task
66
67
68
69
70
71
72
73
74
75
76
77
                    <v-select
                      v-model="report.gender"
                      label="Select your gender "
                      :items="gender"
                      :rules="genderRules"
                      required
                    ></v-select>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12 sm12 lg4 v-if="TransportShow">
                <v-layout>
495e4037c   Neeraj Sharma   update
78
                  <v-flex xs4 sm4 lg4 class="subheading mt-4">
006544386   Neeraj Sharma   implement task
79
80
                    <label class="right">Route:</label>
                  </v-flex>
495e4037c   Neeraj Sharma   update
81
                  <v-flex xs7 sm6 lg8 class="ml-2">
006544386   Neeraj Sharma   implement task
82
83
84
85
86
87
88
89
90
91
92
93
                    <v-select
                      v-model="report.route"
                      label="Select your gender "
                      :items="route"
                      :rules="routeRules"
                      required
                    ></v-select>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12 sm12 lg4 v-if="HostelShow">
                <v-layout>
495e4037c   Neeraj Sharma   update
94
                  <v-flex xs4 sm4 lg4 class="subheading mt-4">
006544386   Neeraj Sharma   implement task
95
96
                    <label class="right">Hostel:</label>
                  </v-flex>
495e4037c   Neeraj Sharma   update
97
                  <v-flex xs7 sm6 lg8 class="ml-2">
006544386   Neeraj Sharma   implement task
98
99
100
101
102
103
104
105
106
107
108
109
                    <v-select
                      v-model="report.route"
                      label="Select your hostel "
                      :items="hostelList"
                      :rules="hostelRules"
                      required
                    ></v-select>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12 sm12 lg4 v-if="countryShow">
                <v-layout>
495e4037c   Neeraj Sharma   update
110
                  <v-flex xs4 sm4 lg4 class="subheading mt-4">
006544386   Neeraj Sharma   implement task
111
112
                    <label class="right">Country :</label>
                  </v-flex>
495e4037c   Neeraj Sharma   update
113
                  <v-flex xs7 sm6 lg8 class="ml-2">
006544386   Neeraj Sharma   implement task
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
                    <v-select
                      v-model="report.country"
                      label="Select your Country "
                      :items="countryList"
                      :rules="countryRules"
                      required
                    ></v-select>
                  </v-flex>
                </v-layout>
              </v-flex>
              <!-- <v-flex xs12 sm12 lg4 v-show="BirthdayShow">
              <v-layout>
                <v-flex xs3 sm6 lg4 class="subheading mt-4">
                  <label class="right">Country :</label>
                </v-flex>
                <v-flex xs12 sm12 lg8 class="ml-2">
                  <v-select
                    v-model="report.country"
                    label="Select your Country "
                    :items="countryList"
                    required
                  ></v-select>
                </v-flex>
              </v-layout>
              </v-flex>-->
79583580d   Neeraj Sharma   implement task ma...
139
              <v-flex xs12 sm12 lg4 v-if="classShow">
006544386   Neeraj Sharma   implement task
140
                <v-layout>
495e4037c   Neeraj Sharma   update
141
                  <v-flex xs4 sm4 lg3 class="subheading mt-4">
006544386   Neeraj Sharma   implement task
142
143
                    <label class="right">Class:</label>
                  </v-flex>
495e4037c   Neeraj Sharma   update
144
                  <v-flex xs7 sm6 lg8 class="ml-2">
006544386   Neeraj Sharma   implement task
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
                    <v-select
                      v-model="report.classId"
                      label="Select your class"
                      type="text"
                      :rules="classRules"
                      :items="classList"
                      item-text="classNum"
                      item-value="_id"
                      @change="getSections(report.classId)"
                      required
                    ></v-select>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12 sm12 lg4 v-if="sectionShow">
                <v-layout>
495e4037c   Neeraj Sharma   update
161
                  <v-flex xs4 sm4 lg3 class="subheading mt-4">
006544386   Neeraj Sharma   implement task
162
163
                    <label class="right">Section:</label>
                  </v-flex>
495e4037c   Neeraj Sharma   update
164
                  <v-flex xs7 sm6 lg8 class="ml-2">
006544386   Neeraj Sharma   implement task
165
166
167
168
169
170
171
172
173
174
175
176
177
                    <v-select
                      :items="addSection"
                      label="Select your Section"
                      v-model="report.sectionId"
                      :rules="sectionRules"
                      item-text="name"
                      item-value="_id"
                      name="Select Section"
                      required
                    ></v-select>
                  </v-flex>
                </v-layout>
              </v-flex>
495e4037c   Neeraj Sharma   update
178
              <v-flex xs12 sm12 lg4 class="hidden-xs-only hidden-sm-only">
006544386   Neeraj Sharma   implement task
179
180
                <v-btn @click="getStudents" round dark :loading="loading" class="mt-3 ml-5">Get Report</v-btn>
              </v-flex>
495e4037c   Neeraj Sharma   update
181
              <v-flex xs12 sm12 lg4 class="hidden-lg-only hidden-md-only hidden-xl-only">
79583580d   Neeraj Sharma   implement task ma...
182
183
184
185
186
187
188
                <v-btn
                  @click="getStudents"
                  round
                  dark
                  :loading="loading"
                  class="mt-3 right"
                >Get Report</v-btn>
495e4037c   Neeraj Sharma   update
189
              </v-flex>
006544386   Neeraj Sharma   implement task
190
191
192
193
            </v-layout>
          </v-flex>
        </v-form>
      </v-card>
79583580d   Neeraj Sharma   implement task ma...
194
195
196
      <!-- <v-card flat>
        <v-flex xs12 v-for="(student,i) in getStudentsReportList" :key="i">
          <v-layout>
495e4037c   Neeraj Sharma   update
197
            <v-flex xs12 sm12 md6>
79583580d   Neeraj Sharma   implement task ma...
198
              <h5 class="mt-2 ml-2">Class: {{ student.classId.classNum }}</h5>
495e4037c   Neeraj Sharma   update
199
200
            </v-flex>
            <v-flex xs12 sm12 md6>
79583580d   Neeraj Sharma   implement task ma...
201
              <h5 class="right mt-2 ml-2">Section: {{ student.sectionId.name }}</h5>
495e4037c   Neeraj Sharma   update
202
            </v-flex>
006544386   Neeraj Sharma   implement task
203
          </v-layout>
495e4037c   Neeraj Sharma   update
204
        </v-flex>
79583580d   Neeraj Sharma   implement task ma...
205
      </v-card>-->
006544386   Neeraj Sharma   implement task
206
207
208
209
210
      <v-data-table
        :headers="headers"
        :items="getStudentsReportList"
        :pagination.sync="pagination"
        :search="search"
495e4037c   Neeraj Sharma   update
211
        v-show="showTable"
006544386   Neeraj Sharma   implement task
212
213
214
215
216
217
218
219
220
221
222
223
      >
        <template slot="items" slot-scope="props">
          <td class="text-xs-center">{{ props.index + 1}}</td>
          <td id="td" class="text-xs-center">
            <v-avatar>
              <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 id="td" class="text-xs-center">{{ props.item.name}}</td>
          <td id="td" class="text-xs-center">{{ props.item.rollNo }}</td>
          <td id="td" class="text-xs-center">{{ props.item.email }}</td>
79583580d   Neeraj Sharma   implement task ma...
224
225
          <td id="td" class="text-xs-center">{{ props.item.classId.classNum }}</td>
          <td id="td" class="text-xs-center">{{ props.item.sectionId.name }}</td>
006544386   Neeraj Sharma   implement task
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
        </template>
        <v-alert
          slot="no-results"
          :value="true"
          color="error"
          icon="warning"
        >Your search for "{{ search }}" found no results.</v-alert>
      </v-data-table>
      <div class="loader" v-if="showLoader">
        <v-progress-circular indeterminate color="white"></v-progress-circular>
      </div>
    </v-app>
  </template>
  
  <script>
  import http from "@/Services/http.js";
  import countryList from "@/script/country.js";
  
  import moment from "moment";
  
  export default {
    data: () => ({
      snackbar: false,
      color: "",
      y: "top",
      x: "right",
      mode: "",
      timeout: 10000,
      text: "",
      loading: false,
      valid: true,
      search: "",
      showLoader: false,
      bloodGroup: false,
      genderShow: false,
      countryShow: false,
      TransportShow: false,
      HostelShow: false,
      BirthdayShow: false,
      sectionShow: false,
      showTable: false,
79583580d   Neeraj Sharma   implement task ma...
267
      ClassShow: true,
006544386   Neeraj Sharma   implement task
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
      addSection: [],
      pagination: {
        rowsPerPage: 15
      },
      formRules: [v => !!v || "Form For is required"],
      bloodGroupRules: [v => !!v || "Blood group is required"],
      classRules: [v => !!v || "Class is required"],
      sectionRules: [v => !!v || "Class is required"],
      genderRules: [v => !!v || "Gender is required"],
      routeRules: [v => !!v || "RouteI is required"],
      hostelRules: [v => !!v || "Hostel is required"],
      countryRules: [v => !!v || "Country is required"],
      headers: [
        {
          align: "justify-center",
          text: "No",
          sortable: false,
          value: "No"
        },
        {
          text: "Profile Pic",
          vaue: "profilePicUrl",
          sortable: false,
          align: "center"
        },
        {
          text: "Name",
          vaue: "name",
          sortable: false,
          align: "center"
        },
        {
          text: "Roll No.",
          value: "rollNo",
          sortable: false,
          align: "center"
        },
        {
          text: "Email",
          value: "email",
          sortable: false,
          align: "center"
79583580d   Neeraj Sharma   implement task ma...
310
311
312
313
314
315
316
317
318
319
320
321
        },
        {
          text: "Class",
          value: "classId",
          sortable: false,
          align: "center"
        },
        {
          text: "Section",
          value: "sectionId",
          sortable: false,
          align: "center"
006544386   Neeraj Sharma   implement task
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
        }
      ],
      classList: [],
      report: {},
      markData: [],
      formList: [
        {
          name: "Blood Group",
          value: "bloodGroup"
        },
        "Country",
        "Gender",
        "Transport",
        "Hostel"
        //   "Birthday"
      ],
      bloodGroupList: ["A+", "A-", "B+", "B-", "O+", "O-", "AB+", "AB-"],
      gender: ["Male", "female"],
      getStudentsReportList: [],
      studentReort: "",
      countryList: [],
      route: [],
      Hostel: [],
      hostelList: [],
      token: ""
    }),
    methods: {
      clear() {
        this.$refs.form.reset();
006544386   Neeraj Sharma   implement task
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
      },
      getClass() {
        http()
          .get("/getClassesList", {
            headers: { Authorization: "Bearer " + this.token }
          })
          .then(response => {
            this.classList = response.data.data;
          })
          .catch(err => {
            // console.log("err====>", err);
          });
      },
      getReport() {
        if (this.report.form === "bloodGroup") {
          this.bloodGroup = true;
          this.genderShow = false;
          this.TransportShow = false;
          this.countryShow = false;
          this.BirthdayShow = false;
          this.HostelShow = false;
79583580d   Neeraj Sharma   implement task ma...
372
373
          this.classShow = false;
          this.sectionShow = false;
006544386   Neeraj Sharma   implement task
374
375
376
377
378
379
380
381
        }
        if (this.report.form === "Gender") {
          this.genderShow = true;
          this.bloodGroup = false;
          this.TransportShow = false;
          this.BirthdayShow = false;
          this.countryShow = false;
          this.HostelShow = false;
79583580d   Neeraj Sharma   implement task ma...
382
          this.classShow = true;
006544386   Neeraj Sharma   implement task
383
384
385
386
387
388
389
390
        }
        if (this.report.form === "Transport") {
          this.TransportShow = true;
          this.genderShow = false;
          this.bloodGroup = false;
          this.BirthdayShow = false;
          this.countryShow = false;
          this.HostelShow = false;
79583580d   Neeraj Sharma   implement task ma...
391
          this.classShow = true;
006544386   Neeraj Sharma   implement task
392
393
394
395
396
397
398
399
        }
        if (this.report.form === "Country") {
          this.countryShow = true;
          this.TransportShow = false;
          this.genderShow = false;
          this.bloodGroup = false;
          this.BirthdayShow = false;
          this.HostelShow = false;
79583580d   Neeraj Sharma   implement task ma...
400
          this.classShow = true;
006544386   Neeraj Sharma   implement task
401
402
403
404
405
406
407
408
        }
        if (this.report.form === "Hostel") {
          this.HostelShow = true;
          this.TransportShow = false;
          this.genderShow = false;
          this.bloodGroup = false;
          this.countryShow = false;
          this.BirthdayShow = false;
79583580d   Neeraj Sharma   implement task ma...
409
          this.classShow = true;
006544386   Neeraj Sharma   implement task
410
411
412
413
414
415
416
417
        }
        if (this.report.form === "Birthday") {
          this.BirthdayShow = true;
          this.TransportShow = false;
          this.genderShow = false;
          this.HostelShow = false;
          this.bloodGroup = false;
          this.countryShow = false;
79583580d   Neeraj Sharma   implement task ma...
418
          this.classShow = true;
006544386   Neeraj Sharma   implement task
419
420
421
422
423
        }
      },
      getStudents() {
        if (this.$refs.form.validate()) {
          this.showLoader = true;
006544386   Neeraj Sharma   implement task
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
          http()
            .get("/getStudentReport", {
              params: {
                bloodGroup: this.report.bloodGroup,
                country: this.report.country,
                gender: this.report.gender,
                classId: this.report.classId,
                sectionId: this.report.sectionId
              },
              headers: { Authorization: "Bearer " + this.token }
            })
            .then(response => {
              this.getStudentsReportList = response.data.data;
              this.showTable = true;
              this.showLoader = false;
              this.clear();
              // console.log("getSectionsList=====>", response.data.data);
            })
            .catch(error => {
              console.log("err====>", error);
              this.showLoader = false;
            });
        }
      },
      getSections() {
        this.sectionShow = true;
        this.showLoader = true;
        http()
          .get(
            "/getSectionsList",
            { params: { classId: this.report.classId } },
            {
              headers: { Authorization: "Bearer " + this.token }
            }
          )
          .then(response => {
            this.addSection = response.data.data;
            this.showLoader = false;
          })
          .catch(error => {
            console.log("err====>", error);
            this.showLoader = false;
          });
      }
      //     getFormList() {
      //       this.showLoader = true;
      //       http()
      //         .get("/getExamsList", {
      //           headers: { Authorization: "Bearer " + this.token }
      //         })
      //         .then(response => {
      //           this.formList = response.data.data;
      //           this.showLoader = false;
      //         })
      //         .catch(error => {
      //           // console.log("err====>", err);
      //           this.showLoader = false;
      //           this.snackbar = true;
      //           this.text = error.response.data.message;
      //           if (error.response.status === 401) {
      //             this.$router.replace({ path: "/" });
      //             this.$store.dispatch("setToken", null);
      //             this.$store.dispatch("Id", null);
      //           }
      //         });
      //     }
    },
    mounted() {
      this.token = this.$store.state.token;
495e4037c   Neeraj Sharma   update
493
494
      const getCountryList = countryList();
      this.countryList = getCountryList;
006544386   Neeraj Sharma   implement task
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
      // console.log("getindustryList", this.countryList);
      // this.getExamList();
      this.getClass();
    },
    created() {
      this.$root.$on("app:search", search => {
        this.search = search;
      });
    },
    beforeDestroy() {
      // dont forget to remove the listener
      this.$root.$off("app:search");
    }
  };
  </script>
  <style scoped>
  .active {
    background-color: gray;
    color: white !important;
  }
  .activebtn {
    color: black !important;
  }
  </style>s