Commit 61ab1167f17a5ecb27367bb8b8236b41103d9fef

Authored by Neeraj Sharma
1 parent b8690bbc9e

implement create issue a book all functionality are done

src/Services/http.js
... ... @@ -3,7 +3,7 @@ import store from '@/store/store'
3 3  
4 4 export default () => {
5 5 return axios.create({
6   - // baseURL: 'http://192.168.2.221:3002/v1',/
  6 + // baseURL: 'http://192.168.2.221:3002/v1',
7 7 baseURL: 'http://13.234.251.173:8001/v1',
8 8 headers: {
9 9 Authorization: `Bearer ${store.state.token}`
... ...
src/pages/Library/books.vue
... ... @@ -223,7 +223,9 @@
223 223 <td id="td" class="text-xs-center">{{ props.item.price }}</td>
224 224 <td id="td" class="text-xs-center">{{ props.item.quantity }}</td>
225 225 <td id="td" class="text-xs-center">{{ props.item.rackNo }}</td>
226   - <td id="td" class="text-xs-center">{{ props.item.status }}</td>
  226 + <td id="td" class="text-xs-center">
  227 + <span class="green lighten-1 pa-2 white--text paymentStatus">{{ props.item.status }}</span>
  228 + </td>
227 229 <!-- <td id="td" class="text-xs-center">{{ props.item.session}}</td> -->
228 230  
229 231 <td class="text-xs-center">
... ...
src/pages/Library/issue.vue
... ... @@ -15,7 +15,7 @@
15 15 id="tab1"
16 16 User
17 17 class="subheading"
18   - >Add Issue</v-tab>
  18 + >Add Issue a book</v-tab>
19 19  
20 20 <!-- ****** EDIT ISSUE ****** -->
21 21  
... ... @@ -40,66 +40,33 @@
40 40 <v-card-text style="height:600px;">
41 41 <v-form ref="form">
42 42 <v-container fluid>
43   - <!-- <v-layout row>
44   - <v-flex
45   - xs12
46   - class="text-xs-center text-sm-center text-md-center text-lg-center my-4 mr-4"
47   - >
48   - <input
49   - type="file"
50   - style="display: none"
51   - ref="image"
52   - accept="image/*"
53   - multiple
54   - @change="onFilePicked"
55   - />
56   - <v-layout justify-center>
57   - <v-flex
58   - xs3
59   - v-for="Image in editedItem.newsImageUrl"
60   - :key="Image._id"
61   - v-if="editedItem.newsImageUrl"
62   - class="profile-image-wrapper"
63   - >
64   - <img
65   - :src="Image.imageUrl"
66   - height="160"
67   - width="160"
68   - alt="Issue"
69   - class="pa-2"
70   - />
71   - <v-icon
72   - class="red edit-profile-icon"
73   - dark
74   - @click="deleteImage(Image._id,editedItem._id)"
75   - >close</v-icon>
  43 + <v-layout>
  44 + <v-flex xs12 sm12>
  45 + <v-layout>
  46 + <v-flex xs4 class="pt-4 subheading">
  47 + <label class="right">Library Id:</label>
76 48 </v-flex>
77   - <v-flex v-for="(file, index) in files" :key="index">
78   - <img :src="file" height="160" width="160" class="pa-2" />
  49 + <v-flex xs5 class="ml-3">
  50 + <v-text-field
  51 + v-model="editedItem.libraryId"
  52 + placeholder="fill your Library Id"
  53 + name="name"
  54 + type="text"
  55 + ></v-text-field>
79 56 </v-flex>
80 57 </v-layout>
81   - <img
82   - src="/static/icon/user.png"
83   - v-if="editedItem.newsImageUrl ==''"
84   - height="160"
85   - width="160"
86   - alt="Issue"
87   - />
88 58 </v-flex>
89   - </v-layout>-->
90   - <v-layout>
91 59 <v-flex xs12 sm12>
92 60 <v-layout>
93 61 <v-flex xs4 class="pt-4 subheading">
94   - <label class="right">Title:</label>
  62 + <label class="right">Book:</label>
95 63 </v-flex>
96 64 <v-flex xs5 class="ml-3">
97 65 <v-text-field
98   - v-model="editedItem.title"
99   - placeholder="fill your Title"
  66 + v-model="editedItem.name"
  67 + placeholder="fill your Book name"
100 68 name="name"
101 69 type="text"
102   - required
103 70 ></v-text-field>
104 71 </v-flex>
105 72 </v-layout>
... ... @@ -107,35 +74,103 @@
107 74 <v-flex xs12 sm12>
108 75 <v-layout>
109 76 <v-flex xs4 class="pt-4 subheading">
110   - <label class="right">Description:</label>
  77 + <label class="right">Author:</label>
  78 + </v-flex>
  79 + <v-flex xs5 class="ml-3">
  80 + <v-text-field
  81 + placeholder="fill your Author Name"
  82 + v-model="editedItem.author"
  83 + type="text"
  84 + ></v-text-field>
  85 + </v-flex>
  86 + </v-layout>
  87 + </v-flex>
  88 + <v-flex xs12 sm12>
  89 + <v-layout>
  90 + <v-flex xs4 class="pt-4 subheading">
  91 + <label class="right">Subject Code:</label>
111 92 </v-flex>
112 93 <v-flex xs5 class="ml-3">
113 94 <v-text-field
114   - placeholder="fill your Description"
115   - v-model="editedItem.description"
  95 + placeholder="fill your Subject Codes"
  96 + v-model="editedItem.subjectCode"
116 97 type="text"
117   - name="email"
118   - required
119 98 ></v-text-field>
120 99 </v-flex>
121 100 </v-layout>
122 101 </v-flex>
123   - <v-flex xs12>
  102 + <v-flex xs12 sm12>
124 103 <v-layout>
125 104 <v-flex xs4 class="pt-4 subheading">
126   - <label class="right">Add New Images:</label>
  105 + <label class="right">Serial Number:</label>
127 106 </v-flex>
128 107 <v-flex xs5 class="ml-3">
129   - <!-- <v-text-field
130   - label="Select Image"
131   - @click="pickFile"
132   - v-model="imageName"
133   - append-icon="attach_file"
134   - multiple
135   - ></v-text-field>-->
  108 + <v-text-field
  109 + placeholder="fill your Serial Number"
  110 + v-model="editedItem.serialNumber"
  111 + type="text"
  112 + ></v-text-field>
136 113 </v-flex>
137 114 </v-layout>
138 115 </v-flex>
  116 + <v-flex xs12 sm12>
  117 + <v-layout>
  118 + <v-flex xs4 class="pt-4 subheading">
  119 + <label class="right">due Date:</label>
  120 + </v-flex>
  121 + <v-flex xs5 class="ml-3">
  122 + <v-menu
  123 + ref="menu1"
  124 + :close-on-content-click="false"
  125 + v-model="menu1"
  126 + :nudge-right="40"
  127 + :return-value.sync="menu1"
  128 + lazy
  129 + transition="scale-transition"
  130 + offset-y
  131 + full-width
  132 + min-width="290px"
  133 + >
  134 + <v-text-field
  135 + slot="activator"
  136 + v-model="editedItem.dueDate"
  137 + label="Select Due Date"
  138 + append-icon="event"
  139 + readonly
  140 + ></v-text-field>
  141 + <v-date-picker v-model="editedItem.dueDate" @input="menu1 = false"></v-date-picker>
  142 + </v-menu>
  143 + </v-flex>
  144 + </v-layout>
  145 + </v-flex>
  146 + <v-flex xs12 sm12>
  147 + <v-layout>
  148 + <v-flex xs4 class="pt-4 subheading">
  149 + <label class="right">Note:</label>
  150 + </v-flex>
  151 + <v-flex xs5 class="ml-3">
  152 + <v-text-field
  153 + placeholder="fill your Serial Number"
  154 + v-model="editedItem.note"
  155 + type="text"
  156 + ></v-text-field>
  157 + </v-flex>
  158 + </v-layout>
  159 + </v-flex>
  160 + <!-- <v-flex xs12 sm12>
  161 + <v-layout>
  162 + <v-flex xs4 class="pt-4 subheading">
  163 + <label class="right">Satus:</label>
  164 + </v-flex>
  165 + <v-flex xs5 class="ml-3">
  166 + <v-text-field
  167 + placeholder="fill your Serial Number"
  168 + v-model="editedItem.status"
  169 + type="text"
  170 + ></v-text-field>
  171 + </v-flex>
  172 + </v-layout>
  173 + </v-flex>-->
139 174 </v-layout>
140 175 <v-layout>
141 176 <v-flex xs12 sm8 offset-sm2>
... ... @@ -159,19 +194,11 @@
159 194 <v-toolbar color="grey lighten-2" flat>
160 195 <v-spacer></v-spacer>
161 196 <v-toolbar-title>
162   - <h3>Issue</h3>
  197 + <h3>Issue a Book</h3>
163 198 </v-toolbar-title>
164 199 <v-spacer></v-spacer>
165 200 <v-icon @click="close1">close</v-icon>
166 201 </v-toolbar>
167   - <!-- <v-flex align-center justify-center layout text-xs-center>
168   - <v-avatar size="50px" style="position:absolute; top:20px;">
169   - <img src="/static/icon/user.png">
170   - </v-avatar>
171   - <span v-for="(image,i) in editedItem.newsImageUrl" :key="i" class="mt-4 pa-2">
172   - <img :src="image.imageUrl" alt="Issue" width="240" height="180" />
173   - </span>
174   - </v-flex>-->
175 202 <v-card-text>
176 203 <v-container grid-list-md>
177 204 <v-layout wrap>
... ... @@ -179,21 +206,51 @@
179 206 <v-layout>
180 207 <v-flex xs5 sm6>
181 208 <h5 class="right my-1">
182   - <b>Title:</b>
  209 + <b>Book:</b>
183 210 </h5>
184 211 </v-flex>
185 212 <v-flex sm6 xs8>
186   - <h5 class="my-1">{{ editedItem.title }}</h5>
  213 + <h5 class="my-1">{{ editedItem.name }}</h5>
187 214 </v-flex>
188 215 </v-layout>
189 216 <v-layout>
190 217 <v-flex xs5 sm6>
191 218 <h5 class="right my-1">
192   - <b>Description:</b>
  219 + <b>Serial Number:</b>
193 220 </h5>
194 221 </v-flex>
195 222 <v-flex sm6 xs8>
196   - <h5 class="my-1">{{ editedItem.description }}</h5>
  223 + <h5 class="my-1">{{ editedItem.serialNumber }}</h5>
  224 + </v-flex>
  225 + </v-layout>
  226 + <v-layout>
  227 + <v-flex xs5 sm6>
  228 + <h5 class="right my-1">
  229 + <b>Issue date:</b>
  230 + </h5>
  231 + </v-flex>
  232 + <v-flex sm6 xs8>
  233 + <h5 class="my-1">{{ dates(editedItem.creted) }}</h5>
  234 + </v-flex>
  235 + </v-layout>
  236 + <v-layout>
  237 + <v-flex xs5 sm6>
  238 + <h5 class="right my-1">
  239 + <b>Due date:</b>
  240 + </h5>
  241 + </v-flex>
  242 + <v-flex sm6 xs8>
  243 + <h5 class="my-1">{{ dates(editedItem.dueDate) }}</h5>
  244 + </v-flex>
  245 + </v-layout>
  246 + <v-layout>
  247 + <v-flex xs5 sm6>
  248 + <h5 class="right my-1">
  249 + <b>Status:</b>
  250 + </h5>
  251 + </v-flex>
  252 + <v-flex sm6 xs8>
  253 + <h5 class="my-1">{{ editedItem.status }}</h5>
197 254 </v-flex>
198 255 </v-layout>
199 256 </v-flex>
... ... @@ -221,7 +278,7 @@
221 278 <v-flex lg2 md3 xs7>
222 279 <v-text-field
223 280 class="pl-3"
224   - @keyup.enter="searchLibrary"
  281 + @keyup.enter="getIssueList"
225 282 v-model="libraryId"
226 283 placeholder="fill your library Id"
227 284 ></v-text-field>
... ... @@ -230,7 +287,7 @@
230 287 <v-btn
231 288 round
232 289 class="black mt-1 right hidden-xs-only"
233   - @click="searchLibrary"
  290 + @click="getIssueList"
234 291 :loading="loadingSearch"
235 292 dark
236 293 >Search</v-btn>
... ... @@ -238,7 +295,7 @@
238 295 round
239 296 class="black mt-4 right hidden-sm-only hidden-xl-only hidden-md-only hidden-lg-only"
240 297 :loading="loadingSearch"
241   - @click="searchLibrary"
  298 + @click="getIssueList"
242 299 small
243 300 dark
244 301 >Search</v-btn>
... ... @@ -251,11 +308,17 @@
251 308 :pagination.sync="pagination"
252 309 :search="search"
253 310 >
254   - <template slot="items" slot-scope="props">
  311 + <template slot="items" slot-scope="props" v-if="props.item.isReturn != true">
255 312 <td class="text-xs-center">{{ props.index + 1}}</td>
256   - <td id="td" class="text-xs-center">{{ props.item.title}}</td>
257   - <td id="td" class="text-xs-center">{{ props.item.description}}</td>
258   -
  313 + <td id="td" class="text-xs-center">{{ props.item.bookId.name}}</td>
  314 + <td id="td" class="text-xs-center">{{ props.item.serialNumber}}</td>
  315 + <td id="td" class="text-xs-center">{{ dates(props.item.created) }}</td>
  316 + <td id="td" class="text-xs-center">{{ dates(props.item.dueDate) }}</td>
  317 + <td id="td" class="text-xs-center">
  318 + <span
  319 + class="green lighten-1 pa-2 white--text paymentStatus"
  320 + >{{ props.item.bookId.status}}</span>
  321 + </td>
259 322 <td class="text-xs-center">
260 323 <span>
261 324 <img
... ... @@ -273,8 +336,8 @@
273 336 <img
274 337 style="cursor:pointer;width:20px; height:20px; "
275 338 class="mr-5"
276   - @click="deleteItem(props.item)"
277   - src="/static/icon/delete1.png"
  339 + @click="returnBook(props.item)"
  340 + src="/static/icon/return.jpg"
278 341 />
279 342 </span>
280 343 </td>
... ... @@ -383,7 +446,7 @@
383 446 <v-flex xs12>
384 447 <v-layout>
385 448 <v-flex xs4 class="pt-4 subheading">
386   - <label class="right">Serial No:</label>
  449 + <label class="right">Due Date:</label>
387 450 </v-flex>
388 451 <v-flex xs4 class="ml-3">
389 452 <v-menu
... ... @@ -401,7 +464,7 @@
401 464 <v-text-field
402 465 slot="activator"
403 466 v-model="date"
404   - label="Picker without buttons"
  467 + label="Select Due Date"
405 468 append-icon="event"
406 469 readonly
407 470 ></v-text-field>
... ... @@ -449,13 +512,16 @@
449 512 <script>
450 513 import http from "@/Services/http.js";
451 514 import Util from "@/util";
  515 +import moment from "moment";
452 516  
453 517 export default {
454 518 data: () => ({
455 519 snackbar: false,
456 520 date: null,
  521 + menu1: false,
457 522 menu2: false,
458 523 color: "",
  524 + dueDate: null,
459 525 y: "top",
460 526 x: "right",
461 527 mode: "",
... ... @@ -491,11 +557,28 @@ export default {
491 557 sortable: false,
492 558 value: "No"
493 559 },
494   - { text: "Image", vaue: "image", sortable: false, align: "center" },
495   - { text: "Title", value: "title", sortable: false, align: "center" },
  560 + { text: "Book", vaue: "name", sortable: false, align: "center" },
  561 + {
  562 + text: "Serial Number",
  563 + value: "serialNumber",
  564 + sortable: false,
  565 + align: "center"
  566 + },
  567 + {
  568 + text: "Issue Date",
  569 + value: "created",
  570 + sortable: false,
  571 + align: "center"
  572 + },
  573 + {
  574 + text: "Due Date",
  575 + value: "dueDate",
  576 + sortable: false,
  577 + align: "center"
  578 + },
496 579 {
497   - text: "Description",
498   - value: "description",
  580 + text: "Status",
  581 + value: "status",
499 582 sortable: false,
500 583 align: "center"
501 584 },
... ... @@ -513,35 +596,37 @@ export default {
513 596 disable: false
514 597 }),
515 598 methods: {
516   - getSections(_id) {
517   - console.log("_id", _id);
518   - http()
519   - .get(
520   - "/getSectionsList",
521   - { params: { classId: _id } },
522   - {
523   - headers: { Authorization: "Bearer " + this.token }
524   - }
525   - )
526   - .then(response => {
527   - this.addSection = response.data.data;
528   - // console.log("getSectionsList=====>", this.addSection);
529   - })
530   - .catch(err => {
531   - console.log("err====>", err);
532   - // this.$router.replace({ path: '/' });
533   - });
  599 + // getIssueList() {
  600 + // console.log("_id", _id);
  601 + // http()
  602 + // .get(
  603 + // "/getBooksIssueList",
  604 + // { params: { libraryId: this.libraryId } },
  605 + // {
  606 + // headers: { Authorization: "Bearer " + this.token }
  607 + // }
  608 + // )
  609 + // .then(response => {
  610 + // // this.addSection = response.data.data;
  611 + // console.log("getSectionsList=====>", response.data.data);
  612 + // })
  613 + // .catch(err => {
  614 + // console.log("err====>", err);
  615 + // // this.$router.replace({ path: '/' });
  616 + // });
  617 + // },
  618 + dates: function(date) {
  619 + return moment(date).format("MMMM DD, YYYY");
534 620 },
535 621 pickFile() {
536 622 this.$refs.image.click();
537 623 },
538   - searchLibrary() {
  624 + getIssueList() {
539 625 this.showLoader = true;
540 626 this.loadingSearch = true;
541   - var token = this.$store.state.token;
542 627 http()
543 628 .get(
544   - "/getLibrary",
  629 + "/getBooksIssueList",
545 630 {
546 631 params: { libraryId: this.libraryId }
547 632 },
... ... @@ -550,11 +635,9 @@ export default {
550 635 }
551 636 )
552 637 .then(response => {
553   - // this.desserts = response.data.data;
  638 + this.desserts = response.data.data;
554 639 this.showLoader = false;
555 640 this.loadingSearch = false;
556   -
557   - // console.log("getIssueList=====>",this.desserts)
558 641 })
559 642 .catch(error => {
560 643 // console.log("err====>", err);
... ... @@ -570,31 +653,38 @@ export default {
570 653 });
571 654 },
572 655 editItem(item) {
  656 + console.log("item", item);
573 657 this.editedIndex = this.desserts.indexOf(item);
574 658 this.editedItem = Object.assign({}, item);
  659 + // console.log("this.editedItem", this.editedItem);
  660 + this.editedItem.name = item.bookId.name;
  661 + this.editedItem.status = item.bookId.status;
  662 + this.editedItem.dueDate =
  663 + this.editedItem.dueDate != undefined
  664 + ? (this.editedItem.dueDate = this.editedItem.dueDate.substring(0, 10))
  665 + : (this.editedItem.dueDate = "");
575 666 this.dialog = true;
576 667 },
577 668 profile(item) {
578 669 this.editedIndex = this.desserts.indexOf(item);
579 670 this.editedItem = Object.assign({}, item);
  671 + this.editedItem.name = item.bookId.name;
  672 + this.editedItem.status = item.bookId.status;
  673 +
580 674 this.dialog1 = true;
581 675 },
582   - deleteItem(item) {
583   - let deleteIssue = {
584   - issueId: item._id
  676 + returnBook(item) {
  677 + let returnBook = {
  678 + bookIssueId: item._id
585 679 };
586 680 http()
587   - .delete(
588   - "/deleteIssue",
589   - confirm("Are you sure you want to delete this?") && {
590   - params: deleteIssue
591   - }
  681 + .put(
  682 + "/returnBook",
  683 + confirm("Are you sure you want to return this?") && returnBook
592 684 )
593 685 .then(response => {
594   - // console.log("deleteIssue",deleteIssue)
595   - if ((this.snackbar = true)) {
596   - this.text = "Successfully delete Existing Issue";
597   - }
  686 + this.snackbar = true;
  687 + this.text = "Successfully return Issue a Book ";
598 688 this.getIssueList();
599 689 })
600 690 .catch(error => {
... ... @@ -616,60 +706,64 @@ export default {
616 706 },
617 707 close() {
618 708 this.dialog = false;
619   - setTimeout(() => {
620   - this.editedItem = Object.assign({}, this.defaultItem);
621   - this.editedIndex = -1;
622   - }, 300);
623 709 },
624 710 close1() {
625 711 this.dialog1 = false;
626 712 },
627 713 submit() {
628 714 this.loading = true;
629   - // if (this.$refs.form.validate()){
630   - // let createBook = {
631   - // bookId: this.bookId,
632   - // author: this.addIssue.author,
633   - // subjectCode: this.addIssue.subjectCode,
634   - // libraryId: this.libraryID,
635   - // serialNumber: this.serialNo,
636   - // note: this.note,
637   - // dueDate: this.date
638   - // };
639   - // console.log("====================", createBook);
640   - // http()
641   - // .post("/createBookIssue", createBook)
642   - // .then(response => {
643   - // this.snackbar = true;
644   - // this.text = "New Issue added successfully";
645   - // // this.getIssueList();
646   - // this.color = "succses";
647   - // this.loading = false;
648   - // this.clear();
649   - // })
650   - // .catch(error => {
651   - // if ((this.snackbar = true)) {
652   - // this.text = error.response.data.message;
653   - // }
654   - // });
655   - // }
  715 + if (this.$refs.form.validate()) {
  716 + let createBook = {
  717 + bookId: this.bookId,
  718 + author: this.addIssue.author,
  719 + subjectCode: this.addIssue.subjectCode,
  720 + libraryId: this.libraryID,
  721 + serialNumber: this.serialNo,
  722 + note: this.note,
  723 + dueDate: this.date
  724 + };
  725 + console.log("====================", createBook);
  726 + http()
  727 + .post("/createBookIssue", createBook)
  728 + .then(response => {
  729 + this.snackbar = true;
  730 + this.text = "New Issue a Book added successfully";
  731 + this.getIssueList();
  732 + this.color = "succses";
  733 + this.loading = false;
  734 + this.clear();
  735 + })
  736 + .catch(error => {
  737 + if ((this.snackbar = true)) {
  738 + this.text = error.response.data.message;
  739 + this.color = "red";
  740 + }
  741 + });
  742 + }
656 743 },
657 744 clear() {
658 745 this.$refs.form.reset();
  746 + this.disable = false;
659 747 },
660 748 save() {
  749 + this.editedItem.bookIssueId = this.editedItem._id;
  750 + this.editedItem.bookId = this.editedItem.bookId._id
661 751 http()
662   - .put("/updateIssue")
  752 + .put("/updateBookIssue", this.editedItem)
663 753 .then(response => {
664   - // console.log("updateIssue",updateIssue);
665   - if ((this.snackbar = true)) {
666   - this.text = "Successfully Edit Existing Issue";
667   - }
  754 + console.log("updateIssue", response);
  755 + this.snackbar = true;
  756 + this.text = "Successfully Edit Issue a Book";
  757 + this.color = "green";
668 758 this.getIssueList();
669 759 this.close();
670 760 })
671 761 .catch(error => {
672 762 // console.log(error);
  763 + if ((this.snackbar = true)) {
  764 + this.text = error.response.data.message;
  765 + this.color = "red";
  766 + }
673 767 });
674 768 },
675 769 getBookData() {
... ...
static/icon/return.jpg

34.9 KB