Blame view

src/pages/Attendence/studentAttendence.vue 14.1 KB
687e0b929   Neeraj Sharma   add user,attenden...
1
  <template>
68d742034   Neeraj Sharma   implement new des...
2
    <v-container fluid class="body-color">
687e0b929   Neeraj Sharma   add user,attenden...
3
4
5
6
7
8
9
10
      <v-snackbar
        :timeout="timeout"
        :top="y === 'top'"
        :right="x === 'right'"
        :vertical="mode === 'vertical'"
        v-model="snackbar"
        color="success"
      >{{ text }}</v-snackbar>
68d742034   Neeraj Sharma   implement new des...
11
12
      <!-- ****** ATTENDENCE STUDENTS TABLE ****** -->
      <!-- <download-csv :data="json_data">
6ae46ca27   Neeraj Sharma   implement upload ...
13
              <v-btn>Download Data</v-btn>
68d742034   Neeraj Sharma   implement new des...
14
15
      </download-csv>-->
      <v-toolbar color="transparent" flat>
710438de6   Shikha Mishra   added teacher mod...
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
        <v-btn
          fab
          dark
          class="open-dialog-button hidden-xl-only hidden-md-only hidden-lg-only"
          small
          @click="addStudentAttendenceDialog = true"
        >
          <v-icon dark>add</v-icon>
        </v-btn>
        <v-btn
          v-if="role != 'ADMIN' && schoolRole != 'SCHOOLADMIN' "
          round
          class="open-dialog-button hidden-sm-only hidden-xs-only"
          dark
          @click="addStudentAttendenceDialog = true"
        >
          <v-icon class="white--text pr-1" size="20">add</v-icon>Add Student Attendence
        </v-btn>
68d742034   Neeraj Sharma   implement new des...
34
35
36
37
38
39
        <v-spacer></v-spacer>
        <v-flex xs12 sm4 md2>
          <v-select
            small
            :items="addclass"
            label="Select Class"
b0e0491ab   Shikha Mishra   solve the issue o...
40
            v-model="getAttendence.classId"
68d742034   Neeraj Sharma   implement new des...
41
42
43
            item-text="classNum"
            item-value="_id"
            name="Select Class"
b0e0491ab   Shikha Mishra   solve the issue o...
44
            @change="getSection(getAttendence.classId)"
710438de6   Shikha Mishra   added teacher mod...
45
46
47
48
49
50
51
52
53
            class="px-2"
            required
          ></v-select>
        </v-flex>
        <v-flex xs12 sm4 md2>
          <v-select
            small
            :items="addSection"
            label="Select Section"
b0e0491ab   Shikha Mishra   solve the issue o...
54
            v-model="getAttendence.sectionId"
710438de6   Shikha Mishra   added teacher mod...
55
56
57
            item-text="name"
            item-value="_id"
            name="Select Section"
b0e0491ab   Shikha Mishra   solve the issue o...
58
            @change="getStudents(getAttendence.sectionId)"
68d742034   Neeraj Sharma   implement new des...
59
60
61
62
63
64
65
            class="px-2"
            required
          ></v-select>
        </v-flex>
        <v-card-title class="body-1" v-show="show">
          <v-btn icon large flat @click="displaySearch">
            <v-avatar size="27">
aa310d61a   Shikha Mishra   added functionali...
66
              <img src="/static/icon/search.png" alt="icon" />
68d742034   Neeraj Sharma   implement new des...
67
68
69
            </v-avatar>
          </v-btn>
        </v-card-title>
612b79bb4   Amber Dev   made serch auto f...
70
        <v-flex xs8 sm8 md3 lg2 v-if="showSearch">
68d742034   Neeraj Sharma   implement new des...
71
          <v-layout>
612b79bb4   Amber Dev   made serch auto f...
72
            <v-text-field autofocus v-model="search" label="Search" prepend-inner-icon="search" color="primary"></v-text-field>
68d742034   Neeraj Sharma   implement new des...
73
            <v-icon @click="closeSearch" color="error">close</v-icon>
