From 8a5617e1d7769e328391dabf2c220bb5c03d7699 Mon Sep 17 00:00:00 2001
From: 张含笑 <zhx18749296735@163.com>
Date: Sat, 10 May 2025 09:57:40 +0800
Subject: [PATCH] 日历样式调整
---
src/assets/images/workbench/ev2.png | 0
src/assets/images/workbench/ev1.png | 0
src/views/wel/components/calendarBox.vue | 117 +++++++++++++++++++++++++++++++---------------------------
3 files changed, 62 insertions(+), 55 deletions(-)
diff --git a/src/assets/images/workbench/ev1.png b/src/assets/images/workbench/ev1.png
new file mode 100644
index 0000000..4322450
--- /dev/null
+++ b/src/assets/images/workbench/ev1.png
Binary files differ
diff --git a/src/assets/images/workbench/ev2.png b/src/assets/images/workbench/ev2.png
new file mode 100644
index 0000000..fdfc60f
--- /dev/null
+++ b/src/assets/images/workbench/ev2.png
Binary files differ
diff --git a/src/views/wel/components/calendarBox.vue b/src/views/wel/components/calendarBox.vue
index d5e3f8a..2d19ee1 100644
--- a/src/views/wel/components/calendarBox.vue
+++ b/src/views/wel/components/calendarBox.vue
@@ -2,7 +2,7 @@
<div class="calenBox">
<el-calendar ref="calendar" v-model="leftValue">
<template #date-cell="{ data }">
- <div>
+ <div :class="data.isSelected ? 'is-selected' : ''">
<div class="date-number">{{ data.day.slice(8, 10) }}</div>
<div class="events">
<div
@@ -10,10 +10,10 @@
:key="index"
class="event-item"
:class="event.type"
- @click="jumpcalendar(event,data.day)"
+ @click="jumpcalendar(event, data.day)"
>
- <span></span>
- {{ event.name }}{{ event.value }}
+ <img :src="getEventIcon(event.type)" alt="" />
+ {{ event.name }}<span>{{ event.value }}</span>
</div>
</div>
</div>
@@ -25,16 +25,22 @@
<script setup>
import dayjs from 'dayjs';
import { jobEventBar, getCalen } from '@/api/home/index';
-import { useRouter } from 'vue-router'
-const router = useRouter()
-// 日历事件数据
-// 格式: 'YYYY-MM-DD': [...events]
+import { useRouter } from 'vue-router';
+import ev1 from '@/assets/images/workbench/ev1.png';
+import ev2 from '@/assets/images/workbench/ev2.png';
+const router = useRouter();
const events = ref({});
const params = ref({
end_date: undefined,
start_date: undefined,
});
-
+const eventIcons = ref({
+ 'work-order': ev1,
+ task: ev2,
+});
+const getEventIcon = type => {
+ return eventIcons.value[type] || eventIcons.value.default;
+};
function getCurrentMonthRange() {
return {
start_date: dayjs().startOf('month').format('YYYY-MM-DD HH:mm:ss'),
@@ -45,26 +51,14 @@
watch(
() => leftValue.value,
(newV, oldV) => {
- if (newV && dayjs(newV).isSame(dayjs(), 'day')) {
- }
-
if (newV && oldV) {
const newDate = dayjs(newV);
const oldDate = dayjs(oldV);
- const newDateStr = newDate.format('YYYY-MM-DD HH:mm:ss');
- const oldDateStr = oldDate.format('YYYY-MM-DD HH:mm:ss');
- // console.log('新日期:', newDateStr, '旧日期:', oldDateStr);
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 (newDate.isBefore(oldDate, 'month')) {
- // console.log('点击了上个月', params.value);
- // } else if (newDate.isAfter(oldDate, 'month')) {
- // console.log('点击了下个月', params.value);
- // }
- getJobEventBar();
+ getJobEventBar();
}
},
{ deep: true, immediate: true }
@@ -83,28 +77,43 @@
const getJobEventBar = () => {
getCalen(params.value).then(res => {
if (res.data.code !== 0) return;
- events.value = res.data.data
- // console.log('日历', res.data.data);
+ console.log('rili', res.data.data);
+
+ events.value = res.data.data;
});
};
-const jumpcalendar=(event,day)=>{
-console.log('eee',event,day);
-if(event.name ==='工单'){
- router.push({
- path: '/tickets/ticket',
- query:{
- day:day
- }
- })
-}
-
-
-}
+const jumpcalendar = (event, day) => {
+ if (event.name === '工单') {
+ router.push({
+ path: '/tickets/ticket',
+ query: {
+ day: day,
+ },
+ });
+ }
+};
onMounted(() => {
getJobEventBar();
});
</script>
+<style lang="scss">
+.calenBox {
+ .el-calendar-table td.is-selected {
+ background-color: #f0f7ff;
+ border: 2px solid #409eff;
+ border-radius: 4px;
+ }
+ .el-calendar-table td.is-selected .date-number {
+ font-weight: bold;
+ color: #409eff;
+ }
+
+ .el-calendar-table td.is-selected .events {
+ // padding: 2px;
+ }
+}
+</style>
<style lang="scss" scoped>
.calenBox {
margin-top: 10px;
@@ -112,36 +121,34 @@
overflow: hidden;
.event-item {
font-size: 12px;
- padding: 2px;
- margin: 2px 0;
+ // padding: 2px;
+
border-radius: 3px;
white-space: nowrap;
// overflow: hidden;
// text-overflow: ellipsis;
&.work-order {
- // background: #ecf5ff;
- color: #409eff;
+ font-weight: 400;
+ font-size: 12px;
+ color: #7b7b7b;
span {
- display: inline-block;
- width: 7px;
- height: 7px;
- background: #1c5cff;
- border-radius: 50%;
- margin-right: 2px;
+ font-weight: 600;
+ font-size: 14px;
+ color: #1c5cff;
+ margin-left: 2px;
}
}
&.task {
- // background: #f0f9eb;
- color: #67c23a;
+ font-weight: 400;
+ font-size: 12px;
+ color: #7b7b7b;
span {
- display: inline-block;
- width: 7px;
- height: 7px;
- background: #029d36;
- border-radius: 50%;
- margin-right: 2px;
+ font-weight: 600;
+ font-size: 14px;
+ color: #029d36;
+ margin-left: 2px;
}
}
}
--
Gitblit v1.9.3