Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

editProperty.vue 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. <template>
  2. <div>
  3. <main id="main">
  4. <section id="services">
  5. <div class="container">
  6. <div class="col-12">
  7. <h1>Property Details</h1>
  8. </div>
  9. <main id="main" style="margin-top:-20px">
  10. <div class="container pt-5 pb-5">
  11. <div class="row my-3">
  12. <div class="col-md-6">
  13. <select
  14. class="form-control uniSelect"
  15. v-model="property.propertyUsageType"
  16. @change="UpdateUsageType"
  17. :disabled="!canEdit"
  18. >
  19. <option>Commercial</option>
  20. <option>Residential</option>
  21. </select>
  22. </div>
  23. <div class="col-md-6">
  24. <select
  25. class="form-control uniSelect"
  26. v-model="property.statusString"
  27. @change="StatusChanged"
  28. >
  29. <option v-for="(item, i) in statuses" :key="i">{{ item }}</option>
  30. </select>
  31. </div>
  32. </div>
  33. <div class="row my-3">
  34. <div class="col-md-6">
  35. <div v-if="!property.propertyName">
  36. <label for="propertyName" class="uniSelectLabel">PROPERTY NAME</label>
  37. </div>
  38. <input
  39. class="form-control uniInput"
  40. type="text"
  41. name="propertyName"
  42. v-model="property.propertyName"
  43. :disabled="!canEdit"
  44. />
  45. </div>
  46. <div class="col-md-6">
  47. <div v-if="!property.propertyRef">
  48. <label for="propertyName" class="uniSelectLabel">PROPERTY REFERENCE</label>
  49. </div>
  50. <input
  51. class="form-control uniInput"
  52. type="text"
  53. name="propertyRef"
  54. v-model="property.propertyRef"
  55. :disabled="!canEdit"
  56. />
  57. </div>
  58. </div>
  59. <div class="row my-3">
  60. <div class="col-md-6">
  61. <select
  62. class="form-control uniSelect"
  63. name="propertyType"
  64. id="propertyType"
  65. v-model="property.propertyTypeId"
  66. :disabled="!canEdit"
  67. >
  68. <option value="0">Please select type *</option>
  69. <option
  70. v-for="item in propertyTypes"
  71. :value="item.id"
  72. :key="item.id"
  73. >{{ item.description }}</option>
  74. </select>
  75. </div>
  76. <div v-if="property.propertyUsageType === 'Commercial'" class="col-md-2">
  77. <div v-if="!property.unit">
  78. <label for="unit" class="uniSelectLabel">UNIT</label>
  79. </div>
  80. <input
  81. class="form-control uniInput"
  82. type="text"
  83. name="unit"
  84. id="unit"
  85. v-model="property.unit"
  86. :disabled="!canEdit"
  87. />
  88. </div>
  89. </div>
  90. <div class="row my-3">
  91. <div class="col-md-6">
  92. <mapSection
  93. v-on:map-location="updateLocation"
  94. :savedCoords="property.propertCoords"
  95. :canEdit="canEdit"
  96. />
  97. <input
  98. type="checkbox"
  99. v-model="property.showAddress"
  100. style="margin-right: 10px; margin-top: 10px;"
  101. :disabled="!canEdit"
  102. />
  103. <label>Show address on listing</label>
  104. </div>
  105. <div class="col-md-6">
  106. <div class="row">
  107. <div class="col-md-6">
  108. <div v-if="property.price < 1">
  109. <label
  110. for="price"
  111. class="uniSelectLabel"
  112. style="text-transform:uppercase; margin-left:17px; background-color:white"
  113. >{{ property.salesTypeString }} Price</label>
  114. </div>
  115. <input
  116. class="form-control uniInput"
  117. type="number"
  118. name="price"
  119. id="price"
  120. v-model="property.price"
  121. :disabled="!canEdit"
  122. />
  123. </div>
  124. <div v-if="!property.isSale" class="col-md-6">
  125. <select
  126. class="form-control uniSelect"
  127. name="propertyType"
  128. id="propertyType"
  129. v-model="property.pricePer"
  130. :disabled="!canEdit"
  131. >
  132. <option value>Please select</option>
  133. <option value="Month">Month</option>
  134. <option value="Day">Day</option>
  135. </select>
  136. </div>
  137. </div>
  138. <div class="row my-3">
  139. <div class="col-md-12">
  140. <input
  141. type="date"
  142. class="form-control uniInput"
  143. name="date"
  144. v-model="property.dateAvailableString"
  145. :disabled="!canEdit"
  146. />
  147. </div>
  148. </div>
  149. <div class="row my-3">
  150. <br />
  151. </div>
  152. <div class="row my-3">
  153. <div class="col-md-12">
  154. <div v-if="!property.streetNumber">
  155. <label for="streetNumber" class="uniSelectLabel">STREET NUMBER</label>
  156. </div>
  157. <input
  158. class="form-control uniInput"
  159. type="text"
  160. name="streetNumber"
  161. id="unit"
  162. v-model="property.streetNumber"
  163. disabled
  164. />
  165. </div>
  166. </div>
  167. <div class="row my-3">
  168. <div class="col-md-12">
  169. <div v-if="!property.streetName">
  170. <label for="streetName" class="uniSelectLabel">STREET NAME</label>
  171. </div>
  172. <input
  173. class="form-control uniInput"
  174. type="text"
  175. name="streetName"
  176. id="unit"
  177. v-model="property.streetName"
  178. disabled
  179. />
  180. </div>
  181. </div>
  182. <div class="row my-3">
  183. <div class="col-md-12">
  184. <div v-if="!property.suburb">
  185. <label for="suburb" class="uniSelectLabel">SUBURB</label>
  186. </div>
  187. <input
  188. class="form-control uniInput"
  189. type="text"
  190. name="suburb"
  191. id="unit"
  192. v-model="property.suburb"
  193. disabled
  194. />
  195. </div>
  196. </div>
  197. <div class="row my-3">
  198. <div class="col-md-12">
  199. <div v-if="!property.city">
  200. <label for="city" class="uniSelectLabel">CITY</label>
  201. </div>
  202. <input
  203. class="form-control uniInput"
  204. type="text"
  205. name="city"
  206. id="unit"
  207. v-model="property.city"
  208. disabled
  209. />
  210. </div>
  211. </div>
  212. <div class="row my-3">
  213. <div class="col-md-12">
  214. <div v-if="!property.province">
  215. <label for="province" class="uniSelectLabel">PROVINCE</label>
  216. </div>
  217. <input
  218. class="form-control uniInput"
  219. type="text"
  220. name="province"
  221. id="unit"
  222. v-model="property.province"
  223. disabled
  224. />
  225. </div>
  226. </div>
  227. <div class="row my-3">
  228. <div class="col-md-12">
  229. <div v-if="!property.postalCode">
  230. <label for="postalCode" class="uniSelectLabel">POSTAL CODE</label>
  231. </div>
  232. <input
  233. class="form-control uniInput"
  234. type="text"
  235. name="postalCode"
  236. id="unit"
  237. v-model="property.postalCode"
  238. disabled
  239. />
  240. </div>
  241. </div>
  242. <div class="row my-3">
  243. <div class="col-md-12">
  244. <div v-if="!property.country">
  245. <label for="country" class="uniSelectLabel">COUNTRY</label>
  246. </div>
  247. <input
  248. class="form-control uniInput"
  249. type="text"
  250. name="country"
  251. id="unit"
  252. v-model="property.country"
  253. disabled
  254. />
  255. </div>
  256. </div>
  257. <div class="row my-3">
  258. <div class="col-md-12">
  259. <button
  260. type="button"
  261. @click="clearAddress()"
  262. class="btn-solid-blue"
  263. >Clear Address</button>
  264. </div>
  265. </div>
  266. </div>
  267. </div>
  268. <div class="row">
  269. <div class="col-md-12">
  270. <label for="Property Description" style="font-family:'muli'">Description:</label>
  271. <vue-editor
  272. v-model="property.description"
  273. :editor-toolbar="customToolbar"
  274. :disabled="!canEdit"
  275. />
  276. <br />
  277. <p>
  278. * A listing fee of R380 including VAT is payable to list your Property on the
  279. Uni-Vate website
  280. </p>
  281. </div>
  282. </div>
  283. <div class="row">
  284. <div class="section-header">
  285. <h2>Property Information</h2>
  286. </div>
  287. <div class="row mb-3" v-for="item in propertyFields" :key="item.id">
  288. <div class="col-md-6" v-for="field in item.fields" :key="field.id">
  289. <div v-if="field.type === 'number'">
  290. {{ field.name }}
  291. <input
  292. type="number"
  293. class="form-control uniInput"
  294. v-model="field.value"
  295. :disabled="!canEdit"
  296. />
  297. </div>
  298. <div v-else class="display:none"></div>
  299. <div v-if="field.type === 'yesno'">
  300. {{ field.name }}
  301. <input
  302. type="checkbox"
  303. v-model="field.value"
  304. :disabled="!canEdit"
  305. />
  306. </div>
  307. </div>
  308. </div>
  309. </div>
  310. <div class="row">
  311. <div class="col-sm-12">
  312. <div class="section-header">
  313. <h2>Media</h2>
  314. </div>
  315. </div>
  316. </div>
  317. <div class="form-group row">
  318. <div class="col-md-12">
  319. <label class="uniSelectLabel">Virtual Tour (URL)</label>
  320. <div class="input-group-prepend">
  321. <input
  322. class="form-control uniInput"
  323. type="link"
  324. name="vtlink"
  325. id="vtlink"
  326. v-model="property.virtualTour"
  327. :disabled="!canEdit"
  328. />
  329. </div>
  330. </div>
  331. </div>
  332. <div class="row">
  333. <div class="col-md-12">
  334. <label class="uniSelectLabel">Video (URL)</label>
  335. <div class="input-group-prepend">
  336. <input
  337. class="form-control uniInput"
  338. type="link"
  339. name="vlink"
  340. id="vlink"
  341. v-model="property.video"
  342. :disabled="!canEdit"
  343. />
  344. </div>
  345. </div>
  346. </div>
  347. <div class="row mt-3">
  348. <div class="col-md-6">
  349. <div class="content-header">
  350. <h2>Images</h2>
  351. </div>
  352. <div class="input-group-prepend"></div>
  353. </div>
  354. </div>
  355. <ImageLoad
  356. :savedImages="propertyImages"
  357. :loadedImages="loadedImages"
  358. @DefaultImage="UpdateDefaultImage"
  359. @DeleteImage="DeleteImage"
  360. :mayEdit="canEdit"
  361. />
  362. <button v-if="!wait" type="button" @click="SubmitData()" class="btn-solid-blue">Save</button>
  363. <button v-if="!wait" type="button" @click="Close()" class="btn-solid-blue">Close</button>
  364. <div v-if="showPropertyTypeError">
  365. <p
  366. class="alert myError"
  367. >Missing fields. Please fill in all required fields. Marked with *</p>
  368. </div>
  369. <div v-if="!addressSet">
  370. <p class="alert myError">Please enter an address.</p>
  371. </div>
  372. <div v-if="wait" id="preloader"></div>
  373. </div>
  374. </main>
  375. </div>
  376. </section>
  377. </main>
  378. </div>
  379. </template>
  380. <script>
  381. /* eslint-disable */
  382. import { mapState, mapActions } from "vuex";
  383. import mapSection from "../mapSection";
  384. import ImageLoad from "../propertyImage";
  385. import _ from "lodash";
  386. export default {
  387. name: "PropertyEditPage",
  388. components: {
  389. mapSection,
  390. ImageLoad,
  391. },
  392. data() {
  393. return {
  394. addressSet: true,
  395. defaultImage: 0,
  396. images: [],
  397. wait: false,
  398. canEdit: true,
  399. };
  400. },
  401. methods: {
  402. ...mapActions("property", [
  403. "getProperty",
  404. "getPropertyTypes",
  405. "getPropertyFields",
  406. "updateProperty",
  407. ]),
  408. StatusChanged(item) {
  409. if (
  410. item.target.value === "Offer Pending" ||
  411. item.target.value === "Sold" ||
  412. item.target.value === "Rented Out"
  413. ) {
  414. this.canEdit = false;
  415. } else {
  416. this.canEdit = true;
  417. }
  418. if (item.target.value === "For Rent") {
  419. this.property.isSale = false;
  420. }
  421. if (item.target.value === "For Sale") {
  422. this.property.isSale = true;
  423. }
  424. },
  425. clearAddress() {
  426. this.addressSet = false;
  427. this.property.streetNumber = undefined;
  428. this.property.streetName = undefined;
  429. this.property.suburb = undefined;
  430. this.property.city = undefined;
  431. this.property.province = undefined;
  432. this.property.country = undefined;
  433. this.property.postalCode = undefined;
  434. this.property.addressUrl = undefined;
  435. this.property.propertCoords = undefined;
  436. },
  437. UpdateUsageType() {
  438. this.getPropertyTypes(this.property.propertyUsageType);
  439. this.getPropertyFields(this.property.propertyUsageType);
  440. },
  441. UpdateDefaultImage(item) {
  442. this.defaultImage = item;
  443. for (let i = 0; i < this.propertyImages.length; i++) {
  444. if (i === item) {
  445. this.propertyImages[i].isDefault = true;
  446. } else {
  447. this.propertyImages[i].isDefault = false;
  448. }
  449. }
  450. },
  451. loadedImages(values) {
  452. this.images = values;
  453. },
  454. SubmitData() {
  455. this.wait = true;
  456. this.property.propertyFields = this.propertyFields;
  457. if (this.images.length > 0) {
  458. this.property.newImages = [];
  459. }
  460. // eslint-disable-next-line no-plusplus
  461. for (let i = 0; i < this.images.length; i++) {
  462. let setAsDefault = false;
  463. if (i === this.defaultImage) {
  464. setAsDefault = true;
  465. }
  466. this.property.newImages.push({
  467. image: this.images[i],
  468. isDefault: setAsDefault,
  469. });
  470. }
  471. this.property.propertyImages = this.propertyImages;
  472. //console.log(JSON.stringify(this.property));
  473. this.updateProperty(this.property).then((fulfilled) => {
  474. this.$router.push("/PropertyAdmin");
  475. });
  476. },
  477. Close() {
  478. this.$router.push("/PropertyAdmin");
  479. },
  480. updateLocation(place) {
  481. this.addressSet = true;
  482. this.property.streetNumber = place.streetNumber;
  483. this.property.streetName = place.streetName;
  484. this.property.suburb = place.suburb;
  485. this.property.city = place.city;
  486. this.property.province = place.province;
  487. this.property.country = place.country;
  488. this.property.postalCode = place.postalCode;
  489. this.property.addressUrl = place.url;
  490. this.property.propertCoords = place.coords;
  491. },
  492. DeleteImage(item) {
  493. this.propertyImages[item].isDeleted = true;
  494. },
  495. },
  496. mounted() {
  497. this.getProperty(this.$route.params.id).then((fulfilled) => {
  498. this.wait = false;
  499. if (
  500. this.property.statusString === "Offer Pending" ||
  501. this.property.statusString === "Sold" ||
  502. this.property.statusString === "Rented Out"
  503. ) {
  504. this.canEdit = false;
  505. } else {
  506. this.canEdit = true;
  507. }
  508. });
  509. },
  510. computed: {
  511. ...mapState("property", [
  512. "property",
  513. "propertyTypes",
  514. "propertyImages",
  515. "propertyFields",
  516. "statuses",
  517. ]),
  518. savedImages() {
  519. const list = [];
  520. for (let i = 0; i < this.propertyImages.length; i++) {
  521. list.push(this.proeprtyImages[i].image);
  522. }
  523. return list;
  524. },
  525. },
  526. };
  527. </script>
  528. <style lang="scss" scoped></style>