This commit is contained in:
XaoLi717 2024-10-22 16:24:59 +08:00
parent 70ac8f8c19
commit 34d0738ad7
6 changed files with 461 additions and 31 deletions

View File

@ -0,0 +1,21 @@
import request from "@/config/axios";
export interface CalendarDate {
isSelected: boolean
type: string
day: string
date: Date
}
/**
* API
*/
export const AgendaApi = {
/**
* Day
* @param params
*/
getAgendaPage: async (params: any) => {
return await request.get({ url: `/calendar/agenda/page`, params })
},
}

View File

@ -0,0 +1,13 @@
<template>
</template>
<script setup lang="ts">
defaultOptions({name:"AgendaForm"})
</script>
<style scoped lang="scss">
</style>

View File

@ -0,0 +1,141 @@
<template>
<ContentWrap>
<el-row :gutter="20">
<el-col v-for="(month, index) in months" :key="index" :span="6" >
<h3 class="month-title">{{ month }}</h3>
<el-calendar
ref="calendar"
class="custom-calendar"
:model-value="new Date(currentYear, index, 1)"
>
<template #header="{ date }">
<el-row>
<el-col :span="24" class="header-date">
<span class="cl-title"> {{ date }}</span>
</el-col>
<!-- <el-col :span="8" style="text-align: center;">-->
<!-- <el-button-group style="display: flex; justify-content: space-between;">-->
<!-- <el-button size="small" @click="selectDate('prev-year')">上年</el-button>-->
<!-- <el-button size="small" @click="selectDate('prev-month')">上月</el-button>-->
<!-- <el-button size="small" @click="selectDate('today')">今天</el-button>-->
<!-- <el-button size="small" @click="selectDate('next-year')">下年</el-button>-->
<!-- <el-button size="small" @click="selectDate('next-month')">下月</el-button>-->
<!-- </el-button-group>-->
</el-row>
</template>
<template #date-cell="{ data }">
<div v-if="holidays[data.day]" @click="handleSelect(data.date)" class="holiday">
<!-- {{ data.day + ": " + holidays[data.day] }}-->
{{ data.date.getDay() }}
</div>
<!-- <div v-if="schedules[data.day]" @click="handleSelect(schedules[data.day])" class="schedule">-->
<!-- {{ data.day + ": " + schedules[data.day] }}-->
<!-- </div>-->
</template>
</el-calendar>
</el-col>
</el-row>
</ContentWrap>
</template>
<script setup lang="ts">
import {CalendarDateType, CalendarInstance} from "element-plus";
defineOptions({ name: 'CalendarAgendaIndex' })
const message = useMessage() //
// const { t } = useI18n() //
// const workdays = {};
const calendar = ref<CalendarInstance>()
// const selectedDate = ref(""); //
const currentYear = ref(new Date().getFullYear()) //
const months = reactive(['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'])
// const selectDate = (val: CalendarDateType) => {
// if (!calendar.value) return
// calendar.value.selectDate(val)
// }
//
const handleSelect = (date: Date) => {
date.getDay()
date.getFullYear()
date.getMonth()
message.success(`${date.getFullYear()}-${date.getMonth()+1}-${date.getDay()}`)
// selectedDate.value = date;
};
//
const holidays = ref({
'2024-01-01': '元旦',
'2024-01-21': '春节',
'2024-02-10': '春节假期',
'2024-04-04': '清明节',
'2024-05-01': '劳动节',
'2024-06-10': '端午节',
'2024-08-10': '中元节',
'2024-09-29': '中秋节',
'2024-10-01': '国庆节',
'2024-10-02': '国庆假期',
'2024-10-03': '国庆假期',
'2024-10-04': '国庆假期',
'2024-10-05': '国庆假期',
});
//
// const schedules = ref({
// '2024-10-15': '',
// '2024-10-16': '',
// '2024-10-17': '',
// '2024-10-18': '',
// '2024-10-19': '',
// '2024-10-20': '',
// '2024-11-20': '',
// '2024-12-20': '',
// });
const getDate = () => {
}
onMounted(()=> {
getDate();
})
</script>
<style>
.custom-calendar .el-calendar-day {
padding: 0 !important;
}
.custom-calendar {
border: 1px solid #1f1f1f !important; /* 使用 !important 确保样式生效 */
border-radius: 5px; /* 可选:添加圆角 */
}
</style>
<style scoped lang="scss">
.holiday {
width: 100%;
height: 100%;
background-color: #15bc83;
font-size: 16px;
}
.schedule {
width: 100%;
height: 100%;
background-color: #CCFFCC;
color: #3b3e55;
font-size: 12px;
}
.month-title {
text-align: center
}
.cl-title {
display: inline-block;
font-size: 10px
}
.header-date {
text-align: center;
font-size: 10px;
}
</style>

