Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

propertyList.vue 10.0KB

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