Blame view

src/pages/Library/issue.vue 27.5 KB
687e0b929   Neeraj Sharma   add user,attenden...
1
  <template>
68d742034   Neeraj Sharma   implement new des...
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
    <v-container fluid class="body-color">
      <!-- ****** EDIT ISSUE  ****** -->
      <v-dialog v-model="editIssueDialog" max-width="600px" scrollable>
        <v-card flat class="card-style pa-2" dark>
          <v-layout>
            <v-flex xs12>
              <label class="title text-xs-center">Edit Issue</label>
              <v-icon size="24" class="right" @click="editIssueDialog = false">cancel</v-icon>
            </v-flex>
          </v-layout>
          <v-card-text>
            <v-form ref="form">
              <v-container fluid>
                <v-layout wrap>
                  <v-flex xs12 sm12>
                    <v-layout>
                      <v-flex xs4 class="pt-4 subheading">
                        <label class="right">Library Id:</label>
                      </v-flex>
                      <v-flex xs7 class="ml-3">
                        <v-text-field
                          v-model="editedItem.libraryId"
                          placeholder="fill your Library Id"
                          name="name"
                          type="text"
a76a6f135   Neeraj Sharma   implelement task
27
                          disabled
68d742034   Neeraj Sharma   implement new des...
28
29
30
31
32
33
34
35
36
37
                        ></v-text-field>
                      </v-flex>
                    </v-layout>
                  </v-flex>
                  <v-flex xs12 sm12>
                    <v-layout>
                      <v-flex xs4 class="pt-4 subheading">
                        <label class="right">Book:</label>
                      </v-flex>
                      <v-flex xs7 class="ml-3">
109a6218c   Neeraj Sharma   solve issue/bugs ...
38
39
40
41
42
43
44
45
                        <v-select
                          v-model="editedItem.bookId"
                          label="Select Book Name"
                          :rules="bookRules"
                          :items="books"
                          item-text="name"
                          item-value="_id"
                        ></v-select>
68d742034   Neeraj Sharma   implement new des...
46
47
48
49
                      </v-flex>
                    </v-layout>
                  </v-flex>
                  <v-flex xs12 sm12>
61ab1167f   Neeraj Sharma   implement create ...
50
                    <v-layout>
68d742034   Neeraj Sharma   implement new des...
51
52
                      <v-flex xs4 class="pt-4 subheading">
                        <label class="right">Author:</label>
687e0b929   Neeraj Sharma   add user,attenden...
53
                      </v-flex>
68d742034   Neeraj Sharma   implement new des...
54
55
56
57
58
59
                      <v-flex xs7 class="ml-3">
                        <v-text-field
                          placeholder="fill your Author Name"
                          v-model="editedItem.author"
                          type="text"
                        ></v-text-field>
687e0b929   Neeraj Sharma   add user,attenden...
60
                      </v-flex>
68d742034   Neeraj Sharma   implement new des...
61
62
63
64
65
66
                    </v-layout>
                  </v-flex>
                  <v-flex xs12 sm12>
                    <v-layout>
                      <v-flex xs4 class="pt-4 subheading">
                        <label class="right">Subject Code:</label>
61ab1167f   Neeraj Sharma   implement create ...
67
                      </v-flex>
68d742034   Neeraj Sharma   implement new des...
68
69
70
71
72
73
                      <v-flex xs7 class="ml-3">
                        <v-text-field
                          placeholder="fill your Subject Codes"
                          v-model="editedItem.subjectCode"
                          type="text"
                        ></v-text-field>
61ab1167f   Neeraj Sharma   implement create ...
74
                      </v-flex>
68d742034   Neeraj Sharma   implement new des...
75
76
77
78
79
80
81
82
83
84
85
86
87
                    </v-layout>
                  </v-flex>
                  <v-flex xs12 sm12>
                    <v-layout>
                      <v-flex xs4 class="pt-4 subheading">
                        <label class="right">Serial Number:</label>
                      </v-flex>
                      <v-flex xs7 class="ml-3">
                        <v-text-field
                          placeholder="fill your Serial Number"
                          v-model="editedItem.serialNumber"
                          type="text"
                        ></v-text-field>
687e0b929   Neeraj Sharma   add user,attenden...
88
                      </v-flex>