View File

@ -0,0 +1,136 @@
<template>
<ContentWrap>
<el-row :gutter="20">
<el-col v-for="(month, index) in months" :key="index" :span="6" >
<h3 class="month-title">{{ month }}</h3>
<el-calendar
ref="calendar"
class="custom-calendar"
:model-value="new Date(currentYear, index, 1)"
>
<template #header="{ date }">
<el-row>
<el-col :span="24" class="header-date">
<span class="cl-title"> {{ date }}</span>
</el-col>
</el-row>
</template>
<template #date-cell="{ data }">
<div @click="handleSelect(data)" :class="{ 'holiday': holidays[data.day] }">
{{ data.date.getDate()}}
</div>
</template>
</el-calendar>
</el-col>
</el-row>
</ContentWrap>
</template>
<script setup lang="ts">
import {CalendarDateType, CalendarInstance} from "element-plus";
defineOptions({ name: 'CalendarAgendaIndex' })
const message = useMessage() //
const calendar = ref<CalendarInstance>()
// const selectedDate = ref(""); //
// const today = ref("")
const currentYear = ref(new Date().getFullYear()) //
const months = reactive(['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'])
// const selectDate = (val: CalendarDateType) => {
// if (!calendar.value) return
// calendar.value.selectDate(val)
// }
//
const handleSelect = (date:CalendarDate) => {
const date2 = date.date
// message.info(`${date2.getFullYear()}-${date2.getMonth()+1}-${date2.getDate()}`)
// selectedDate.value = date;
};
//
const holidays = ref({
'2024-01-01': '元旦',
'2024-01-21': '春节',
'2024-02-10': '春节假期',
'2024-04-04': '清明节',
'2024-05-01': '劳动节',
'2024-06-10': '端午节',
'2024-08-10': '中元节',
'2024-09-29': '中秋节',
'2024-10-01': '国庆节',
'2024-10-02': '国庆假期',
'2024-10-03': '国庆假期',
'2024-10-04': '国庆假期',
'2024-10-05': '国庆假期',
});
//
// const schedules = ref({
// '2024-10-15': '',
// '2024-10-16': '',
// '2024-10-17': '',
// '2024-10-18': '',
// '2024-10-19': '',
// '2024-10-20': '',
// '2024-11-20': '',
// '2024-12-20': '',
// });
const getDate = () => {
// const d = new Date();
// today.value=`${d.getFullYear()}-${d.getMonth()+1}-${d.getDate()}`
// console.log(today.value)
}
onMounted(()=> {
getDate();
})
</script>
<style>
.custom-calendar .el-calendar-day {
width: 100%;
height: 100%;
padding: 0 !important;
}
.custom-calendar .is-today {
width: 100%;
height: 100%;
background-color: #f56c6c;
font-size: 16px;
}
.custom-calendar {
border: 1px solid #1f1f1f !important; /* 使用 !important 确保样式生效 */
border-radius: 5px; /* 可选:添加圆角 */
}
</style>
<style scoped lang="scss">
.holiday {
width: 100%;
height: 100%;
background-color: #15bc83;
font-size: 16px;
}
.schedule {
width: 100%;
height: 100%;
background-color: #CCFFCC;
color: #3b3e55;
font-size: 12px;
}
.month-title {
text-align: center
}
.cl-title {
display: inline-block;
font-size: 10px
}
.header-date {
text-align: center;
font-size: 10px;
}
</style>

View File

