Переглянути джерело

Edit timeshare weeks

master
Lene 4 роки тому
джерело
коміт
578648fe22

+ 58
- 33
src/components/admin/status/editTimeShareAdminPage.vue Переглянути файл

19
               <div class="form-row">
19
               <div class="form-row">
20
                 <div class="form-group col-md-6">
20
                 <div class="form-group col-md-6">
21
                   <div class="input-group">
21
                   <div class="input-group">
22
-                    <label v-if="!selectedRegion" class="uniSelectLabel" for="weekInfoRegionSelect"
23
-                      >REGION</label
24
-                    >
22
+                    <label
23
+                      v-if="!selectedRegion"
24
+                      class="uniSelectLabel"
25
+                      for="weekInfoRegionSelect"
26
+                    >REGION</label>
25
                   </div>
27
                   </div>
26
                   <float-label label="REGION" fixed>
28
                   <float-label label="REGION" fixed>
27
                     <select
29
                     <select
29
                       v-model="selectedRegion"
31
                       v-model="selectedRegion"
30
                       style="font-size: 15px"
32
                       style="font-size: 15px"
31
                     >
33
                     >
32
-                      <option v-for="(region, r) in regions" :key="r" :value="region.regionCode">{{
34
+                      <option v-for="(region, r) in regions" :key="r" :value="region.regionCode">
35
+                        {{
33
                         region.regionName
36
                         region.regionName
34
-                      }}</option>
37
+                        }}
38
+                      </option>
35
                     </select>
39
                     </select>
36
                   </float-label>
40
                   </float-label>
37
 
41
 
48
                           v-for="(resort, r) in filteredResort"
52
                           v-for="(resort, r) in filteredResort"
49
                           :key="r"
53
                           :key="r"
50
                           :value="resort.resortCode"
54
                           :value="resort.resortCode"
51
-                          >{{ resort.resortName }}</option
52
-                        >
55
+                        >{{ resort.resortName }}</option>
53
                       </select>
56
                       </select>
54
                     </float-label>
57
                     </float-label>
55
 
58
 
71
                 </div>
74
                 </div>
72
                 <div class="form-group col-md-6">
75
                 <div class="form-group col-md-6">
73
                   <div v-if="weekParam.otherResort">
76
                   <div v-if="weekParam.otherResort">
74
-                    <label v-if="!weekParam.region" class="uniSelectLabel" for="region"
75
-                      >REGION</label
76
-                    >
77
+                    <label v-if="!weekParam.region" class="uniSelectLabel" for="region">REGION</label>
77
                   </div>
78
                   </div>
78
                   <float-label>
79
                   <float-label>
79
                     <select
80
                     <select
83
                       id="region"
84
                       id="region"
84
                       v-model="weekParam.region"
85
                       v-model="weekParam.region"
85
                     >
86
                     >
86
-                      <option v-for="(region, r) in regions" :key="r">{{
87
+                      <option v-for="(region, r) in regions" :key="r">
88
+                        {{
87
                         region.regionName
89
                         region.regionName
88
-                      }}</option>
90
+                        }}
91
+                      </option>
89
                     </select>
92
                     </select>
90
                   </float-label>
93
                   </float-label>
91
                 </div>
94
                 </div>
242
                     id="customSwitch2"
245
                     id="customSwitch2"
243
                     :checked="sellItem.currentYearBanked"
246
                     :checked="sellItem.currentYearBanked"
244
                   />
247
                   />
245
-                  <label class="custom-control-label" for="customSwitch2">
246
-                    {{ sellItem.currentYearBanked ? "Yes" : "No" }}
247
-                  </label>
248
+                  <label
249
+                    class="custom-control-label"
250
+                    for="customSwitch2"
251
+                  >{{ sellItem.currentYearBanked ? "Yes" : "No" }}</label>
248
                   <div
252
                   <div
249
                     class="spacebanked1"
253
                     class="spacebanked1"
250
                     :class="{ 'spacebanked1--clicked': sellItem.currentYearBanked }"
254
                     :class="{ 'spacebanked1--clicked': sellItem.currentYearBanked }"
253
                       <label
257
                       <label
254
                         for="If yes, please confirm with whom"
258
                         for="If yes, please confirm with whom"
255
                         v-if="sellItem.currentYearBanked"
259
                         v-if="sellItem.currentYearBanked"
256
-                        >Please confirm with whom</label
257
-                      >
260
+                      >Please confirm with whom</label>
258
                     </div>
261
                     </div>
259
                     <div class="validation"></div>
262
                     <div class="validation"></div>
260
                   </div>
263
                   </div>
361
                       placeholder="Cell Number"
364
                       placeholder="Cell Number"
362
                       data-rule="minlen:4"
365
                       data-rule="minlen:4"
363
                       data-msg="Please enter your cell number"
366
                       data-msg="Please enter your cell number"
364
-                      v-model="week.owner.cellNumner"
367
+                      v-model="week.owner.cellNumber"
365
                     />
368
                     />
366
                   </float-label>
369
                   </float-label>
367
 
370
 
390
             <div class="form">
393
             <div class="form">
391
               <div class="row">
