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.

84 lines
1.9 KiB

  1. <template>
  2. <div class="v-data-footer">
  3. <span>
  4. {{ page }} of {{ total }}
  5. </span>
  6. <v-tooltip bottom>
  7. <template v-slot:activator="{ on }">
  8. <v-btn
  9. v-shortkey.once="['arrowleft']"
  10. text
  11. :disabled="page===1"
  12. fab
  13. small
  14. v-on="on"
  15. @shortkey="prevPage"
  16. @click="prevPage"
  17. >
  18. <v-icon>mdi-chevron-left</v-icon>
  19. </v-btn>
  20. </template>
  21. <span></span>
  22. </v-tooltip>
  23. <v-tooltip bottom>
  24. <template v-slot:activator="{ on }">
  25. <v-btn
  26. v-shortkey.once="['arrowright']"
  27. text
  28. :disabled="page===total"
  29. fab
  30. small
  31. v-on="on"
  32. @shortkey="nextPage(total)"
  33. @click="nextPage(total)"
  34. >
  35. <v-icon>mdi-chevron-right</v-icon>
  36. </v-btn>
  37. </template>
  38. <span></span>
  39. </v-tooltip>
  40. </div>
  41. </template>
  42. <script>
  43. import Vue from 'vue'
  44. import { mapState, mapActions, mapMutations, mapGetters } from 'vuex'
  45. Vue.use(require('vue-shortkey'))
  46. export default {
  47. computed: {
  48. ...mapState('documents', ['items', 'total']),
  49. ...mapGetters('pagination', ['current', 'limit', 'offset', 'page'])
  50. },
  51. watch: {
  52. offset() {
  53. this.updateSearchOptions({
  54. limit: this.limit,
  55. offset: this.offset
  56. })
  57. this.getDocumentList({
  58. projectId: this.$route.params.id
  59. })
  60. },
  61. current() {
  62. this.setCurrent(this.current)
  63. }
  64. },
  65. created() {
  66. this.initPage({
  67. projectId: this.$route.params.id
  68. })
  69. this.getDocumentList({
  70. projectId: this.$route.params.id
  71. })
  72. },
  73. methods: {
  74. ...mapActions('documents', ['getDocumentList']),
  75. ...mapActions('pagination', ['prevPage', 'nextPage', 'initPage']),
  76. ...mapMutations('documents', ['setCurrent', 'updateSearchOptions'])
  77. }
  78. }
  79. </script>