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

field editor comp - WIP

master
George Williams 5 роки тому
джерело
коміт
2bb817ec66

+ 4
- 4
src/components/property/propertyFieldEditor.vue Переглянути файл

47
           @change="SelectorSelected"
47
           @change="SelectorSelected"
48
         >
48
         >
49
           <option value="0"></option>
49
           <option value="0"></option>
50
-          <option v-for="item in arrayObject" :value="item.id" :key="item.id">{{ item.description }}</option>
50
+          <option v-for="item in arrayObject" :value="item.id" :key="item.id">{{
51
+            item.description
52
+          }}</option>
51
         </select>
53
         </select>
52
         <!-- yesno -->
54
         <!-- yesno -->
53
         <select v-if="editType === 'yesno'" class="form-control" @change="YesNoSelected">
55
         <select v-if="editType === 'yesno'" class="form-control" @change="YesNoSelected">
99
     },
101
     },
100
     SelectorSelected(item) {
102
     SelectorSelected(item) {
101
       if (item.target.options.selectedIndex > 0) {
103
       if (item.target.options.selectedIndex > 0) {
102
-        this.updatedDisplay = this.arrayObject[
103
-          item.target.options.selectedIndex - 1
104
-        ].description;
104
+        this.updatedDisplay = this.arrayObject[item.target.options.selectedIndex - 1].description;
105
       }
105
       }
106
     },
106
     },
