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.

timeshareAdminList.vue 9.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. <template>
  2. <section id="contact2">
  3. <div class="container">
  4. <div class="section-header">
  5. <h1>Property Admin</h1>
  6. </div>
  7. <div class="row">
  8. <div class="col-lg-6 offset-3">
  9. <input class="form-control uniSelect" type="text" placeholder="SEARCH" v-model="filter" />
  10. </div>
  11. </div>
  12. <div class="row">
  13. <br />
  14. </div>
  15. <div class="row">
  16. <div class="col-lg-12">
  17. <table class="table table-striped table-responsive">
  18. <thead>
  19. <tr>
  20. <th scope="col" v-for="(col, c) in displayColumns" :key="c">
  21. <div @click="sortBy(columns[c])" style="cursor: pointer;">
  22. <div class="d-flex bd-highlight">
  23. <div class="w-100 bd-highlight">{{ col }}</div>
  24. <div class="flex-shrink-1 bd-highlight">
  25. <img
  26. src="../../../../public/img/sort-up.png"
  27. height="8px;"
  28. v-if="sortKey === columns[c] && reverse"
  29. />
  30. <img
  31. src="../../../../public/img/sort-down.png"
  32. height="8px;"
  33. v-if="sortKey === columns[c] && !reverse"
  34. />
  35. </div>
  36. </div>
  37. </div>
  38. </th>
  39. <!-- <th scope="col">Property</th>
  40. <th scope="col">Unit</th>
  41. <th scope="col">Size</th>
  42. <th scope="col">Price Ex VAT</th>
  43. <th scope="col">Region</th>
  44. <th scope="col">Town</th>
  45. <th scope="col">Suburb</th>
  46. <th scope="col">Status</th>
  47. <th scope="col">Type</th>-->
  48. <th scope="col">Publish</th>
  49. <th scope="col">Edit</th>
  50. <th scope="col">Delete</th>
  51. </tr>
  52. </thead>
  53. <tbody>
  54. <tr v-for="(item, i) in DisplayItems" :key="i">
  55. <td>{{ item.owner }}</td>
  56. <td>{{ item.agent }}</td>
  57. <td>{{ item.resort.resortName }}</td>
  58. <td>{{ item.weekNumber }}</td>
  59. <td>{{ item.unitNumber }}</td>
  60. <td>{{ item.bedrooms }}</td>
  61. <td>{{ item.season }}</td>
  62. <td>{{ item.region.regionName }}</td>
  63. <td>{{ item.sellPrice | toCurrency }}</td>
  64. <td>{{ item.pulbishedDate | toDate }}</td>
  65. <td>{{ item.weekStatus }}</td>
  66. <td v-if="!item.publish">
  67. <a v-on:click="Publish(item)">
  68. <img src="../../../../public/img/icons/Upload.png" height="25" width="25" />
  69. </a>
  70. </td>
  71. <td v-else>
  72. <a v-on:click="Unpublish(item)">
  73. <img
  74. src="../../../../public/img/icons/Download-grey.png"
  75. height="25"
  76. width="25"
  77. />
  78. </a>
  79. </td>
  80. <td>
  81. <a v-on:click="Edit(item)">
  82. <img src="../../../../public/img/icons/Edit.png" height="25" width="25" />
  83. </a>
  84. </td>
  85. <td>
  86. <a v-on:click="Delete(item)">
  87. <img src="../../../../public/img/icons/delete.png" height="25" width="25" />
  88. </a>
  89. </td>
  90. </tr>
  91. </tbody>
  92. </table>
  93. <div class="d-flex justify-content-between" v-if="showPager">
  94. <div class="p-1">
  95. {{ currentPage + " / " + PageCount + (" - (" + FilteredListings.length + " items)") }}
  96. </div>
  97. <div class="p-1">
  98. <BasePagination
  99. :currentPage="currentPage"
  100. :pageCount="PageCount"
  101. @nextPage="pageChangeHandle('next')"
  102. @previousPage="pageChangeHandle('previous')"
  103. @loadPage="pageChangeHandle"
  104. />
  105. </div>
  106. <div class="p-2">
  107. <div class="d-flex flex-row">
  108. <div>
  109. <select
  110. class="form-control uniSelect"
  111. v-model="visibleItemsPerPageCount"
  112. @change="onChangeItemsPerPage()"
  113. >
  114. <option v-for="(item, i) in itemsPerPageList" :key="i">{{ item }}</option>
  115. </select>
  116. </div>
  117. </div>
  118. </div>
  119. </div>
  120. <div class="p-2">
  121. <div class="d-flex flex-row">
  122. <div>
  123. <button v-if="sortKey !== 'id'" class="btn-solid-blue" @click="ClearSort">
  124. Clear Sort
  125. </button>
  126. </div>
  127. </div>
  128. </div>
  129. </div>
  130. </div>
  131. <div v-if="wait" id="preloader"></div>
  132. </div>
  133. </section>
  134. </template>
  135. <script>
  136. /* eslint-disable */
  137. import { mapState, mapActions, mapGetters } from "vuex";
  138. import Log from "../../../assets/Log";
  139. import BasePagination from "../../shared/basePagination";
  140. import ItemsPerPageList from "../../../assets/staticData/itemsPerPageFive";
  141. import _ from "lodash";
  142. export default {
  143. components: {
  144. BasePagination
  145. },
  146. data() {
  147. return {
  148. hover: -1,
  149. filter: undefined,
  150. userId: Log.getUser().id,
  151. wait: true,
  152. showPager: true,
  153. visibleItemsPerPageCount: 10,
  154. itemsPerPageList: ItemsPerPageList,
  155. currentPage: 1,
  156. reverse: true,
  157. sortKey: "id",
  158. displayColumns: [
  159. "Owner",
  160. "Agent",
  161. "Resort",
  162. "Week Module",
  163. "Unit",
  164. "Beds",
  165. "Season",
  166. "Region",
  167. "Amount",
  168. "Submitted",
  169. "Status"
  170. ],
  171. columns: [
  172. "owner",
  173. "agent",
  174. "resort",
  175. "weekNumber",
  176. "unitNumber",
  177. "bedrooms",
  178. "season",
  179. "region",
  180. "sellPrice",
  181. "weekStatus"
  182. ]
  183. };
  184. },
  185. methods: {
  186. ...mapActions("myWeeks", ["getAllItems"]),
  187. ...mapActions("myWeeks", ["getItems", "verifyWeek", "editSave"]),
  188. Publish(item) {
  189. var today = new Date();
  190. var dd = String(today.getDate()).padStart(2, "0");
  191. var mm = String(today.getMonth() + 1).padStart(2, "0"); //January is 0!
  192. var yyyy = today.getFullYear();
  193. item.pulbishedDate = today.toISOString().substring(0, 19);
  194. item.publish = true;
  195. item.owner = {
  196. name: item.owner
  197. };
  198. item.agent = {
  199. name: item.agent
  200. };
  201. console.log(JSON.stringify(item));
  202. this.editSave(item);
  203. },
  204. Unpublish(item) {
  205. item.publish = false;
  206. item.owner = {
  207. name: item.owner
  208. };
  209. item.agent = {
  210. name: item.agent
  211. };
  212. console.log(item);
  213. this.editSave(item);
  214. },
  215. Edit(item) {
  216. this.$router.push({ name: "EditTimeshare", params: { weekParam: item } });
  217. // this.$router.push(`/editTimeShare/${item.id}`);
  218. },
  219. Delete(item) {
  220. this.deleteProperty(item.id);
  221. },
  222. async pageChangeHandle(value) {
  223. switch (value) {
  224. case "next":
  225. this.currentPage += 1;
  226. break;
  227. case "previous":
  228. this.currentPage -= 1;
  229. break;
  230. default:
  231. this.currentPage = value;
  232. }
  233. },
  234. sortBy(sortKey) {
  235. this.reverse = this.sortKey === sortKey ? !this.reverse : false;
  236. this.sortKey = sortKey;
  237. },
  238. ClearSort() {
  239. this.reverse = true;
  240. this.sortKey = "id";
  241. }
  242. },
  243. computed: {
  244. ...mapState("propertyList", ["properties"]),
  245. ...mapGetters({ getNeedsVerify: "myWeeks/getNeedsVerify" }),
  246. FilteredListings() {
  247. if (this.filter) {
  248. const list = _.filter(this.getNeedsVerify, item =>
  249. Object.values(item).some(
  250. i =>
  251. JSON.stringify(i)
  252. .toLowerCase()
  253. .indexOf(this.filter.toLowerCase()) > -1
  254. )
  255. );
  256. return _.orderBy(list, this.sortKey, this.SortDirection);
  257. } else {
  258. return _.orderBy(this.getNeedsVerify, this.sortKey, this.SortDirection);
  259. }
  260. },
  261. PageCount() {
  262. return this.visibleItemsPerPageCount !== 0
  263. ? Math.ceil(this.FilteredListings.length / this.visibleItemsPerPageCount)
  264. : 1;
  265. },
  266. DisplayItems() {
  267. const list = this.FilteredListings;
  268. const startSlice = (this.currentPage - 1) * this.visibleItemsPerPageCount;
  269. let endSlice = this.currentPage * this.visibleItemsPerPageCount;
  270. if (endSlice > list.length) {
  271. endSlice = list.length;
  272. }
  273. return list.slice(startSlice, endSlice);
  274. },
  275. SortDirection() {
  276. return this.reverse ? "desc" : "asc";
  277. }
  278. },
  279. created() {
  280. this.getItems(this.userId).then(() => {
  281. this.wait = false;
  282. });
  283. },
  284. mounted() {
  285. // this.getAdminProperties(this.userId).then(fulfuilled => {
  286. // this.wait = false;
  287. // if (this.itemsPerPageList && this.itemsPerPageList.length > 0) {
  288. // const [startItem] = this.itemsPerPageList;
  289. // this.visibleItemsPerPageCount = startItem;
  290. // }
  291. // });
  292. },
  293. watch: {
  294. filter: {
  295. immediate: true,
  296. handler(val, oldVal) {
  297. if (val != oldVal) {
  298. this.currentPage = 1;
  299. }
  300. }
  301. }
  302. }
  303. };
  304. </script>
  305. <style lang="scss" scoped>
  306. .refbyAgent {
  307. will-change: transform;
  308. transition: height 500ms;
  309. height: 0px;
  310. }
  311. .refbyAgent--clicked {
  312. height: 150px;
  313. }
  314. .spacebanked1 {
  315. will-change: transform;
  316. transition: height 500ms;
  317. height: 0px;
  318. }
  319. .spacebanked1--clicked {
  320. height: 150px;
  321. }
  322. .custom-file-label {
  323. border-width: 2px;
  324. border-color: rgb(27, 117, 187);
  325. margin-bottom: 20px;
  326. }
  327. .custom-file-label::after {
  328. border-left: none;
  329. border-bottom: solid;
  330. border-width: 2px;
  331. border-color: rgb(27, 117, 187);
  332. font-family: "Muli";
  333. }
  334. </style>