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.

weekListComponent.vue 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <template>
  2. <div>
  3. <div v-if="filteredWeeks.length > 0">
  4. <table class="table table-striped table-responsive text-nowrap">
  5. <thead>
  6. <tr>
  7. <th scope="col">Ref</th>
  8. <th scope="col">Unit</th>
  9. <th scope="col">Module</th>
  10. <th scope="col">Arrival</th>
  11. <th scope="col">Departure</th>
  12. <th scope="col">Bedrooms</th>
  13. <th scope="col">Season</th>
  14. <th scope="col">Type</th>
  15. <th scope="col">Price Incl VAT</th>
  16. <th scope="col">Status</th>
  17. <th scope="col">Interested?</th>
  18. </tr>
  19. </thead>
  20. <tbody>
  21. <tr v-for="(item, i) in DisplayItems" :key="i">
  22. <td>#{{ item.id }}</td>
  23. <td>{{ item.unitNumber }}</td>
  24. <td>{{ item.module }}</td>
  25. <td
  26. v-if="
  27. item.arrivalDate === '0001-01-01T00:00:00' ||
  28. item.arrivalDate === '1753-01-01T00:00:00'
  29. "
  30. ></td>
  31. <td v-else>{{ item.arrivalDate | toDate }}</td>
  32. <td
  33. v-if="
  34. item.departureDate === '0001-01-01T00:00:00' ||
  35. item.departureDate === '1753-01-01T00:00:00'
  36. "
  37. ></td>
  38. <td v-else>{{ item.departureDate | toDate }}</td>
  39. <td>{{ item.bedrooms }}</td>
  40. <td>{{ item.season }}</td>
  41. <td>{{ item.weekType }}</td>
  42. <td>{{ item.sellPrice | toCurrency }}</td>
  43. <td v-if="item.status">{{ item.status.description }}</td>
  44. <!-- <td>{{ item.region ? item.region.regionName : "" }}</td>
  45. <td>{{ item.resort ? item.resort.resortName : "" }}</td>
  46. <td>{{ item.arrivalDate | toDate }}</td>
  47. <td>{{ item.departureDate | toDate }}</td>-->
  48. <!-- <td>{{item.status ? item.status.description : ''}}</td> -->
  49. <td>
  50. <button
  51. :disabled="checkStatus(item)"
  52. v-on:click="View(item)"
  53. :class="checkStatus(item) ? 'btn-disabled' : 'btn-white-border'"
  54. style="color: white;"
  55. >
  56. Yes
  57. </button>
  58. </td>
  59. <!-- <div class="col-md-12">
  60. <button type="button" class="btn btn-b-n" >View</button>
  61. </div>-->
  62. </tr>
  63. </tbody>
  64. </table>
  65. <div class="row">
  66. <div class="col-md-2">
  67. Items Per Page:
  68. <select
  69. class="form-control"
  70. v-model="visibleItemsPerPageCount"
  71. @change="onChangeItemsPerPage()"
  72. >
  73. <option v-for="(item, i) in visibleItemSelector" :key="i">
  74. {{ item }}
  75. </option>
  76. </select>
  77. </div>
  78. <div class="col-md-10 mt-4">
  79. <div style="float: right;">
  80. <BasePagination
  81. :currentPage="currentPage"
  82. :pageCount="PageCount"
  83. @nextPage="pageChangeHandle('next')"
  84. @previousPage="pageChangeHandle('previous')"
  85. @loadPage="pageChangeHandle"
  86. />
  87. </div>
  88. </div>
  89. </div>
  90. </div>
  91. <div v-else>
  92. <div class="row">
  93. <hr />
  94. <div class="col-md-12" v-if="status !== '' && status !== undefined">
  95. <b>{{ status }}</b>
  96. </div>
  97. <div class="col-md-12" v-if="status !== '' && status !== undefined">
  98. <img
  99. class="img-fluid"
  100. src="/img/kloader.gif"
  101. alt="UVProp logo"
  102. style="width: 128px; height: 128px;"
  103. />
  104. </div>
  105. <div v-else>No Results Found</div>
  106. <hr />
  107. </div>
  108. </div>
  109. </div>
  110. </template>
  111. <script>
  112. /* eslint-disable */
  113. import BasePagination from '../../shared/basePagination'
  114. import { mapState, mapActions, mapGetters } from 'vuex'
  115. export default {
  116. props: {
  117. resortCode: undefined,
  118. userId: undefined,
  119. currentPage: {
  120. default: 1,
  121. },
  122. },
  123. data() {
  124. return {
  125. visibleItemsPerPageCount: 8,
  126. visibleItemSelector: [5, 8, 10, 20, 50, 100],
  127. }
  128. },
  129. components: {
  130. BasePagination,
  131. },
  132. computed: {
  133. ...mapState('weekList', ['weeks', 'status']),
  134. ...mapGetters({
  135. filteredWeeks: 'weekList/filteredWeeks',
  136. getRegions: 'weekList/getRegions',
  137. }),
  138. DisplayItems() {
  139. const list = []
  140. this.filteredWeeks.forEach((week) => {
  141. if (week.publish) {
  142. list.push(week)
  143. }
  144. })
  145. const startSlice = (this.currentPage - 1) * this.visibleItemsPerPageCount
  146. let endSlice = this.currentPage * this.visibleItemsPerPageCount
  147. if (endSlice > list.length) {
  148. endSlice = list.length
  149. }
  150. return list.slice(startSlice, endSlice)
  151. },
  152. PageCount() {
  153. var list = []
  154. this.filteredWeeks.forEach((week) => {
  155. if (!week.isTender) {
  156. list.push(week)
  157. }
  158. })
  159. return this.visibleItemsPerPageCount !== 0
  160. ? Math.ceil(list.length / this.visibleItemsPerPageCount)
  161. : 1
  162. },
  163. },
  164. mounted() {
  165. //if (this.resortCode) {
  166. // this.applyResortFilter(this.resortCode);
  167. //}
  168. this.getByResortCode(this.$route.params.resortCode)
  169. //this.getWeeks();
  170. },
  171. methods: {
  172. ...mapActions('weekList', [
  173. 'getWeeks',
  174. 'applyResortFilter',
  175. 'getByResortCode',
  176. ]),
  177. View(item) {
  178. this.$router.push(`/resort/${item.resort.resortCode}/${item.unitNumber}`)
  179. },
  180. onChangeItemsPerPage() {
  181. if (this.currentPage !== 1) {
  182. this.currentPage = 1
  183. }
  184. },
  185. async pageChangeHandle(value) {
  186. switch (value) {
  187. case 'next':
  188. this.currentPage += 1
  189. break
  190. case 'previous':
  191. this.currentPage -= 1
  192. break
  193. default:
  194. this.currentPage = value
  195. }
  196. },
  197. checkStatus(item) {
  198. if (
  199. item.status.code === 'CIP' ||
  200. item.status.code === 'S' ||
  201. item.status.code === 'P'
  202. ) {
  203. return true
  204. } else {
  205. return false
  206. }
  207. },
  208. },
  209. }
  210. </script>
  211. <style lang="scss" scoped>
  212. .btn-disabled {
  213. font-family: 'Muli';
  214. font-size: 15px;
  215. letter-spacing: 1px;
  216. display: inline-block;
  217. padding: 10px 32px;
  218. border-radius: 2px;
  219. transition: 0.5s;
  220. margin: 10px;
  221. color: #fff;
  222. background: grey;
  223. border-color: black;
  224. color: black;
  225. cursor: not-allowed;
  226. }
  227. .btn-disabled :hover {
  228. background: grey;
  229. border-color: black;
  230. color: black;
  231. cursor: not-allowed;
  232. }
  233. </style>