index.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <div class="calendar">
  3. <span class="prev" @click="emits('prev', props.name)" v-show="controls"><i class="iconfont icon-arrows_left"></i></span>
  4. <span class="cale" @click="onPickDate()">{{ value.format('YYYY-mm-dd') }}<i class="iconfont icon-date"></i></span>
  5. <span class="next" @click="emits('next', props.name)" v-show="controls"><i class="iconfont icon-arrows_right"></i></span>
  6. <div class="calendar-list" v-if="showCalendar" @click="showCalendar = false">
  7. <div @click.stop>
  8. <datepicker language="zh" :inline="true" :value="value" :highlighted="highlighted" @selected="onSelected"></datepicker>
  9. </div>
  10. </div>
  11. </div>
  12. </template>
  13. <script setup>
  14. import { ref, defineProps } from 'vue'
  15. import Datepicker from '@/components/datepicker/Datepicker'
  16. const props = defineProps({
  17. name: String,
  18. value: Date,
  19. controls:Boolean,
  20. highlighted: Object,
  21. })
  22. const emits = defineEmits(['prev', 'selected', 'next', 'pick'])
  23. const showCalendar = ref(false)
  24. const onPickDate = () => {
  25. if(props.count<2){
  26. return
  27. }
  28. showCalendar.value = !showCalendar.value
  29. if (showCalendar.value) {
  30. emits('pick', props.name)
  31. }
  32. }
  33. const onSelected =(payload)=>{
  34. emits('selected', { name: props.name, payload })
  35. showCalendar.value = false
  36. }
  37. </script>
  38. <style lang="scss" scoped>
  39. .calendar {
  40. height: 50px;
  41. background: rgba(27, 27, 28, 0.8);
  42. box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25);
  43. border-radius: 47px 47px 47px 47px;
  44. border: 1px solid #000000;
  45. display: flex;
  46. justify-content: center;
  47. align-items: center;
  48. margin-left: 10px;
  49. margin-right: 10px;
  50. font-size: 16px;
  51. padding: 0 16px;
  52. span {
  53. cursor: pointer;
  54. }
  55. .cale {
  56. i {
  57. margin-left: 4px;
  58. font-size: 15px;
  59. }
  60. }
  61. .prev {
  62. margin-right: 10px;
  63. }
  64. .next {
  65. margin-left: 10px;
  66. }
  67. }
  68. .calendar-list {
  69. position: absolute;
  70. left: 0;
  71. right: 0;
  72. bottom: 0;
  73. height: 100vh;
  74. z-index: 1000;
  75. display: flex;
  76. align-items: flex-end;
  77. justify-content: center;
  78. > div {
  79. position: relative;
  80. margin-bottom: 80px;
  81. }
  82. }
  83. </style>