Blame view

src/pages/Account/feeTypes.vue 13.9 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
    <v-container fluid class="body-color">
      <!-- ****** EDIT  SECTION  ****** -->
      <v-dialog v-model="editFeeTypeDialog" max-width="600px">
        <v-card flat class="card-style pa-2" dark>
          <v-layout>
            <v-flex xs12>
              <label class="title text-xs-center">Edit Fee Type</label>
              <v-icon size="24" class="right" @click="editFeeTypeDialog = false">cancel</v-icon>
            </v-flex>
          </v-layout>
          <v-container fluid>
            <v-layout wrap justify-center>
              <v-flex xs12 sm11>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">Fee Type:</label>
                  </v-flex>
                  <v-flex xs8>
                    <v-text-field
                      class="ml-3"
                      v-model="editedItem.feeType"
                      placeholder="fill your Fee Type"
                      required
                    ></v-text-field>
99cd79184   Neeraj Sharma   implement all tas...
26
27
                  </v-flex>
                </v-layout>
68d742034   Neeraj Sharma   implement new des...
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">Note:</label>
                  </v-flex>
                  <v-flex xs8>
                    <v-textarea
                      name="input-7-1"
                      class="ml-3"
                      v-model="editedItem.note"
                      placeholder="fill your Note"
                      multi-line
                      required
                    ></v-textarea>
                  </v-flex>
                </v-layout>
                <v-card-actions class="hidden-xs-only hidden-sm-only ">
                  <v-spacer></v-spacer>
                  <v-btn round dark @click="save" class="add-button">Save</v-btn>
                </v-card-actions>
                 <v-card-actions class="hidden-md-only hidden-lg-only hidden-xl-only">
                  <v-spacer></v-spacer>
                  <v-btn round dark @click="save" class="add-button">Save</v-btn>
                  <v-spacer></v-spacer>
                </v-card-actions>
              </v-flex>
            </v-layout>
          </v-container>
        </v-card>
      </v-dialog>
687e0b929   Neeraj Sharma   add user,attenden...
57

68d742034   Neeraj Sharma   implement new des...
58
      <!-- ****** PROFILE VIEW FEE TYPE DATA ******  -->
687e0b929   Neeraj Sharma   add user,attenden...
59

68d742034   Neeraj Sharma   implement new des...
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
      <v-dialog v-model="viewFeeTypeDialog" max-width="400px">
        <v-card flat class="card-style pa-3" dark>
          <v-layout>
            <v-flex xs12>
              <label class="title text-xs-center">View Fee Type</label>
              <v-icon size="24" class="right" @click="viewFeeTypeDialog = false">cancel</v-icon>
            </v-flex>
          </v-layout>
          <v-container grid-list-md>
            <v-layout wrap>
              <v-flex>
                <v-layout>
                  <v-flex xs5 sm6>
                    <h5 class="right my-1">
                      <b>Fee Type:</b>
                    </h5>
                  </v-flex>
                  <v-flex sm6 xs8>
                    <h5 class="my-1">{{ editedItem.feeType }}</h5>
                  </v-flex>
                </v-layout>
                <v-layout>
                  <v-flex xs5 sm6>
                    <h5 class="right my-1">
                      <b>Note:</b>
                    </h5>
                  </v-flex>
                  <v-flex sm6 xs8>
                    <h5 class="my-1">{{ editedItem.note }}</h5>
                  </v-flex>
                </v-layout>
              </v-flex>
            </v-layout>
          </v-container>
        </v-card>
      </v-dialog>
687e0b929   Neeraj Sharma   add user,attenden...
96

68d742034   Neeraj Sharma   implement new des...
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
      <!-- ****** EXISTING-FEETYPE TABLE ****** -->
      <v-toolbar color="transparent" flat>
        <v-btn
          fab
          dark
          class="open-dialog-button hidden-xl-only hidden-md-only hidden-lg-only"
          small
          @click="addFeeTypeDialog = true"
        >
          <v-icon dark>add</v-icon>
        </v-btn>
        <v-btn
          round
          class="open-dialog-button hidden-sm-only hidden-xs-only"
          dark
          @click="addFeeTypeDialog = true"
        >
          <v-icon class="white--text pr-1" size="20">add</v-icon>Add Fee Type
        </v-btn>
        <v-spacer></v-spacer>
        <v-card-title class="body-1" v-show="show">
          <v-btn icon large flat @click="displaySearch">
            <v-avatar size="27">
aa310d61a   Shikha Mishra   added functionali...
120
              <img src="/static/icon/search.png" alt="icon" />
