BaseCalendar.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <div class="base-calendar-wrap">
  3. <FullCalendar class="full-calendar-wrap"
  4. ref="fullCalendar"
  5. :options="calendarOptions"
  6. >
  7. <template #eventContent="arg">
  8. <div class="popper-content"
  9. :style="{fontWeight:arg.event.extendedProps.FontBold?'bold':'normal'}"
  10. >
  11. {{arg.event.title||''}}
  12. </div>
  13. </template>
  14. </FullCalendar>
  15. <div class="water-mark" v-if="showMark">
  16. <p>{{ markText.date }}</p>
  17. <p>{{ markText.type }}</p>
  18. </div>
  19. </div>
  20. </template>
  21. <script>
  22. import FullCalendar from "@fullcalendar/vue";
  23. import dayGridPlugin from '@fullcalendar/daygrid'
  24. import interactionPlugin from '@fullcalendar/interaction'
  25. export default {
  26. components: {FullCalendar},
  27. props:{
  28. showMark:{
  29. type:Boolean,
  30. default:true
  31. },
  32. markText:{
  33. type:Object,
  34. default:()=>{
  35. return {
  36. date:'当前日期',
  37. type:'当前品种'
  38. }
  39. }
  40. },
  41. options:{
  42. type:Object,
  43. default:{}
  44. }
  45. },
  46. data() {
  47. return {
  48. calendarOptions:{
  49. height:'100%',
  50. locale: "zh-cn",
  51. plugins: [ dayGridPlugin, interactionPlugin ],
  52. initialView:'dayGridMonth',
  53. headerToolbar:false,//不显示头部信息
  54. weekNumberCalculation:'ISO',//从周一开始
  55. dayHeaderFormat:{ //https://fullcalendar.io/docs/v5/date-formatting
  56. weekday:'narrow', //头部星期显示为一 二 三...
  57. },
  58. dayCellContent:function(arg){ //单元格日期显示为 1 2 3...
  59. return arg.date.getDate()
  60. },
  61. fixedWeekCount:false,//是否固定6周
  62. eventOrder:'Sort', //指定事项排序字段
  63. /* dayMaxEventRows:6,//一天最多展示6条
  64. moreLinkClick:(info)=>{this.handleDateClick(info)},//点击more时触发 */
  65. events:[
  66. /* {
  67. id:1,
  68. title:'我是默认事件', //事件名称
  69. start:'2024-03-26',//日期,默认是全天事件
  70. textColor:'#000',//字体颜色
  71. backgroundColor:'#ffc0cb',//背景色
  72. borderColor:'#ffc0cb',//边框色
  73. //↑此外的属性会被FullCalendar插件放到extendedProps属性中
  74. //extendedProps
  75. isTextBold:true,//是否加粗
  76. }, */
  77. ],
  78. dateClick:this.handleDateClick,
  79. eventClick:this.handleEventClick
  80. }
  81. };
  82. },
  83. methods: {
  84. handleDateClick(info){
  85. this.$emit("dateClick",info)
  86. },
  87. handleEventClick(info){
  88. this.$emit("eventClick",info)
  89. }
  90. },
  91. };
  92. </script>
  93. <style lang="scss">
  94. .base-calendar-wrap{
  95. .full-calendar-wrap{
  96. .fc-daygrid-day-top{ //日期偏左显示
  97. flex-direction: row;
  98. }
  99. .fc-daygrid-event{
  100. border-radius: 0;
  101. margin:0 !important;
  102. }
  103. .fc-scrollgrid{
  104. border:none;
  105. .fc-scrollgrid-section-header{
  106. th{
  107. border:none !important;
  108. }
  109. .fc-col-header-cell{
  110. text-align: left;
  111. //font-weight: 500;
  112. }
  113. }
  114. .fc-scrollgrid-section-body{
  115. td{
  116. border: none !important;
  117. border-left:2px solid #002D78 !important;
  118. }
  119. }
  120. }
  121. .fc-more-popover{
  122. display:none !important;
  123. }
  124. }
  125. }
  126. </style>
  127. <style scoped lang="scss">
  128. .base-calendar-wrap{
  129. flex: 1;
  130. display: flex;
  131. flex-direction: column;
  132. position:relative;
  133. .full-calendar-wrap{
  134. flex:1;
  135. .popper-content{
  136. cursor: pointer;
  137. }
  138. }
  139. .water-mark{
  140. position: absolute;
  141. top:0;
  142. bottom: 0;
  143. left: 0;
  144. right: 0;
  145. display: flex;
  146. flex-direction: column;
  147. justify-content: center;
  148. align-items: center;
  149. font-size: 64px;
  150. opacity: 0.3;
  151. }
  152. }
  153. </style>