From fcc6acbcee5ea27a868ede82f528f7991025bf82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=96=87=E5=B3=B0?= Date: Wed, 6 May 2026 18:55:17 +0800 Subject: [PATCH] up --- .workbuddy/memory/2026-05-06.md | 32 ++++++++++ backend/my_work/routers/apiCalendar.go | 60 +++++++++++-------- frontend/ops_vue_js/src/i18n/en.json | 1 + frontend/ops_vue_js/src/i18n/zh-CN.json | 1 + .../src/views/calendar/CalendarDetail.vue | 31 +++++++--- 5 files changed, 91 insertions(+), 34 deletions(-) create mode 100644 .workbuddy/memory/2026-05-06.md diff --git a/.workbuddy/memory/2026-05-06.md b/.workbuddy/memory/2026-05-06.md new file mode 100644 index 0000000..3487e3b --- /dev/null +++ b/.workbuddy/memory/2026-05-06.md @@ -0,0 +1,32 @@ +# 2026-05-06 日志 + +## 日历事件日程类型功能 + +### 修改内容 +- **后端** `routers/apiCalendar.go`: + - `TabCalendarEvent` 结构体新增 `ScheduleType string` 字段(默认值 work) + - `addevent`/`updateevent` 接口解析并保存 `schedule_type` 参数 + +- **前端** `CalendarDetail.vue`: + - `eventData` 新增 `scheduleType` 字段 + - `openEventModal`/`editEvent` 传递 `scheduleType` + - `selectColor` 函数联动更新 `scheduleType` + - `saveEvent`/`eventDrop` 提交 `schedule_type` + - `getEvents` 返回数据附加 `extendedProps.scheduleType` + - 模态框显示日程类型标签 + +- **i18n**: + - `zh-CN.json`: 新增 `event_type: "日程类型"` + - `en.json`: 新增 `event_type: "Event Type"` + +### 日程类型选项 +- work - 工作 +- duty - 值班 +- exam - 考试 +- standby - 备用 +- personal_holiday - 个人假期 +- public_holiday - 公众假期 + +### 注意事项 +- GORM AutoMigrate 会自动添加新字段 +- 前端颜色选择与日程类型联动 diff --git a/backend/my_work/routers/apiCalendar.go b/backend/my_work/routers/apiCalendar.go index c26fbc1..e87163b 100644 --- a/backend/my_work/routers/apiCalendar.go +++ b/backend/my_work/routers/apiCalendar.go @@ -27,17 +27,17 @@ type TabCalendar struct { // TabCalendarEvent 日历事件表 type TabCalendarEvent struct { - ID uint `gorm:"primarykey"` - CalendarID uint `gorm:"not null;index;comment:关联日历ID"` - UserID uint `gorm:"not null;comment:创建人ID"` - //UsersID []uint `gorm:"type:json; null;comment:其他关联用户ID"` - Title string `gorm:"size:200;not null;comment:事件标题"` - StartDate *time.Time `gorm:"size:10;not null;index;comment:开始日期 YYYY-MM-DD"` - EndDate *time.Time `gorm:"size:10;not null;index;comment:结束日期 YYYY-MM-DD"` - IsAllDay bool `gorm:"default:true;comment:是否全日事件"` - BgColor string `gorm:"size:50;default:#3788d9;comment:背景颜色"` - IsPublic bool `gorm:"default:false;comment:是否为公共日程"` - Remark string `gorm:"type:text;comment:备注"` + ID uint `gorm:"primarykey"` + CalendarID uint `gorm:"not null;index;comment:关联日历ID"` + UserID uint `gorm:"not null;comment:创建人ID"` + Title string `gorm:"size:200;not null;comment:事件标题"` + StartDate *time.Time `gorm:"size:10;not null;index;comment:开始日期 YYYY-MM-DD"` + EndDate *time.Time `gorm:"size:10;not null;index;comment:结束日期 YYYY-MM-DD"` + IsAllDay bool `gorm:"default:true;comment:是否全日事件"` + ScheduleType string `gorm:"size:50;default:work;comment:日程类型: work-工作 duty-值班 exam-考试 standby-待命 personal_holiday-调休 personal_holiday-公假"` + BgColor string `gorm:"size:50;default:#3788d9;comment:背景颜色"` + IsPublic bool `gorm:"default:false;comment:是否为公共日程"` + Remark string `gorm:"type:text;comment:备注"` CreatedAt *time.Time `gorm:"type:datetime;autoCreateTime;comment:创建时间"` UpdatedAt *time.Time `gorm:"type:datetime;autoUpdateTime;comment:最后修改时间"` @@ -376,19 +376,24 @@ func ApiCalendar(r *gin.RouterGroup) { color, _ := data["color"].(string) remark, _ := data["remark"].(string) isPublic, _ := data["is_public"].(bool) + scheduleType, _ := data["schedule_type"].(string) + if scheduleType == "" { + scheduleType = "work" + } startDate, _ := time.Parse("2006-01-02 15:04:05", startStr) endDate, _ := time.Parse("2006-01-02 15:04:05", endStr) event := TabCalendarEvent{ - CalendarID: calendarID, - UserID: user.ID, - Title: title, - StartDate: &startDate, - EndDate: &endDate, - BgColor: color, - IsPublic: isPublic, - Remark: remark, + CalendarID: calendarID, + UserID: user.ID, + Title: title, + StartDate: &startDate, + EndDate: &endDate, + ScheduleType: scheduleType, + BgColor: color, + IsPublic: isPublic, + Remark: remark, } if event.BgColor == "" { event.BgColor = calendar.Color @@ -442,17 +447,22 @@ func ApiCalendar(r *gin.RouterGroup) { color, _ := data["color"].(string) remark, _ := data["remark"].(string) isPublic, _ := data["is_public"].(bool) + scheduleType, _ := data["schedule_type"].(string) + if scheduleType == "" { + scheduleType = "work" + } startDate, _ := time.Parse("2006-01-02 15:04:05", startStr) endDate, _ := time.Parse("2006-01-02 15:04:05", endStr) newEvent := TabCalendarEvent{ - Title: title, - StartDate: &startDate, - EndDate: &endDate, - BgColor: color, - IsPublic: isPublic, - Remark: remark, + Title: title, + StartDate: &startDate, + EndDate: &endDate, + ScheduleType: scheduleType, + BgColor: color, + IsPublic: isPublic, + Remark: remark, } if newEvent.BgColor == "" { // 获取日历颜色 diff --git a/frontend/ops_vue_js/src/i18n/en.json b/frontend/ops_vue_js/src/i18n/en.json index 0e6d2df..017c91e 100644 --- a/frontend/ops_vue_js/src/i18n/en.json +++ b/frontend/ops_vue_js/src/i18n/en.json @@ -312,6 +312,7 @@ "standby": "Standby", "personal_holiday": "Personal Holiday", "public_holiday": "Public Holiday", + "event_type": "Event Type", "to": "To", "close": "Close", "copy": "Copy", diff --git a/frontend/ops_vue_js/src/i18n/zh-CN.json b/frontend/ops_vue_js/src/i18n/zh-CN.json index b5b0974..d7e8bea 100644 --- a/frontend/ops_vue_js/src/i18n/zh-CN.json +++ b/frontend/ops_vue_js/src/i18n/zh-CN.json @@ -312,6 +312,7 @@ "standby": "备用", "personal_holiday": "个人假期", "public_holiday": "公众假期", + "event_type": "日程类型", "to": "至", "close": "关闭", "copy": "复制", diff --git a/frontend/ops_vue_js/src/views/calendar/CalendarDetail.vue b/frontend/ops_vue_js/src/views/calendar/CalendarDetail.vue index c5e578d..c8dbe69 100644 --- a/frontend/ops_vue_js/src/views/calendar/CalendarDetail.vue +++ b/frontend/ops_vue_js/src/views/calendar/CalendarDetail.vue @@ -37,6 +37,7 @@ const eventData = ref({ startDate: "", endDate: "", color: "#3788d9", + scheduleType: "work", isPublic: false, isEditing: false, isEditable: false, @@ -78,13 +79,14 @@ function closeEventModal() { showModal.value = false } -function openEventModal(dateStr, dataEnd, id = 0, title = "", color = "#3788d9", isPublic = false, isEditing = false, isEditable = true) { +function openEventModal(dateStr, dataEnd, id = 0, title = "", color = "#3788d9", scheduleType = "work", isPublic = false, isEditing = false, isEditable = true) { eventData.value = { id: id, title: title, startDate: dateStr, endDate: dataEnd, color: color, + scheduleType: scheduleType, isPublic: isPublic, isEditing: isEditing, isEditable: isEditable, @@ -99,6 +101,7 @@ function editEvent(info) { parseInt(info.event.id), info.event.title, info.event.backgroundColor, + info.event.extendedProps?.scheduleType || "work", info.event.extendedProps?.isPublic || false, true, info.event.durationEditable, @@ -108,6 +111,11 @@ function editEvent(info) { function selectColor(colorValue) { if (eventData.value.isEditable) { eventData.value.color = colorValue + // 根据颜色更新日程类型 + const selectedColor = colorOptions.value.find(c => c.value === colorValue) + if (selectedColor) { + eventData.value.scheduleType = selectedColor.type + } } } @@ -129,9 +137,6 @@ async function saveEvent() { return } - const selectedColor = colorOptions.value.find(c => c.value === eventData.value.color) - const scheduleType = selectedColor ? selectedColor.type : "work" - try { let result if (eventData.value.isEditing) { @@ -144,7 +149,7 @@ async function saveEvent() { ? eventData.value.endDate : DateUtils.toRealEnd(eventData.value.endDate), ), - schedule_type: scheduleType, + schedule_type: eventData.value.scheduleType, is_public: eventData.value.isPublic, }) } else { @@ -157,7 +162,7 @@ async function saveEvent() { ? eventData.value.endDate : DateUtils.toRealEnd(eventData.value.endDate), ), - schedule_type: scheduleType, + schedule_type: eventData.value.scheduleType, is_public: eventData.value.isPublic, }) } @@ -218,6 +223,10 @@ async function getEvents() { backgroundColor: item.BgColor, borderColor: item.ID === pageData.value.seleEventID ? "#000000" : "#F7F7F7", allDay: true, + extendedProps: { + scheduleType: item.ScheduleType || "work", + isPublic: item.IsPublic || false, + }, }) }) } @@ -391,8 +400,6 @@ const calendarOptions = ref({ eventDrop(info) { // 拖拽后直接更新 - const selectedColor = colorOptions.value.find(c => c.value === info.event.backgroundColor) - const scheduleType = selectedColor ? selectedColor.type : "work" const startStr = info.event.startStr const endStr = info.event.end ? info.event.endStr : startStr calendarApi.updateEvent({ @@ -400,7 +407,7 @@ const calendarOptions = ref({ title: info.event.title, start: toDatetime(startStr), end: toDatetime(startStr === endStr ? endStr : DateUtils.toRealEnd(endStr)), - schedule_type: scheduleType, + schedule_type: info.event.extendedProps?.scheduleType || "work", }).then(r => { if (r.errCode !== 0) toast.error(t('message.server_error')) else getEvents() @@ -569,6 +576,12 @@ onMounted(() => { + +
+ {{ t('schedule.event_type') }}: + {{ t('schedule.' + eventData.scheduleType) || eventData.scheduleType }} +
+
{{ t('calendar.is_public_event') }}