You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

address.vue 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <!-- eslint-disable max-len -->
  3. <div>
  4. <br />
  5. <div class="col-md-12" style="text-align:centre">
  6. <div class="myWell">
  7. <h4>Address</h4>
  8. </div>
  9. <div class="form-group row"></div>
  10. <div class="row" style="text-align:left">
  11. <div class="col-md-6" style="margin-bottom: 1em">
  12. <label>Street Number *</label>
  13. <div class="input-group-prepend">
  14. <span class="input-group-text">
  15. <eva-icon name="home-outline" fill="#60CBEB"></eva-icon>
  16. </span>
  17. <input
  18. class="form-control"
  19. type="text"
  20. name="streetnumber"
  21. v-model="address.streetNumber"
  22. />
  23. </div>
  24. </div>
  25. <div class="col-md-6" style="margin-bottom: 1em">
  26. <label>Street Name *</label>
  27. <div class="input-group-prepend">
  28. <span class="input-group-text">
  29. <eva-icon name="home-outline" fill="#60CBEB"></eva-icon>
  30. </span>
  31. <input class="form-control" type="text" name="streetname" v-model="address.streetName" />
  32. </div>
  33. </div>
  34. <div class="col-md-6" style="margin-bottom: 1em">
  35. <label>Province *</label>
  36. <div class="input-group-prepend">
  37. <span class="input-group-text">
  38. <eva-icon name="home-outline" fill="#60CBEB"></eva-icon>
  39. </span>
  40. <select
  41. class="form-control"
  42. name="propertyType"
  43. id="propertyType"
  44. @change="ProvinceSelected"
  45. v-model="address.provinceId"
  46. >
  47. <option value="0">Please select province</option>
  48. <option
  49. v-for="province in provinces"
  50. :value="province.id"
  51. :key="province.id"
  52. >{{ province.description }}</option>
  53. </select>
  54. </div>
  55. </div>
  56. <div class="col-md-6" style="margin-bottom: 1em">
  57. <label>City *</label>
  58. <div class="input-group-prepend">
  59. <span class="input-group-text">
  60. <eva-icon name="home-outline" fill="#60CBEB"></eva-icon>
  61. </span>
  62. <select
  63. class="form-control"
  64. name="propertyType"
  65. id="propertyType"
  66. @change="CitySelected"
  67. v-model="address.cityId"
  68. >
  69. <option value="0">Please select city</option>
  70. <option v-for="city in cities" :value="city.id" :key="city.id">{{ city.description }}</option>
  71. </select>
  72. </div>
  73. </div>
  74. <div class="col-md-6" style="margin-bottom: 1em">
  75. <label>Suburb *</label>
  76. <div class="input-group-prepend">
  77. <span class="input-group-text">
  78. <eva-icon name="home-outline" fill="#60CBEB"></eva-icon>
  79. </span>
  80. <select
  81. class="form-control"
  82. name="propertyType"
  83. id="suburbselector"
  84. v-model="address.suburbId"
  85. @change="getPostalCode"
  86. >
  87. <option value="0">Please select suburb</option>
  88. <option
  89. v-for="suburb in suburbs"
  90. :value="suburb.id"
  91. :key="suburb.id"
  92. >{{ suburb.description }}</option>
  93. </select>
  94. </div>
  95. </div>
  96. <div class="col-md-6" style="margin-bottom: 1em">
  97. <label>Postal Code *</label>
  98. <div class="input-group-prepend">
  99. <span class="input-group-text">
  100. <eva-icon name="home-outline" fill="#60CBEB"></eva-icon>
  101. </span>
  102. <input class="form-control" type="text" name="postalcode" v-model="address.postalCode" />
  103. </div>
  104. </div>
  105. </div>
  106. </div>
  107. </div>
  108. </template>
  109. <script>
  110. import { mapState, mapActions } from 'vuex';
  111. export default {
  112. data() {
  113. return {
  114. propertyType: 'Residential',
  115. };
  116. },
  117. props: {
  118. address: {},
  119. },
  120. computed: {
  121. ...mapState('searchTab', ['provinces', 'cities', 'suburbs']),
  122. },
  123. methods: {
  124. ...mapActions('searchTab', ['getProvince', 'getCities', 'getSuburbs']),
  125. ProvinceSelected(item) {
  126. if (item.target.options.selectedIndex > 0) {
  127. this.selectedProvince = this.provinces[
  128. item.target.options.selectedIndex - 1
  129. ].description;
  130. this.getCities(Object.assign({}, { province: this.selectedProvince }));
  131. }
  132. },
  133. CitySelected(item) {
  134. if (item.target.options.selectedIndex > 0) {
  135. this.selectedCity = this.cities[
  136. item.target.options.selectedIndex - 1
  137. ].description;
  138. this.getSuburbs(
  139. Object.assign(
  140. {},
  141. { province: this.selectedProvince, city: this.selectedCity },
  142. ),
  143. );
  144. }
  145. },
  146. getPostalCode(item) {
  147. this.address.postalCode = this.suburbs[
  148. item.target.options.selectedIndex - 1
  149. ].postalCode;
  150. },
  151. },
  152. mounted() {
  153. this.getProvince();
  154. },
  155. };
  156. </script>
  157. <style>
  158. .goDown {
  159. margin-top: 150px;
  160. }
  161. </style>