123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317 |
- <template>
- <div @submit.prevent="SubmitData">
- <div class="container">
- <section class="intro-single">
- <div class="container">
- <div class="row">
- <div class="col-md-12 col-lg-8">
- <div class="title-single-box">
- <h1 class="title-single">List {{ propertyType }} {{ salesType }} Property</h1>
- </div>
- </div>
- </div>
- </div>
- </section>
- <div class="row">
- <div class="col-sm-12">
- <div class="title-box-d">
- <h5 class="title-d">Property Overview</h5>
- </div>
- </div>
- </div>
- <div class="row mb-3">
- <div class="col-md-12">
- <form
- id="mainForm"
- method="POST"
- action="/to-sell"
- accept-charset="UTF-8"
- enctype="multipart/form-data"
- >
- <div class="form-group row">
- <div class="col-md-4">
- <label for="Property Type"></label>
- <select
- class="form-control"
- name="propertyType"
- id="propertyType"
- v-model="property.propertyTypeId"
- >
- <option value="0">Please select Property Type</option>
- <option v-for="item in propertyTypes" :value="item.id">{{ item.description }}</option>
- </select>
- </div>
- </div>
- <div class="form-group row">
- <div class="col-md-4">
- <label for="Address Line 1"></label>
- <input
- class="form-control"
- type="text"
- placeholder="Address Line 1"
- name="address1"
- id="address1"
- v-model="property.addressLine1"
- />
- </div>
- <div class="col-md-4">
- <label for="Address Line 2"></label>
- <input
- class="form-control"
- type="text"
- placeholder="Address Line 2"
- name="address2"
- id="address2"
- v-model="property.addressLine2"
- />
- </div>
- <div class="col-md-4">
- <label for="Address Line 3"></label>
- <input
- class="form-control"
- type="text"
- placeholder="Address Line 3"
- name="address3"
- id="address3"
- v-model="property.addressLine3"
- />
- </div>
- </div>
- <div class="form-group row">
- <div class="col-md-4">
- <label for="Province"></label>
- <select
- class="form-control"
- name="propertyType"
- id="propertyType"
- @change="ProvinceSelected"
- v-model="property.provinceId"
- >
- <option value="0">Please select Province</option>
- <option
- v-for="province in provinces"
- :value="province.id"
- >{{ province.description }}</option>
- </select>
- </div>
- <div class="col-md-4">
- <label for="City"></label>
- <select
- class="form-control"
- name="propertyType"
- id="propertyType"
- @change="CitySelected"
- v-model="property.cityId"
- >
- <option value="0">Please select City</option>
- <option v-for="city in cities" :value="city.id">{{ city.description }}</option>
- </select>
- </div>
- <div class="col-md-4">
- <label for="Suburb"></label>
- <select
- class="form-control"
- name="propertyType"
- id="suburbselector"
- v-model="property.suburbId"
- >
- <option value="0">Please select Suburb</option>
- <option v-for="suburb in suburbs" :value="suburb.id">{{ suburb.description }}</option>
- </select>
- </div>
- </div>
- <div class="form-group row">
- <div class="col-md-4">
- <label v-if="salesType === 'Rental'">Rental Price</label>
- <label v-if="salesType !== 'Rental'">Sales Price</label>
- <input
- class="form-control"
- type="number"
- name="price"
- id="price"
- placeholder="R"
- v-model="property.price"
- />
- </div>
- <div class="col-md-4" v-if="salesType === 'Rental'">
- <label>Per</label>
- <select
- class="form-control"
- name="propertyType"
- id="propertyType"
- v-model="property.per"
- >
- <option value>Please select</option>
- <option value="month">Month</option>
- <option value="day">Day</option>
- </select>
- </div>
- </div>
- <div class="form-group row">
- <div class="col-md-12">
- <label for="Property Description"></label>
- <textarea
- class="form-control editor"
- placeholder="Property Description"
- name="description"
- v-model="property.description"
- ></textarea>
- <br />
- <p>* A listing fee of R380 including VAT is payable to list your Property on the Uni-Vate website</p>
- </div>
- </div>
- <div class="form-group row" />
- <UserField v-if="ApiRunning" :fields="propValuesProp[0].fields"></UserField>
- <div class="form-group row" />
- <div v-for="item in propertyValues">
- <div class="row">
- <div class="col-sm-12">
- <div class="title-box-d">
- <h5 class="title-d">{{ item.name }}</h5>
- </div>
- </div>
- </div>
- <UserField :fields="item.fields" :id="item.id" />
- </div>
- <div class="form-group row" />
- <div class="row">
- <div class="col-sm-12">
- <div class="title-box-d">
- <h5 class="title-d">Images</h5>
- </div>
- </div>
- </div>
- <ImageLoad />
- <button type="submit" class="btn btn-b-n" style="width: 85px; height:40px;">Save</button>
- </form>
- </div>
- </div>
- </div>
- </div>
- </template>
-
- <script>
- import UserField from "./propertyUserField.vue";
- import ImageLoad from "./propertyImage.vue";
-
- export default {
- name: "PropertyEdit",
- components: {
- UserField,
- ImageLoad
- },
- data() {
- return {
- ApiRunning: false,
- propertyType: "Residential",
- salesType: "Rental",
- imageFile: "",
- provinces: [],
- cities: [],
- suburbs: [],
- propertyValues: [],
- propValuesProp: [],
- propertyTypes: [],
- selectedProvince: "",
- selectedCity: "",
- property: {
- propertyTypeId: 0,
- addressLine1: "",
- addressLine2: "",
- addressLine3: "",
- suburbId: 0,
- cityId: 0,
- provinceId: 0,
- price: "",
- per: "",
- description: "",
- isSale: false
- }
- };
- },
- methods: {
- SubmitData() {
- const axios = require("axios");
- axios
- .post("http://localhost:57260/Property/Property", this.property, {
- headers: {
- "Content-type": "application/json"
- }
- })
- .then(response => {})
- .catch(e => {
- alert(e);
- });
-
- console.log(JSON.stringify(this.property));
- },
- ProvinceSelected(item) {
- if (item.target.options.selectedIndex > 0) {
- this.selectedProvince = this.provinces[
- item.target.options.selectedIndex - 1
- ].description;
- const axios = require("axios");
- axios
- .get(
- `http://localhost:57260/region/city/getby/${this.selectedProvince}`
- )
- .then(response => (this.cities = response.data));
- }
- },
- CitySelected(item) {
- if (item.target.options.selectedIndex > 0) {
- this.selectedCity = this.cities[
- item.target.options.selectedIndex - 1
- ].description;
- const axios = require("axios");
- axios
- .get(
- `http://localhost:57260/region/Suburb/${this.selectedProvince}/${this.selectedCity}`
- )
- .then(response => (this.suburbs = response.data));
- }
- }
- },
- mounted() {
- this.propertyType = this.$route.params.propType;
- this.salesType = this.$route.params.saleType;
-
- const axios = require("axios");
- axios
- .get("http://localhost:57260/Property/PropertyFields/Property Overview")
- .then(response => (this.propValuesProp = response.data));
-
- axios
- .get("http://localhost:57260/Property/PropertyFields")
- .then(response => (this.propertyValues = response.data));
-
- axios
- .get(
- `http://localhost:57260/Property/PropertyType/type/${this.propertyType}`
- )
- .then(response => (this.propertyTypes = response.data));
-
- axios
- .get("http://localhost:57260/region/province")
- .then(response => (this.provinces = response.data));
- },
- computed: {
- SalesTypeChanged() {
- this.propertyType = this.$route.params.propType;
- this.salesType = this.$route.params.saleType;
-
- const axios = require("axios");
- axios
- .get(
- `http://localhost:57260/Property/PropertyType/type/${this.propertyType}`
- )
- .then(response => (this.propertyTypes = response.data));
- }
- },
- watch: {
- SalesTypeChanged() {
- console.log(this.salesType);
- }
- }
- };
- </script>
|