Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

commercialCreateNew.vue 18KB

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