|
| 1 | +<template> |
| 2 | + <div class="app-container"> |
| 3 | + <!-- Echarts 图表 --> |
| 4 | + <el-row :gutter="10"> |
| 5 | + <el-col :span="8" :xs="24" :sm="24" :lg="24" :key="chartId"> |
| 6 | + <div class="elcol"> |
| 7 | + <div> |
| 8 | + <VueMonthCalendar |
| 9 | + v-if="isMounted" |
| 10 | + @get-date="getDate" |
| 11 | + @change-year="changeYear" |
| 12 | + @change-month="changeMonth" |
| 13 | + @decrement-year="decrementYear" |
| 14 | + @increment-year="incrementYear" |
| 15 | + @next-month="nextMonth" |
| 16 | + @prev-month="prevMonth" |
| 17 | + @reset-month="resetMonth" |
| 18 | + @change-first-week-day="changeFirstWeekDay" |
| 19 | + :setEvents="setEvents" |
| 20 | + /> |
| 21 | + </div> |
| 22 | + </div> |
| 23 | + </el-col> |
| 24 | + </el-row> |
| 25 | + </div> |
| 26 | +</template> |
| 27 | + |
| 28 | +<script setup lang="ts"> |
| 29 | +import { VueMonthCalendar } from "@howbizarre/vue-month-calendar"; |
| 30 | +import "@howbizarre/vue-month-calendar/dist/style.css"; |
| 31 | +import { ref, onMounted } from "vue"; |
| 32 | +
|
| 33 | +const chartId = ref("resold-month-calendar"); |
| 34 | +const isMounted = ref(false); |
| 35 | +
|
| 36 | +const setEvents = [ |
| 37 | + { |
| 38 | + date: 29, |
| 39 | + month: 6, |
| 40 | + year: 2024, |
| 41 | + }, |
| 42 | +]; |
| 43 | +
|
| 44 | +function getDate(activeDate: { month: number; year: number; date: number }) { |
| 45 | + console.group("The returned data is:"); |
| 46 | + console.log("Day: ", activeDate.date); |
| 47 | + console.log("Month: ", activeDate.month); |
| 48 | + console.log("Year: ", activeDate.year); |
| 49 | + console.groupEnd(); |
| 50 | +} |
| 51 | +
|
| 52 | +function changeYear(yearValue: number): void { |
| 53 | + console.log("Change Year to: ", yearValue); |
| 54 | +} |
| 55 | +
|
| 56 | +function changeMonth(monthValue: number): void { |
| 57 | + console.log("Change Month to: ", monthValue); |
| 58 | +} |
| 59 | +
|
| 60 | +function decrementYear(decYear: number): void { |
| 61 | + console.log("Decrement Year: ", decYear); |
| 62 | +} |
| 63 | +
|
| 64 | +function incrementYear(incYear: number): void { |
| 65 | + console.log("Increment Year: ", incYear); |
| 66 | +} |
| 67 | +
|
| 68 | +function nextMonth(nextMonth: number): void { |
| 69 | + console.log("Next Month: ", nextMonth); |
| 70 | +} |
| 71 | +
|
| 72 | +function prevMonth(prevMonth: number): void { |
| 73 | + console.log("Previous Month: ", prevMonth); |
| 74 | +} |
| 75 | +
|
| 76 | +function resetMonth(resetMonth: number): void { |
| 77 | + console.log("Reset Month: ", resetMonth); |
| 78 | +} |
| 79 | +
|
| 80 | +function changeFirstWeekDay(firstWeekDay: number): void { |
| 81 | + console.log("Change First Week Day: ", firstWeekDay); |
| 82 | +} |
| 83 | +
|
| 84 | +onMounted(() => (isMounted.value = true)); |
| 85 | +</script> |
| 86 | + |
| 87 | +<style lang="scss" scope> |
| 88 | +.item { |
| 89 | + display: flex; |
| 90 | +
|
| 91 | + /* 水平居中对齐, flex-end右对齐 */ |
| 92 | + flex-wrap: wrap; |
| 93 | + justify-content: center; |
| 94 | + width: 100px; |
| 95 | + height: 98px; |
| 96 | + border: 1px solid #ccc; |
| 97 | +} |
| 98 | +
|
| 99 | +.dian { |
| 100 | + width: 30px; |
| 101 | + height: 30px; |
| 102 | + border: 1px solid #000; |
| 103 | + border-radius: 50px; |
| 104 | +} |
| 105 | +
|
| 106 | +.elcol { |
| 107 | + display: flex; |
| 108 | + align-items: center; |
| 109 | + justify-content: center; |
| 110 | +} |
| 111 | +
|
| 112 | +.flex-container { |
| 113 | + display: flex; |
| 114 | + align-items: center; |
| 115 | + justify-content: center; |
| 116 | + width: 100%; |
| 117 | +} |
| 118 | +
|
| 119 | +.flex-item { |
| 120 | + align-self: flex-end; |
| 121 | + width: 100px; |
| 122 | + height: 100px; |
| 123 | + margin: 10px; |
| 124 | + background-color: #ccc; |
| 125 | +} |
| 126 | +</style> |
0 commit comments