From 2dfc8dc4bcd3d3cd4aed1b6054e073e140eba9c8 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Mon, 19 May 2025 16:05:50 +0800
Subject: [PATCH] Merge branch 'master' into jiangwu
---
src/views/wel/components/calendarBox.vue | 144 ++++++++++++++++++++++++-----------------------
1 files changed, 74 insertions(+), 70 deletions(-)
diff --git a/src/views/wel/components/calendarBox.vue b/src/views/wel/components/calendarBox.vue
index 92e4549..5ea7bc5 100644
--- a/src/views/wel/components/calendarBox.vue
+++ b/src/views/wel/components/calendarBox.vue
@@ -1,8 +1,8 @@
<template>
<div class="calenBox">
- <el-calendar ref="calendar" v-model="leftValue" @change="handleMonthChange(date)">
+ <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,9 +10,10 @@
:key="index"
class="event-item"
:class="event.type"
+ @click="jumpcalendar(event, data.day)"
>
- <span></span>
- {{ event.content }}
+ <img :src="getEventIcon(event.type)" alt="" />
+ {{ event.name }}<span>{{ event.value }}</span>
</div>
</div>
</div>
@@ -24,23 +25,23 @@
<script setup>
import dayjs from 'dayjs';
import { jobEventBar, getCalen } from '@/api/home/index';
-// 日历事件数据
-// 格式: 'YYYY-MM-DD': [...events]
-const events = ref({
- '2025-05-01': [
- { type: 'work-order', content: '工单26' },
- { type: 'task', content: '任务26' },
- ],
- '2025-05-04': [
- { type: 'task', content: '任务26' },
- { type: 'work-order', content: '工单26' },
- ],
-});
+import { useRouter } from 'vue-router';
+import ev1 from '@/assets/images/workbench/ev1.png';
+import ev2 from '@/assets/images/workbench/ev2.png';
+import { ElMessage } from 'element-plus'
+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'),
@@ -51,63 +52,68 @@
watch(
() => leftValue.value,
(newV, oldV) => {
- if (newV && dayjs(newV).isSame(dayjs(), 'day')) {
- console.log('点击了今天');
- }
-
if (newV && oldV) {
const newDate = dayjs(newV);
- const oldDate = dayjs(oldV);
-
- if (newDate.isBefore(oldDate, 'month')) {
- console.log('点击了上个月');
- } else if (newDate.isAfter(oldDate, 'month')) {
- console.log('点击了下个月');
- }
+ 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 }
+ { deep: true, immediate: true }
);
-const handleMonthChange = date => {
- console.log('date', date);
- // 获取当前视图月份的第一天
- const firstDay = new Date(date.getFullYear(), date.getMonth(), 1);
-
- // 获取当前视图月份的最后一天
- const lastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0);
-
- // 格式化为YYYY-MM-DD格式(可选)
- const formatDate = d => d.toISOString().slice(0, 10);
-
- console.log('首日:', formatDate(firstDay));
- console.log('末日:', formatDate(lastDay));
-};
// 获取日期数字
const getDate = date => {
return date.getDate();
};
// 获取对应日期的事件
const getEvents = dateString => {
- // console.log('000',dateString);
-
return events.value[dateString] || [];
};
+const monthRange = getCurrentMonthRange();
+params.value = monthRange;
const getJobEventBar = () => {
- const monthRange = getCurrentMonthRange();
- params.value = monthRange;
- console.log(monthRange);
getCalen(params.value).then(res => {
if (res.data.code !== 0) return;
- // events.value = res.data.data
- console.log('日历', res.data.data);
+ events.value = res.data.data;
});
+};
+const jumpcalendar = (event, day) => {
+ if (event.name === '工单') {
+ router.push({
+ path: '/tickets/ticket',
+ query: {
+ day: day,
+ },
+ });
+ }else{
+ ElMessage.warning('加急开发中...')
+ }
};
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;
@@ -115,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;
+ // 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