Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

weekListComponent.vue 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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-solid-blue'"
  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", ["getWeeks", "applyResortFilter", "getByResortCode"]),
  173. View(item) {
  174. this.$router.push(`/resort/${item.resort.resortCode}/${item.unitNumber}`);
  175. },
  176. onChangeItemsPerPage() {
  177. if (this.currentPage !== 1) {
  178. this.currentPage = 1;
  179. }
  180. },
  181. async pageChangeHandle(value) {
  182. switch (value) {
  183. case "next":
  184. this.currentPage += 1;
  185. break;
  186. case "previous":
  187. this.currentPage -= 1;
  188. break;
  189. default:
  190. this.currentPage = value;
  191. }
  192. },
  193. checkStatus(item) {
  194. if (item.status.code === "CIP" || item.status.code === "S" || item.status.code === "P") {
  195. return true;
  196. } else {
  197. return false;
  198. }
  199. }
  200. }
  201. };
  202. </script>
  203. <style lang="scss" scoped>
  204. .btn-disabled {
  205. font-family: "Muli";
  206. font-size: 15px;
  207. letter-spacing: 1px;
  208. display: inline-block;
  209. padding: 10px 32px;
  210. border-radius: 2px;
  211. transition: 0.5s;
  212. margin: 10px;
  213. color: #fff;
  214. background: grey;
  215. border-color: black;
  216. color: black;
  217. cursor: not-allowed;
  218. }
  219. .btn-disabled :hover {
  220. background: grey;
  221. border-color: black;
  222. color: black;
  223. cursor: not-allowed;
  224. }
  225. </style>