123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- <template>
- <div class="form">
- <div id="sendmessage">Your details has been sent. Thank you!</div>
- <div id="errormessage"></div>
- <form method="post" role="form" class="contactForm">
- <div class="form-row">
- <div class="form-group col-md-6">
- <input
- type="text"
- name="street-nr"
- class="form-control"
- id="street-nr"
- placeholder="Street Number"
- data-rule="minlen:4"
- data-msg="Please enter your street number"
- v-model="address.streetNumber"
- />
- <div class="validation"></div>
- </div>
- <div class="form-group col-md-6">
- <input
- type="text"
- class="form-control"
- name="street"
- id="street"
- placeholder="Street Name"
- data-msg="Please enter your street name"
- v-model="address.street"
- />
- <div class="validation"></div>
- </div>
- <div class="form-group col-md-6">
- <input
- type="text"
- name="province"
- class="form-control"
- id="province"
- placeholder="Province"
- data-rule="minlen:4"
- data-msg="Please enter your province"
- v-model="address.province"
- />
- <div class="validation"></div>
- </div>
- <div class="form-group col-md-6">
- <input
- type="text"
- class="form-control"
- name="city"
- id="city"
- placeholder="City"
- data-rule="minlen:4"
- data-msg="Please enter your city"
- v-model="address.city"
- />
- <div class="validation"></div>
- </div>
- <div class="form-group col-md-6">
- <input
- type="text"
- name="suburb"
- class="form-control"
- id="suburb"
- placeholder="Suburb"
- data-rule="minlen:4"
- data-msg="Please enter your suburb"
- v-model="address.suburb"
- />
- <div class="validation"></div>
- </div>
- <div class="form-group col-md-6">
- <input
- type="text"
- class="form-control"
- name="postal"
- id="postal"
- placeholder="Postal Code"
- data-msg="Please enter your postal code"
- v-model="address.postalCode"
- />
- <div class="validation"></div>
- </div>
- </div>
- </form>
- </div>
- </template>
-
- <script>
- /* eslint-disable */
- import { mapState, mapActions } from "vuex";
- import propField from "../property/propertyFieldEditor.vue";
-
- export default {
- components: {
- propField
- },
- data() {
- return {
- propertyType: "Residential"
- };
- },
- props: {
- address: {}
- },
- computed: {
- ...mapState("searchTab", ["provinces", "cities", "suburbs"])
- },
- methods: {
- ...mapActions("searchTab", ["getProvince", "getCities", "getSuburbs"]),
- ProvinceSelected(item) {
- if (item.target.options.selectedIndex > 0) {
- this.selectedProvince = this.provinces[item.target.options.selectedIndex - 1].description;
- this.getCities(Object.assign({}, { province: this.selectedProvince }));
- }
- },
- CitySelected(item) {
- if (item.target.options.selectedIndex > 0) {
- this.selectedCity = this.cities[item.target.options.selectedIndex - 1].description;
- this.getSuburbs(
- Object.assign({}, { province: this.selectedProvince, city: this.selectedCity })
- );
- }
- },
- getPostalCode(item) {
- this.address.postalCode = this.suburbs[item.target.options.selectedIndex - 1].postalCode;
- },
- UpdateValue(item) {
- if (item.fieldName) {
- if (item.fieldName === "streetNumber") {
- this.address.streetNumber = item.value;
- }
- if (item.fieldName === "street") {
- this.address.street = item.value;
- }
- if (item.fieldName === "province") {
- if (item.value !== "") {
- this.address.province = item.value;
- this.getCities(Object.assign({}, { province: item.value }));
- this.address.city = null;
- this.address.suburb = null;
- this.address.postalCode = "";
- } else {
- this.address.province = null;
- this.address.city = null;
- this.address.suburb = null;
- this.address.postalCode = "";
- this.cities = [];
- this.suburbs = [];
- }
- }
- if (item.fieldName === "city") {
- if (item.value !== "") {
- this.address.city = item.value;
- // this.address.city = newCity;
- // this.address.cityId = newCity.id;
- this.getSuburbs(
- Object.assign(
- {},
- {
- province: item.value,
- city: item.value
- }
- )
- );
- this.address.suburb = null;
- this.address.postalCode = "";
- } else {
- this.address.city = null;
- this.address.suburb = null;
- this.address.postalCode = "";
- this.suburbs = [];
- }
- }
- if (item.fieldName === "suburb") {
- if (item.value !== "") {
- // const newSuburb = this.suburbs.find(
- // p => p.description === item.value,
- // );
- // this.address.suburb = newSuburb;
- // this.address.suburbId = newSuburb.id;
- console.log(item.value);
- this.address.suburb = item.value;
- this.address.postalCode = this.address.suburb.postalCode;
- } else {
- this.address.suburb = null;
- this.address.postalCode = "";
- }
- }
- }
- }
- },
- mounted() {
- this.getProvince();
- }
- };
- </script>
-
- <style lang="scss" scoped></style>
|