394
               <div class="row">
392
                 <div class="form-group col-md-6">
395
                 <div class="form-group col-md-6">
393
-                  <label v-if="!weekParam.weekStatus" class="uniSelectLabel" for="status"
394
-                    >STATUS</label
395
-                  >
396
+                  <label v-if="!weekParam.weekStatus" class="uniSelectLabel" for="status">STATUS</label>
396
                   <float-label label="STATUS" fixed>
397
                   <float-label label="STATUS" fixed>
397
                     <select
398
                     <select
398
                       class="form-control uniSelect"
399
                       class="form-control uniSelect"
406
                   </float-label>
407
                   </float-label>
407
                 </div>
408
                 </div>
408
                 <div class="form-group col-md-6">
409
                 <div class="form-group col-md-6">
409
-                  <label v-if="!weekParam.publish" class="uniSelectLabel" for="publish"
410
-                    >Publish</label
411
-                  >
410
+                  <label v-if="!weekParam.publish" class="uniSelectLabel" for="publish">Publish</label>
412
                   <float-label label="Publish" fixed>
411
                   <float-label label="Publish" fixed>
413
                     <select
412
                     <select
414
                       class="form-control uniSelect"
413
                       class="form-control uniSelect"
515
     this.selectedWeekType = this.weekParam.weekType;
514
     this.selectedWeekType = this.weekParam.weekType;
516
     this.selectedStatus = this.weekParam.status;
515
     this.selectedStatus = this.weekParam.status;
517
     this.selectedPublish = this.weekParam.publish;
516
     this.selectedPublish = this.weekParam.publish;
518
-    var date = new Date(this.weekParam.arrivalDate).toISOString().substring(0, 10);
517
+    var date = new Date(this.weekParam.arrivalDate)
518
+      .toISOString()
519
+      .substring(0, 10);
519
     this.dateParam = date;
520
     this.dateParam = date;
520
-    var depDate = new Date(this.weekParam.departureDate).toISOString().substring(0, 10);
521
+    var depDate = new Date(this.weekParam.departureDate)
522
+      .toISOString()
523
+      .substring(0, 10);
521
     this.depDateParam = depDate;
524
     this.depDateParam = depDate;
522
-    var datePub = new Date(this.weekParam.publish).toISOString().substring(0, 10);
525
+    var datePub = new Date(this.weekParam.publish)
526
+      .toISOString()
527
+      .substring(0, 10);
523
     this.pubDateParam = datePub;
528
     this.pubDateParam = datePub;
524
   },
529
   },
525
   created() {
530
   created() {
553
     },
558
     },
554
     filteredResort() {
559
     filteredResort() {
555
       let list = [];
560
       let list = [];
556
-      if (this.sellItem && this.sellItem.region && this.sellItem.region.regionCode) {
561
+      if (
562
+        this.sellItem &&
563
+        this.sellItem.region &&
564
+        this.sellItem.region.regionCode
565
+      ) {
557
         const item = this.detailedRegion.find(
566
         const item = this.detailedRegion.find(
558
           region => region.region.regionCode === this.sellItem.region.regionCode
567
           region => region.region.regionCode === this.sellItem.region.regionCode
559
         );
568
         );
571
   },
580
   },
572
   methods: {
581
   methods: {
573
     ...mapActions("individual", ["getIndividual"]),
582
     ...mapActions("individual", ["getIndividual"]),
574
-    ...mapActions("timeshare", ["initTimeshare", "onResortChange", "saveWeek", "getBlankWeek"]),
583
+    ...mapActions("timeshare", [
584
+      "initTimeshare",
585
+      "onResortChange",
586
+      "saveWeek",
587
+      "getBlankWeek"
588
+    ]),
575
     ...mapActions("payment", ["addPayment"]),
589
     ...mapActions("payment", ["addPayment"]),
576
     ...mapActions("bank", ["getBanks"]),
590
     ...mapActions("bank", ["getBanks"]),
577
     ...mapActions("myWeeks", ["getItems", "getWeek", "editSave"]),
591
     ...mapActions("myWeeks", ["getItems", "getWeek", "editSave"]),
605
           this.weekParam.maxSleep = sleepMax;
619
           this.weekParam.maxSleep = sleepMax;
606
         }
620
         }
607
       });
621
       });
608
-      this.weekParam.arrivalDate = new Date(this.dateParam).toISOString().substring(0, 10);
609
-      this.weekParam.departureDate = new Date(this.depDateParam).toISOString().substring(0, 10);
610
-      this.weekParam.publishedDate = new Date(this.pubDateParam).toISOString().substring(0, 10);
622
+      if (this.week.owner.cellNumber === "") {
623
+        this.week.owner.cellNumber = "0000000000";
624
+      }
625
+      this.weekParam.arrivalDate = new Date(this.dateParam)
626
+        .toISOString()
627
+        .substring(0, 10);
628
+      this.weekParam.departureDate = new Date(this.depDateParam)
629
+        .toISOString()
630
+        .substring(0, 10);
631
+      this.weekParam.publishedDate = new Date(this.pubDateParam)
632
+        .toISOString()
633
+        .substring(0, 10);
611
       this.weekParam.regionId = this.weekParam.region.id;