68d742034   Neeraj Sharma   implement new des...
89
90
91
92
93
94
                    </v-layout>
                  </v-flex>
                  <v-flex xs12 sm12>
                    <v-layout>
                      <v-flex xs4 class="pt-4 subheading">
                        <label class="right">due Date:</label>
687e0b929   Neeraj Sharma   add user,attenden...
95
                      </v-flex>
68d742034   Neeraj Sharma   implement new des...
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
                      <v-flex xs7 class="ml-3">
                        <v-menu
                          ref="menu1"
                          :close-on-content-click="false"
                          v-model="menu1"
                          :nudge-right="40"
                          :return-value.sync="menu1"
                          lazy
                          transition="scale-transition"
                          offset-y
                          full-width
                          min-width="290px"
                        >
                          <v-text-field
                            slot="activator"
                            v-model="editedItem.dueDate"
                            label="Select Due Date"
                            append-icon="event"
                            readonly
                          ></v-text-field>
                          <v-date-picker v-model="editedItem.dueDate" @input="menu1 = false"></v-date-picker>
                        </v-menu>
61ab1167f   Neeraj Sharma   implement create ...
118
                      </v-flex>
687e0b929   Neeraj Sharma   add user,attenden...
119
                    </v-layout>
68d742034   Neeraj Sharma   implement new des...
120
121
                  </v-flex>
                  <v-flex xs12 sm12>
687e0b929   Neeraj Sharma   add user,attenden...
122
                    <v-layout>
68d742034   Neeraj Sharma   implement new des...
123
124
125
126
127
128
129
130
131
                      <v-flex xs4 class="pt-4 subheading">
                        <label class="right">Note:</label>
                      </v-flex>
                      <v-flex xs7 class="ml-3">
                        <v-text-field
                          placeholder="fill your Serial Number"
                          v-model="editedItem.note"
                          type="text"
                        ></v-text-field>
687e0b929   Neeraj Sharma   add user,attenden...
132
133
                      </v-flex>
                    </v-layout>
68d742034   Neeraj Sharma   implement new des...
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
                  </v-flex>
                </v-layout>
                <v-layout>
                  <v-flex xs12>
                    <v-card-actions>
                      <v-spacer></v-spacer>
                      <v-btn round dark @click="save" class="add-button">Save</v-btn>
                    </v-card-actions>
                  </v-flex>
                </v-layout>
              </v-container>
            </v-form>
          </v-card-text>
        </v-card>
      </v-dialog>
687e0b929   Neeraj Sharma   add user,attenden...
149

68d742034   Neeraj Sharma   implement new des...
150
      <!-- ****** PROFILE VIEW PARTICULAR ISSUE DATA ******  -->
687e0b929   Neeraj Sharma   add user,attenden...
151

68d742034   Neeraj Sharma   implement new des...
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
      <v-dialog v-model="viewIssueDialog" max-width="500px">
        <v-card flat class="card-style pa-3" dark>
          <v-layout>
            <v-flex xs12>
              <label class="title text-xs-center">View Issue</label>
              <v-icon size="24" class="right" @click="viewIssueDialog = 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 xs5 sm6>
                      <h5 class="right my-1">
                        <b>Book:</b>
                      </h5>
                    </v-flex>
                    <v-flex sm6 xs8>
                      <h5 class="my-1">{{ editedItem.name }}</h5>
687e0b929   Neeraj Sharma   add user,attenden...
172
173
                    </v-flex>
                  </v-layout>
68d742034   Neeraj Sharma   implement new des...
174
175
176
177
178
                  <v-layout>
                    <v-flex xs5 sm6>
                      <h5 class="right my-1">
                        <b>Serial Number:</b>
                      </h5>
687e0b929   Neeraj Sharma   add user,attenden...
179
                    </v-flex>
68d742034   Neeraj Sharma   implement new des...
180
181
                    <v-flex sm6 xs8>
                      <h5 class="my-1">{{ editedItem.serialNumber }}</h5>
687e0b929   Neeraj Sharma   add user,attenden...
182
                    </v-flex>
68d742034   Neeraj Sharma   implement new des...
183
184
185
186
187
188
                  </v-layout>
                  <v-layout>
                    <v-flex xs5 sm6>
                      <h5 class="right my-1">
                        <b>Issue date:</b>
                      </h5>
687e0b929   Neeraj Sharma   add user,attenden...
189
                    </v-flex>
