PageScroller.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <div class="row items-center q-ml-md q-my-xs" style="font-size: 120%">
  3. <div class="q-mr-xs">
  4. Страница
  5. </div>
  6. <div class="trans" :class="{'bg-green-4': highlight, 'bg-white': !highlight}">
  7. <NumInput
  8. v-model="page" :min="1" :max="pageCount" mask="#######"
  9. style="width: 220px" minus-icon="la la-chevron-circle-left" plus-icon="la la-chevron-circle-right" :disable="disable" mm-buttons
  10. />
  11. </div>
  12. <div class="q-ml-xs">
  13. из {{ pageCount }}
  14. </div>
  15. </div>
  16. </template>
  17. <script>
  18. //-----------------------------------------------------------------------------
  19. import vueComponent from '../../vueComponent.js';
  20. import NumInput from '../../share/NumInput.vue';
  21. import * as utils from '../../../share/utils';
  22. const componentOptions = {
  23. components: {
  24. NumInput
  25. },
  26. watch: {
  27. modelValue(newValue) {
  28. this.page = newValue;
  29. },
  30. page(newValue) {
  31. this.$emit('update:modelValue', newValue);
  32. },
  33. }
  34. };
  35. class PageScroller {
  36. _options = componentOptions;
  37. _props = {
  38. modelValue: Number,
  39. disable: Boolean,
  40. pageCount: Number,
  41. };
  42. page = 1;
  43. highlight = false;
  44. created() {
  45. }
  46. async highlightScroller() {
  47. if (this.inTrans)
  48. return;
  49. this.inTrans = true;
  50. await utils.sleep(300);
  51. this.highlight = true;
  52. await utils.sleep(300);
  53. this.highlight = false;
  54. await utils.sleep(300);
  55. this.inTrans = false;
  56. }
  57. }
  58. export default vueComponent(PageScroller);
  59. //-----------------------------------------------------------------------------
  60. </script>
  61. <style scoped>
  62. .trans {
  63. border-radius: 5px;
  64. transition: background-color 0.3s linear;
  65. }
  66. </style>