123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440 |
- <template>
- <!-- eslint-disable max-len -->
- <div>
- <div class="container">
- <div class="col-sm-12">
- <div class="tobuy-img-box">
- <img
- src="img/Listings2.jpg"
- alt="Timeshare To Buy"
- class="img-fluid"
- style="width:800px;height:400px;"
- />
- </div>
- <div class="sinse-box">
- <h3 class="sinse-title">
- List {{ propertyType }} {{ salesType }} Property
- <span></span>
- </h3>
- </div>
- </div>
- <br />
- <div class="row">
- <div class="container col-md-10">
- <div class="title-box-d">
- <h5 class="title-d">Property Overview</h5>
- </div>
- </div>
- </div>
- <div class="row mb-3">
- <div class="container col-md-10">
- <form id="mainForm">
- <div class="form-group row">
- <div class="col-md-4">
- <label>Property Type</label>
- <select
- class="form-control"
- name="propertyType"
- id="propertyType"
- v-model="property.propertyTypeId"
- >
- <option value="0">Please select type</option>
- <option
- v-for="item in propertyTypes"
- :value="item.id"
- :key="item.id"
- >{{ item.description }}</option>
- </select>
- </div>
- <div v-if="propertyType === 'Commercial'" class="col-md-4">
- <label>Property Name</label>
- <input
- class="form-control"
- type="text"
- name="propertyName"
- id="propertyName"
- v-model="property.propertyName"
- />
- </div>
- <div v-if="propertyType === 'Commercial'" class="col-md-4">
- <label>Unit</label>
- <input
- class="form-control"
- type="text"
- name="unit"
- id="unit"
- v-model="property.unit"
- />
- </div>
- </div>
- <div class="form-group row">
- <div class="col-md-4">
- <label>Address Line 1</label>
- <input
- class="form-control"
- type="text"
- name="address1"
- placeholder="Apartment, suite, unit, building, floor, Po Box etc."
- style="font-size: 50%"
- id="address1"
- v-model="property.addressLine1"
- />
- </div>
- <div class="col-md-4">
- <label>Address Line 2</label>
- <input
- class="form-control"
- type="text"
- name="address2"
- placeholder="Complex, estate, company name, etc."
- style="font-size: 50%"
- id="address2"
- v-model="property.addressLine2"
- />
- </div>
- <div class="col-md-4">
- <label>Street</label>
- <input
- class="form-control"
- type="text"
- name="address3"
- placeholder="Street or c/o name"
- style="font-size: 50%"
- id="address3"
- v-model="property.addressLine3"
- />
- </div>
- </div>
- <div class="form-group row">
- <div class="col-md-4">
- <label>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"
- :key="province.id"
- >{{ province.description }}</option>
- </select>
- </div>
- <div class="col-md-4">
- <label>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"
- :key="city.id"
- >{{ city.description }}</option>
- </select>
- </div>
- <div class="col-md-4">
- <label>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"
- :key="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>
- <div class="input-group-prepend">
- <span class="input-group-text" style="color: #60CBEB">
- <b>R</b>
- </span>
- <input
- class="form-control"
- type="number"
- name="price"
- id="price"
- placeholder="R"
- v-model="property.price"
- />
- </div>
- </div>
- <div class="col-md-4" v-if="salesType === 'Rental'">
- <label>Per</label>
- <select
- class="form-control"
- name="propertyType"
- id="propertyType"
- v-model="property.pricePer"
- >
- <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">Description</label>
- <TextEditor
- name="description"
- v-model="property.description"
- id="description"
- style="text-align:left"
- />
- <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="propertyType === 'Residential' & propertyOverviewFields.length > 0"
- :fields="propertyOverviewFields[0].fields"
- @UpdateUserDefinedFields="UpdateUserDefinedFields"
- :id="1"
- ></UserField>
- <div class="form-group row" />
- <div v-for="(item, i) in propertyFields" :key="item.id">
- <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.name"
- @UpdateUserDefinedFields="UpdateUserDefinedFields"
- />
- </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 :loadedImages="loadedImages" :savedImages="propertyImages" />
- <button
- v-if="!wait"
- type="button"
- @click="SubmitData()"
- class="btn btn-b-n"
- style="width: 85px; height:40px;"
- >
- <!-- <span class="spinner-border" role="status" aria-hidden="true"></span>
- <span class="sr-only">Loading...</span>-->
- Save
- </button>
- <label v-if="wait">Please wait...</label>
- </form>
- </div>
- </div>
- </div>
- </div>
- </template>
-
- <script>
- import { mapState, mapActions } from 'vuex';
- import TextEditor from 'vue-trix';
- import UserField from './propertyUserField.vue';
- import ImageLoad from './propertyImage.vue';
-
- export default {
- name: 'PropertyEdit',
- components: {
- UserField,
- ImageLoad,
- TextEditor,
- },
- data() {
- return {
- propertyType: 'Residential',
- salesType: 'Rental',
- selectedProvince: '',
- selectedCity: '',
- images: [],
- propertyFieldValues: [],
- defaultImage: 0,
- wait: false,
- };
- },
- methods: {
- ...mapActions('searchTab', ['getProvince', 'getCities', 'getSuburbs']),
- ...mapActions('property', [
- 'getPropertyTypes',
- 'getPropertyOverviewFields',
- 'getPropertyFields',
- 'saveProperty',
- 'getProperty',
- 'getPropertyImages',
- 'clearProperty',
- 'clearPropertyImages',
- 'getPropertyEditDisplay',
- 'getPropertySavedOverviewFields',
- 'getPropertySavedFields',
- 'getSavedPropertyData',
- ]),
- SubmitData() {
- this.wait = true;
- for (let i = 0; i < this.images.length; i++) {
- let setAsDefault = false;
- if (i === this.defaultImage) {
- setAsDefault = true;
- }
- this.property.propertyImages.push({
- image: this.images[i],
- isDefault: setAsDefault,
- });
- }
- this.property.createdBy = 'GeorgeW';
-
- this.saveProperty(this.property);
-
- setTimeout(
- () => this.$router.push({
- path: '/property/search',
- query: { type: this.salesType, propertyType: this.propertyType },
- }),
- 3000,
- );
- },
- 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 },
- ),
- );
- }
- },
- loadedImages(values) {
- this.images = values;
- },
- UpdateUserDefinedFields(item) {
- let update = false;
- this.propertyFieldValues.forEach((element) => {
- if (element.userDefinedFieldId === item.userDefinedFieldId) {
- element.value = item.value;
- update = true;
- }
- });
- if (!update) {
- this.propertyFieldValues.push(item);
- }
- },
- UpdateDefaultImage(item) {
- this.defaultImage = item;
- },
- },
- mounted() {
- this.wait = false;
- this.clearProperty();
- this.clearPropertyImages();
- this.images = [];
- this.defaultImage = 0;
-
- if (this.propertyOverviewFields.length > 0) {
- this.propertyOverviewFields = [];
- }
- if (this.propertyFields.length > 0) {
- this.propertyFields = [];
- }
-
- this.propertyType = this.$route.params.propType;
- this.salesType = this.$route.params.saleType;
-
- this.getPropertyTypes(this.$route.params.propType);
-
- this.getProvince();
- if (this.$route.query.id) {
- // this.getCities(Object.assign({}, { province: this.selectedProvince }));
- this.getSavedPropertyData(
- Object.assign({}, { id: this.$route.query.id, type: this.propertyType }),
- );
- } else {
- this.getPropertyOverviewFields();
- this.getPropertyFields(this.$route.params.propType);
- }
- // if (this.$route.params.id) {
- // this.getPropertyEditDisplay(4); // (this.$route.params.id);
- // this.propertyType = 'Residential'; // this.propertyEditDisplay.propertyType;
- // this.salesType = 'Rental'; // this.propertyEditDisplay.saleType;
-
- // this.getProvince();
- // this.getPropertyTypes('Residential');
- // this.getPropertySavedOverviewFields(4);
- // this.getPropertySavedFields(
- // Object.assign(
- // {},
- // {
- // type: 'Residential',
- // id: 4,
- // },
- // ),
- // );
-
- // this.getProperty(this.$route.params.id);
- // } else {
-
- // }
- },
- computed: {
- ...mapState('searchTab', ['provinces', 'cities', 'suburbs']),
- ...mapState('property', [
- 'propertyTypes',
- 'propertyOverviewFields',
- 'propertyFields',
- 'property',
- 'propertyImages',
- ]),
- SalesTypeChanged() {
- // eslint-disable-next-line vue/no-side-effects-in-computed-properties
- this.propertyType = this.$route.params.propType;
- // eslint-disable-next-line vue/no-side-effects-in-computed-properties
- this.salesType = this.$route.params.saleType;
- if (!this.$route.query.id) {
- this.getPropertyTypes(this.$route.params.propType);
- this.getPropertyFields(this.$route.params.propType);
- }
-
- return this.propertyType;
- },
- },
- watch: {
- SalesTypeChanged() {
- console.log(this.salesType);
- },
- },
- };
- </script>
|