687e0b929   Neeraj Sharma   add user,attenden...
74
          </v-layout>
68d742034   Neeraj Sharma   implement new des...
75
76
        </v-flex>
      </v-toolbar>
687e0b929   Neeraj Sharma   add user,attenden...
77
78
      <v-data-table
        :headers="headers"
710438de6   Shikha Mishra   added teacher mod...
79
        :items="studentsData"
687e0b929   Neeraj Sharma   add user,attenden...
80
81
82
83
        :pagination.sync="pagination"
        :search="search"
      >
        <template slot="items" slot-scope="props">
68d742034   Neeraj Sharma   implement new des...
84
85
86
87
88
89
90
91
92
          <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>
710438de6   Shikha Mishra   added teacher mod...
93
            <td class="text-xs-center td td-row">{{ props.item.fatherCellNo}}</td>
68d742034   Neeraj Sharma   implement new des...
94
95
            <td class="text-xs-center td td-row">{{ props.item.email }}</td>
            <td class="text-xs-center td td-row">
2fe1115d8   Shikha Mishra   added csv button ...
96
              <router-link :to="{ name:'View Students Attendence',params: { id:props.item._id } }">
68d742034   Neeraj Sharma   implement new des...
97
98
99
100
101
                <v-tooltip top>
                  <img
                    slot="activator"
                    style="cursor:pointer; width:20px; height:25px; "
                    class="mr-3"
aa310d61a   Shikha Mishra   added functionali...
102
                    src="/static/icon/view.png"
68d742034   Neeraj Sharma   implement new des...
103
                  />
67a276510   Shikha Mishra   fixed all bugs
104
                  <span>View</span>
68d742034   Neeraj Sharma   implement new des...
105
106
                </v-tooltip>
              </router-link>
68d742034   Neeraj Sharma   implement new des...
107
108
            </td>
          </tr>
687e0b929   Neeraj Sharma   add user,attenden...
109
110
111
112
113
114
115
116
        </template>
        <v-alert
          slot="no-results"
          :value="true"
          color="error"
          icon="warning"
        >Your search for "{{ search }}" found no results.</v-alert>
      </v-data-table>
710438de6   Shikha Mishra   added teacher mod...
117
118
119
120
121
122
      <!-- ****** Add Students Attendece****** -->
      <v-dialog v-model="addStudentAttendenceDialog" width="1600">
        <v-card flat class="pa-2">
          <v-layout>
            <v-flex xs12>
              <label class="title text-xs-center">Add Student Attendence</label>
f5329b707   Amber Dev   added form reset ...
123
              <v-icon size="24" class="right" @click="$refs.form.reset();addStudentAttendenceDialog = false">cancel</v-icon>