634
       this.weekParam.regionId = this.weekParam.region.id;
612
       this.weekParam.agentId = this.week.agentId;
635
       this.weekParam.agentId = this.week.agentId;
613
       this.weekParam.bankedWith = this.week.bankedWith;
636
       this.weekParam.bankedWith = this.week.bankedWith;
619
       delete this.weekParam.agency;
642
       delete this.weekParam.agency;
620
       delete this.weekParam.agent;
643
       delete this.weekParam.agent;
621
       delete this.status;
644
       delete this.status;
622
-      console.log(this.weekParam);
645
+      delete this.weekParam.owner.howMarried;
646
+      delete this.weekParam.cellNumber;
647
+      console.log(JSON.stringify(this.weekParam));
623
       this.editSave(this.weekParam);
648
       this.editSave(this.weekParam);
624
     },
649
     },
625
     resortChange() {
650
     resortChange() {

+ 32
- 36
src/store/modules/timeshare/myWeeks.js Переглянути файл

1
 /* eslint-disable no-restricted-syntax */
1
 /* eslint-disable no-restricted-syntax */
2
 /* eslint-disable guard-for-in */
2
 /* eslint-disable guard-for-in */
3
-import axios from 'axios';
3
+import axios from "axios";
4
 
4
 
5
 export default {
5
 export default {
6
   namespaced: true,
6
   namespaced: true,
7
   state: {
7
   state: {
8
-    items: [],
8
+    items: []
9
   },
9
   },
10
   mutations: {
10
   mutations: {
11
     setItems(state, list) {
11
     setItems(state, list) {
15
       state.week = item;
15
       state.week = item;
16
     },
16
     },
17
     updateItem(state, item) {
17
     updateItem(state, item) {
18
-      var index
19
-    var count = 0
20
-    state.items.forEach((el) => {
21
-      if (el.id === item.id) {
22
-        index = count
23
-      }
24
-      count++
25
-    })
18
+      var index;
19
+      var count = 0;
20
+      state.items.forEach(el => {
21
+        if (el.id === item.id) {
22
+          index = count;
23
+        }
24
+        count++;
25
+      });
26
 
26
 
27
-    Object.assign(state.items[index], item)
28
-    },
27
+      Object.assign(state.items[index], item);
28
+    }
29
   },
29
   },
30
   getters: {
30
   getters: {
31
     getNeedsVerify(state) {
31
     getNeedsVerify(state) {
32
-      return _.filter(state.items, x => x.status && x.status.code === 'A1');
33
-    },
32
+      return _.filter(state.items, x => x.status && x.status.code === "A1");
33
+    }
34
     // removeListing(state, id) {
34
     // removeListing(state, id) {
35
     //   state.myWeeks.pop(state.myWeeks.find(w => w.id === id));
35
     //   state.myWeeks.pop(state.myWeeks.find(w => w.id === id));
36
     // },
36
     // },
37
   },
37
   },
38
   actions: {
38
   actions: {
39
-    getItems({
40
-      commit,
41
-    }, id) {
42
-      axios.get(`/api/timeshareweek/getMyWeek/${id}`).then(r => commit('setItems', r.data)).catch(
43
-        console
44
-          .error,
45
-      );
39
+    getItems({ commit }, id) {
40
+      axios
41
+        .get(`/api/timeshareweek/getMyWeek/${id}`)
42
+        .then(r => commit("setItems", r.data))
43
+        .catch(console.error);
46
     },
44
     },
47
-    verifyWeek({
48
-      commit,
49
-    }, id) {
45
+    verifyWeek({ commit }, id) {
50
       try {
46
       try {
51
         axios.post(`/api/timeshareweek/verifyweek/${id}`).catch(console.error);
47
         axios.post(`/api/timeshareweek/verifyweek/${id}`).catch(console.error);
52
       } catch (err) {
48
       } catch (err) {
64
     // }
60
     // }
65
     getWeek({ commit }, id) {
61
     getWeek({ commit }, id) {
66
       axios
62
       axios
67
-      .get(`/api/timeshareweek/${id}`)
68
-      .then(r => {
69
-        console.log(JSON.stringify(r));
70
-        commit('setItem', r.data);
71
-      })
72
-      .catch(console.error);
63
+        .get(`/api/timeshareweek/${id}`)
64
+        .then(r => {
65
+          console.log(JSON.stringify(r));
66
+          commit("setItem", r.data);
67
+        })
68
+        .catch(console.error);
73
     },
69
     },
74
     editSave({ commit }, week) {
70
     editSave({ commit }, week) {
75
       axios
71
       axios
76
-      .put(`/api/timeshareweek`, week)
77
-      .then(r => {
78
-        commit('updateItem', r.data);
79
-      })
80
-      .catch(console.error);
72
+        .put(`/api/timeshareweek`, week)
73
+        .then(r => {
74
+          commit("setItem", r.data);
75
+        })
76
+        .catch(console.error);
81
     }
77
     }
82
-  },
78
+  }
83
 };
79
 };

Завантаження…
Відмінити
Зберегти