選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

propertyList.vue 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <!-- eslint-disable max-len -->
  3. <div>
  4. <div class="container">
  5. <div class="container">
  6. <br />
  7. <br />
  8. <div class="row">
  9. <div class="col-md-12 col-lg-8">
  10. <div class="title-box-d">
  11. <h1 class="title-d" style="text-align:left; font-size: 250%">Properties</h1>
  12. </div>
  13. </div>
  14. </div>
  15. </div>
  16. </div>
  17. <div class="container">
  18. <listView
  19. :items="properties"
  20. :showNew="false"
  21. :editable="true"
  22. :deleteable="true"
  23. @onEdit="Edit"
  24. @onDelete="Delete"
  25. />
  26. </div>
  27. <br />
  28. </div>
  29. </template>
  30. <script>
  31. import { mapState, mapActions } from 'vuex';
  32. import listView from '../shared/listView.vue';
  33. export default {
  34. name: 'PropertyList',
  35. components: {
  36. listView,
  37. },
  38. data() {
  39. return {
  40. propertyType: '',
  41. role: 'MY',
  42. };
  43. },
  44. methods: {
  45. ...mapActions('propertyList', ['getProperties', 'deleteProperty']),
  46. Edit(item) {
  47. const salesType = item.isSale ? 'Sale' : 'Rental';
  48. this.$router.push({
  49. path: '/property/edit',
  50. query: { id: item.id },
  51. });
  52. },
  53. Delete(item) {
  54. this.deleteProperty(item.id);
  55. },
  56. },
  57. mounted() {
  58. if (this.user.role === 'Super Admin') {
  59. this.role = 'SUPERADMIN';
  60. }
  61. if (this.user.role === 'Agency') {
  62. this.user.role = 'ADMIN';
  63. }
  64. this.getProperties(
  65. Object.assign({
  66. propertyType: this.role,
  67. user: this.user.id,
  68. }),
  69. );
  70. },
  71. computed: {
  72. ...mapState('propertyList', ['properties']),
  73. ...mapState('authentication', ['user']),
  74. UserChanged() {
  75. if (this.user.role === 'Super Admin') {
  76. // eslint-disable-next-line vue/no-side-effects-in-computed-properties
  77. this.role = 'SUPERADMIN';
  78. }
  79. if (this.user.role === 'Agency') {
  80. // eslint-disable-next-line vue/no-side-effects-in-computed-properties
  81. this.user.role = 'ADMIN';
  82. }
  83. this.getProperties(
  84. Object.assign({
  85. propertyType: this.role,
  86. user: this.user.id,
  87. }),
  88. );
  89. return this.user;
  90. },
  91. },
  92. watch: {
  93. UserChanged() {
  94. console.log(this.user);
  95. },
  96. },
  97. };
  98. </script>