68d742034   Neeraj Sharma   implement new des...
190
191
                    <v-flex sm6 xs8>
                      <h5 class="my-1">{{ dates(editedItem.creted) }}</h5>
687e0b929   Neeraj Sharma   add user,attenden...
192
                    </v-flex>
68d742034   Neeraj Sharma   implement new des...
193
194
195
196
197
198
                  </v-layout>
                  <v-layout>
                    <v-flex xs5 sm6>
                      <h5 class="right my-1">
                        <b>Due date:</b>
                      </h5>
687e0b929   Neeraj Sharma   add user,attenden...
199
                    </v-flex>
68d742034   Neeraj Sharma   implement new des...
200
201
                    <v-flex sm6 xs8>
                      <h5 class="my-1">{{ dates(editedItem.dueDate) }}</h5>
b8690bbc9   Neeraj Sharma   implement create ...
202
                    </v-flex>
68d742034   Neeraj Sharma   implement new des...
203
204
205
206
207
208
                  </v-layout>
                  <v-layout>
                    <v-flex xs5 sm6>
                      <h5 class="right my-1">
                        <b>Status:</b>
                      </h5>
687e0b929   Neeraj Sharma   add user,attenden...
209
                    </v-flex>
68d742034   Neeraj Sharma   implement new des...
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
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
                    <v-flex sm6 xs8>
                      <h5 class="my-1">{{ editedItem.status }}</h5>
                    </v-flex>
                  </v-layout>
                </v-flex>
              </v-layout>
            </v-container>
          </v-card-text>
        </v-card>
      </v-dialog>
      <!-- ****** EXISTING ISSUE TABLE****** -->
      <!-- <v-card>
        <v-layout>
          <v-flex lg1 xs4 md4 xl1 class="hidden-xs-only">
            <label class="right pt-4">Library ID:</label>
          </v-flex>
          <v-flex lg2 md3 xs7>
            <v-text-field
              class="pl-3"
              @keyup.enter="getIssueList"
              v-model="libraryId"
              placeholder="fill your library Id"
            ></v-text-field>
          </v-flex>
          <v-flex lg9 md3 xs5>
            <v-btn
              round
              class="black mt-1 right hidden-xs-only"
              @click="getIssueList"
              :loading="loadingSearch"
              dark
            >Search</v-btn>
            <v-btn
              round
              class="black mt-4 right hidden-sm-only hidden-xl-only hidden-md-only hidden-lg-only"
              :loading="loadingSearch"
              @click="getIssueList"
              small
              dark
            >Search</v-btn>
          </v-flex>
        </v-layout>
      </v-card>-->
  
      <v-toolbar color="transparent" flat>
        <v-btn
          fab
          dark
          class="open-dialog-button hidden-xl-only hidden-md-only hidden-lg-only"
          small
          @click="addIssueDialog = true"
        >
          <v-icon dark>add</v-icon>
        </v-btn>
        <v-btn
          round
          class="open-dialog-button hidden-sm-only hidden-xs-only"
          dark
          @click="addIssueDialog = true"
        >
          <v-icon class="white--text pr-1" size="20">add</v-icon>Add Issue
        </v-btn>
        <v-flex lg2 md3 xs7>
          <v-text-field
            class="pl-3"
            @keyup.enter="getIssueList"
            v-model="libraryId"
            placeholder="fill your library Id"
          ></v-text-field>
        </v-flex>
        <v-spacer></v-spacer>
        <v-btn
          round
          class="add-button mt-1 right hidden-xs-only"
          @click="getIssueList"
          :loading="loadingSearch"
          dark
        >Search</v-btn>
        <v-btn
          round
          class="add-button mt-4 right hidden-sm-only hidden-xl-only hidden-md-only hidden-lg-only"
          :loading="loadingSearch"
          @click="getIssueList"
          small
          dark
        >Search</v-btn>
        <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...
299
              <img src="/static/icon/search.png" alt="icon" />
