You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

propertyeditPage.vue 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <template>
  2. <div @submit.prevent="SubmitData">
  3. <div class="container">
  4. <section class="intro-single">
  5. <div class="container">
  6. <div class="row">
  7. <div class="col-md-12 col-lg-8">
  8. <div class="title-single-box">
  9. <h1 class="title-single">List {{ propertyType }} {{ salesType }} Property</h1>
  10. </div>
  11. </div>
  12. </div>
  13. </div>
  14. </section>
  15. <div class="row">
  16. <div class="col-sm-12">
  17. <div class="title-box-d">
  18. <h5 class="title-d">Property Overview</h5>
  19. </div>
  20. </div>
  21. </div>
  22. <div class="row mb-3">
  23. <div class="col-md-12">
  24. <form
  25. id="mainForm"
  26. method="POST"
  27. action="/to-sell"
  28. accept-charset="UTF-8"
  29. enctype="multipart/form-data"
  30. >
  31. <div class="form-group row">
  32. <div class="col-md-4">
  33. <label for="Property Type"></label>
  34. <select
  35. class="form-control"
  36. name="propertyType"
  37. id="propertyType"
  38. v-model="property.propertyTypeId"
  39. >
  40. <option value="0">Please select Property Type</option>
  41. <option v-for="item in propertyTypes" :value="item.id">{{ item.description }}</option>
  42. </select>
  43. </div>
  44. </div>
  45. <div class="form-group row">
  46. <div class="col-md-4">
  47. <label for="Address Line 1"></label>
  48. <input
  49. class="form-control"
  50. type="text"
  51. placeholder="Address Line 1"
  52. name="address1"
  53. id="address1"
  54. v-model="property.addressLine1"
  55. />
  56. </div>
  57. <div class="col-md-4">
  58. <label for="Address Line 2"></label>
  59. <input
  60. class="form-control"
  61. type="text"
  62. placeholder="Address Line 2"
  63. name="address2"
  64. id="address2"
  65. v-model="property.addressLine2"
  66. />
  67. </div>
  68. <div class="col-md-4">
  69. <label for="Address Line 3"></label>
  70. <input
  71. class="form-control"
  72. type="text"
  73. placeholder="Address Line 3"
  74. name="address3"
  75. id="address3"
  76. v-model="property.addressLine3"
  77. />
  78. </div>
  79. </div>
  80. <div class="form-group row">
  81. <div class="col-md-4">
  82. <label for="Province"></label>
  83. <select
  84. class="form-control"
  85. name="propertyType"
  86. id="propertyType"
  87. @change="ProvinceSelected"
  88. v-model="property.provinceId"
  89. >
  90. <option value="0">Please select Province</option>
  91. <option
  92. v-for="province in provinces"
  93. :value="province.id"
  94. >{{ province.description }}</option>
  95. </select>
  96. </div>
  97. <div class="col-md-4">
  98. <label for="City"></label>
  99. <select
  100. class="form-control"
  101. name="propertyType"
  102. id="propertyType"
  103. @change="CitySelected"
  104. v-model="property.cityId"
  105. >
  106. <option value="0">Please select City</option>
  107. <option v-for="city in cities" :value="city.id">{{ city.description }}</option>
  108. </select>
  109. </div>
  110. <div class="col-md-4">
  111. <label for="Suburb"></label>
  112. <select
  113. class="form-control"
  114. name="propertyType"
  115. id="suburbselector"
  116. v-model="property.suburbId"
  117. >
  118. <option value="0">Please select Suburb</option>
  119. <option v-for="suburb in suburbs" :value="suburb.id">{{ suburb.description }}</option>
  120. </select>
  121. </div>
  122. </div>
  123. <div class="form-group row">
  124. <div class="col-md-4">
  125. <label v-if="salesType === 'Rental'">Rental Price</label>
  126. <label v-if="salesType !== 'Rental'">Sales Price</label>
  127. <input
  128. class="form-control"
  129. type="number"
  130. name="price"
  131. id="price"
  132. placeholder="R"
  133. v-model="property.price"
  134. />
  135. </div>
  136. <div class="col-md-4" v-if="salesType === 'Rental'">
  137. <label>Per</label>
  138. <select
  139. class="form-control"
  140. name="propertyType"
  141. id="propertyType"
  142. v-model="property.per"
  143. >
  144. <option value>Please select</option>
  145. <option value="month">Month</option>
  146. <option value="day">Day</option>
  147. </select>
  148. </div>
  149. </div>
  150. <div class="form-group row">
  151. <div class="col-md-12">
  152. <label for="Property Description"></label>
  153. <textarea
  154. class="form-control editor"
  155. placeholder="Property Description"
  156. name="description"
  157. v-model="property.description"
  158. ></textarea>
  159. <br />
  160. <p>* A listing fee of R380 including VAT is payable to list your Property on the Uni-Vate website</p>
  161. </div>
  162. </div>
  163. <div class="form-group row" />
  164. <UserField v-if="ApiRunning" :fields="propValuesProp[0].fields"></UserField>
  165. <div class="form-group row" />
  166. <div v-for="item in propertyValues">
  167. <div class="row">
  168. <div class="col-sm-12">
  169. <div class="title-box-d">
  170. <h5 class="title-d">{{ item.name }}</h5>
  171. </div>
  172. </div>
  173. </div>
  174. <UserField :fields="item.fields" :id="item.id" />
  175. </div>
  176. <div class="form-group row" />
  177. <div class="row">
  178. <div class="col-sm-12">
  179. <div class="title-box-d">
  180. <h5 class="title-d">Images</h5>
  181. </div>
  182. </div>
  183. </div>
  184. <ImageLoad />
  185. <button type="submit" class="btn btn-b-n" style="width: 85px; height:40px;">Save</button>
  186. </form>
  187. </div>
  188. </div>
  189. </div>
  190. </div>
  191. </template>
  192. <script>
  193. import UserField from "./propertyUserField.vue";
  194. import ImageLoad from "./propertyImage.vue";
  195. export default {
  196. name: "PropertyEdit",
  197. components: {
  198. UserField,
  199. ImageLoad
  200. },
  201. data() {
  202. return {
  203. ApiRunning: false,
  204. propertyType: "Residential",
  205. salesType: "Rental",
  206. imageFile: "",
  207. provinces: [],
  208. cities: [],
  209. suburbs: [],
  210. propertyValues: [],
  211. propValuesProp: [],
  212. propertyTypes: [],
  213. selectedProvince: "",
  214. selectedCity: "",
  215. property: {
  216. propertyTypeId: 0,
  217. addressLine1: "",
  218. addressLine2: "",
  219. addressLine3: "",
  220. suburbId: 0,
  221. cityId: 0,
  222. provinceId: 0,
  223. price: "",
  224. per: "",
  225. description: "",
  226. isSale: false
  227. }
  228. };
  229. },
  230. methods: {
  231. SubmitData() {
  232. const axios = require("axios");
  233. axios
  234. .post("http://localhost:57260/Property/Property", this.property, {
  235. headers: {
  236. "Content-type": "application/json"
  237. }
  238. })
  239. .then(response => {})
  240. .catch(e => {
  241. alert(e);
  242. });
  243. console.log(JSON.stringify(this.property));
  244. },
  245. ProvinceSelected(item) {
  246. if (item.target.options.selectedIndex > 0) {
  247. this.selectedProvince = this.provinces[
  248. item.target.options.selectedIndex - 1
  249. ].description;
  250. const axios = require("axios");
  251. axios
  252. .get(
  253. `http://localhost:57260/region/city/getby/${this.selectedProvince}`
  254. )
  255. .then(response => (this.cities = response.data));
  256. }
  257. },
  258. CitySelected(item) {
  259. if (item.target.options.selectedIndex > 0) {
  260. this.selectedCity = this.cities[
  261. item.target.options.selectedIndex - 1
  262. ].description;
  263. const axios = require("axios");
  264. axios
  265. .get(
  266. `http://localhost:57260/region/Suburb/${this.selectedProvince}/${this.selectedCity}`
  267. )
  268. .then(response => (this.suburbs = response.data));
  269. }
  270. }
  271. },
  272. mounted() {
  273. this.propertyType = this.$route.params.propType;
  274. this.salesType = this.$route.params.saleType;
  275. const axios = require("axios");
  276. axios
  277. .get("http://localhost:57260/Property/PropertyFields/Property Overview")
  278. .then(response => (this.propValuesProp = response.data));
  279. axios
  280. .get("http://localhost:57260/Property/PropertyFields")
  281. .then(response => (this.propertyValues = response.data));
  282. axios
  283. .get(
  284. `http://localhost:57260/Property/PropertyType/type/${this.propertyType}`
  285. )
  286. .then(response => (this.propertyTypes = response.data));
  287. axios
  288. .get("http://localhost:57260/region/province")
  289. .then(response => (this.provinces = response.data));
  290. },
  291. computed: {
  292. SalesTypeChanged() {
  293. this.propertyType = this.$route.params.propType;
  294. this.salesType = this.$route.params.saleType;
  295. const axios = require("axios");
  296. axios
  297. .get(
  298. `http://localhost:57260/Property/PropertyType/type/${this.propertyType}`
  299. )
  300. .then(response => (this.propertyTypes = response.data));
  301. }
  302. },
  303. watch: {
  304. SalesTypeChanged() {
  305. console.log(this.salesType);
  306. }
  307. }
  308. };
  309. </script>