Compare commits

...

4 Commits

View File

@ -1,13 +1,21 @@
<template> <template>
<ContentWrap> <ContentWrap>
<el-row>
<el-button-group style="display: flex; justify-content: space-between;"> <el-col :span="4">
<el-button size="large" @click="selectDate(-1)">上年</el-button> <span style="font-size: 24px">
<el-button size="large" @click="toYear()">今年</el-button> {{currentYear}}&nbsp;
<el-button size="large" @click="selectDate(1)">下年</el-button> </span>
<el-button size="large" @click="getListDate()">刷新</el-button> </el-col>
<!-- <el-button size="small" @click="createDate()">创建</el-button>--> <el-col :span="20">
</el-button-group> <el-button-group style="display: flex; justify-content: space-between;">
<el-button size="large" @click="selectDate(-1)">上年</el-button>
<el-button size="large" @click="toYear()">今年</el-button>
<el-button size="large" @click="selectDate(1)">下年</el-button>
<el-button size="large" @click="getListDate()">刷新</el-button>
<!-- <el-button size="small" @click="createDate()">创建</el-button>-->
</el-button-group>
</el-col>
</el-row>
<el-row v-if="loading" :gutter="10"> <el-row v-if="loading" :gutter="10">
<el-col v-for="(month, index) in months" :key="index" :span="6" > <el-col v-for="(month, index) in months" :key="index" :span="6" >
@ -15,7 +23,6 @@
<h5 class="month-title">{{ month }}</h5> <h5 class="month-title">{{ month }}</h5>
<el-calendar <el-calendar
v-loading="!loading"
ref="calendar" ref="calendar"
class="custom-calendar" class="custom-calendar"
:model-value="new Date(currentYear, index)" :model-value="new Date(currentYear, index)"
@ -29,20 +36,38 @@
</template> </template>
<template #date-cell="{ data }"> <template #date-cell="{ data }">
<el-popover :visible="holidayDate[data.day]?.visible" placement="right" :width="240" trigger="click"> <el-popover
v-if="isCurrentMonth(data,index)"
:visible="holidayDate[data.day]?.visible"
placement="right"
:width="240"
trigger="click"
>
<template #reference> <template #reference>
<div @click="handleSelect(data)" :class="{ 'holidayWork': holidayDate[data.day]?.isWorkday }"> <div @click="handleSelect(data)" :class="{ 'holidayWork': holidayDate[data.day]?.isWorkday }">
<span style="font-size: 14px"> <span style="font-size: 12px">
{{ formatDate2(data.date) === current? data.date.getDate()+'(今天)':data.date.getDate() }} {{ formatDate2(data.date) === current? data.date.getDate()+'(今天)':data.date.getDate() }}
</span> </span>
<span v-if="holidayDate[data.day]?.content !== ''&&holidayDate[data.day]?.content !== null&&holidayDate[data.day]?.content !== undefined" style="font-size: 12px"> <span
v-if="holidayDate[data.day]?.content !== ''&&holidayDate[data.day]?.content !== null&&holidayDate[data.day]?.content !== undefined"
style="font-size: 12px"
>
{{'('+getIntDictOptions(DICT_TYPE.CALENDAR_CONTENT)[holidayDate[data.day]?.content].label+')'}} {{'('+getIntDictOptions(DICT_TYPE.CALENDAR_CONTENT)[holidayDate[data.day]?.content].label+')'}}
</span> </span>
</div> </div>
</template> </template>
<!-- 右上角关闭按钮 -->
<el-button
type="primary"
class="close-But"
@click="closePopover(data)"
>
<el-icon style="margin-right: 3px;margin-left: 3px;" class="el-icon--right"><Close /></el-icon>
</el-button>
<el-form <el-form
ref="formRef" ref="formRef"
:model="formDataCaln" :model="formDataCaln"
style="margin-top: 20px"
label-width="70px" label-width="70px"
> >
<el-form-item label="状态" > <el-form-item label="状态" >
@ -50,7 +75,7 @@
<el-radio <el-radio
v-for="dict in nowWork" v-for="dict in nowWork"
:key="dict.value" :key="dict.value"
:label="dict.value" :value="dict.value"
> >
{{ dict.label }} {{ dict.label }}
</el-radio> </el-radio>
@ -67,7 +92,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-button size="small" @click="submitForm();" type="primary">确定</el-button> <el-button size="small" @click="submitForm(data);" type="primary">确定</el-button>
</el-popover> </el-popover>
</template> </template>
@ -83,6 +108,7 @@
import {CalendarInstance} from "element-plus"; import {CalendarInstance} from "element-plus";
import {CalendarApi, CalendarVO} from "@/api/home/calendar"; import {CalendarApi, CalendarVO} from "@/api/home/calendar";
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict' import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
import {Close} from "@element-plus/icons-vue";
defineOptions({ name: 'CalendarAgendaIndex' }) defineOptions({ name: 'CalendarAgendaIndex' })
@ -127,17 +153,22 @@ const formDataCaln = ref({
// const data = await CalendarApi.createCalendar(dda) // const data = await CalendarApi.createCalendar(dda)
// console.log(data) // console.log(data)
// } // }
//
const isCurrentMonth = (date:any,index:number) => {
const SelectDate = date.date;
return SelectDate.getMonth() === index;
};
/** 查询列表 */ /** 查询列表 */
const getListDate = async () => { const getListDate = async () => {
loading.value = false loading.value = false;
try { try {
const data = await CalendarApi.getCalendarPage(queryParamsDate) const data = await CalendarApi.getCalendarPage(queryParamsDate);
list.value = data.list list.value = data.list;
mapDate() mapDate();
total.value = data.total total.value = data.total;
} finally { } finally {
loading.value = true loading.value = true;
} }
} }
@ -201,7 +232,9 @@ const handleSelect = async (date:any) => {
}; };
// //
const submitForm = async ()=> { const submitForm = async (date:any)=> {
//
await getDate(date);
const dataClan = formDataCaln.value as unknown as CalendarVO const dataClan = formDataCaln.value as unknown as CalendarVO
// //
try { try {
@ -219,7 +252,14 @@ const submitForm = async ()=> {
// //
updatedHoliday.visible = false; updatedHoliday.visible = false;
} }
const closePopover = async (date:any)=> {
//
await getDate(date);
//
const updatedHoliday = holidayDate.value[sDate.value];
//
updatedHoliday.visible = false;
}
// //
function formatDate2(dat: number|Date) { function formatDate2(dat: number|Date) {
const date = new Date(dat) const date = new Date(dat)
@ -246,7 +286,14 @@ onMounted( async ()=> {
</script> </script>
<!-- 样式很重要 --> <!-- 样式很重要 -->
<style lang="scss"> <style lang="scss">
.close-But {
position: absolute;
top: 5px;
right: 5px;
padding: 0;
width: 12px;
height: 12px;
}
.custom-calendar { .custom-calendar {
border: 1px solid #1f1f1f !important; /* 使用 !important 确保样式生效 */ border: 1px solid #1f1f1f !important; /* 使用 !important 确保样式生效 */
border-radius: 10px; /* 可选:添加圆角 */ border-radius: 10px; /* 可选:添加圆角 */