107
     YesNoSelected(item) {
107
     YesNoSelected(item) {

+ 1
- 1
src/components/property/propertyImage.vue Переглянути файл

28
         <label v-if="allowMultiple" for="checkbox" style="margin: 10px;">Main Image</label>
28
         <label v-if="allowMultiple" for="checkbox" style="margin: 10px;">Main Image</label>
29
         <img :src="img" style="height:200px; width:150px; object-fit: cover;" />
29
         <img :src="img" style="height:200px; width:150px; object-fit: cover;" />
30
         <br />
30
         <br />
31
-        <span class="input-group-text" align="center" @click="removeImage(key)">
31
+        <span class="input-group-text" align="center" style="width:150px" @click="removeImage(key)">
32
           <eva-icon name="trash-2-outline" fill="#60CBEB"></eva-icon>Delete
32
           <eva-icon name="trash-2-outline" fill="#60CBEB"></eva-icon>Delete
33
         </span>
33
         </span>
34
       </div>
34
       </div>

+ 96
- 168
src/components/property/propertyeditPage.vue Переглянути файл

35
       <div class="row mb-3">
35
       <div class="row mb-3">
36
         <div class="container col-md-10" style="text-align:left">
36
         <div class="container col-md-10" style="text-align:left">
37
           <form id="mainForm">
37
           <form id="mainForm">
38
+            <div class="form-goup row">
39
+              <div class="col-md-4">
40
+                <field :type="'datetime'" :mayEdit="true" />
41
+              </div>
42
+            </div>
38
             <div class="form-goup row">
43
             <div class="form-goup row">
39
               <div class="col-md-4">
44
               <div class="col-md-4">
40
                 <label>Usage Type</label>
45
                 <label>Usage Type</label>
41
                 <div class="input-group-prepend">
46
                 <div class="input-group-prepend">
42
-                  <!-- <span class="input-group-text" style="color: #60CBEB">
43
-                    <b>U</b>
44
-                  </span>-->
45
                   <input
47
                   <input
46
                     class="form-control"
48
                     class="form-control"
47
                     type="text"
49
                     type="text"
73
             <div class="form-group row">
75
             <div class="form-group row">
74
               <div class="col-md-4">
76
               <div class="col-md-4">
75
                 <label>Property Type *</label>
77
                 <label>Property Type *</label>
76
-                <propField
77
-                  :display="property.propertyType ? property.propertyType.description : ''"
78
-                  :editType="'selector'"
79
-                  :arrayObject="propertyTypes"
80
-                  :propertyName="'propertyType'"
78
+                <field
79
+                  :type="'select'"
80
+                  :selectOptions="propertyTypes"
81
+                  :selectValue="'id'"
82
+                  :selectText="'description'"
83
+                  v-model="property.propertyType"
81
                   :mayEdit="mayEdit"
84
                   :mayEdit="mayEdit"
82
-                  @UpdateValue="UpdateValue"
83
                 />
85
                 />
84
               </div>
86
               </div>
85
               <div v-if="propertyType === 'Commercial'" class="col-md-4">
87
               <div v-if="propertyType === 'Commercial'" class="col-md-4">
86
                 <label>Property Name</label>
88
                 <label>Property Name</label>
87
-                <propField
88
-                  :display="property.propertyName"
89
-                  :editType="'text'"
90
-                  :propertyName="'propertyName'"
91
-                  :mayEdit="mayEdit"
92
-                  @UpdateValue="UpdateValue"
93
-                />
89
+                <field :type="'text'" v-model="property.propertyName" :mayEdit="mayEdit" />
94
               </div>
90
               </div>
95
               <div v-if="propertyType === 'Commercial'" class="col-md-4">
91
               <div v-if="propertyType === 'Commercial'" class="col-md-4">
96
                 <label>Unit</label>
92
                 <label>Unit</label>
97
-                <propField
98
-                  :label="'Property Type'"
99
-                  :display="property.unit"
100
-                  :editType="'text'"
101
-                  :propertyName="'unit'"
102
-                  :mayEdit="mayEdit"
103
-                  @UpdateValue="UpdateValue"
104
-                />
93
+                <field :type="'text'" v-model="property.unit" :mayEdit="mayEdit" />
105
               </div>
94
               </div>
106
             </div>
95
             </div>
107
             <div class="form-group row">
96
             <div class="form-group row">
108
               <div class="col-md-6" style="margin-bottom: 1em">
97
               <div class="col-md-6" style="margin-bottom: 1em">
109
                 <label>Street Number</label>
98
                 <label>Street Number</label>
110
-                <propField
111
-                  :display="property.addressLine1"
112
-                  :editType="'text'"
113
-                  :propertyName="'addressLine1'"
114
-                  :mayEdit="mayEdit"
115
-                  @UpdateValue="UpdateValue"
116
-                />
99
+                <field :type="'text'" v-model="property.addressLine1" :mayEdit="mayEdit" />
117
               </div>
100
               </div>
118
               <div class="col-md-6" style="margin-bottom: 1em">
101
               <div class="col-md-6" style="margin-bottom: 1em">
119
                 <label>Street Name</label>
102
                 <label>Street Name</label>
120
-                <propField
121
-                  :display="property.addressLine2"
122
-                  :editType="'text'"
123
-                  :propertyName="'addressLine2'"
124
-                  :mayEdit="mayEdit"
125
-                  @UpdateValue="UpdateValue"
126
-                />
103
+                <field :type="'text'" v-model="property.addressLine2" :mayEdit="mayEdit" />
127
               </div>
104
               </div>
128
               <div class="col-md-6" style="margin-bottom: 1em">
105
               <div class="col-md-6" style="margin-bottom: 1em">
129
                 <label>Province *</label>
106
                 <label>Province *</label>
130
-                <propField
107
+                <!-- <propField
131
                   :display="property.province ? property.province.description : ''"
108
                   :display="property.province ? property.province.description : ''"
132
                   :editType="'selector'"
109
                   :editType="'selector'"
133
                   :arrayObject="provinces"
110
                   :arrayObject="provinces"
134
                   :propertyName="'province'"
111
                   :propertyName="'province'"
135
                   :mayEdit="mayEdit"
112
                   :mayEdit="mayEdit"
136
                   @UpdateValue="UpdateValue"
113
                   @UpdateValue="UpdateValue"
114
+                />-->
115
+                <field
116
+                  :type="'select'"
117
+                  :selectOptions="provinces"
118
+                  :selectValue="'id'"
119
+                  :selectText="'description'"
120
+                  v-model="property.province"
121
+                  :mayEdit="mayEdit"
122
+                  @change="provChanged"
137
                 />
123
                 />
138
                 <div v-if="showProvinceError">
124
                 <div v-if="showProvinceError">
139
                   <p class="alert myError">Please select a Province</p>
125
                   <p class="alert myError">Please select a Province</p>
141
               </div>
127
               </div>
142
               <div class="col-md-6" style="margin-bottom: 1em">
128
               <div class="col-md-6" style="margin-bottom: 1em">
143
                 <label>City *</label>
129
                 <label>City *</label>
144
-                <propField
130
+                <!-- <propField
145
                   :display="property.city ? property.city.description : ''"
131
                   :display="property.city ? property.city.description : ''"
146
                   :editType="'selector'"
132
                   :editType="'selector'"
147
                   :arrayObject="cities"
133
                   :arrayObject="cities"
148
                   :propertyName="'city'"
134
                   :propertyName="'city'"
149
                   :mayEdit="mayEdit"
135
                   :mayEdit="mayEdit"
150
                   @UpdateValue="UpdateValue"
136
                   @UpdateValue="UpdateValue"
137
+                />-->
138
+                <field
139
+                  :type="'select'"
140
+                  :selectOptions="cities"
141
+                  :selectValue="'id'"
142
+                  :selectText="'description'"
143
+                  v-model="property.city"
144
+                  :mayEdit="mayEdit"
145
+                  @change="cityChanged"
151
                 />
146
                 />
152
                 <div v-if="showCityError">
147
                 <div v-if="showCityError">
153
                   <p class="alert myError">Please select a City</p>
148
                   <p class="alert myError">Please select a City</p>
154
                 </div>
149
                 </div>
155
               </div>
150
               </div>
156
               <div class="col-md-6" style="margin-bottom: 1em">
151
               <div class="col-md-6" style="margin-bottom: 1em">
157
-                <label>Suburb * </label>
158
-                <propField
152
+                <label>Suburb *</label>
153
+                <!-- <propField
159
                   :display="property.suburb ? property.suburb.description : ''"
154
                   :display="property.suburb ? property.suburb.description : ''"
160
                   :editType="'selector'"
155
                   :editType="'selector'"
161
                   :arrayObject="suburbs"
156
                   :arrayObject="suburbs"
162
                   :propertyName="'suburb'"
157
                   :propertyName="'suburb'"
163
                   :mayEdit="mayEdit"
158
                   :mayEdit="mayEdit"
164
                   @UpdateValue="UpdateValue"
159
                   @UpdateValue="UpdateValue"
160
+                />-->
161
+                <field
162
+                  :type="'select'"
163
+                  :selectOptions="suburbs"
164
+                  :selectValue="'id'"
165
+                  :selectText="'description'"
166
+                  v-model="property.suburb"
167
+                  :mayEdit="mayEdit"
168
+                  @change="suburbChanged"
165
                 />
169
                 />
166
                 <div v-if="showSuburbError">
170
                 <div v-if="showSuburbError">
167
                   <p class="alert myError">Please select a suburb</p>
171
                   <p class="alert myError">Please select a suburb</p>
169
               </div>
173
               </div>
170
               <div class="col-md-6" style="margin-bottom: 1em">
174
               <div class="col-md-6" style="margin-bottom: 1em">
171
                 <label>Postal Code</label>
175
                 <label>Postal Code</label>
172
-                <propField
173
-                  :display="property.addressLine3"
174
-                  :editType="'text'"
175
-                  :propertyName="'addressLine3'"
176
-                  :mayEdit="mayEdit"
177
-                  @UpdateValue="UpdateValue"
178
-                />
176
+                <field :type="'text'" v-model="property.addressLine3" :mayEdit="mayEdit" />
179
               </div>
177
               </div>
180
             </div>
178
             </div>
181
 
179
 
183
               <div class="col-md-6">
181
               <div class="col-md-6">
184
                 <label v-if="salesType === 'Rental'">Rental Price</label>
182
                 <label v-if="salesType === 'Rental'">Rental Price</label>
185
                 <label v-if="salesType !== 'Rental'">Sales Price</label>
183
                 <label v-if="salesType !== 'Rental'">Sales Price</label>
186
-                <propField
184
+                <field :type="'number'" v-model="property.price" :mayEdit="mayEdit" />
185
+                <!-- <propField
187
                   :display="String(property.price)"
186
                   :display="String(property.price)"
188
                   :editType="'number'"
187
                   :editType="'number'"
189
                   :propertyName="'price'"
188
                   :propertyName="'price'"
190
                   :mayEdit="mayEdit"
189
                   :mayEdit="mayEdit"
191
                   @UpdateValue="UpdateValue"
190
                   @UpdateValue="UpdateValue"
192
-                />
191
+                />-->
193
               </div>
192
               </div>
194
               <div class="col-md-6" v-if="salesType === 'Rental'">
193
               <div class="col-md-6" v-if="salesType === 'Rental'">
195
                 <label>Per</label>
194
                 <label>Per</label>
196
-                <propField
195
+                <!-- <propField
197
                   :display="property.pricePer"
196
                   :display="property.pricePer"
198
                   :editType="'selector'"
197
                   :editType="'selector'"
199
                   :propertyName="'pricePer'"
198
                   :propertyName="'pricePer'"
200
                   :arrayObject="pricePerArr"
199
                   :arrayObject="pricePerArr"
201
                   :mayEdit="mayEdit"
200
                   :mayEdit="mayEdit"
202
                   @UpdateValue="UpdateValue"
201
                   @UpdateValue="UpdateValue"
202
+                />-->
203
+                <field
204
+                  :type="'selectlist'"
205
+                  :selectOptions="pricePerArr"
206
+                  v-model="property.pricePer"
207
+                  :mayEdit="mayEdit"
203
                 />
208
                 />
204
               </div>
209
               </div>
205
             </div>
210
             </div>
271
             <div class="form-group row">
276
             <div class="form-group row">
272
               <div class="col-md-12">
277
               <div class="col-md-12">
273
                 <label>Virtual Tour (URL)</label>
278
                 <label>Virtual Tour (URL)</label>
274
-                <propField
275
-                  :display="property.virtualTour"
276
-                  :editType="'text'"
277
-                  :propertyName="'virtualTour'"
278
-                  :mayEdit="mayEdit"
279
-                  @UpdateValue="UpdateValue"
280
-                />
279
+                <field :type="'text'" v-model="property.virtualTour" :mayEdit="mayEdit" />
281
               </div>
280
               </div>
282
             </div>
281
             </div>
283
             <div class="form-group row">
282
             <div class="form-group row">
284
               <div class="col-md-12">
283
               <div class="col-md-12">
285
                 <label>Video (URL)</label>
284
                 <label>Video (URL)</label>
286
-                <propField
287
-                  :display="property.video"
288
-                  :editType="'text'"
289
-                  :propertyName="'video'"
290
-                  :mayEdit="mayEdit"
291
-                  @UpdateValue="UpdateValue"
292
-                />
285
+                <field :type="'text'" v-model="property.video" :mayEdit="mayEdit" />
293
               </div>
286
               </div>
294
             </div>
287
             </div>
295
             <div class="form-group row">
288
             <div class="form-group row">
319
                   class="input-group-text spanCursor"
312
                   class="input-group-text spanCursor"
320
                   align="center"
313
                   align="center"
321
                   @click="DeleteImage(img)"
314
                   @click="DeleteImage(img)"
315
+                  style="width:150px"
322
                 >
316
                 >
323
                   <eva-icon name="trash-2-outline" fill="#60CBEB"></eva-icon>Delete
317
                   <eva-icon name="trash-2-outline" fill="#60CBEB"></eva-icon>Delete
324
                 </span>
318
                 </span>
371
 import { VueEditor } from 'vue2-editor';
365
 import { VueEditor } from 'vue2-editor';
372
 import ImageLoad from './propertyImage.vue';
366
 import ImageLoad from './propertyImage.vue';
373
 import propField from './propertyFieldEditor.vue';
367
 import propField from './propertyFieldEditor.vue';
368
+import field from '../shared/fieldEditor.vue';
374
 
369
 
375
 export default {
370
 export default {
376
   name: 'PropertyEdit',
371
   name: 'PropertyEdit',
378
     ImageLoad,
373
     ImageLoad,
379
     VueEditor,
374
     VueEditor,
380
     propField,
375
     propField,
376
+    field,
381
   },
377
   },
382
   data() {
378
   data() {
383
     return {
379
     return {
399
         { id: 1, description: 'Sale' },
395
         { id: 1, description: 'Sale' },
400
         { id: 2, description: 'Rental' },
396
         { id: 2, description: 'Rental' },
401
       ],
397
       ],
402
-      pricePerArr: [
403
-        { id: 'Month', description: 'Month' },
404
-        { id: 'Day', description: 'Day' },
405
-      ],
398
+      pricePerArr: ['Month', 'Day'],
399
+      yesno: ['Yes', 'No'],
406
       showPropertyTypeError: false,
400
       showPropertyTypeError: false,
407
       showProvinceError: false,
401
       showProvinceError: false,
408
       showCityError: false,
402
       showCityError: false,
418
     ]),
412
     ]),
