您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

propertyeditPage.vue 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. <template>
  2. <!-- eslint-disable max-len -->
  3. <div>
  4. <div class="container">
  5. <div class="col-sm-12">
  6. <div class="tobuy-img-box">
  7. <img
  8. src="img/Listings2.jpg"
  9. alt="Timeshare To Buy"
  10. class="img-fluid"
  11. style="width:800px;height:400px; border-radius:10px"
  12. />
  13. </div>
  14. <div class="sinse-box" style="opacity:0.7; border: white solid 3px; border-radius: 15px">
  15. <h3 class="sinse-title">List {{ propertyType }} {{ salesType }} Property</h3>
  16. </div>
  17. </div>
  18. <br />
  19. <div class="row">
  20. <div class="container col-md-10">
  21. <div class="title-box-d">
  22. <h5 class="title-d" style="text-align:left">Property Overview</h5>
  23. </div>
  24. </div>
  25. </div>
  26. <div class="row mb-3">
  27. <div class="container col-md-10" style="text-align:left">
  28. <form id="mainForm">
  29. <div class="form-group row">
  30. <div class="col-md-4">
  31. <label>Property Type</label>
  32. <div class="input-group-prepend">
  33. <span class="input-group-text" style="color: #60CBEB">
  34. <b>T</b>
  35. </span>
  36. <select
  37. class="form-control"
  38. name="propertyType"
  39. id="propertyType"
  40. v-model="property.propertyTypeId"
  41. >
  42. <option value="0">Please select type</option>
  43. <option
  44. v-for="item in propertyTypes"
  45. :value="item.id"
  46. :key="item.id"
  47. >{{ item.description }}</option>
  48. </select>
  49. </div>
  50. </div>
  51. <div v-if="propertyType === 'Commercial'" class="col-md-4">
  52. <label>Property Name</label>
  53. <div class="input-group-prepend">
  54. <span class="input-group-text" style="color: #60CBEB">
  55. <b>N</b>
  56. </span>
  57. <input
  58. class="form-control"
  59. type="text"
  60. name="propertyName"
  61. id="propertyName"
  62. v-model="property.propertyName"
  63. />
  64. </div>
  65. </div>
  66. <div v-if="propertyType === 'Commercial'" class="col-md-4">
  67. <label>Unit</label>
  68. <div class="input-group-prepend">
  69. <span class="input-group-text" style="color: #60CBEB">
  70. <b>U#</b>
  71. </span>
  72. <input
  73. class="form-control"
  74. type="text"
  75. name="unit"
  76. id="unit"
  77. v-model="property.unit"
  78. />
  79. </div>
  80. </div>
  81. </div>
  82. <div class="form-group row">
  83. <div class="col-md-6" style="margin-bottom: 1em">
  84. <label>Street Number</label>
  85. <div class="input-group-prepend">
  86. <span class="input-group-text">
  87. <eva-icon name="home-outline" fill="#60CBEB"></eva-icon>
  88. </span>
  89. <input
  90. class="form-control"
  91. type="text"
  92. name="streetnumber"
  93. v-model="property.addressLine1"
  94. />
  95. </div>
  96. </div>
  97. <div class="col-md-6" style="margin-bottom: 1em">
  98. <label>Street Name</label>
  99. <div class="input-group-prepend">
  100. <span class="input-group-text">
  101. <eva-icon name="home-outline" fill="#60CBEB"></eva-icon>
  102. </span>
  103. <input
  104. class="form-control"
  105. type="text"
  106. name="streetname"
  107. id="streetname"
  108. v-model="property.addressLine2"
  109. />
  110. </div>
  111. </div>
  112. <div class="col-md-6" style="margin-bottom: 1em">
  113. <label>Province</label>
  114. <div class="input-group-prepend">
  115. <span class="input-group-text">
  116. <eva-icon name="home-outline" fill="#60CBEB"></eva-icon>
  117. </span>
  118. <select
  119. class="form-control"
  120. name="propertyType"
  121. id="propertyType"
  122. @change="ProvinceSelected"
  123. v-model="property.provinceId"
  124. >
  125. <option value="0">Please select province</option>
  126. <option
  127. v-for="province in provinces"
  128. :value="province.id"
  129. :key="province.id"
  130. >{{ province.description }}</option>
  131. </select>
  132. </div>
  133. </div>
  134. <div class="col-md-6" style="margin-bottom: 1em">
  135. <label>City</label>
  136. <div class="input-group-prepend">
  137. <span class="input-group-text">
  138. <eva-icon name="home-outline" fill="#60CBEB"></eva-icon>
  139. </span>
  140. <select
  141. class="form-control"
  142. name="propertyType"
  143. id="propertyType"
  144. @change="CitySelected"
  145. v-model="property.cityId"
  146. >
  147. <option value="0">Please select city</option>
  148. <option
  149. v-for="city in cities"
  150. :value="city.id"
  151. :key="city.id"
  152. >{{ city.description }}</option>
  153. </select>
  154. </div>
  155. </div>
  156. <div class="col-md-6" style="margin-bottom: 1em">
  157. <label>Suburb</label>
  158. <div class="input-group-prepend">
  159. <span class="input-group-text">
  160. <eva-icon name="home-outline" fill="#60CBEB"></eva-icon>
  161. </span>
  162. <select
  163. class="form-control"
  164. name="propertyType"
  165. id="suburbselector"
  166. v-model="property.suburbId"
  167. @change="getPostalCode"
  168. >
  169. <option value="0">Please select suburb</option>
  170. <option
  171. v-for="suburb in suburbs"
  172. :value="suburb.id"
  173. :key="suburb.id"
  174. >{{ suburb.description }}</option>
  175. </select>
  176. </div>
  177. </div>
  178. <div class="col-md-6" style="margin-bottom: 1em">
  179. <label>Postal Code</label>
  180. <div class="input-group-prepend">
  181. <span class="input-group-text">
  182. <eva-icon name="home-outline" fill="#60CBEB"></eva-icon>
  183. </span>
  184. <input
  185. class="form-control"
  186. type="text"
  187. name="postalcode"
  188. v-model="property.addressLine3"
  189. />
  190. </div>
  191. </div>
  192. </div>
  193. <div class="form-group row">
  194. <div class="col-md-6">
  195. <label v-if="salesType === 'Rental'">Rental Price</label>
  196. <label v-if="salesType !== 'Rental'">Sales Price</label>
  197. <div class="input-group-prepend">
  198. <span class="input-group-text" style="color: #60CBEB">
  199. <b>R</b>
  200. </span>
  201. <input
  202. class="form-control"
  203. type="number"
  204. name="price"
  205. id="price"
  206. placeholder="R"
  207. v-model="property.price"
  208. />
  209. </div>
  210. </div>
  211. <div class="col-md-6" v-if="salesType === 'Rental'">
  212. <label>Per</label>
  213. <div class="input-group-prepend">
  214. <span class="input-group-text" style="color: #60CBEB">
  215. <b>D/M</b>
  216. </span>
  217. <select
  218. class="form-control"
  219. name="propertyType"
  220. id="propertyType"
  221. v-model="property.pricePer"
  222. >
  223. <option value>Please select</option>
  224. <option value="Month">Month</option>
  225. <option value="Day">Day</option>
  226. </select>
  227. </div>
  228. </div>
  229. </div>
  230. <div class="form-group row">
  231. <div class="col-md-12">
  232. <label for="Property Description">Description</label>
  233. <TextEditor
  234. name="description"
  235. v-model="property.description"
  236. id="description"
  237. style="text-align:left"
  238. />
  239. <br />
  240. <p>* A listing fee of R380 including VAT is payable to list your Property on the Uni-Vate website</p>
  241. </div>
  242. </div>
  243. <div class="form-group row" />
  244. <UserField
  245. v-if="propertyType === 'Residential' & propertyOverviewFields.length > 0"
  246. :fields="propertyOverviewFields[0].fields"
  247. @UpdateUserDefinedFields="UpdateUserDefinedFields"
  248. :id="1"
  249. ></UserField>
  250. <div class="form-group row" />
  251. <div v-for="(item, i) in propertyFields" :key="item.id">
  252. <div class="row">
  253. <div class="col-sm-12">
  254. <div class="title-box-d">
  255. <h5 class="title-d">{{ item.name }}</h5>
  256. </div>
  257. </div>
  258. </div>
  259. <UserField
  260. :fields="item.fields"
  261. :id="item.name"
  262. @UpdateUserDefinedFields="UpdateUserDefinedFields"
  263. />
  264. </div>
  265. <div class="form-group row" />
  266. <div class="row">
  267. <div class="col-sm-12">
  268. <div class="title-box-d">
  269. <h5 class="title-d">Images</h5>
  270. </div>
  271. </div>
  272. </div>
  273. <ImageLoad
  274. :loadedImages="loadedImages"
  275. :savedImages="propertyImages"
  276. @DefaultImage="UpdateDefaultImage"
  277. />
  278. <button
  279. v-if="!wait"
  280. type="button"
  281. @click="SubmitData()"
  282. class="btn btn-b-n"
  283. style="width: 85px; height:40px;"
  284. >Save</button>
  285. <div v-if="wait" id="preloader"></div>
  286. </form>
  287. </div>
  288. </div>
  289. </div>
  290. </div>
  291. </template>
  292. <script>
  293. import { mapState, mapActions } from 'vuex';
  294. import TextEditor from 'vue-trix';
  295. import { setTimeout } from 'timers';
  296. import UserField from './propertyUserField.vue';
  297. import ImageLoad from './propertyImage.vue';
  298. export default {
  299. name: 'PropertyEdit',
  300. components: {
  301. UserField,
  302. ImageLoad,
  303. TextEditor,
  304. },
  305. data() {
  306. return {
  307. propertyType: 'Residential',
  308. salesType: 'Rental',
  309. selectedProvince: '',
  310. selectedCity: '',
  311. images: [],
  312. propertyFieldValues: [],
  313. defaultImage: 0,
  314. wait: false,
  315. };
  316. },
  317. methods: {
  318. ...mapActions('searchTab', ['getProvince', 'getCities', 'getSuburbs']),
  319. ...mapActions('property', [
  320. 'getPropertyTypes',
  321. 'getPropertyOverviewFields',
  322. 'getPropertyFields',
  323. 'saveProperty',
  324. 'getProperty',
  325. 'getPropertyImages',
  326. 'clearProperty',
  327. 'clearPropertyImages',
  328. 'getPropertyEditDisplay',
  329. 'getPropertySavedOverviewFields',
  330. 'getPropertySavedFields',
  331. 'getSavedPropertyData',
  332. ]),
  333. SubmitData() {
  334. this.wait = true;
  335. if (this.salesType === 'Sale') {
  336. this.property.isSale = true;
  337. }
  338. for (let i = 0; i < this.images.length; i++) {
  339. let setAsDefault = false;
  340. if (i === this.defaultImage) {
  341. setAsDefault = true;
  342. }
  343. this.property.propertyImages.push({
  344. image: this.images[i],
  345. isDefault: setAsDefault,
  346. });
  347. }
  348. this.property.propertyUserFields = this.propertyFieldValues;
  349. this.saveProperty(this.property);
  350. setTimeout(
  351. () => this.$router.push({
  352. path: '/property/search',
  353. query: {
  354. salesType: this.salesType,
  355. propertyUsageType: this.propertyType,
  356. },
  357. }),
  358. 3000,
  359. );
  360. },
  361. ProvinceSelected(item) {
  362. if (item.target.options.selectedIndex > 0) {
  363. this.selectedProvince = this.provinces[
  364. item.target.options.selectedIndex - 1
  365. ].description;
  366. this.getCities(Object.assign({}, { province: this.selectedProvince }));
  367. }
  368. },
  369. CitySelected(item) {
  370. if (item.target.options.selectedIndex > 0) {
  371. this.selectedCity = this.cities[
  372. item.target.options.selectedIndex - 1
  373. ].description;
  374. this.getSuburbs(
  375. Object.assign(
  376. {},
  377. { province: this.selectedProvince, city: this.selectedCity },
  378. ),
  379. );
  380. }
  381. },
  382. getPostalCode(item) {
  383. this.property.addressLine3 = this.suburbs[
  384. item.target.options.selectedIndex - 1
  385. ].postalCode;
  386. },
  387. loadedImages(values) {
  388. this.images = values;
  389. },
  390. UpdateUserDefinedFields(item) {
  391. let update = false;
  392. this.propertyFieldValues.forEach((element) => {
  393. if (element.userDefinedFieldId === item.userDefinedFieldId) {
  394. element.value = item.value;
  395. update = true;
  396. }
  397. });
  398. if (!update) {
  399. this.propertyFieldValues.push(item);
  400. }
  401. },
  402. UpdateDefaultImage(item) {
  403. this.defaultImage = item;
  404. },
  405. },
  406. mounted() {
  407. this.wait = false;
  408. this.clearProperty();
  409. this.clearPropertyImages();
  410. this.images = [];
  411. this.defaultImage = 0;
  412. if (this.propertyOverviewFields.length > 0) {
  413. this.propertyOverviewFields = [];
  414. }
  415. if (this.propertyFields.length > 0) {
  416. this.propertyFields = [];
  417. }
  418. if (this.property.description !== '') {
  419. this.property.description = '';
  420. }
  421. this.propertyType = this.$route.params.propType;
  422. this.salesType = this.$route.params.saleType;
  423. this.getPropertyTypes(this.$route.params.propType);
  424. this.getProvince();
  425. if (this.$route.query.id) {
  426. // this.getCities(Object.assign({}, { province: this.selectedProvince }));
  427. this.getSavedPropertyData(
  428. Object.assign({}, { id: this.$route.query.id, type: this.propertyType }),
  429. );
  430. } else {
  431. this.getPropertyOverviewFields();
  432. this.getPropertyFields(this.$route.params.propType);
  433. }
  434. // if (this.$route.params.id) {
  435. // this.getPropertyEditDisplay(4); // (this.$route.params.id);
  436. // this.propertyType = 'Residential'; // this.propertyEditDisplay.propertyType;
  437. // this.salesType = 'Rental'; // this.propertyEditDisplay.saleType;
  438. // this.getProvince();
  439. // this.getPropertyTypes('Residential');
  440. // this.getPropertySavedOverviewFields(4);
  441. // this.getPropertySavedFields(
  442. // Object.assign(
  443. // {},
  444. // {
  445. // type: 'Residential',
  446. // id: 4,
  447. // },
  448. // ),
  449. // );
  450. // this.getProperty(this.$route.params.id);
  451. // } else {
  452. // }
  453. },
  454. computed: {
  455. ...mapState('searchTab', ['provinces', 'cities', 'suburbs']),
  456. ...mapState('property', [
  457. 'propertyTypes',
  458. 'propertyOverviewFields',
  459. 'propertyFields',
  460. 'property',
  461. 'propertyImages',
  462. ]),
  463. SalesTypeChanged() {
  464. // eslint-disable-next-line vue/no-side-effects-in-computed-properties
  465. this.propertyType = this.$route.params.propType;
  466. // eslint-disable-next-line vue/no-side-effects-in-computed-properties
  467. this.salesType = this.$route.params.saleType;
  468. if (!this.$route.query.id) {
  469. this.getPropertyTypes(this.$route.params.propType);
  470. this.getPropertyFields(this.$route.params.propType);
  471. }
  472. return this.propertyType;
  473. },
  474. },
  475. watch: {
  476. SalesTypeChanged() {
  477. console.log(this.salesType);
  478. },
  479. },
  480. };
  481. </script>