|
|
@@ -1,5 +1,6 @@
|
|
1
|
1
|
<template>
|
|
2
|
|
- <div @submit.prevent="SubmitData">
|
|
|
2
|
+ <!-- eslint-disable max-len -->
|
|
|
3
|
+ <div>
|
|
3
|
4
|
<div class="container">
|
|
4
|
5
|
<section class="intro-single">
|
|
5
|
6
|
<div class="container">
|
|
|
@@ -21,13 +22,7 @@
|
|
21
|
22
|
</div>
|
|
22
|
23
|
<div class="row mb-3">
|
|
23
|
24
|
<div class="col-md-12">
|
|
24
|
|
- <form
|
|
25
|
|
- id="mainForm"
|
|
26
|
|
- method="POST"
|
|
27
|
|
- action="/to-sell"
|
|
28
|
|
- accept-charset="UTF-8"
|
|
29
|
|
- enctype="multipart/form-data"
|
|
30
|
|
- >
|
|
|
25
|
+ <form id="mainForm">
|
|
31
|
26
|
<div class="form-group row">
|
|
32
|
27
|
<div class="col-md-4">
|
|
33
|
28
|
<label for="Property Type"></label>
|
|
|
@@ -37,10 +32,34 @@
|
|
37
|
32
|
id="propertyType"
|
|
38
|
33
|
v-model="property.propertyTypeId"
|
|
39
|
34
|
>
|
|
40
|
|
- <option value="0">Please select Property Type</option>
|
|
41
|
|
- <option v-for="item in propertyTypes" :value="item.id">{{ item.description }}</option>
|
|
|
35
|
+ <option value="0">Please Select</option>
|
|
|
36
|
+ <option
|
|
|
37
|
+ v-for="item in propertyTypes"
|
|
|
38
|
+ :value="item.id"
|
|
|
39
|
+ :key="item.id"
|
|
|
40
|
+ >{{ item.description }}</option>
|
|
42
|
41
|
</select>
|
|
43
|
42
|
</div>
|
|
|
43
|
+ <div v-if="propertyType === 'Commercial'" class="col-md-4">
|
|
|
44
|
+ <label>Property Name</label>
|
|
|
45
|
+ <input
|
|
|
46
|
+ class="form-control form-control-lg form-control-a"
|
|
|
47
|
+ type="text"
|
|
|
48
|
+ name="propertyName"
|
|
|
49
|
+ id="propertyName"
|
|
|
50
|
+ v-model="property.propertyName"
|
|
|
51
|
+ />
|
|
|
52
|
+ </div>
|
|
|
53
|
+ <div v-if="propertyType === 'Commercial'" class="col-md-4">
|
|
|
54
|
+ <label>Unit</label>
|
|
|
55
|
+ <input
|
|
|
56
|
+ class="form-control form-control-lg form-control-a"
|
|
|
57
|
+ type="text"
|
|
|
58
|
+ name="unit"
|
|
|
59
|
+ id="unit"
|
|
|
60
|
+ v-model="property.unit"
|
|
|
61
|
+ />
|
|
|
62
|
+ </div>
|
|
44
|
63
|
</div>
|
|
45
|
64
|
<div class="form-group row">
|
|
46
|
65
|
<div class="col-md-4">
|
|
|
@@ -91,6 +110,7 @@
|
|
91
|
110
|
<option
|
|
92
|
111
|
v-for="province in provinces"
|
|
93
|
112
|
:value="province.id"
|
|
|
113
|
+ :key="province.id"
|
|
94
|
114
|
>{{ province.description }}</option>
|
|
95
|
115
|
</select>
|
|
96
|
116
|
</div>
|
|
|
@@ -103,8 +123,12 @@
|
|
103
|
123
|
@change="CitySelected"
|
|
104
|
124
|
v-model="property.cityId"
|
|
105
|
125
|
>
|
|
106
|
|
- <option value="0">Please select City</option>
|
|
107
|
|
- <option v-for="city in cities" :value="city.id">{{ city.description }}</option>
|
|
|
126
|
+ <option value="0">Please Select</option>
|
|
|
127
|
+ <option
|
|
|
128
|
+ v-for="city in cities"
|
|
|
129
|
+ :value="city.id"
|
|
|
130
|
+ :key="city.id"
|
|
|
131
|
+ >{{ city.description }}</option>
|
|
108
|
132
|
</select>
|
|
109
|
133
|
</div>
|
|
110
|
134
|
<div class="col-md-4">
|
|
|
@@ -115,8 +139,12 @@
|
|
115
|
139
|
id="suburbselector"
|
|
116
|
140
|
v-model="property.suburbId"
|
|
117
|
141
|
>
|
|
118
|
|
- <option value="0">Please select Suburb</option>
|
|
119
|
|
- <option v-for="suburb in suburbs" :value="suburb.id">{{ suburb.description }}</option>
|
|
|
142
|
+ <option value="0">Please Select</option>
|
|
|
143
|
+ <option
|
|
|
144
|
+ v-for="suburb in suburbs"
|
|
|
145
|
+ :value="suburb.id"
|
|
|
146
|
+ :key="suburb.id"
|
|
|
147
|
+ >{{ suburb.description }}</option>
|
|
120
|
148
|
</select>
|
|
121
|
149
|
</div>
|
|
122
|
150
|
</div>
|
|
|
@@ -155,15 +183,21 @@
|
|
155
|
183
|
placeholder="Property Description"
|
|
156
|
184
|
name="description"
|
|
157
|
185
|
v-model="property.description"
|
|
|
186
|
+ id="description"
|
|
158
|
187
|
></textarea>
|
|
159
|
188
|
<br />
|
|
160
|
189
|
<p>* A listing fee of R380 including VAT is payable to list your Property on the Uni-Vate website</p>
|
|
161
|
190
|
</div>
|
|
162
|
191
|
</div>
|
|
163
|
192
|
<div class="form-group row" />
|
|
164
|
|
- <UserField v-if="ApiRunning" :fields="propValuesProp[0].fields"></UserField>
|
|
|
193
|
+ <UserField
|
|
|
194
|
+ v-if="ApiRunning & propertyType === 'Residential'"
|
|
|
195
|
+ :fields="propValuesProp[0].fields"
|
|
|
196
|
+ :id="overviewProps"
|
|
|
197
|
+ @UpdateUserDefinedFields="UpdateUserDefinedFields"
|
|
|
198
|
+ ></UserField>
|
|
165
|
199
|
<div class="form-group row" />
|
|
166
|
|
- <div v-for="item in propertyValues">
|
|
|
200
|
+ <div v-for="item in propertyValues" :key="item.id">
|
|
167
|
201
|
<div class="row">
|
|
168
|
202
|
<div class="col-sm-12">
|
|
169
|
203
|
<div class="title-box-d">
|
|
|
@@ -171,7 +205,11 @@
|
|
171
|
205
|
</div>
|
|
172
|
206
|
</div>
|
|
173
|
207
|
</div>
|
|
174
|
|
- <UserField :fields="item.fields" :id="item.id" />
|
|
|
208
|
+ <UserField
|
|
|
209
|
+ :fields="item.fields"
|
|
|
210
|
+ :id="item.id"
|
|
|
211
|
+ @UpdateUserDefinedFields="UpdateUserDefinedFields"
|
|
|
212
|
+ />
|
|
175
|
213
|
</div>
|
|
176
|
214
|
<div class="form-group row" />
|
|
177
|
215
|
<div class="row">
|
|
|
@@ -181,8 +219,14 @@
|
|
181
|
219
|
</div>
|
|
182
|
220
|
</div>
|
|
183
|
221
|
</div>
|
|
184
|
|
- <ImageLoad />
|
|
185
|
|
- <button type="submit" class="btn btn-b-n" style="width: 85px; height:40px;">Save</button>
|
|
|
222
|
+ <ImageLoad :loadedImages="loadedImages" />
|
|
|
223
|
+ <button type="button" @click="SubmitData()" class="btn btn-a">Save</button>
|
|
|
224
|
+ <!-- <router-link
|
|
|
225
|
+ to="/property/search"
|
|
|
226
|
+ @click.stop.prevent="SubmitData()"
|
|
|
227
|
+ class="btn btn-b"
|
|
|
228
|
+ tag="button"
|
|
|
229
|
+ >Save</router-link>-->
|
|
186
|
230
|
</form>
|
|
187
|
231
|
</div>
|
|
188
|
232
|
</div>
|
|
|
@@ -193,7 +237,7 @@
|
|
193
|
237
|
<script>
|
|
194
|
238
|
import UserField from "./propertyUserField.vue";
|
|
195
|
239
|
import ImageLoad from "./propertyImage.vue";
|
|
196
|
|
-
|
|
|
240
|
+// https://vuejsexamples.com/a-vue-wrapper-around-the-trix-rich-text-editor/
|
|
197
|
241
|
export default {
|
|
198
|
242
|
name: "PropertyEdit",
|
|
199
|
243
|
components: {
|
|
|
@@ -202,7 +246,7 @@ export default {
|
|
202
|
246
|
},
|
|
203
|
247
|
data() {
|
|
204
|
248
|
return {
|
|
205
|
|
- ApiRunning: false,
|
|
|
249
|
+ ApiRunning: true,
|
|
206
|
250
|
propertyType: "Residential",
|
|
207
|
251
|
salesType: "Rental",
|
|
208
|
252
|
imageFile: "",
|
|
|
@@ -216,6 +260,8 @@ export default {
|
|
216
|
260
|
selectedCity: "",
|
|
217
|
261
|
property: {
|
|
218
|
262
|
propertyTypeId: 0,
|
|
|
263
|
+ propertyName: "",
|
|
|
264
|
+ unit: "",
|
|
219
|
265
|
addressLine1: "",
|
|
220
|
266
|
addressLine2: "",
|
|
221
|
267
|
addressLine3: "",
|
|
|
@@ -225,25 +271,40 @@ export default {
|
|
225
|
271
|
price: "",
|
|
226
|
272
|
per: "",
|
|
227
|
273
|
description: "",
|
|
228
|
|
- isSale: false
|
|
229
|
|
- }
|
|
|
274
|
+ isSale: false,
|
|
|
275
|
+ propertyUserFields: [],
|
|
|
276
|
+ propertyImages: []
|
|
|
277
|
+ },
|
|
|
278
|
+ images: [],
|
|
|
279
|
+ propertyFieldValues: []
|
|
230
|
280
|
};
|
|
231
|
281
|
},
|
|
232
|
282
|
methods: {
|
|
233
|
283
|
SubmitData() {
|
|
234
|
|
- const axios = require("axios");
|
|
235
|
|
- axios
|
|
236
|
|
- .post("http://localhost:57260/Property/Property", this.property, {
|
|
237
|
|
- headers: {
|
|
238
|
|
- "Content-type": "application/json"
|
|
239
|
|
- }
|
|
240
|
|
- })
|
|
241
|
|
- .then(response => {})
|
|
242
|
|
- .catch(e => {
|
|
243
|
|
- alert(e);
|
|
244
|
|
- });
|
|
|
284
|
+ // let isDefault = true;
|
|
|
285
|
+ // this.images.forEach((imagedata) => {
|
|
|
286
|
+ // this.property.propertyImages.push({
|
|
|
287
|
+ // image: imagedata,
|
|
|
288
|
+ // isDefault,
|
|
|
289
|
+ // });
|
|
|
290
|
+ // isDefault = false;
|
|
|
291
|
+ // });
|
|
|
292
|
+
|
|
|
293
|
+ // this.property.propertyUserFields = this.propertyFieldValues;
|
|
|
294
|
+
|
|
|
295
|
+ // const axios = require('axios');
|
|
|
296
|
+ // axios
|
|
|
297
|
+ // .post('http://localhost:57260/Property/Property', this.property)
|
|
|
298
|
+ // .then((response) => {})
|
|
|
299
|
+ // .catch((e) => {
|
|
|
300
|
+ // alert(e);
|
|
|
301
|
+ // });
|
|
245
|
302
|
|
|
246
|
|
- console.log(JSON.stringify(this.property));
|
|
|
303
|
+ // this.$router.push("/property/search");
|
|
|
304
|
+ this.$router.push({
|
|
|
305
|
+ path: "/property/search",
|
|
|
306
|
+ query: { type: this.salesType, propertyType: this.propertyType }
|
|
|
307
|
+ });
|
|
247
|
308
|
},
|
|
248
|
309
|
ProvinceSelected(item) {
|
|
249
|
310
|
if (item.target.options.selectedIndex > 0) {
|
|
|
@@ -270,6 +331,21 @@ export default {
|
|
270
|
331
|
)
|
|
271
|
332
|
.then(response => (this.suburbs = response.data));
|
|
272
|
333
|
}
|
|
|
334
|
+ },
|
|
|
335
|
+ loadedImages(values) {
|
|
|
336
|
+ this.images = values;
|
|
|
337
|
+ },
|
|
|
338
|
+ UpdateUserDefinedFields(item) {
|
|
|
339
|
+ let update = false;
|
|
|
340
|
+ this.propertyFieldValues.forEach(element => {
|
|
|
341
|
+ if (element.userDefinedFieldId === item.userDefinedFieldId) {
|
|
|
342
|
+ element.value = item.value;
|
|
|
343
|
+ update = true;
|
|
|
344
|
+ }
|
|
|
345
|
+ });
|
|
|
346
|
+ if (!update) {
|
|
|
347
|
+ this.propertyFieldValues.push(item);
|
|
|
348
|
+ }
|
|
273
|
349
|
}
|
|
274
|
350
|
},
|
|
275
|
351
|
mounted() {
|
|
|
@@ -282,7 +358,9 @@ export default {
|
|
282
|
358
|
.then(response => (this.propValuesProp = response.data));
|
|
283
|
359
|
|
|
284
|
360
|
axios
|
|
285
|
|
- .get("http://localhost:57260/Property/PropertyFields")
|
|
|
361
|
+ .get(
|
|
|
362
|
+ `http://localhost:57260/property/propertyfields/Propertytype/${this.propertyType}`
|
|
|
363
|
+ )
|
|
286
|
364
|
.then(response => (this.propertyValues = response.data));
|
|
287
|
365
|
|
|
288
|
366
|
axios
|
|
|
@@ -306,6 +384,12 @@ export default {
|
|
306
|
384
|
`http://localhost:57260/Property/PropertyType/type/${this.propertyType}`
|
|
307
|
385
|
)
|
|
308
|
386
|
.then(response => (this.propertyTypes = response.data));
|
|
|
387
|
+
|
|
|
388
|
+ axios
|
|
|
389
|
+ .get(
|
|
|
390
|
+ `http://localhost:57260/property/propertyfields/Propertytype/${this.propertyType}`
|
|
|
391
|
+ )
|
|
|
392
|
+ .then(response => (this.propertyValues = response.data));
|
|
309
|
393
|
}
|
|
310
|
394
|
},
|
|
311
|
395
|
watch: {
|