68d742034   Neeraj Sharma   implement new des...
121
122
123
            </v-avatar>
          </v-btn>
        </v-card-title>
612b79bb4   Amber Dev   made serch auto f...
124
        <v-flex xs8 sm8 md3 lg2 v-if="showSearch">
68d742034   Neeraj Sharma   implement new des...
125
          <v-layout>
612b79bb4   Amber Dev   made serch auto f...
126
            <v-text-field autofocus v-model="search" label="Search" prepend-inner-icon="search" color="primary"></v-text-field>
68d742034   Neeraj Sharma   implement new des...
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
            <v-icon @click="closeSearch" color="error">close</v-icon>
          </v-layout>
        </v-flex>
      </v-toolbar>
      <v-data-table
        :headers="headers"
        :items="feeTypeList"
        :pagination.sync="pagination"
        :search="search"
      >
        <template slot="items" slot-scope="props">
          <tr class="tr">
            <td class="td td-row">{{ props.index + 1}}</td>
            <td class="text-xs-center td td-row">{{ props.item.feeType }}</td>
            <td class="text-xs-center td td-row">{{ props.item.note }}</td>
            <!-- <td id="td" class="text-xs-center">{{ props.item.session}}</td> -->
687e0b929   Neeraj Sharma   add user,attenden...
143

68d742034   Neeraj Sharma   implement new des...
144
145
146
147
148
149
150
151
            <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...
152
                  src="/static/icon/view.png"
68d742034   Neeraj Sharma   implement new des...
153
154
155
156
157
158
159
160
161
                />
                <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...
162
                  src="/static/icon/edit.png"
68d742034   Neeraj Sharma   implement new des...
163
164
165
166
167
168
169
170
171
                />
                <span>Edit</span>
              </v-tooltip>
              <v-tooltip top>
                <img
                  slot="activator"
                  style="cursor:pointer; width:20px; height:20px; "
                  @click="deleteItem(props.item)"
                  class="mr-3"
aa310d61a   Shikha Mishra   added functionali...
172
                  src="/static/icon/delete.png"
68d742034   Neeraj Sharma   implement new des...
173
174
175
176
177
178
179
180
181
182
183
184
185
186
                />
                <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>
687e0b929   Neeraj Sharma   add user,attenden...
187

68d742034   Neeraj Sharma   implement new des...
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
      <!-- ****** ADD Fee Type ****** -->
      <v-dialog v-model="addFeeTypeDialog" max-width="500px">
        <v-card flat class="card-style pa-2" dark>
          <v-layout>
            <v-flex xs12>
              <label class="title text-xs-center">Add Fee Type</label>
              <v-icon size="24" class="right" @click="addFeeTypeDialog = false">cancel</v-icon>
            </v-flex>
          </v-layout>
          <v-container fluid fill-height>
            <v-layout align-center>
              <v-flex xs12 class="mt-4">
                <v-form ref="form" v-model="valid" lazy-validation>
                  <v-layout>
                    <v-flex xs4 class="pt-4 subheading">
                      <label class="right">Fee Type:</label>
                    </v-flex>
                    <v-flex xs7 class="ml-3">
                      <v-text-field
                        v-model="feeTypeData.feeType"
                        placeholder="fill your Fee Type"
                        type="text"
                        :rules="feetTypeRules"
                        required
                      ></v-text-field>
                    </v-flex>
                  </v-layout>
                  <v-layout>
                    <v-flex xs4 class="pt-4 subheading">
                      <label class="right">Note:</label>
                    </v-flex>
                    <v-flex xs7 class="ml-3">
                      <v-textarea
                        name="input-7-1"
                        v-model="feeTypeData.note"
                        placeholder="fill your Note"
                        type="text"
                        multi-line
                        required
                      ></v-textarea>
                    </v-flex>
                  </v-layout>
                  <!-- <v-layout>
687e0b929   Neeraj Sharma   add user,attenden...
231
232
233
234
235
236
237
238
239
240
241
                          <v-flex xs4 class="pt-4 subheading">
                            <label class="right">Monthly:</label>
                          </v-flex>
                          <v-flex xs6 class="ml-3">
                            <v-checkbox
                              v-model="feeTypeData.monthly"
                              :rules="monthlyRules"
                              multi-line
                              required
                            ></v-checkbox>
                          </v-flex>
68d742034   Neeraj Sharma   implement new des...
242
243
244
245
246
247
248
249
                  </v-layout>-->
                  <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">Add</v-btn>
                      </v-card-actions>
687e0b929   Neeraj Sharma   add user,attenden...
250
251
                    </v-flex>
                  </v-layout>
