Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

address.vue 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <div class="form">
  3. <div id="sendmessage">Your details has been sent. Thank you!</div>
  4. <div id="errormessage"></div>
  5. <form method="post" role="form" class="contactForm">
  6. <div class="form-row">
  7. <div class="form-group col-md-6">
  8. <input
  9. type="text"
  10. name="street-nr"
  11. class="form-control"
  12. id="street-nr"
  13. placeholder="Street Number"
  14. data-rule="minlen:4"
  15. data-msg="Please enter your street number"
  16. v-model="address.streetNumber"
  17. />
  18. <div class="validation"></div>
  19. </div>
  20. <div class="form-group col-md-6">
  21. <input
  22. type="text"
  23. class="form-control"
  24. name="street"
  25. id="street"
  26. placeholder="Street Name"
  27. data-msg="Please enter your street name"
  28. v-model="address.street"
  29. />
  30. <div class="validation"></div>
  31. </div>
  32. <div class="form-group col-md-6">
  33. <input
  34. type="text"
  35. name="province"
  36. class="form-control"
  37. id="province"
  38. placeholder="Province"
  39. data-rule="minlen:4"
  40. data-msg="Please enter your province"
  41. v-model="address.province"
  42. />
  43. <div class="validation"></div>
  44. </div>
  45. <div class="form-group col-md-6">
  46. <input
  47. type="text"
  48. class="form-control"
  49. name="city"
  50. id="city"
  51. placeholder="City"
  52. data-rule="minlen:4"
  53. data-msg="Please enter your city"
  54. v-model="address.city"
  55. />
  56. <div class="validation"></div>
  57. </div>
  58. <div class="form-group col-md-6">
  59. <input
  60. type="text"
  61. name="suburb"
  62. class="form-control"
  63. id="suburb"
  64. placeholder="Suburb"
  65. data-rule="minlen:4"
  66. data-msg="Please enter your suburb"
  67. v-model="address.suburb"
  68. />
  69. <div class="validation"></div>
  70. </div>
  71. <div class="form-group col-md-6">
  72. <input
  73. type="text"
  74. class="form-control"
  75. name="postal"
  76. id="postal"
  77. placeholder="Postal Code"
  78. data-msg="Please enter your postal code"
  79. v-model="address.postalCode"
  80. />
  81. <div class="validation"></div>
  82. </div>
  83. </div>
  84. </form>
  85. </div>
  86. </template>
  87. <script>
  88. /* eslint-disable */
  89. import { mapState, mapActions } from "vuex";
  90. import propField from "../property/propertyFieldEditor.vue";
  91. export default {
  92. components: {
  93. propField
  94. },
  95. data() {
  96. return {
  97. propertyType: "Residential"
  98. };
  99. },
  100. props: {
  101. address: {}
  102. },
  103. computed: {
  104. ...mapState("searchTab", ["provinces", "cities", "suburbs"])
  105. },
  106. methods: {
  107. ...mapActions("searchTab", ["getProvince", "getCities", "getSuburbs"]),
  108. ProvinceSelected(item) {
  109. if (item.target.options.selectedIndex > 0) {
  110. this.selectedProvince = this.provinces[item.target.options.selectedIndex - 1].description;
  111. this.getCities(Object.assign({}, { province: this.selectedProvince }));
  112. }
  113. },
  114. CitySelected(item) {
  115. if (item.target.options.selectedIndex > 0) {
  116. this.selectedCity = this.cities[item.target.options.selectedIndex - 1].description;
  117. this.getSuburbs(
  118. Object.assign({}, { province: this.selectedProvince, city: this.selectedCity })
  119. );
  120. }
  121. },
  122. getPostalCode(item) {
  123. this.address.postalCode = this.suburbs[item.target.options.selectedIndex - 1].postalCode;
  124. },
  125. UpdateValue(item) {
  126. if (item.fieldName) {
  127. if (item.fieldName === "streetNumber") {
  128. this.address.streetNumber = item.value;
  129. }
  130. if (item.fieldName === "street") {
  131. this.address.street = item.value;
  132. }
  133. if (item.fieldName === "province") {
  134. if (item.value !== "") {
  135. this.address.province = item.value;
  136. this.getCities(Object.assign({}, { province: item.value }));
  137. this.address.city = null;
  138. this.address.suburb = null;
  139. this.address.postalCode = "";
  140. } else {
  141. this.address.province = null;
  142. this.address.city = null;
  143. this.address.suburb = null;
  144. this.address.postalCode = "";
  145. this.cities = [];
  146. this.suburbs = [];
  147. }
  148. }
  149. if (item.fieldName === "city") {
  150. if (item.value !== "") {
  151. this.address.city = item.value;
  152. // this.address.city = newCity;
  153. // this.address.cityId = newCity.id;
  154. this.getSuburbs(
  155. Object.assign(
  156. {},
  157. {
  158. province: item.value,
  159. city: item.value
  160. }
  161. )
  162. );
  163. this.address.suburb = null;
  164. this.address.postalCode = "";
  165. } else {
  166. this.address.city = null;
  167. this.address.suburb = null;
  168. this.address.postalCode = "";
  169. this.suburbs = [];
  170. }
  171. }
  172. if (item.fieldName === "suburb") {
  173. if (item.value !== "") {
  174. // const newSuburb = this.suburbs.find(
  175. // p => p.description === item.value,
  176. // );
  177. // this.address.suburb = newSuburb;
  178. // this.address.suburbId = newSuburb.id;
  179. console.log(item.value);
  180. this.address.suburb = item.value;
  181. this.address.postalCode = this.address.suburb.postalCode;
  182. } else {
  183. this.address.suburb = null;
  184. this.address.postalCode = "";
  185. }
  186. }
  187. }
  188. }
  189. },
  190. mounted() {
  191. this.getProvince();
  192. }
  193. };
  194. </script>
  195. <style lang="scss" scoped></style>