710438de6   Shikha Mishra   added teacher mod...
124
125
126
127
128
129
130
131
132
133
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
163
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
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
            </v-flex>
          </v-layout>
          <v-flex xs12 class="mt-4">
            <v-form ref="form" v-model="valid" lazy-validation>
              <v-flex xs12 sm12 lg12>
                <v-layout wrap>
                  <v-flex xs6 sm6 lg3 md4>
                    <v-layout>
                      <v-flex xs3 sm6 lg2 class="subheading mt-4">
                        <label class="right">Class:</label>
                      </v-flex>
                      <v-flex xs9 sm6 lg8 class="ml-2">
                        <v-select
                          v-model="getReport.classId"
                          label="Select your class"
                          type="text"
                          :items="addclass"
                          item-text="classNum"
                          item-value="_id"
                          :rules="classRules"
                          @change="getSection(getReport.classId)"
                          required
                        ></v-select>
                      </v-flex>
                    </v-layout>
                  </v-flex>
                  <v-flex xs6 sm6 lg3 md8>
                    <v-layout>
                      <v-flex xs3 sm6 lg2 class="subheading mt-4">
                        <label class="right">Section:</label>
                      </v-flex>
                      <v-flex xs9 sm6 lg8 class="ml-2">
                        <v-select
                          :items="addSection"
                          label="Select your Section"
                          v-model="getReport.sectionId"
                          item-text="name"
                          item-value="_id"
                          name="Select Section"
                          :rules="sectionRules"
                          required
                        ></v-select>
                      </v-flex>
                    </v-layout>
                  </v-flex>
                  <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 round dark class="add-button" @click="showTable">Attendence</v-btn>
                  </v-flex>
                </v-layout>
              </v-flex>
            </v-form>
          </v-flex>
          <v-flex xs12 v-show="attendeceTable" class>
            <v-data-table
              :headers="headers"
              :items="studentsData"
              :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="text-xs-center td td-row">{{ props.item.name}}</td>
                  <td class="text-xs-center td td-row">{{ props.item.fatherCellNo }}</td>
                  <td class="text-xs-center td td-row">{{ props.item.email }}</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>
              </template>
            </v-data-table>
            <v-flex xs12>
              <v-card-actions>
                <v-spacer></v-spacer>
                <v-btn @click="update()" class="add-button" round dark>Submit</v-btn>
              </v-card-actions>
            </v-flex>
          </v-flex>
        </v-card>
      </v-dialog>
      <v-snackbar
        :timeout="timeout"
        :top="y === 'top'"
        :right="x === 'right'"
        :vertical="mode === 'vertical'"
        v-model="snackbar"
        color="success"
      >{{ text }}</v-snackbar>
687e0b929   Neeraj Sharma   add user,attenden...
254
255
256
      <div class="loader" v-if="showLoader">
        <v-progress-circular indeterminate color="white"></v-progress-circular>
      </div>
68d742034   Neeraj Sharma   implement new des...
257
    </v-container>
687e0b929   Neeraj Sharma   add user,attenden...
258
259
260
261
  </template>
  
  <script>
  import http from "@/Services/http.js";
