126 lines
3.1 KiB
Vue
Raw Normal View History

2023-07-27 13:34:39 +08:00
<template>
2023-08-14 18:10:43 +08:00
<div id="example-simple">
<calendar-view
:show-date="showDate"
class="holiday-us-traditional holiday-us-official holiday-ue theme-gcal"
:enable-drag-drop="false"
:item-top="themeOptions.top"
:item-content-height="themeOptions.height"
:item-border-height="themeOptions.border"
@click-item="clickItems"
:items="taskList"
:current-period-label="'今日'"
>
<template #header="{ headerProps }">
<calendar-view-header
:header-props="headerProps"
:previous-year-label="themeOptions.previousYearLabel"
:previous-period-label="themeOptions.previousPeriodLabel"
:next-period-label="themeOptions.nextPeriodLabel"
:next-year-label="themeOptions.nextYearLabel"
@input="setShowDate"
2023-08-12 16:05:13 +08:00
/>
2023-08-14 18:10:43 +08:00
</template>
</calendar-view>
</div>
2023-07-27 13:34:39 +08:00
</template>
2023-08-14 18:10:43 +08:00
2023-07-27 13:34:39 +08:00
<script lang="ts" setup name="task">
2023-08-14 18:10:43 +08:00
// 日历组件
import { CalendarView, CalendarViewHeader } from "vue-simple-calendar";
2023-07-27 13:34:39 +08:00
2023-08-14 18:10:43 +08:00
const showDate = ref(new Date());
const setShowDate = (d) => {
showDate.value = d;
emits("initShowDate", d);
};
2023-07-27 13:34:39 +08:00
2023-08-14 18:10:43 +08:00
const props = defineProps({
list: {
type: Array,
default: () => {
return [];
2023-08-12 16:05:13 +08:00
},
2023-08-14 18:10:43 +08:00
},
});
2023-07-27 13:34:39 +08:00
2023-08-14 18:10:43 +08:00
const taskList = ref([]);
onUpdated(() => {
taskList.value = [];
props.list.forEach((item) => {
taskList.value.push({
id: item.id,
title: item.template_name,
startDate: new Date(item.start_time),
endDate: new Date(item.end_time),
});
});
});
2023-07-27 13:34:39 +08:00
2023-08-14 18:10:43 +08:00
const emits = defineEmits(["clickItem", "initShowDate"]);
2023-07-27 13:34:39 +08:00
2023-08-14 18:10:43 +08:00
const clickItems = (e) => {
emits("clickItem", e.id);
};
2023-07-27 13:34:39 +08:00
2023-08-14 18:10:43 +08:00
const themeOptions = computed((): any => {
return {
top: "2.6em",
height: "2.1em",
border: "0px",
previousYearLabel: "<<",
previousPeriodLabel: "<",
nextPeriodLabel: ">",
nextYearLabel: ">>",
currentPeriodLabel: "今天",
};
});
</script>
<style lang="scss">
@import "../../../node_modules/vue-simple-calendar/dist/style.css";
@import "../../../node_modules/vue-simple-calendar/dist/css/default.css";
@import "../../../node_modules/vue-simple-calendar/dist/css/holidays-us.css";
/* @import "../../../node_modules/vue-simple-calendar/dist/css/holidays-ue.css"; */
@import "../../../node_modules/vue-simple-calendar/dist/css/gcal.css";
2023-07-27 13:34:39 +08:00
2023-08-14 18:10:43 +08:00
#example-simple {
font-family: Avenir, Arial, Helvetica, sans-serif;
display: flex;
flex-direction: column;
height: 85vh !important;
width: 100% !important;
margin-left: auto;
margin-right: auto;
margin-top: 30px;
2023-08-12 16:05:13 +08:00
}
2023-07-27 13:34:39 +08:00
2023-08-14 18:10:43 +08:00
.theme-gcal .cv-day.today .cv-day-number {
background-color: #4a5dff;
2023-08-12 16:05:13 +08:00
}
2023-07-27 13:34:39 +08:00
2023-08-14 18:10:43 +08:00
#example-simple .cv-item {
/* background-color: #f56c6c; */
background-color: rgba($color: #4a5dff, $alpha: 0.8) !important;
color: #fff;
2023-08-12 16:05:13 +08:00
}
2023-07-27 13:34:39 +08:00
2023-08-14 18:10:43 +08:00
#example-simple .cv-item.custom-date-class-red {
background-color: #f66;
color: #fff;
2023-07-27 13:34:39 +08:00
}
2023-08-14 18:10:43 +08:00
.cv-wrapper.holiday-us-traditional .d05-05 .cv-day-number::before {
content: "" !important;
2023-07-27 13:34:39 +08:00
}
2023-08-14 18:15:23 +08:00
.theme-gcal .periodLabel {
font-size: 16px !important;
}
.theme-gcal .cv-header button.previousYear,
.theme-gcal .cv-header button.previousPeriod,
.theme-gcal .cv-header button.nextPeriod,
.theme-gcal .cv-header button.nextYear {
width: 2em;
}
2023-08-02 09:09:24 +08:00
</style>
2023-08-14 18:10:43 +08:00