@ -1,40 +1,161 @@
<template>
<ContentWrap>
<el-calendar ref="calendar" class="custom-calendar">
<template #header = "{date}">
<el-row>
<el-col :span="8" style="text-align: center;">
<span style="display: inline-block;font-size: 10px">{{ date }}</span>
</el-col>
<el-col :span="8" style="text-align: center;">
1
</el-col>
<el-col :span="8" style="text-align: center;">
<el-button-group style="display: flex; justify-content: space-between;">
<el-button size="small" @click="selectDate('prev-year')">上年</el-button>
<el-button size="small" @click="selectDate('prev-month')">上月</el-button>
<el-button size="small" @click="selectDate('today')">今天</el-button>
<el-button size="small" @click="selectDate('next-year')">下年</el-button>
<el-button size="small" @click="selectDate('next-month')">下月</el-button>
</el-button-group>
</el-col>
</el-row>
</template>
</el-calendar>
<el-button-group style="display: flex; justify-content: space-between;">
<el-button size="large" @click="selectDate2(-1)">上年</el-button>
<el-button size="large" @click="toYear()">今年</el-button>
<el-button size="large" @click="selectDate2(1)">下年</el-button>
</el-button-group>
<el-row :gutter="10">
<el-col v-for="(month, index) in months" :key="index" :span="6" >
<h5 class="month-title">{{ month }}</h5>
<el-calendar
ref="calendar"
class="custom-calendar"
:model-value="new Date(currentYear, index, 1)"
>
<template #header="{ date }">
<el-row>
<el-col :span="24" class="header-date">
<span class="cl-title"> {{ date }}</span>
</el-col>
</el-row>
</template>
<template #date-cell="{ data }">
<div @click="handleSelect(data)" :class="{ 'holiday': holidays2[data.day] }">
{{ data.date.getDate()}}
</div>
</template>
</el-calendar>
</el-col>
</el-row>
</ContentWrap>
</template>
<script setup lang="ts">
import {CalendarDateType, CalendarInstance} from "element-plus";
import {AgendaApi,CalendarDate} from "@/api/calendar/agenda";
defineOptions({ name: 'CalendarAgendaIndex' })
// const message = useMessage() //
const calendar = ref<CalendarInstance>()
const currentYear = ref(new Date().getFullYear()) //
const months = reactive(['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'])
const selectDate = (val: CalendarDateType) => {
if (!calendar.value) return
calendar.value.selectDate(val)
console.log(calendar.value.selectDate(val))
}
const selectDate2 = (val:number) => {
if (!val){
return
}
currentYear.value += val
}
const toYear = () => {
currentYear.value = new Date().getFullYear()
}
//
const handleSelect = (date:CalendarDate) => {
const date2 = date.date
const da = `${date2.getFullYear()}-${(date2.getMonth() + 1).toString().padStart(2, '0')}-${date2.getDate().toString().padStart(2, '0')}`;
holidays2[da] = !holidays2[da]
console.log("da",da)
console.log("holidays[da]",holidays2[da])
console.log("date2",date2)
console.log("holidays2",holidays2)
};
//
const holidays = reactive({
'2024-01-01': 1,
'2024-01-21': 1,
'2024-02-10': 1,
'2024-04-04': 1,
'2024-05-01': 1,
'2024-06-10': 1,
'2024-08-10': 1,
'2024-09-29': 1,
'2024-10-01': 1,
'2024-10-02': 1,
'2024-10-03': 1,
'2024-10-04': 1,
'2024-10-05': 1,
'2024-10-06': 0,
'2024-10-07': 0,
'2024-10-08': 0,
'2024-10-09': 1,
});
const holidays2 = reactive({});
const startDate = new Date('2024-01-01');
const endDate = new Date('2024-12-31');
for (let d = startDate; d <= endDate; d.setDate(d.getDate() + 1)) {
const formattedDate = d.toISOString().split('T')[0]; // YYYY-MM-DD
holidays2[formattedDate] = Math.floor(Math.random() * 2); // 0 1
}
console.log(holidays2);
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
id: undefined,
date:[]
})
const getDate = () => {
const data = AgendaApi.getAgendaPage(queryParams)
}
onMounted(()=> {
// getDate();
})
</script>
<style scoped lang="scss">
<style>
.custom-calendar .el-calendar-day {
width: 100%;
height: 100%;
padding: 0 !important;
}
.custom-calendar .is-today {
width: 100%;
height: 100%;
background-color: #f56c6c;
font-size: 16px;
}
.custom-calendar {
border: 1px solid #1f1f1f !important; /* 使用 !important 确保样式生效 */
border-radius: 10px; /* 可选:添加圆角 */
}
</style>
<style scoped lang="scss">
.holiday {
width: 100%;
height: 100%;
background-color: #15bc83;
font-size: 16px;
}
.schedule {
width: 100%;
height: 100%;
background-color: #CCFFCC;
color: #3b3e55;
font-size: 12px;
}
.month-title {
text-align: center
}
.cl-title {
display: inline-block;
font-size: 12px
}
.header-date {
text-align: center;
font-size: 10px;
}
</style>

View File

@ -65,23 +65,21 @@
<el-table-column label="文件内容" align="center" prop="url" width="110px">
<template #default="{ row }">
<el-image
v-if="row.type.includes('image')"
class="h-80px w-80px"
lazy
:src="row.url"
:preview-src-list="[row.url]"
:src="`${row.url}?id=${row.id}`"
:preview-src-list="[`${row.url}?id=${row.id}`]"
preview-teleported
fit="cover"
/>
<el-link
v-else-if="row.type.includes('pdf')"
type="primary"
:href="row.url"
:href="`${row.url}?id=${row.id}`"
:underline="false"
target="_blank"
>预览</el-link
>
<el-link v-else type="primary" download :href="row.url" :underline="false" target="_blank"
<el-link type="primary" download :href="`${row.url}?id=${row.id}`" :underline="false" target="_blank"
>下载</el-link
>
</template>