687e0b929   Neeraj Sharma   add user,attenden...
262
263
264
265
266
267
268
269
270
271
  import moment from "moment";
  
  export default {
    data: () => ({
      snackbar: false,
      y: "top",
      x: "right",
      mode: "",
      timeout: 3000,
      text: "",
68d742034   Neeraj Sharma   implement new des...
272
273
      show: true,
      showSearch: false,
687e0b929   Neeraj Sharma   add user,attenden...
274
275
276
277
278
279
      showLoader: false,
      loading: false,
      date: null,
      search: "",
      addclass: [],
      pagination: {
b0e0491ab   Shikha Mishra   solve the issue o...
280
        rowsPerPage: 10,
687e0b929   Neeraj Sharma   add user,attenden...
281
282
283
284
285
286
287
288
      },
      imageData: {},
      imageName: "",
      imageUrl: "",
      imageFile: "",
      headers: [
        {
          text: "No",
68d742034   Neeraj Sharma   implement new des...
289
          align: "",
687e0b929   Neeraj Sharma   add user,attenden...
290
          sortable: false,
b0e0491ab   Shikha Mishra   solve the issue o...
291
          value: "index",
687e0b929   Neeraj Sharma   add user,attenden...
292
293
294
295
296
        },
        {
          text: "Profile Pic",
          value: "profilprofilePicUrlePicUrl",
          sortable: false,
b0e0491ab   Shikha Mishra   solve the issue o...
297
          align: "center",
687e0b929   Neeraj Sharma   add user,attenden...
298
299
        },
        { text: "Name", value: "name", sortable: false, align: "center" },
710438de6   Shikha Mishra   added teacher mod...
300
301
302
303
        {
          text: "Mobile No",
          value: "fatherCellNo",
          sortable: false,
b0e0491ab   Shikha Mishra   solve the issue o...
304
          align: "center",
710438de6   Shikha Mishra   added teacher mod...
305
        },
687e0b929   Neeraj Sharma   add user,attenden...
306
        { text: "Email", value: "email", sortable: false, align: "center" },
b0e0491ab   Shikha Mishra   solve the issue o...
307
        { text: "Attendance", value: "", sortable: false, align: "center" },
687e0b929   Neeraj Sharma   add user,attenden...
308
      ],
6ae46ca27   Neeraj Sharma   implement upload ...
309
      // json_data: [],
687e0b929   Neeraj Sharma   add user,attenden...
310
311
312
313
      parentId: "",
      token: "",
      selectStudents: {
        select: "",
b0e0491ab   Shikha Mishra   solve the issue o...
314
        selectSection: "",
710438de6   Shikha Mishra   added teacher mod...
315
316
317
318
319
320
321
322
323
324
      },
  
      role: "",
      schoolRole: "",
      addStudentAttendenceDialog: false,
      attendeceTable: false,
      menu: false,
      valid: true,
  
      getReport: {},
b0e0491ab   Shikha Mishra   solve the issue o...
325
      getAttendence: {},
710438de6   Shikha Mishra   added teacher mod...
326
327
328
329
330
      studentsList: [],
      studentsData: [],
      addSection: [],
  
      SectionName: ["A", "B", "C", "D", "E", "F"],
b0e0491ab   Shikha Mishra   solve the issue o...
331
332
333
334
      classRules: [(v) => !!v || "Class is required"],
      sectionRules: [(v) => !!v || "Class is required"],
      studentRules: [(v) => !!v || "Student is required"],
      dataValid: [(v) => !!v || "Date is required"],
710438de6   Shikha Mishra   added teacher mod...
335
336
337
338
  
      attendenceType: [
        {
          label: "Present",
b0e0491ab   Shikha Mishra   solve the issue o...
339
          value: true,
710438de6   Shikha Mishra   added teacher mod...
340
341
342
        },
        {
          label: "Absent",
b0e0491ab   Shikha Mishra   solve the issue o...
343
344
345
          value: false,
        },
      ],
687e0b929   Neeraj Sharma   add user,attenden...
346
347
    }),
    methods: {
710438de6   Shikha Mishra   added teacher mod...
348
349
350
351
352
353
354
355
356
357
      save(date) {
        this.$refs.menu.save(date);
      },
      showTable() {
        this.attendeceTable = true;
        this.getStudents();
      },
      getAllClass() {
        http()
          .get("/getClassesList", {
b0e0491ab   Shikha Mishra   solve the issue o...
358
            headers: { Authorization: "Bearer " + this.token },
710438de6   Shikha Mishra   added teacher mod...
359
          })
b0e0491ab   Shikha Mishra   solve the issue o...
360
          .then((response) => {
710438de6   Shikha Mishra   added teacher mod...
361
362
            this.addclass = response.data.data;
          })
b0e0491ab   Shikha Mishra   solve the issue o...
363
          .catch((error) => {
710438de6   Shikha Mishra   added teacher mod...
364
365
366
367
368
            // console.log("err====>", err);
            // this.$router.replace({ path: "/" });
          });
      },
      getSection(_id) {
6ae46ca27   Neeraj Sharma   implement upload ...
369
        this.showLoader = true;
687e0b929   Neeraj Sharma   add user,attenden...
370
371
        http()
          .get(
710438de6   Shikha Mishra   added teacher mod...
372
            "/getSectionsList",
687e0b929   Neeraj Sharma   add user,attenden...
373
374
            { params: { classId: _id } },
            {
b0e0491ab   Shikha Mishra   solve the issue o...
375
              headers: { Authorization: "Bearer " + this.token },
687e0b929   Neeraj Sharma   add user,attenden...
376
377
            }
          )
b0e0491ab   Shikha Mishra   solve the issue o...
378
          .then((response) => {
710438de6   Shikha Mishra   added teacher mod...
379
            this.addSection = response.data.data;
6ae46ca27   Neeraj Sharma   implement upload ...
380
            this.showLoader = false;
687e0b929   Neeraj Sharma   add user,attenden...
381
          })
b0e0491ab   Shikha Mishra   solve the issue o...
382
          .catch((err) => {
6ae46ca27   Neeraj Sharma   implement upload ...
383
            this.showLoader = false;
710438de6   Shikha Mishra   added teacher mod...
384
            // console.log("err====>", err);
687e0b929   Neeraj Sharma   add user,attenden...
385
386
          });
      },
710438de6   Shikha Mishra   added teacher mod...
387
388
      getStudents(_id) {
        this.showLoader = true;
687e0b929   Neeraj Sharma   add user,attenden...
389
        http()
710438de6   Shikha Mishra   added teacher mod...
390
391
          .get("/getStudentWithClass", {
            params: {
b0e0491ab   Shikha Mishra   solve the issue o...
392
393
394
              classId: this.getAttendence.classId,
              sectionId: this.getAttendence.sectionId,
            },
687e0b929   Neeraj Sharma   add user,attenden...
395
          })
b0e0491ab   Shikha Mishra   solve the issue o...
396
          .then((response) => {
710438de6   Shikha Mishra   added teacher mod...
397
398
399
400
401
402
403
            this.studentsData = response.data.data;
            this.showLoader = false;
            // this.addStudentAttendenceDialog = false;
            var attendence = "";
            for (let i = 0; i < this.studentsData.length; i++) {
              this.studentsData[i].attendence = true;
            }
687e0b929   Neeraj Sharma   add user,attenden...
404
          })
b0e0491ab   Shikha Mishra   solve the issue o...
405
          .catch((error) => {
710438de6   Shikha Mishra   added teacher mod...
406
407
408
409
410
411
412
413
414
            console.log("err====>", error);
            this.showLoader = false;
          });
      },
      update() {
        var studentsAttendence = [];
        for (var j = 0; j < this.studentsData.length; j++) {
          studentsAttendence.push({
            studentId: this.studentsData[j]._id,
b0e0491ab   Shikha Mishra   solve the issue o...
415
            isPresent: this.studentsData[j].attendence,
687e0b929   Neeraj Sharma   add user,attenden...
416
          });
710438de6   Shikha Mishra   added teacher mod...
417
418
419
420
421
        }
        if (this.$refs.form.validate()) {
          let attendanceData = {
            sectionId: this.getReport.sectionId,
            date: this.date,
b0e0491ab   Shikha Mishra   solve the issue o...
422
            students: studentsAttendence,
710438de6   Shikha Mishra   added teacher mod...
423
424
425
          };
          http()
            .put("/updateAttendance", attendanceData)
b0e0491ab   Shikha Mishra   solve the issue o...
426
            .then((response) => {
710438de6   Shikha Mishra   added teacher mod...
427
428
429
430
              this.snackbar = true;
              this.text = response.data.message;
              this.addStudentAttendenceDialog = false;
            })
b0e0491ab   Shikha Mishra   solve the issue o...
431
            .catch((error) => {
710438de6   Shikha Mishra   added teacher mod...
432
433
434
435
              this.snackbar = true;
              this.text = error.response.data.message;
            });
        }
68d742034   Neeraj Sharma   implement new des...
436
      },
710438de6   Shikha Mishra   added teacher mod...
437

68d742034   Neeraj Sharma   implement new des...
438
      displaySearch() {
f5329b707   Amber Dev   added form reset ...
439
440
        this.show = false
         this.showSearch = true;
68d742034   Neeraj Sharma   implement new des...
441
442
443
444
445
      },
      closeSearch() {
        this.showSearch = false;
        this.show = true;
        this.search = "";
b0e0491ab   Shikha Mishra   solve the issue o...
446
      },
687e0b929   Neeraj Sharma   add user,attenden...
447
448
449
450
451
    },
    mounted() {
      // this.getStudentList();
      this.token = this.$store.state.token;
      this.getAllClass();
710438de6   Shikha Mishra   added teacher mod...
452
      this.role = this.$store.state.role;
b0e0491ab   Shikha Mishra   solve the issue o...
453
    },
687e0b929   Neeraj Sharma   add user,attenden...
454
  };
68d742034   Neeraj Sharma   implement new des...
455
  </script>