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.

propertyList.vue 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <!-- eslint-disable max-len -->
  3. <div>
  4. <div class="container">
  5. <section class="intro-single">
  6. <div class="container">
  7. <div class="row">
  8. <div class="col-md-12 col-lg-8">
  9. <div class="title-single-box">
  10. <h1 v-if="user !== 'All'" class="title-single">My {{ propertyType }} Properties</h1>
  11. <h1 v-else class="title-single">All {{ propertyType }} Properties</h1>
  12. </div>
  13. </div>
  14. </div>
  15. </div>
  16. </section>
  17. </div>
  18. <div class="container">
  19. <table class="table table-bordered">
  20. <thead>
  21. <tr>
  22. <th>Name</th>
  23. <th>Property ID</th>
  24. <th>Size</th>
  25. <th>Price</th>
  26. <th>Type</th>
  27. <th>Publish</th>
  28. <th>Status</th>
  29. <th></th>
  30. <th></th>
  31. </tr>
  32. </thead>
  33. <tbody>
  34. <tr v-for="(item, i) in properties" :key="i">
  35. <td>{{ item.name }}</td>
  36. <td>{{ item.id }}</td>
  37. <td v-html="item.size" />
  38. <td>{{ item.price }}</td>
  39. <td>{{ item.type }}</td>
  40. <td>{{ item.publish }}</td>
  41. <td>{{ item.status }}</td>
  42. <td>
  43. <button
  44. type="button"
  45. @click="Edit(item)"
  46. class="btn btn-b-n"
  47. style="width: 85px; height:40px;"
  48. >Edit</button>
  49. </td>
  50. <td>
  51. <button type="button" class="btn btn-b-n" style="width: 85px; height:40px;">Delete</button>
  52. </td>
  53. </tr>
  54. </tbody>
  55. </table>
  56. </div>
  57. </div>
  58. </template>
  59. <script>
  60. import { mapState, mapActions } from 'vuex';
  61. export default {
  62. name: 'PropertyList',
  63. data() {
  64. return {
  65. propertyType: '',
  66. user: '',
  67. };
  68. },
  69. methods: {
  70. ...mapActions('propertyList', ['getProperties']),
  71. Edit(item) {
  72. const salesType = item.isSale ? 'Sale' : 'Rental';
  73. this.$router.push({
  74. path: `/property/${this.propertyType}/${salesType}`,
  75. query: { id: item.id },
  76. });
  77. },
  78. },
  79. mounted() {
  80. this.propertyType = this.$route.params.propertyType;
  81. this.user = this.$route.params.user;
  82. if (this.user === 'MyListings') {
  83. this.user = 'GeorgeW';
  84. }
  85. this.getProperties(
  86. Object.assign(
  87. {},
  88. {
  89. propertyType: this.propertyType,
  90. user: this.user,
  91. },
  92. ),
  93. );
  94. },
  95. computed: {
  96. ...mapState('propertyList', ['properties']),
  97. TypeChanged() {
  98. // eslint-disable-next-line vue/no-side-effects-in-computed-properties
  99. this.propertyType = this.$route.params.propertyType;
  100. // eslint-disable-next-line vue/no-side-effects-in-computed-properties
  101. this.user = this.$route.params.user;
  102. this.getProperties(
  103. Object.assign(
  104. {},
  105. {
  106. propertyType: this.$route.params.propertyType,
  107. user: this.$route.params.user,
  108. },
  109. ),
  110. );
  111. return this.propertyType;
  112. },
  113. },
  114. watch: {
  115. TypeChanged() {
  116. console.log(this.propertyType);
  117. },
  118. },
  119. };
  120. </script>