68d742034   Neeraj Sharma   implement new des...
252
253
254
                </v-form>
              </v-flex>
            </v-layout>
687e0b929   Neeraj Sharma   add user,attenden...
255
          </v-container>
68d742034   Neeraj Sharma   implement new des...
256
257
        </v-card>
      </v-dialog>
687e0b929   Neeraj Sharma   add user,attenden...
258
259
260
      <div class="loader" v-if="showLoader">
        <v-progress-circular indeterminate color="white"></v-progress-circular>
      </div>
68d742034   Neeraj Sharma   implement new des...
261
262
263
264
265
266
267
268
269
      <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...
270
271
272
273
  </template>
  
  <script>
  import http from "@/Services/http.js";
687e0b929   Neeraj Sharma   add user,attenden...
274
275
276
277
278
279
280
  
  export default {
    data: () => ({
      snackbar: false,
      y: "top",
      x: "right",
      mode: "",
68d742034   Neeraj Sharma   implement new des...
281
      timeout: 5000,
687e0b929   Neeraj Sharma   add user,attenden...
282
      text: "",
68d742034   Neeraj Sharma   implement new des...
283
      color: "",
687e0b929   Neeraj Sharma   add user,attenden...
284
285
286
287
      showLoader: false,
      loading: false,
      date: null,
      search: "",
68d742034   Neeraj Sharma   implement new des...
288
289
      editFeeTypeDialog: false,
      viewFeeTypeDialog: false,
687e0b929   Neeraj Sharma   add user,attenden...
290
      valid: true,
68d742034   Neeraj Sharma   implement new des...
291
292
293
      show: true,
      showSearch: false,
      addFeeTypeDialog: false,
687e0b929   Neeraj Sharma   add user,attenden...
294
      validEdit: true,
687e0b929   Neeraj Sharma   add user,attenden...
295
      pagination: {
68d742034   Neeraj Sharma   implement new des...
296
        rowsPerPage: 10
687e0b929   Neeraj Sharma   add user,attenden...
297
298
299
300
301
302
303
      },
      feetTypeRules: [v => !!v || " Fee Type Name is required"],
      monthlyRules: [v => !!v || " Select Monthly"],
      noteRules: [v => !!v || " Note is required"],
      headers: [
        {
          text: "No",
68d742034   Neeraj Sharma   implement new des...
304
          align: "",
687e0b929   Neeraj Sharma   add user,attenden...
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
          sortable: false,
          value: "No"
        },
        {
          text: "fee Type",
          value: "feeType",
          sortable: false,
          align: "center"
        },
        { text: "Note", value: "note", sortable: false, align: "center" },
        // { text: "Session", value: "session", sortable: false, align: "center" },
        { text: "Action", value: "", sortable: false, align: "center" }
      ],
      feeTypeList: [],
      select: "",
      token: "",
      editedItem: {},
      feeTypeData: {}
    }),
    methods: {
      getFeeTypeList() {
        this.showLoader = true;
        http()
          .get("/getFeesList", {
99cd79184   Neeraj Sharma   implement all tas...
329
            params: { schoolId: this.$store.state.schoolId },
687e0b929   Neeraj Sharma   add user,attenden...
330
331
332
333
334
            headers: { Authorization: "Bearer " + this.token }
          })
          .then(response => {
            this.feeTypeList = response.data.data;
            this.showLoader = false;
687e0b929   Neeraj Sharma   add user,attenden...
335
          })
00e4bc4e1   Neeraj Sharma   fixed auntentication
336
          .catch(error => {
687e0b929   Neeraj Sharma   add user,attenden...
337
338
339
340
341
            this.showLoader = false;
            if (error.response.status === 401) {
              this.$router.replace({ path: "/" });
              this.$store.dispatch("setToken", null);
              this.$store.dispatch("Id", null);
00e4bc4e1   Neeraj Sharma   fixed auntentication
342
              this.$store.dispatch("Role", null);
687e0b929   Neeraj Sharma   add user,attenden...
343
344
345
346
347
348
            }
          });
      },
      editItem(item) {
        this.editedIndex = this.feeTypeList.indexOf(item);
        this.editedItem = Object.assign({}, item);
68d742034   Neeraj Sharma   implement new des...
349
        this.editFeeTypeDialog = true;
687e0b929   Neeraj Sharma   add user,attenden...
350
351
352
353
      },
      profile(item) {
        this.editedIndex = this.feeTypeList.indexOf(item);
        this.editedItem = Object.assign({}, item);
68d742034   Neeraj Sharma   implement new des...
354
        this.viewFeeTypeDialog = true;
687e0b929   Neeraj Sharma   add user,attenden...
355
356
      },
      deleteItem(item) {
006544386   Neeraj Sharma   implement task
357
        let deleteFeeType = {
687e0b929   Neeraj Sharma   add user,attenden...
358
359
360
361
362
363
          feeId: item._id
        };
        http()
          .delete(
            "/deleteFee",
            confirm("Are you sure you want to delete this?") && {
006544386   Neeraj Sharma   implement task
364
              params: deleteFeeType
687e0b929   Neeraj Sharma   add user,attenden...
365
366
367
            }
          )
          .then(response => {
68d742034   Neeraj Sharma   implement new des...
368
369
370
            this.snackbar = true;
            this.text = response.data.message;
            this.color = "green";
687e0b929   Neeraj Sharma   add user,attenden...
371
372
373
            this.getFeeTypeList();
          })
          .catch(error => {
68d742034   Neeraj Sharma   implement new des...
374
375
376
            this.snackbar = true;
            this.color = "error";
            this.text = error.response.data.message;
687e0b929   Neeraj Sharma   add user,attenden...
377
378
          });
      },
687e0b929   Neeraj Sharma   add user,attenden...
379
380
      close() {
        this.dialog = false;
687e0b929   Neeraj Sharma   add user,attenden...
381
382
383
384
385
386
387
388
389
390
      },
      close1() {
        this.dialog1 = false;
      },
      close2() {
        this.dialog2 = false;
      },
      submit() {
        if (this.$refs.form.validate()) {
          this.loading = true;
99cd79184   Neeraj Sharma   implement all tas...
391
          this.schoolId = this.$store.state.schoolId;
687e0b929   Neeraj Sharma   add user,attenden...
392
393
394
          http()
            .post("/createFee", this.feeTypeData)
            .then(response => {
687e0b929   Neeraj Sharma   add user,attenden...
395
              this.getFeeTypeList();
99cd79184   Neeraj Sharma   implement all tas...
396
              this.snackbar = true;
68d742034   Neeraj Sharma   implement new des...
397
398
              this.text = response.data.message;
              this.color = "green";
687e0b929   Neeraj Sharma   add user,attenden...
399
              this.clear();
68d742034   Neeraj Sharma   implement new des...
400
              this.addFeeTypeDialog = false;
687e0b929   Neeraj Sharma   add user,attenden...
401
402
403
404
              this.loading = false;
            })
            .catch(error => {
              // console.log(error);
99cd79184   Neeraj Sharma   implement all tas...
405
              this.snackbar = true;
68d742034   Neeraj Sharma   implement new des...
406
              this.color = "error";
99cd79184   Neeraj Sharma   implement all tas...
407
              this.text = error.response.data.message;
687e0b929   Neeraj Sharma   add user,attenden...
408
409
410
411
412
413
414
415
416
417
418
419
              this.loading = false;
            });
        }
      },
      clear() {
        this.$refs.form.reset();
      },
      save() {
        this.editedItem.feeId = this.editedItem._id;
        http()
          .put("/updateFee", this.editedItem)
          .then(response => {
68d742034   Neeraj Sharma   implement new des...
420
421
422
            this.snackbar = true;
            this.text = response.data.message;
            this.color = "green";
687e0b929   Neeraj Sharma   add user,attenden...
423
            this.getFeeTypeList();
acb6c9e2b   Shikha Mishra   issues solved rel...
424
            this.editFeeTypeDialog = false;
687e0b929   Neeraj Sharma   add user,attenden...
425
426
427
            this.close();
          })
          .catch(error => {
68d742034   Neeraj Sharma   implement new des...
428
429
            this.snackbar = true;
            this.color = "error";
687e0b929   Neeraj Sharma   add user,attenden...
430
            this.text = error.response.data.message;
687e0b929   Neeraj Sharma   add user,attenden...
431
          });
68d742034   Neeraj Sharma   implement new des...
432
433
434
435
436
437
438
439
      },
      displaySearch() {
        (this.show = false), (this.showSearch = true);
      },
      closeSearch() {
        this.showSearch = false;
        this.show = true;
        this.search = "";
687e0b929   Neeraj Sharma   add user,attenden...
440
441
442
443
444
      }
    },
    mounted() {
      this.token = this.$store.state.token;
      this.getFeeTypeList();
687e0b929   Neeraj Sharma   add user,attenden...
445
446
    }
  };
68d742034   Neeraj Sharma   implement new des...
447
  </script>