419
     ...mapActions('property', ['getPropertyTypes']),
413
     ...mapActions('property', ['getPropertyTypes']),
420
     ...mapActions('propertyEdit', ['getSavedPropertyData', 'updateProperty', 'mayEditProperty']),
414
     ...mapActions('propertyEdit', ['getSavedPropertyData', 'updateProperty', 'mayEditProperty']),
415
+    provChanged(item) {
416
+      this.getCities(Object.assign({}, { province: item.description }));
417
+      this.property.city = null;
418
+      this.property.suburb = null;
419
+      this.property.addressLine3 = '';
420
+      this.showProvinceError = false;
421
+      this.showCityError = true;
422
+      this.showSuburbError = true;
423
+    },
424
+    cityChanged(item) {
425
+      this.getSuburbs(
426
+        Object.assign(
427
+          {},
428
+          {
429
+            province: this.property.province.description,
430
+            city: item.description,
431
+          },
432
+        ),
433
+      );
434
+      this.property.suburb = null;
435
+      this.property.addressLine3 = '';
436
+      this.showCityError = false;
437
+      this.showSuburbError = true;
438
+    },
439
+    suburbChanged(item) {
440
+      const newSuburb = this.suburbs.find(p => p.description === item.description);
441
+      this.property.addressLine3 = newSuburb.postalCode;
442
+      this.showSuburbError = false;
443
+    },
444
+    salesTypeChanged(item) {
445
+      console.log(item);
446
+    },
421
     UpdateValue(item) {
447
     UpdateValue(item) {
422
       if (item.isUDF) {
448
       if (item.isUDF) {
423
         if (item.isPropOverview) {
449
         if (item.isPropOverview) {
434
             } else isSaleValue = false;
460
             } else isSaleValue = false;
435
             this.property.isSale = isSaleValue;
461
             this.property.isSale = isSaleValue;
436
           }
462
           }
437
-          if (item.fieldName === 'propertyType') {
438
-            if (item.value !== '') {
439
-              this.property.propertyType = this.propertyTypes.find(
440
-                pt => pt.description === item.value,
441
-              );
442
-              this.property.propertyTypeId = this.property.propertyType.id;
443
-              this.showPropertyTypeError = false;
444
-            } else {
445
-              this.showPropertyTypeError = true;
446
-            }
447
-          }
448
-          if (item.fieldName === 'propertyName') {
449
-            this.property.propertyName = item.value;
450
-          }
451
-          if (item.fieldName === 'unit') {
452
-            this.property.unit = item.value;
453
-          }
454
-          if (item.fieldName === 'addressLine1') {
455
-            this.property.addressLine1 = item.value;
456
-          }
457
-          if (item.fieldName === 'addressLine2') {
458
-            this.property.addressLine2 = item.value;
459
-          }
460
-          if (item.fieldName === 'addressLine3') {
461
-            this.property.addressLine3 = item.value;
462
-          }
463
-          if (item.fieldName === 'province') {
464
-            if (item.value !== '') {
465
-              this.property.province = this.provinces.find(p => p.description === item.value);
466
-              this.property.provinceId = this.property.province.id;
467
-              this.getCities(Object.assign({}, { province: item.value }));
468
-              this.property.city = null;
469
-              this.property.suburb = null;
470
-              this.property.addressLine3 = '';
471
-              this.showProvinceError = false;
472
-              this.showCityError = true;
473
-              this.showSuburbError = true;
474
-            } else {
475
-              this.property.province = null;
476
-              this.property.city = null;
477
-              this.property.suburb = null;
478
-              this.property.addressLine3 = '';
479
-              this.cities = [];
480
-              this.suburbs = [];
481
-              this.showProvinceError = true;
482
-            }
483
-          }
484
-          if (item.fieldName === 'city') {
485
-            if (item.value !== '') {
486
-              const newCity = this.cities.find(p => p.description === item.value);
487
-              this.property.city = newCity;
488
-              this.property.cityId = newCity.id;
489
-              this.getSuburbs(
490
-                Object.assign(
491
-                  {},
492
-                  {
493
-                    province: this.property.province.description,
494
-                    city: item.value,
495
-                  },
496
-                ),
497
-              );
498
-              this.property.suburb = null;
499
-              this.property.addressLine3 = '';
500
-              this.showCityError = false;
501
-              this.showSuburbError = true;
502
-            } else {
503
-              this.property.city = null;
504
-              this.property.suburb = null;
505
-              this.property.addressLine3 = '';
506
-              this.suburbs = [];
507
-              this.showCityError = true;
508
-            }
509
-          }
510
-          if (item.fieldName === 'suburb') {
511
-            if (item.value !== '') {
512
-              const newSuburb = this.suburbs.find(p => p.description === item.value);
513
-              this.property.suburb = newSuburb;
514
-              this.property.suburbId = newSuburb.id;
515
-              this.property.addressLine3 = this.property.suburb.postalCode;
516
-              this.showSuburbError = false;
517
-            } else {
518
-              this.property.suburb = null;
519
-              this.property.addressLine3 = '';
520
-              this.showSuburbError = true;
521
-            }
522
-          }
523
-          if (item.fieldName === 'price') {
524
-            this.property.price = item.value;
525
-          }
526
-          if (item.fieldName === 'pricePer') {
527
-            this.property.pricePer = item.value;
528
-          }
529
-          if (item.fieldName === 'virtualTour') {
530
-            this.property.virtualTour = item.value;
531
-          }
532
-          if (item.fieldName === 'video') {
533
-            this.property.video = item.value;
534
-          }
535
         }
463
         }
