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

propertySearchFields.vue 7.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <div>
  3. <div class="container text-left">
  4. <div class="form-group">
  5. <label for="city">For:</label>
  6. <div class="input-group mb-3">
  7. <div class="input-group-prepend">
  8. <span class="input-group-text" style="color: #60CBEB">
  9. <b>F</b>
  10. </span>
  11. </div>
  12. <select
  13. class="form-control form-control-lg form-control-a"
  14. id="forSelector"
  15. v-model="propertySearch.salesType"
  16. @change="salesTypeSelected"
  17. >
  18. <option value="Sale">Sale</option>
  19. <option value="Rent">Rent</option>
  20. </select>
  21. </div>
  22. </div>
  23. <div class="form-group" v-if="propertyType === 'Residential'">
  24. <label for="propertytype">Property Type</label>
  25. <div class="input-group mb-3">
  26. <div class="input-group-prepend">
  27. <span class="input-group-text" style="color: #60CBEB">
  28. <b>T</b>
  29. </span>
  30. </div>
  31. <select
  32. class="form-control form-control-lg form-control-a"
  33. id="forSelector"
  34. v-model="resType"
  35. @change="PropertyTypeSelected"
  36. >
  37. <option>All</option>
  38. <option
  39. v-for="(propertyType, i) in propertyTypesRes"
  40. :key="i"
  41. >{{ propertyType.description }}</option>
  42. </select>
  43. <div class="input-group-append" @click="clearResType">
  44. <span class="input-group-text cursor-pointer" style="color: #60CBEB">
  45. <b>X</b>
  46. </span>
  47. </div>
  48. </div>
  49. </div>
  50. <div v-else class="form-group">
  51. <label for="propertytype">Property Type</label>
  52. <div class="input-group mb-3">
  53. <div class="input-group-prepend">
  54. <span class="input-group-text" style="color: #60CBEB">
  55. <b>T</b>
  56. </span>
  57. </div>
  58. <select
  59. class="form-control form-control-lg form-control-a"
  60. id="forSelector"
  61. v-model="comType"
  62. @change="PropertyTypeSelected"
  63. >
  64. <option>All</option>
  65. <option
  66. v-for="(propertyType, i) in propertyTypesCom"
  67. :key="i"
  68. >{{ propertyType.description }}</option>
  69. </select>
  70. <div class="input-group-append" @click="clearComType">
  71. <span class="input-group-text cursor-pointer" style="color: #60CBEB">
  72. <b>X</b>
  73. </span>
  74. </div>
  75. </div>
  76. </div>
  77. <div class="form-group">
  78. <label for="province">Province</label>
  79. <div class="input-group mb-3">
  80. <div class="input-group-prepend">
  81. <span class="input-group-text" style="color: #60CBEB">
  82. <b>P</b>
  83. </span>
  84. </div>
  85. <select
  86. class="form-control form-control-lg form-control-a"
  87. id="provinceselector"
  88. @change="ProvinceSelected"
  89. v-model="propertySearch.province"
  90. >
  91. <option>All</option>
  92. <option v-for="(province, i) in provinces" :key="i">{{ province.description }}</option>
  93. </select>
  94. <div class="input-group-append" @click="clearFilter('province')">
  95. <span class="input-group-text cursor-pointer" style="color: #60CBEB">
  96. <b>X</b>
  97. </span>
  98. </div>
  99. </div>
  100. </div>
  101. </div>
  102. <div class="container text-left">
  103. <div class="form-group">
  104. <label for="city">City</label>
  105. <div class="input-group mb-3">
  106. <div class="input-group-prepend">
  107. <span class="input-group-text" style="color: #60CBEB">
  108. <b>C</b>
  109. </span>
  110. </div>
  111. <select
  112. class="form-control form-control-lg form-control-a"
  113. id="cityselector"
  114. @change="CitySelected"
  115. v-model="propertySearch.city"
  116. >
  117. <option>All</option>
  118. <option v-for="(city, i) in cities" :key="i">{{ city.description }}</option>
  119. </select>
  120. <div class="input-group-append" @click="clearFilter('city')">
  121. <span class="input-group-text cursor-pointer" style="color: #60CBEB">
  122. <b>X</b>
  123. </span>
  124. </div>
  125. </div>
  126. </div>
  127. </div>
  128. <div class="container text-left">
  129. <div class="form-group">
  130. <label for="suburb">Suburb</label>
  131. <div class="input-group mb-3">
  132. <div class="input-group-prepend">
  133. <span class="input-group-text" style="color: #60CBEB">
  134. <b>S</b>
  135. </span>
  136. </div>
  137. <select
  138. class="form-control form-control-lg form-control-a"
  139. id="suburbselector"
  140. v-model="propertySearch.suburb"
  141. @change="SuburbSeleted"
  142. >
  143. <option>All</option>
  144. <option v-for="(suburb, i) in suburbs" :key="i">{{ suburb.description }}</option>
  145. </select>
  146. <div class="input-group-append" @click="clearFilter('suburb')">
  147. <span class="input-group-text cursor-pointer" style="color: #60CBEB">
  148. <b>X</b>
  149. </span>
  150. </div>
  151. </div>
  152. </div>
  153. </div>
  154. </div>
  155. </template>
  156. <script>
  157. import { mapState, mapActions } from 'vuex';
  158. export default {
  159. props: {
  160. propertyType: String,
  161. },
  162. data() {
  163. return {
  164. resType: 'All',
  165. comType: 'All',
  166. };
  167. },
  168. mounted() {
  169. this.getProvince();
  170. this.getPropertyTypesRes();
  171. this.getPropertyTypesCom();
  172. this.getPropertySearchObject();
  173. setTimeout(() => {
  174. this.propertySearch.propertyUsageType = this.propertyType;
  175. }, 100);
  176. },
  177. computed: {
  178. ...mapState('searchTab', ['provinces', 'cities', 'suburbs']),
  179. ...mapState('property', ['propertyTypesRes', 'propertyTypesCom']),
  180. ...mapState('propertySearch', ['propertySearch']),
  181. },
  182. methods: {
  183. ...mapActions('searchTab', ['getProvince', 'getCities', 'getSuburbs']),
  184. ...mapActions('property', ['getPropertyTypesRes', 'getPropertyTypesCom']),
  185. ...mapActions('propertySearch', ['getPropertySearchObject', 'clearFilter']),
  186. clearResType() {
  187. this.clearFilter('propertyType');
  188. this.resType = 'All';
  189. },
  190. clearComType() {
  191. this.clearFilter('propertyType');
  192. this.comType = 'All';
  193. },
  194. salesTypeSelected() {
  195. this.$emit('updateSearch', this.propertySearch);
  196. },
  197. PropertyTypeSelected(item) {
  198. this.propertySearch.propertyType = item.target.value;
  199. this.$emit('updateSearch', this.propertySearch);
  200. },
  201. ProvinceSelected(item) {
  202. if (item.target.value !== 'All') {
  203. this.getCities(
  204. Object.assign({}, { province: this.propertySearch.province }),
  205. );
  206. }
  207. this.$emit('updateSearch', this.propertySearch);
  208. },
  209. CitySelected(item) {
  210. if (item.target.value !== 'All') {
  211. this.getSuburbs(
  212. Object.assign(
  213. {},
  214. {
  215. province: this.propertySearch.province,
  216. city: this.propertySearch.city,
  217. },
  218. ),
  219. );
  220. }
  221. this.$emit('updateSearch', this.propertySearch);
  222. },
  223. SuburbSeleted() {
  224. this.$emit('updateSearch', this.propertySearch);
  225. },
  226. },
  227. };
  228. </script>