DataTimingRange.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <main class="d-flex align-baseline">
  3. <div v-if="show" class="d-flex align-baseline">
  4. <span class="mr-2 ot-dark_grey--text font-weight-bold">{{ $t('period_choose') }}</span>
  5. <UiInputDatePicker
  6. class="time-range"
  7. label="date_choose"
  8. :data="datesRange"
  9. :range="true"
  10. :dense="true"
  11. :single-line="true"
  12. @update="updateDateTimeRange"
  13. />
  14. </div>
  15. <v-tooltip bottom>
  16. <template #activator="{ on, attrs }">
  17. <v-btn
  18. class="time-btn"
  19. max-height="25"
  20. v-bind="attrs"
  21. elevation="0"
  22. max-width="10px"
  23. min-width="10px"
  24. v-on="on"
  25. @click="show=!show"
  26. >
  27. <v-icon color="ot-grey" class="font-weight-normal" x-small>
  28. fas fa-history
  29. </v-icon>
  30. </v-btn>
  31. </template>
  32. <span>{{ $t('history_help') }}</span>
  33. </v-tooltip>
  34. </main>
  35. </template>
  36. <script setup lang="ts">
  37. import {ComputedRef, Ref} from "@vue/reactivity";
  38. import {useAccessProfileStore} from "~/stores/accessProfile";
  39. import {useFormStore} from "~/stores/form";
  40. import {WatchStopHandle} from "@vue/runtime-core";
  41. const emit = defineEmits(['showDateTimeRange'])
  42. const { setDirty } = useFormStore()
  43. const accessProfileStore = useAccessProfileStore()
  44. const { updateMyProfile, setHistoricalRange, historical } = useAccessProfileStore()
  45. const datesRange: ComputedRef<Array<any>> = computed(() => {
  46. return [accessProfileStore.historical.dateStart, accessProfileStore.historical.dateEnd]
  47. })
  48. const show: Ref<boolean> = ref(false)
  49. if (accessProfileStore.historical.dateStart || accessProfileStore.historical.dateEnd) {
  50. show.value = true
  51. emit('showDateTimeRange', true)
  52. }
  53. const unwatch: WatchStopHandle = watch(show, (newValue) => {
  54. emit('showDateTimeRange', newValue)
  55. })
  56. onUnmounted(() => {
  57. unwatch()
  58. })
  59. const updateDateTimeRange = async (dates:Array<string>): Promise<any> => {
  60. setHistoricalRange(dates)
  61. setDirty(false)
  62. await updateMyProfile()
  63. window.location.reload()
  64. }
  65. </script>
  66. <style lang="scss">
  67. .v-btn--active .v-icon {
  68. color: #FFF !important;
  69. }
  70. .time-btn {
  71. border-width: 1px 1px 1px 0;
  72. border-style: solid;
  73. border-color: rgba(0, 0, 0, 0.12) !important;
  74. }
  75. .time-range {
  76. max-height: 20px;
  77. .v-text-field {
  78. padding-top: 0 !important;
  79. margin-top: 0 !important;
  80. }
  81. .v-icon {
  82. font-size: 20px;
  83. }
  84. input {
  85. font-size: 14px;
  86. width: 400px !important;
  87. }
  88. }
  89. </style>