536
       }
464
       }
537
     },
465
     },

+ 118
- 0
src/components/shared/fieldEditor.vue Переглянути файл

1
+<template>
2
+  <div>
3
+    <div v-if="!edit" class="input-group-prepend">
4
+      <input class="form-control" v-model="myDisplay" disabled />
5
+      <span
6
+        v-if="mayEdit"
7
+        @click="EditClick()"
8
+        class="input-group-text spanCursor"
9
+        style="color: #60CBEB"
10
+      >
11
+        <eva-icon name="edit-outline" fill="#60CBEB"></eva-icon>
12
+      </span>
13
+    </div>
14
+    <div v-if="edit" class="input-group-prepend">
15
+      <input v-if="type === 'text'" class="form-control" v-model="value" />
16
+      <input v-if="type === 'number'" type="number" class="form-control" v-model="value" />
17
+      <select v-if="type === 'select'" class="form-control" @change="selectionClick">
18
+        <option>Please select</option>
19
+        <option
20
+          v-for="option in selectOptions"
21
+          :value="option[selectValue]"
22
+          :key="option[selectValue]"
23
+          >{{ option[selectText] }}</option
24
+        >
25
+      </select>
26
+      <select v-if="type === 'selectlist'" class="form-control" v-model="value">
27
+        <option v-for="item in selectOptions" :value="item" :key="item">{{ item }}</option>
28
+      </select>
29
+      <!-- <Datetime class="form-control" v-if="type === 'datetime'" v-model="value" /> -->
30
+      <span
31
+        v-if="edit"
32
+        @click="UpdateValue()"
33
+        class="input-group-text spanCursor"
34
+        style="color: #60CBEB"
35
+      >
36
+        <eva-icon name="checkmark-outline" fill="#60CBEB"></eva-icon>
37
+      </span>
38
+      <span v-if="edit" @click="Close()" class="input-group-text spanCursor" style="color: #60CBEB">
39
+        <eva-icon name="close-outline" fill="#60CBEB"></eva-icon>
40
+      </span>
41
+    </div>
42
+  </div>
43
+</template>
44
+
45
+<script>
46
+export default {
47
+  props: ['value', 'type', 'mayEdit', 'selectOptions', 'selectValue', 'selectText', 'display'],
48
+  data() {
49
+    return {
50
+      edit: false,
51
+      myDisplay: '',
52
+    };
53
+  },
54
+  methods: {
55
+    UpdateValue() {
56
+      this.edit = false;
57
+      if (this.type !== 'select' && this.value) {
58
+        this.$emit('input', this.value);
59
+        this.$emit('change', this.value);
60
+      }
61
+    },
62
+    EditClick() {
63
+      this.edit = true;
64
+    },
65
+    Close() {
66
+      this.edit = false;
67
+    },
68
+    selectionClick(item) {
69
+      if (item.target.options.selectedIndex > 0) {
70
+        if (!this.value) {
71
+          this.myDisplay = this.selectOptions[item.target.options.selectedIndex - 1][
72
+            this.selectText
73
+          ];
74
+        }
75
+        if (this.selectOptions[item.target.options.selectedIndex - 1]) {
76
+          this.$emit('input', this.selectOptions[item.target.options.selectedIndex - 1]);
77
+          this.$emit('change', this.selectOptions[item.target.options.selectedIndex - 1]);
78
+        }
79
+      }
80
+    },
81
+  },
82
+  mounted() {
83
+    if (this.value) {
84
+      // eslint-disable-next-line vue/no-side-effects-in-computed-properties
85
+      this.myDisplay = this.value;
86
+    }
87
+    if (this.value && this.selectText) {
88
+      // eslint-disable-next-line vue/no-side-effects-in-computed-properties
89
+      this.myDisplay = this.value[this.selectText];
90
+    }
91
+    if (this.display) {
92
+      this.myDisplay = this.display;
93
+    }
94
+  },
95
+  computed: {
96
+    // eslint-disable-next-line vue/return-in-computed-property
97
+    checkValue() {
98
+      if (this.value) {
99
+        // eslint-disable-next-line vue/no-side-effects-in-computed-properties
100
+        this.myDisplay = this.value;
101
+      }
102
+      if (this.value && this.selectText) {
103
+        // eslint-disable-next-line vue/no-side-effects-in-computed-properties
104
+        this.myDisplay = this.value[this.selectText];
105
+      }
106
+      if (this.display) {
107
+        // eslint-disable-next-line vue/no-side-effects-in-computed-properties
108
+        this.myDisplay = this.display;
109
+      }
110
+    },
111
+  },
112
+  watch: {
113
+    checkValue() {
114
+      return null;
115
+    },
116
+  },
117
+};
118
+</script>

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