68d742034   Neeraj Sharma   implement new des...
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
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
            </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" v-if="props.item.isReturn != true">
          <tr class="tr">
            <td class="td td-row">{{ props.index + 1}}</td>
            <td class="text-xs-center td td-row">{{ props.item.bookId.name}}</td>
            <td class="text-xs-center td td-row">{{ props.item.serialNumber}}</td>
            <td class="text-xs-center td td-row">{{ dates(props.item.created) }}</td>
            <td class="text-xs-center td td-row">{{ dates(props.item.dueDate) }}</td>
            <td class="text-xs-center td td-row">
              <span
                v-if="props.item.bookId.status === 'AVAILABLE'"
                class="green lighten-1 pa-1 px-2 white--text paymentStatus"
              >{{ props.item.bookId.status}}</span>
              <span
                v-if="props.item.bookId.status === 'UNAVAILABLE'"
                class="red lighten-1 pa-1 px-2 white--text paymentStatus"
              >{{ props.item.bookId.status}}</span>
            </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   Shikha Mishra   added functionali...
341
                    src="/static/icon/view.png"
68d742034   Neeraj Sharma   implement new des...
342
343
344
345
346
347
348
349
350
                  />
                  <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   Shikha Mishra   added functionali...
351
                    src="/static/icon/edit.png"
68d742034   Neeraj Sharma   implement new des...
352
353
354
355
356
357
358
359
                  />
                  <span>Edit</span>
                </v-tooltip>
                <v-tooltip top>
                  <img
                    slot="activator"
                    style="cursor:pointer; width:20px; height:20px; "
                    @click="deleteItem(props.item)"
aa310d61a   Shikha Mishra   added functionali...
360
                    src="/static/icon/delete.png"
68d742034   Neeraj Sharma   implement new des...
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
                  />
                  <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>
  
      <!-- ****** ADD Issue ****** -->
      <v-dialog v-model="addIssueDialog" max-width="600px">
        <v-card flat class="card-style pa-2" dark>
          <v-layout>
            <v-flex xs12>
              <label class="title text-xs-center">Add Issue</label>
              <v-icon size="24" class="right" @click="addIssueDialog = false">cancel</v-icon>
687e0b929   Neeraj Sharma   add user,attenden...
383
            </v-flex>
68d742034   Neeraj Sharma   implement new des...
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
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
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
          </v-layout>
          <v-form ref="form" v-model="valid" lazy-validation>
            <v-container fluid>
              <v-flex xs12>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">Library ID:</label>
                  </v-flex>
                  <v-flex xs7 class="ml-3">
                    <v-text-field
                      v-model="libraryID"
                      placeholder="fill your Library ID"
                      :rules="libraryIDRules"
                      required
                    ></v-text-field>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">Book:</label>
                  </v-flex>
                  <v-flex xs7 class="ml-3">
                    <v-select
                      label="Select Book Name"
                      :rules="bookRules"
                      :items="books"
                      item-text="name"
                      item-value="_id"
                      v-model="bookId"
                      @change="getParticularBookData(bookId)"
                      required
                    ></v-select>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">Author:</label>
                  </v-flex>
                  <v-flex xs7 class="ml-3">
                    <v-text-field
                      placeholder="fill your Author"
                      :rules="authorRules"
                      v-model="addIssue.author"
                    ></v-text-field>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">Subject Code:</label>
                  </v-flex>
                  <v-flex xs7 class="ml-3">
                    <v-text-field
                      placeholder="fill your Subject Code"
                      :rules="subjectCodeRules"
                      v-model="addIssue.subjectCode"
                    ></v-text-field>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">Serial No:</label>
                  </v-flex>
                  <v-flex xs7 class="ml-3">
                    <v-text-field
                      placeholder="fill your Serial No"
                      :rules="authorRules"
                      v-model="serialNo"
                    ></v-text-field>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">Due Date:</label>
                  </v-flex>
                  <v-flex xs7 class="ml-3">
                    <v-menu
                      ref="menu2"
                      :close-on-content-click="false"
                      v-model="menu2"
                      :nudge-right="40"
                      :return-value.sync="date"
                      lazy
                      transition="scale-transition"
                      offset-y
                      full-width
                      min-width="290px"
                    >
                      <v-text-field
                        slot="activator"
                        v-model="date"
                        label="Select Due Date"
                        append-icon="event"
                        :rules="dueDateRule"
                        readonly
                      ></v-text-field>
                      <v-date-picker v-model="date" @input="$refs.menu2.save(date)"></v-date-picker>
                    </v-menu>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">Note:</label>
                  </v-flex>
                  <v-flex xs7 class="ml-3">
                    <v-text-field placeholder="fill your Note" :rules="noteRules" v-model="note"></v-text-field>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-layout>
                <v-flex xs12>
                  <v-card-actions>
                    <v-spacer></v-spacer>
                    <v-btn @click="clear" round dark class="clear-button">clear</v-btn>
                    <v-btn
                      @click="submit"
                      round
                      dark
                      :loading="loading"
                      class="add-button"
                      :disabled="disable"
                    >Add</v-btn>
                  </v-card-actions>
                </v-flex>
              </v-layout>
            </v-container>
          </v-form>
        </v-card>
      </v-dialog>
