您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

propertyeditPage.vue 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. <template>
  2. <!-- eslint-disable max-len -->
  3. <div>
  4. <div class="container">
  5. <div class="col-sm-12">
  6. <div class="tobuy-img-box">
  7. <img
  8. src="img/Listings2.jpg"
  9. alt="Timeshare To Buy"
  10. class="img-fluid"
  11. style="width:800px;height:400px;"
  12. />
  13. </div>
  14. <div class="sinse-box">
  15. <h3 class="sinse-title">
  16. List {{ propertyType }} {{ salesType }} Property
  17. <span></span>
  18. </h3>
  19. </div>
  20. </div>
  21. <br />
  22. <div class="row">
  23. <div class="container col-md-10">
  24. <div class="title-box-d">
  25. <h5 class="title-d">Property Overview</h5>
  26. </div>
  27. </div>
  28. </div>
  29. <div class="row mb-3">
  30. <div class="container col-md-10">
  31. <form id="mainForm">
  32. <div class="form-group row">
  33. <div class="col-md-4">
  34. <label>Property Type</label>
  35. <select
  36. class="form-control"
  37. name="propertyType"
  38. id="propertyType"
  39. v-model="property.propertyTypeId"
  40. >
  41. <option value="0">Please Select</option>
  42. <option
  43. v-for="item in propertyTypes"
  44. :value="item.id"
  45. :key="item.id"
  46. >{{ item.description }}</option>
  47. </select>
  48. </div>
  49. <div v-if="propertyType === 'Commercial'" class="col-md-4">
  50. <label>Property Name</label>
  51. <input
  52. class="form-control"
  53. type="text"
  54. name="propertyName"
  55. id="propertyName"
  56. v-model="property.propertyName"
  57. />
  58. </div>
  59. <div v-if="propertyType === 'Commercial'" class="col-md-4">
  60. <label>Unit</label>
  61. <input
  62. class="form-control"
  63. type="text"
  64. name="unit"
  65. id="unit"
  66. v-model="property.unit"
  67. />
  68. </div>
  69. </div>
  70. <div class="form-group row">
  71. <div class="col-md-4">
  72. <label>Address Line 1</label>
  73. <input
  74. class="form-control"
  75. type="text"
  76. name="address1"
  77. id="address1"
  78. v-model="property.addressLine1"
  79. />
  80. </div>
  81. <div class="col-md-4">
  82. <label>Address Line 2</label>
  83. <input
  84. class="form-control"
  85. type="text"
  86. name="address2"
  87. id="address2"
  88. v-model="property.addressLine2"
  89. />
  90. </div>
  91. <div class="col-md-4">
  92. <label>Address Line 3</label>
  93. <input
  94. class="form-control"
  95. type="text"
  96. name="address3"
  97. id="address3"
  98. v-model="property.addressLine3"
  99. />
  100. </div>
  101. </div>
  102. <div class="form-group row">
  103. <div class="col-md-4">
  104. <label>Province</label>
  105. <select
  106. class="form-control"
  107. name="propertyType"
  108. id="propertyType"
  109. @change="ProvinceSelected"
  110. v-model="property.provinceId"
  111. >
  112. <option value="0">Please select</option>
  113. <option
  114. v-for="province in provinces"
  115. :value="province.id"
  116. :key="province.id"
  117. >{{ province.description }}</option>
  118. </select>
  119. </div>
  120. <div class="col-md-4">
  121. <label>City</label>
  122. <select
  123. class="form-control"
  124. name="propertyType"
  125. id="propertyType"
  126. @change="CitySelected"
  127. v-model="property.cityId"
  128. >
  129. <option value="0">Please Select</option>
  130. <option
  131. v-for="city in cities"
  132. :value="city.id"
  133. :key="city.id"
  134. >{{ city.description }}</option>
  135. </select>
  136. </div>
  137. <div class="col-md-4">
  138. <label>Suburb</label>
  139. <select
  140. class="form-control"
  141. name="propertyType"
  142. id="suburbselector"
  143. v-model="property.suburbId"
  144. >
  145. <option value="0">Please Select</option>
  146. <option
  147. v-for="suburb in suburbs"
  148. :value="suburb.id"
  149. :key="suburb.id"
  150. >{{ suburb.description }}</option>
  151. </select>
  152. </div>
  153. </div>
  154. <div class="form-group row">
  155. <div class="col-md-4">
  156. <label v-if="salesType === 'Rental'">Rental Price</label>
  157. <label v-if="salesType !== 'Rental'">Sales Price</label>
  158. <input
  159. class="form-control"
  160. type="number"
  161. name="price"
  162. id="price"
  163. placeholder="R"
  164. v-model="property.price"
  165. />
  166. </div>
  167. <div class="col-md-4" v-if="salesType === 'Rental'">
  168. <label>Per</label>
  169. <select
  170. class="form-control"
  171. name="propertyType"
  172. id="propertyType"
  173. v-model="property.per"
  174. >
  175. <option value>Please select</option>
  176. <option value="month">Month</option>
  177. <option value="day">Day</option>
  178. </select>
  179. </div>
  180. </div>
  181. <div class="form-group row">
  182. <div class="col-md-12">
  183. <label for="Property Description">Description</label>
  184. <TextEditor
  185. name="description"
  186. v-model="property.description"
  187. id="description"
  188. style="text-align:left"
  189. />
  190. <br />
  191. <p>* A listing fee of R380 including VAT is payable to list your Property on the Uni-Vate website</p>
  192. </div>
  193. </div>
  194. <div class="form-group row" />
  195. <UserField
  196. v-if="propertyType === 'Residential' & propertyOverviewFields.length > 0"
  197. :fields="propertyOverviewFields[0].fields"
  198. @UpdateUserDefinedFields="UpdateUserDefinedFields"
  199. ></UserField>
  200. <div class="form-group row" />
  201. <div v-for="item in propertyFields" :key="item.id">
  202. <div class="row">
  203. <div class="col-sm-12">
  204. <div class="title-box-d">
  205. <h5 class="title-d">{{ item.name }}</h5>
  206. </div>
  207. </div>
  208. </div>
  209. <UserField
  210. :fields="item.fields"
  211. :id="item.id"
  212. @UpdateUserDefinedFields="UpdateUserDefinedFields"
  213. />
  214. </div>
  215. <div class="form-group row" />
  216. <div class="row">
  217. <div class="col-sm-12">
  218. <div class="title-box-d">
  219. <h5 class="title-d">Images</h5>
  220. </div>
  221. </div>
  222. </div>
  223. <ImageLoad
  224. :loadedImages="loadedImages"
  225. :savedImages="propertyImages"
  226. @DefaultImage="UpdateDefaultImage"
  227. />
  228. <button
  229. type="button"
  230. @click="SubmitData()"
  231. class="btn btn-b-n"
  232. style="width: 85px; height:40px;"
  233. >Save</button>
  234. </form>
  235. </div>
  236. </div>
  237. </div>
  238. </div>
  239. </template>
  240. <script>
  241. import { mapState, mapActions } from 'vuex';
  242. import TextEditor from 'vue-trix';
  243. import UserField from './propertyUserField.vue';
  244. import ImageLoad from './propertyImage.vue';
  245. export default {
  246. name: 'PropertyEdit',
  247. components: {
  248. UserField,
  249. ImageLoad,
  250. TextEditor,
  251. },
  252. data() {
  253. return {
  254. propertyType: 'Residential',
  255. salesType: 'Rental',
  256. selectedProvince: '',
  257. selectedCity: '',
  258. images: [],
  259. propertyFieldValues: [],
  260. defaultImage: 0,
  261. };
  262. },
  263. methods: {
  264. ...mapActions('searchTab', ['getProvince', 'getCities', 'getSuburbs']),
  265. ...mapActions('property', [
  266. 'getPropertyTypes',
  267. 'getPropertyOverviewFields',
  268. 'getPropertyFields',
  269. 'saveProperty',
  270. 'getProperty',
  271. 'getPropertyImages',
  272. 'clearProperty',
  273. 'clearPropertyImages',
  274. 'getPropertyEditDisplay',
  275. 'getPropertySavedOverviewFields',
  276. 'getPropertySavedFields',
  277. ]),
  278. SubmitData() {
  279. for (let i = 0; i < this.images.length; i++) {
  280. let setAsDefault = false;
  281. if (i === this.defaultImage) {
  282. setAsDefault = true;
  283. }
  284. this.property.propertyImages.push({
  285. image: this.images[i],
  286. isDefault: setAsDefault,
  287. });
  288. }
  289. this.saveProperty(this.property);
  290. this.$router.push({
  291. path: '/property/search',
  292. query: { type: this.salesType, propertyType: this.propertyType },
  293. });
  294. },
  295. ProvinceSelected(item) {
  296. if (item.target.options.selectedIndex > 0) {
  297. this.selectedProvince = this.provinces[
  298. item.target.options.selectedIndex - 1
  299. ].description;
  300. this.getCities(Object.assign({}, { province: this.selectedProvince }));
  301. }
  302. },
  303. CitySelected(item) {
  304. if (item.target.options.selectedIndex > 0) {
  305. this.selectedCity = this.cities[
  306. item.target.options.selectedIndex - 1
  307. ].description;
  308. this.getSuburbs(
  309. Object.assign(
  310. {},
  311. { province: this.selectedProvince, city: this.selectedCity },
  312. ),
  313. );
  314. }
  315. },
  316. loadedImages(values) {
  317. this.images = values;
  318. },
  319. UpdateUserDefinedFields(item) {
  320. let update = false;
  321. this.propertyFieldValues.forEach((element) => {
  322. if (element.userDefinedFieldId === item.userDefinedFieldId) {
  323. element.value = item.value;
  324. update = true;
  325. }
  326. });
  327. if (!update) {
  328. this.propertyFieldValues.push(item);
  329. }
  330. },
  331. UpdateDefaultImage(item) {
  332. this.defaultImage = item;
  333. },
  334. },
  335. mounted() {
  336. this.clearProperty();
  337. this.clearPropertyImages();
  338. this.images = [];
  339. this.defaultImage = 0;
  340. // if (this.$route.params.id) {
  341. // this.getPropertyEditDisplay(4); // (this.$route.params.id);
  342. // this.propertyType = 'Residential'; // this.propertyEditDisplay.propertyType;
  343. // this.salesType = 'Rental'; // this.propertyEditDisplay.saleType;
  344. // this.getProvince();
  345. // this.getPropertyTypes('Residential');
  346. // this.getPropertySavedOverviewFields(4);
  347. // this.getPropertySavedFields(
  348. // Object.assign(
  349. // {},
  350. // {
  351. // type: 'Residential',
  352. // id: 4,
  353. // },
  354. // ),
  355. // );
  356. // this.getProperty(this.$route.params.id);
  357. // } else {
  358. this.propertyType = this.$route.params.propType;
  359. this.salesType = this.$route.params.saleType;
  360. this.getProvince();
  361. this.getPropertyTypes(this.$route.params.propType);
  362. this.getPropertyOverviewFields();
  363. this.getPropertyFields(this.$route.params.propType);
  364. // }
  365. },
  366. computed: {
  367. ...mapState('searchTab', ['provinces', 'cities', 'suburbs']),
  368. ...mapState('property', [
  369. 'propertyTypes',
  370. 'propertyOverviewFields',
  371. 'propertyFields',
  372. 'property',
  373. 'propertyImages',
  374. 'propertyEditDisplay',
  375. ]),
  376. SalesTypeChanged() {
  377. // eslint-disable-next-line vue/no-side-effects-in-computed-properties
  378. this.propertyType = this.$route.params.propType;
  379. // eslint-disable-next-line vue/no-side-effects-in-computed-properties
  380. this.salesType = this.$route.params.saleType;
  381. this.getPropertyTypes(this.$route.params.propType);
  382. this.getPropertyFields(this.$route.params.propType);
  383. return this.propertyType;
  384. },
  385. },
  386. watch: {
  387. SalesTypeChanged() {
  388. console.log(this.salesType);
  389. },
  390. },
  391. };
  392. </script>