From 346700c5e1d9340f95f574458ee0498bde09ec0d Mon Sep 17 00:00:00 2001
From: 张含笑 <zhx18749296735@163.com>
Date: Tue, 22 Jul 2025 16:56:45 +0800
Subject: [PATCH] feat:日历恢复

---
 src/views/wel/components/calendarBox.vue |  133 ++++++++-----------------------------------
 1 files changed, 26 insertions(+), 107 deletions(-)

diff --git a/src/views/wel/components/calendarBox.vue b/src/views/wel/components/calendarBox.vue
index b38e237..1fb2eb7 100644
--- a/src/views/wel/components/calendarBox.vue
+++ b/src/views/wel/components/calendarBox.vue
@@ -1,13 +1,6 @@
 <template>
   <div class="calenBox">
     <el-calendar ref="calendar" v-model="leftValue">
-      <template #header="{ date }">
-        <div>
-          <img :src="caleft" alt="" @click="selectDate('prev-month')" />
-          <span>{{ date }}</span>
-          <img :src="caright" alt="" @click="selectDate('next-month')" />
-        </div>
-      </template>
       <template #date-cell="{ data }">
         <div :class="data.isSelected ? 'is-selected' : ''">
           <div class="date-number">{{ data.day.slice(8, 10) }}</div>
@@ -19,9 +12,7 @@
               :class="event.type"
               @click="jumpcalendar(event, data.day)"
             >
-              <div class="imgBox">
-                <img :src="getEventIcon(event.type)" alt="" /> {{ event.name }}
-              </div>
+              <div class="imgBox"><img :src="getEventIcon(event.type)" alt="" /> {{ event.name }}</div>
               <span>{{ event.value }}</span>
             </div>
           </div>
@@ -37,20 +28,13 @@
 import { useRouter } from 'vue-router';
 import ev1 from '@/assets/images/workbench/ev1.svg';
 import ev2 from '@/assets/images/workbench/ev2.svg';
-import caleft from '@/assets/images/workbench/caleft.png';
-import caright from '@/assets/images/workbench/caright.png';
 import { ElMessage } from 'element-plus';
-const calendar = ref();
 const router = useRouter();
 const events = ref({});
 const params = ref({
   end_date: undefined,
   start_date: undefined,
 });
-const isCurrentMonth = (date) => {
-  return dayjs(date).isSame(dayjs(), 'month');
-};
-const leftValue = ref(null);
 const eventIcons = ref({
   'work-order': ev1,
   task: ev2,
@@ -64,49 +48,22 @@
     end_date: dayjs().endOf('month').format('YYYY-MM-DD HH:mm:ss'),
   };
 }
-const selectDate = val => {
-  if (!calendar.value) return;
-  calendar.value.selectDate(val);
-};
-
-// watch(
-//   () => leftValue.value,
-//   (newV, oldV) => {
-//     if (newV && oldV) {
-//       const newDate = dayjs(newV);
-//       params.value = {
-//         start_date: newDate.startOf('month').format('YYYY-MM-DD HH:mm:ss'),
-//         end_date: newDate.endOf('month').format('YYYY-MM-DD HH:mm:ss'),
-//       };
-//       getJobEventBar();
-//     }
-//   },
-//   { deep: true, immediate: true }
-// );
+const leftValue = ref(new Date());
 watch(
   () => leftValue.value,
   (newV, oldV) => {
-    if (newV) {
+    if (newV && oldV) {
       const newDate = dayjs(newV);
       params.value = {
         start_date: newDate.startOf('month').format('YYYY-MM-DD HH:mm:ss'),
         end_date: newDate.endOf('month').format('YYYY-MM-DD HH:mm:ss'),
       };
-      
-      // 新增:如果是当前月份,自动选中当天
-      if (isCurrentMonth(newV)) {
-        nextTick(() => {
-          if (calendar.value) {
-            calendar.value.selectDate(new Date());
-          }
-        });
-      }
-      
       getJobEventBar();
     }
   },
   { deep: true, immediate: true }
 );
+
 // 获取日期数字
 const getDate = date => {
   return date.getDate();
@@ -149,64 +106,19 @@
   }
 };
 onMounted(() => {
-  // 新增:挂载时如果是当前月份,设置默认选中
-  if (isCurrentMonth(leftValue.value)) {
-    leftValue.value = new Date();
-  }
   getJobEventBar();
 });
 </script>
 <style lang="scss">
 .calenBox {
+  //  height: 630px;
   height: pxToVh(660);
   // 隐藏按钮组中间按钮
   .el-button-group > .el-button:not(:first-child):not(:last-child) {
     display: none;
   }
-  .el-calendar__body {
-    padding-top: 0;
-  }
   .date-number {
-    font-size: 13px !important;
-  }
-  .el-calendar__header {
-    justify-content: center;
-    margin-top: 18px;
-    padding-bottom: 0;
-    border-bottom: transparent;
-    div {
-      display: flex;
-      justify-content: center;
-      align-items: center;
-      img {
-        width: 28px;
-        height: 28px;
-        cursor: pointer;
-      }
-      span {
-        font-weight: bold;
-        font-size: 14px;
-        color: #363636;
-        margin: 0 18px;
-      }
-    }
-  }
-  .el-calendar-table td {
-    border: none;
-  }
-  .el-calendar-table tr td {
-    border: none;
-  }
-  .el-calendar-table .el-calendar-day {
-    box-sizing: border-box;
-
-    padding: 0.8rem;
-    background: #f5f7fa;
-    border-radius: 6px 6px 6px 6px;
-    border: 1px solid #efefef;
-    margin-right: 5px;
-    margin-bottom: 8px;
-  }
+  font-size: 13px !important;}
 }
 </style>
 
@@ -220,35 +132,43 @@
   background-color: #fff;
 
   ::v-deep(.el-calendar) {
+    // height: 80%; // 日历填充容器
     // 标题样式
     .el-calendar__title {
       font-weight: bold;
       font-size: 14px;
       color: #363636;
     }
-    .el-calendar-table .el-calendar-day {
-      height: pxToVh(88) !important;
-    }
 
+    // 日历主体
+    // &__body {
+    //   height: 98%; // 关键:继承父高度
+
+    //   .el-calendar-table {
+    //     height: 90% !important; // 百分比生效
+    //   }
+    // }
+    .el-calendar-table .el-calendar-day {
+   
+       height: pxToVh(91) !important;
+    }
+ 
     // 选中日期样式
     .el-calendar-table td.is-selected {
-    .el-calendar-day {
-      outline: 2px solid #409eff;
-      outline-offset: -2px;
-      border: none !important;
+      background-color: #f0f7ff;
+      border: 2px solid #409eff;
+      border-radius: 4px;
+
       .date-number {
         font-weight: bold;
         color: #409eff;
       }
-    }}
-    .el-calendar-table td.is-selected {
-      background-color: transparent;
     }
-   
   }
 
   .event-item {
     font-size: 12px;
+    // padding: 2px;
     text-align: center;
     border-radius: 3px;
     white-space: nowrap;
@@ -279,8 +199,7 @@
       }
     }
     .imgBox {
-      font-size: 12px;
-    }
+   font-size: 12px;}
   }
 }
 </style>

--
Gitblit v1.9.3