687e0b929   Neeraj Sharma   add user,attenden...
524
525
526
      <div class="loader" v-if="showLoader">
        <v-progress-circular indeterminate color="white"></v-progress-circular>
      </div>
68d742034   Neeraj Sharma   implement new des...
527
528
529
530
531
532
533
534
535
      <v-snackbar
        :timeout="timeout"
        :top="y === 'top'"
        :right="x === 'right'"
        :vertical="mode === 'vertical'"
        v-model="snackbar"
        :color="color"
      >{{ text }}</v-snackbar>
    </v-container>
687e0b929   Neeraj Sharma   add user,attenden...
536
537
538
539
  </template>
  
  <script>
  import http from "@/Services/http.js";
61ab1167f   Neeraj Sharma   implement create ...
540
  import moment from "moment";
687e0b929   Neeraj Sharma   add user,attenden...
541
542
543
544
  
  export default {
    data: () => ({
      snackbar: false,
b8690bbc9   Neeraj Sharma   implement create ...
545
      date: null,
61ab1167f   Neeraj Sharma   implement create ...
546
      menu1: false,
b8690bbc9   Neeraj Sharma   implement create ...
547
548
      menu2: false,
      color: "",
68d742034   Neeraj Sharma   implement new des...
549
550
      show: true,
      showSearch: false,
61ab1167f   Neeraj Sharma   implement create ...
551
      dueDate: null,
687e0b929   Neeraj Sharma   add user,attenden...
552
553
554
      y: "top",
      x: "right",
      mode: "",
b8690bbc9   Neeraj Sharma   implement create ...
555
      timeout: 10000,
687e0b929   Neeraj Sharma   add user,attenden...
556
      text: "",
6c05a9f84   Neeraj Sharma   add functionalit ...
557
      libraryId: "",
687e0b929   Neeraj Sharma   add user,attenden...
558
      loading: false,
6c05a9f84   Neeraj Sharma   add functionalit ...
559
      loadingSearch: false,
687e0b929   Neeraj Sharma   add user,attenden...
560
561
      date: null,
      search: "",
68d742034   Neeraj Sharma   implement new des...
562
563
      addIssueDialog: false,
      viewIssueDialog: false,
687e0b929   Neeraj Sharma   add user,attenden...
564
      showLoader: false,
68d742034   Neeraj Sharma   implement new des...
565
      editIssueDialog: false,
687e0b929   Neeraj Sharma   add user,attenden...
566
567
568
569
570
571
      dialog1: false,
      valid: true,
      isActive: true,
      newActive: false,
      addclass: [],
      addSection: [],
687e0b929   Neeraj Sharma   add user,attenden...
572
      pagination: {
68d742034   Neeraj Sharma   implement new des...
573
        rowsPerPage: 10
687e0b929   Neeraj Sharma   add user,attenden...
574
575
576
577
578
579
580
      },
      libraryIDRules: [v => !!v || " Library ID is required"],
      bookRules: [v => !!v || " book Name is required"],
      authorRules: [v => !!v || "Author Name is required"],
      subjectCodeRules: [v => !!v || "Subject Code is required"],
      authorRules: [v => !!v || "Author is required"],
      noteRules: [v => !!v || "Note is required"],
4d1fcaddc   Neeraj Sharma   fixed validation ...
581
      dueDateRule: [v => !!v || "Due Date is required"],
687e0b929   Neeraj Sharma   add user,attenden...
582
583
584
585
586
587
588
      headers: [
        {
          align: "justify-center",
          text: "No",
          sortable: false,
          value: "No"
        },
61ab1167f   Neeraj Sharma   implement create ...
589
        { text: "Book", vaue: "name", sortable: false, align: "center" },
687e0b929   Neeraj Sharma   add user,attenden...
590
        {
61ab1167f   Neeraj Sharma   implement create ...
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
          text: "Serial Number",
          value: "serialNumber",
          sortable: false,
          align: "center"
        },
        {
          text: "Issue Date",
          value: "created",
          sortable: false,
          align: "center"
        },
        {
          text: "Due Date",
          value: "dueDate",
          sortable: false,
          align: "center"
        },
        {
          text: "Status",
          value: "status",
687e0b929   Neeraj Sharma   add user,attenden...
611
612
613
614
615
616
617
          sortable: false,
          align: "center"
        },
        { text: "Action", value: "", sortable: false, align: "center" }
      ],
      desserts: [],
      addIssue: {},
b8690bbc9   Neeraj Sharma   implement create ...
618
619
620
621
622
623
624
625
      bookId: "",
      libraryID: "",
      serialNo: "",
      note: "",
      editedItem: {},
      books: [],
      token: "",
      disable: false
687e0b929   Neeraj Sharma   add user,attenden...
626
627
    }),
    methods: {
61ab1167f   Neeraj Sharma   implement create ...
628
629
      dates: function(date) {
        return moment(date).format("MMMM DD, YYYY");
687e0b929   Neeraj Sharma   add user,attenden...
630
631
632
633
      },
      pickFile() {
        this.$refs.image.click();
      },
61ab1167f   Neeraj Sharma   implement create ...
634
      getIssueList() {
687e0b929   Neeraj Sharma   add user,attenden...
635
        this.showLoader = true;
6c05a9f84   Neeraj Sharma   add functionalit ...
636
        this.loadingSearch = true;
a76a6f135   Neeraj Sharma   implelement task
637
638
639
        if (this.libraryID) {
          this.libraryId = this.libraryID;
        }
687e0b929   Neeraj Sharma   add user,attenden...
640
        http()
6c05a9f84   Neeraj Sharma   add functionalit ...
641
          .get(
61ab1167f   Neeraj Sharma   implement create ...
642
            "/getBooksIssueList",
6c05a9f84   Neeraj Sharma   add functionalit ...
643
            {
99cd79184   Neeraj Sharma   implement all tas...
644
645
646
647
              params: {
                libraryId: this.libraryId,
                schoolId: this.$store.state.schoolId
              }
6c05a9f84   Neeraj Sharma   add functionalit ...
648
649
650
651
652
            },
            {
              headers: { Authorization: "Bearer " + this.token }
            }
          )
687e0b929   Neeraj Sharma   add user,attenden...
653
          .then(response => {
61ab1167f   Neeraj Sharma   implement create ...
654
            this.desserts = response.data.data;
687e0b929   Neeraj Sharma   add user,attenden...
655
            this.showLoader = false;
6c05a9f84   Neeraj Sharma   add functionalit ...
656
            this.loadingSearch = false;
687e0b929   Neeraj Sharma   add user,attenden...
657
          })
6c05a9f84   Neeraj Sharma   add functionalit ...
658
          .catch(error => {
687e0b929   Neeraj Sharma   add user,attenden...
659
            this.showLoader = false;
6c05a9f84   Neeraj Sharma   add functionalit ...
660
661
662
            this.loadingSearch = false;
            this.snackbar = true;
            this.text = error.response.data.message;
687e0b929   Neeraj Sharma   add user,attenden...
663
664
665
666
            if (error.response.status === 401) {
              this.$router.replace({ path: "/" });
              this.$store.dispatch("setToken", null);
              this.$store.dispatch("Id", null);
00e4bc4e1   Neeraj Sharma   fixed auntentication
667
              this.$store.dispatch("Role", null);
687e0b929   Neeraj Sharma   add user,attenden...
668
669
670
671
672
673
            }
          });
      },
      editItem(item) {
        this.editedIndex = this.desserts.indexOf(item);
        this.editedItem = Object.assign({}, item);
61ab1167f   Neeraj Sharma   implement create ...
674
675
676
677
678
679
        this.editedItem.name = item.bookId.name;
        this.editedItem.status = item.bookId.status;
        this.editedItem.dueDate =
          this.editedItem.dueDate != undefined
            ? (this.editedItem.dueDate = this.editedItem.dueDate.substring(0, 10))
            : (this.editedItem.dueDate = "");
68d742034   Neeraj Sharma   implement new des...
680
        this.editIssueDialog = true;
687e0b929   Neeraj Sharma   add user,attenden...
681
682
683
684
      },
      profile(item) {
        this.editedIndex = this.desserts.indexOf(item);
        this.editedItem = Object.assign({}, item);
61ab1167f   Neeraj Sharma   implement create ...
685
686
        this.editedItem.name = item.bookId.name;
        this.editedItem.status = item.bookId.status;
68d742034   Neeraj Sharma   implement new des...
687
        this.viewIssueDialog = true;
687e0b929   Neeraj Sharma   add user,attenden...
688
      },
109a6218c   Neeraj Sharma   solve issue/bugs ...
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
      deleteItem(item) {
        let deleteParticularIssue = {
          bookIssueId: item._id
        };
        http()
          .delete(
            "/deleteBookIssue",
            confirm("Are you sure you want to delete this?") && {
              params: deleteParticularIssue
            }
          )
          .then(response => {
            this.snackbar = true;
            this.text = "Delete Successfully";
            this.getIssueList();
            if (this.libraryID) {
              this.libraryId = this.libraryID;
            }
            if (this.libraryId) {
              this.libraryId = this.libraryId;
            }
            this.snackbar = true;
            this.text = response.data.message;
            this.color = "green";
            this.loading = false;
          })
          .catch(error => {
            // console.log(error);
            this.snackbar = true;
            this.text = error.response.data.message;
            this.color = "red";
          });
      },
61ab1167f   Neeraj Sharma   implement create ...
722
723
724
      returnBook(item) {
        let returnBook = {
          bookIssueId: item._id
687e0b929   Neeraj Sharma   add user,attenden...
725
726
        };
        http()
61ab1167f   Neeraj Sharma   implement create ...
727
728
729
          .put(
            "/returnBook",
            confirm("Are you sure you want to return this?") && returnBook
687e0b929   Neeraj Sharma   add user,attenden...
730
731
          )
          .then(response => {
61ab1167f   Neeraj Sharma   implement create ...
732
733
            this.snackbar = true;
            this.text = "Successfully return Issue a Book ";
687e0b929   Neeraj Sharma   add user,attenden...
734
735
            this.getIssueList();
          })
68d742034   Neeraj Sharma   implement new des...
736
          .catch(error => {});
687e0b929   Neeraj Sharma   add user,attenden...
737
738
      },
      close() {
68d742034   Neeraj Sharma   implement new des...
739
        this.editIssueDialog = false;
687e0b929   Neeraj Sharma   add user,attenden...
740
741
      },
      close1() {
68d742034   Neeraj Sharma   implement new des...
742
        this.viewIssueDialog = false;
687e0b929   Neeraj Sharma   add user,attenden...
743
744
      },
      submit() {
61ab1167f   Neeraj Sharma   implement create ...
745
746
747
748
749
750
751
752
        if (this.$refs.form.validate()) {
          let createBook = {
            bookId: this.bookId,
            author: this.addIssue.author,
            subjectCode: this.addIssue.subjectCode,
            libraryId: this.libraryID,
            serialNumber: this.serialNo,
            note: this.note,
99cd79184   Neeraj Sharma   implement all tas...
753
754
            dueDate: this.date,
            schoolId: this.$store.state.schoolId
61ab1167f   Neeraj Sharma   implement create ...
755
          };
4d1fcaddc   Neeraj Sharma   fixed validation ...
756
          this.loading = true;
61ab1167f   Neeraj Sharma   implement create ...
757
          http()
a76a6f135   Neeraj Sharma   implelement task
758
            .post("/createBookIssue", createBook)
61ab1167f   Neeraj Sharma   implement create ...
759
            .then(response => {
a76a6f135   Neeraj Sharma   implelement task
760
              this.getIssueList();
61ab1167f   Neeraj Sharma   implement create ...
761
              this.snackbar = true;
68d742034   Neeraj Sharma   implement new des...
762
              this.text = response.data.message;
a76a6f135   Neeraj Sharma   implelement task
763
              this.addIssueDialog = false;
68d742034   Neeraj Sharma   implement new des...
764
              this.color = "green";
61ab1167f   Neeraj Sharma   implement create ...
765
766
767
768
              this.loading = false;
              this.clear();
            })
            .catch(error => {
4d1fcaddc   Neeraj Sharma   fixed validation ...
769
770
771
              this.snackbar = true;
              this.text = error.response.data.message;
              this.color = "red";
68d742034   Neeraj Sharma   implement new des...
772
              this.loading = false;
61ab1167f   Neeraj Sharma   implement create ...
773
774
            });
        }
687e0b929   Neeraj Sharma   add user,attenden...
775
776
777
      },
      clear() {
        this.$refs.form.reset();
61ab1167f   Neeraj Sharma   implement create ...
778
        this.disable = false;
687e0b929   Neeraj Sharma   add user,attenden...
779
780
      },
      save() {
61ab1167f   Neeraj Sharma   implement create ...
781
        this.editedItem.bookIssueId = this.editedItem._id;
109a6218c   Neeraj Sharma   solve issue/bugs ...
782
        this.editedItem.bookId = this.editedItem.bookId;
687e0b929   Neeraj Sharma   add user,attenden...
783
        http()
61ab1167f   Neeraj Sharma   implement create ...
784
          .put("/updateBookIssue", this.editedItem)
687e0b929   Neeraj Sharma   add user,attenden...
785
          .then(response => {
a76a6f135   Neeraj Sharma   implelement task
786
            this.editIssueDialog = false;
61ab1167f   Neeraj Sharma   implement create ...
787
788
789
            this.snackbar = true;
            this.text = "Successfully Edit Issue a Book";
            this.color = "green";
687e0b929   Neeraj Sharma   add user,attenden...
790
791
792
793
            this.getIssueList();
            this.close();
          })
          .catch(error => {
68d742034   Neeraj Sharma   implement new des...
794
795
796
            this.snackbar = true;
            this.text = error.response.data.message;
            this.color = "red";
687e0b929   Neeraj Sharma   add user,attenden...
797
          });
b8690bbc9   Neeraj Sharma   implement create ...
798
799
800
801
802
      },
      getBookData() {
        this.showLoader = true;
        http()
          .get("/getBooksList", {
99cd79184   Neeraj Sharma   implement all tas...
803
804
805
            params: {
              schoolId: this.$store.state.schoolId
            },
b8690bbc9   Neeraj Sharma   implement create ...
806
807
808
809
810
            headers: { Authorization: "Bearer " + this.token }
          })
          .then(response => {
            this.books = response.data.data;
            this.showLoader = false;
b8690bbc9   Neeraj Sharma   implement create ...
811
812
          })
          .catch(error => {
b8690bbc9   Neeraj Sharma   implement create ...
813
            this.showLoader = false;
0551a0f15   Neeraj Sharma   implemnet functio...
814
815
816
817
818
            if (error.response.status === 401) {
              this.$router.replace({ path: "/" });
              this.$store.dispatch("setToken", null);
              this.$store.dispatch("Id", null);
            }
b8690bbc9   Neeraj Sharma   implement create ...
819
820
821
          });
      },
      getParticularBookData(books) {
b8690bbc9   Neeraj Sharma   implement create ...
822
823
        for (let i = 0; i < this.books.length; i++) {
          if (books == this.books[i]._id) {
b8690bbc9   Neeraj Sharma   implement create ...
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
            if (this.books[i].remaining <= 0) {
              this.snackbar = true;
              this.text = "Book is unavailable";
              this.color = "red";
              this.disable = true;
            } else if (this.books[i].remaining > 0) {
              this.disable = false;
            }
            this.addIssue = {
              author: this.books[i].author,
              subjectCode: this.books[i].subjectCode
            };
          }
        }
        this.addIssue.boojk = books;
68d742034   Neeraj Sharma   implement new des...
839
840
841
842
843
844
845
846
      },
      displaySearch() {
        (this.show = false), (this.showSearch = true);
      },
      closeSearch() {
        this.showSearch = false;
        this.show = true;
        this.search = "";
687e0b929   Neeraj Sharma   add user,attenden...
847
848
849
      }
    },
    mounted() {
b8690bbc9   Neeraj Sharma   implement create ...
850
851
      this.token = this.$store.state.token;
      this.getBookData();
687e0b929   Neeraj Sharma   add user,attenden...
852
853
854
855
856
857
858
859
860
861
862
863
    }
  };
  </script>
  <style scoped>
  .active {
    background-color: gray;
    color: white !important;
  }
  .activebtn {
    color: black !important;
  }
  </style>