From b25c4c6797ac5708a94386a17d5743dfd6392673 Mon Sep 17 00:00:00 2001 From: "DESKTOP-JKIE562\\PC" <1013397054@qq.com> Date: Tue, 26 May 2026 11:39:27 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BA=BA=E4=BA=8B=E8=AF=B7=E5=81=87?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/views/ChatView.vue | 185 ++++++++++++++++++++++++++------ 1 file changed, 151 insertions(+), 34 deletions(-) diff --git a/frontend/src/views/ChatView.vue b/frontend/src/views/ChatView.vue index 5f1faf97..858ee1b6 100644 --- a/frontend/src/views/ChatView.vue +++ b/frontend/src/views/ChatView.vue @@ -925,45 +925,162 @@ const calculateDurationHours = (startTime: string, endTime: string) => { const formatDurationLabel = (hours: number) => { if (!hours) return `0 ${t('chat.hourUnit')}`; - if (hours >= 8 && Number.isInteger((hours / 8) * 10) && (hours / 8) >= 1) { - const days = Number((hours / 8).toFixed(2)); - return `${days} ${t('chat.dayUnit')} / ${hours} ${t('chat.hourUnit')}`; - } return `${hours} ${t('chat.hourUnit')}`; }; +const LEAVE_TYPE_MAP: Record = { + '事假': '005', + '病假': '006', + '丧假': '007', + '年假': '010', + '因公出差': '021', + '出差': '021', + '调休': '025', + '产假': '401', + '陪产假': '402', + '婚假': '403', + '住院': '405', + '工伤': '406', + '育儿假': '408', + '返乡': 'ZZ01', +}; + const extractLeaveTypeFromIntent = (content: string) => { if (!content) return ''; - const map: Record = { - '事假': '005', - '病假': '006', - '丧假': '007', - '年假': '010', - '因公出差': '021', - '出差': '021', - '调休': '025', - '产假': '401', - '陪产假': '402', - '婚假': '403', - '住院': '405', - '工伤': '406', - '育儿假': '408', - '返乡': 'ZZ01', - }; - for (const [key, val] of Object.entries(map)) { - if (content.includes(key)) { - return val; - } + for (const [key, val] of Object.entries(LEAVE_TYPE_MAP)) { + if (content.includes(key)) return val; } return ''; }; -const createLeaveFormData = (content?: string): LeaveRequestFormData => { +interface ExtractedLeaveInfo { + leaveType: string; + startTime: string; + endTime: string; + durationHours: number; +} + +const extractLeaveInfoFromIntent = (content: string): ExtractedLeaveInfo | null => { + const normalized = content.replace(/\s+/g, ' ').trim(); + let leaveType = extractLeaveTypeFromIntent(normalized); + let startTime = ''; + let endTime = ''; + let durationHours = 0; + + const today = new Date(); + const thisYear = today.getFullYear(); + + const parseDateStr = (m: RegExpMatchArray | null, groupOffset: number): Date | null => { + if (!m) return null; + const mo = parseInt(m[groupOffset], 10); + const da = parseInt(m[groupOffset + 1], 10); + if (Number.isNaN(mo) || Number.isNaN(da) || mo < 1 || mo > 12 || da < 1 || da > 31) return null; + return new Date(thisYear, mo - 1, da, 9, 0); + }; + + const fmtDt = (d: Date, hour: number, minute: number) => { + const y = d.getFullYear(); + const mo = String(d.getMonth() + 1).padStart(2, '0'); + const da = String(d.getDate()).padStart(2, '0'); + const h = String(hour).padStart(2, '0'); + const mi = String(minute).padStart(2, '0'); + return `${y}-${mo}-${da}T${h}:${mi}`; + }; + + let startDay: Date | null = null; + let endDay: Date | null = null; + let startHM = { h: 9, m: 0 }; + let endHM = { h: 18, m: 0 }; + + const rangeM = normalized.match(/从?(\d{1,2})[月./-](\d{1,2})[日号]?[到至—\-–](\d{1,2})[月./-]?(\d{1,2})[日号]?/); + if (rangeM) { + const s = parseDateStr(rangeM, 1); + if (rangeM[3] && rangeM[3].length <= 2 && rangeM[4] && rangeM[4].length <= 2) { + const eMo = parseInt(rangeM[3], 10); + const eDa = parseInt(rangeM[4], 10); + if (!Number.isNaN(eMo) && eMo >= 1 && eMo <= 12 && !Number.isNaN(eDa) && eDa >= 1 && eDa <= 31) { + endDay = new Date(thisYear, eMo - 1, eDa, 18, 0); + } else if (!Number.isNaN(eDa) && eDa >= 1 && eDa <= 31 && s) { + endDay = new Date(thisYear, s.getMonth(), eDa, 18, 0); + } + } + if (s) startDay = s; + } + + if (!startDay) { + const singleM = normalized.match(/(\d{1,2})[月./-](\d{1,2})[日号]?/); + if (singleM) { + const s = parseDateStr(singleM, 1); + if (s) { + startDay = s; + const dayUnitM = normalized.match(/(\d+\.?\d*)\s*[天日]/); + if (dayUnitM) { + const days = parseFloat(dayUnitM[1]); + if (days > 1) endDay = new Date(s.getFullYear(), s.getMonth(), s.getDate() + Math.ceil(days) - 1, 18, 0); + else endDay = new Date(s.getFullYear(), s.getMonth(), s.getDate(), 18, 0); + } else { + endDay = new Date(s.getFullYear(), s.getMonth(), s.getDate(), 18, 0); + } + } + } + } + + const hourM = normalized.match(/(\d+\.?\d*)\s*小时/); + if (hourM) { + durationHours = parseFloat(hourM[1]); + if (startDay && !endDay) { + endDay = new Date(startDay.getTime() + durationHours * 3600000); + } + } + + const dayM = normalized.match(/(\d+\.?\d*)\s*[天日]/); + if (dayM && !hourM) { + const days = parseFloat(dayM[1]); + durationHours = days * 8; + if (startDay && !endDay) { + endDay = new Date(startDay.getFullYear(), startDay.getMonth(), startDay.getDate() + Math.ceil(days) - 1, 18, 0); + } + } + + if (startDay) { + if (durationHours > 0 && durationHours <= 8 && !endDay) { + endDay = new Date(startDay.getTime() + durationHours * 3600000); + } + startTime = fmtDt(startDay, startHM.h, startHM.m); + } + + if (endDay) { + if (hourM && durationHours <= 8) { + endHM = { h: 9 + Math.floor(durationHours), m: (durationHours % 1) * 60 }; + } else if (!hourM && durationHours > 0 && durationHours <= 8) { + endHM = { h: 9 + Math.floor(durationHours), m: 0 }; + } + endTime = fmtDt(endDay, endHM.h, endHM.m); + } + + if (startTime && endTime) { + durationHours = durationHours || calculateDurationHours(startTime, endTime); + } + + if (!leaveType && !startTime) return null; + + return { + leaveType, + startTime, + endTime, + durationHours, + }; +}; + +const createLeaveFormData = (content?: string, extractedInfo?: ExtractedLeaveInfo | null): LeaveRequestFormData => { const now = new Date(); const oneHourLater = new Date(now.getTime() + 60 * 60 * 1000); - const startTime = formatDateTime(now); - const endTime = formatDateTime(oneHourLater); - const initialLeaveType = extractLeaveTypeFromIntent(content || ''); + const defaultStart = formatDateTime(now); + const defaultEnd = formatDateTime(oneHourLater); + const initialLeaveType = extractedInfo?.leaveType || extractLeaveTypeFromIntent(content || ''); + const startTime = extractedInfo?.startTime || defaultStart; + const endTime = extractedInfo?.endTime || defaultEnd; + const durationHours = extractedInfo?.durationHours || calculateDurationHours(startTime, endTime); return { applicantName: currentUserDisplayName.value, employeeId: currentUserEmployeeId.value, @@ -976,7 +1093,7 @@ const createLeaveFormData = (content?: string): LeaveRequestFormData => { leaveType: initialLeaveType, startTime, endTime, - durationHours: calculateDurationHours(startTime, endTime), + durationHours, isOutOfOffice: 1, isWorkInjury: 1, }; @@ -995,11 +1112,10 @@ const getLeaveIntentNormalized = (content: string) => (content || '').replace(/\ const isStrongLeaveIntent = (content: string) => { const normalized = getLeaveIntentNormalized(content); - // 弱意图(咨询流程/步骤)应走正常问答,不触发表单分流。 const weakConsultationIntent = /(请假流程|请假怎么走|请假步骤|请假如何申请|请假如何走流程|请假怎么办|请假需要什么|请假规定)/; if (weakConsultationIntent.test(normalized)) return false; - if (/^(请假|休假|年假|事假|病假|调休)$/.test(normalized)) return true; - return /(我要请|申请请|发起请|请假申请|我要休|申请休|想请|帮我请|代我请|提交请)/.test(normalized); + if (/^(请假|休假|年假|事假|病假|调休|休年假|请事假|请病假|请年假)$/.test(normalized)) return true; + return /(我要请|申请请|发起请|请假申请|我要休|申请休|想请|帮我请|代我请|提交请|帮我申请|我要申请|想申请|申请.*假|请.*假|休.*假)/.test(normalized); }; const saveLocalMessageToBackend = async (msg: any, userQuery: string = '') => { @@ -1063,7 +1179,8 @@ const checkLeaveBalance = async (leaveTypeCode: string): Promise<{ }; const startLocalLeaveFlow = async (content: string) => { - const initialLeaveType = extractLeaveTypeFromIntent(content); + const extractedInfo = extractLeaveInfoFromIntent(content); + const initialLeaveType = extractedInfo?.leaveType || extractLeaveTypeFromIntent(content); if (initialLeaveType && NEED_BALANCE_CHECK_TYPES.has(initialLeaveType)) { messages.value.push({ role: 'user', content, type: 'text' }); @@ -1111,7 +1228,7 @@ const startLocalLeaveFlow = async (content: string) => { const formId = newLocalMessageId('leave-form'); const payload: LeaveFormPayload = { formId, - form: createLeaveFormData(content), + form: createLeaveFormData(content, extractedInfo), submitting: false, confirmationGenerated: false, }; From 041c2d033fec9e1f11630c3af839d2646fc76f06 Mon Sep 17 00:00:00 2001 From: sophie <16087569+sophie_liang@user.noreply.gitee.com> Date: Tue, 26 May 2026 14:40:09 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E6=9A=97=E9=BB=91?= =?UTF-8?q?=E4=B8=BB=E9=A2=98=E4=B8=8B=E7=9B=B8=E5=85=B3=E8=83=8C=E6=99=AF?= =?UTF-8?q?=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/style.css | 2 +- frontend/src/views/AdminView.vue | 19 +++++--- frontend/src/views/ChatView.vue | 17 ++++--- frontend/src/views/WorkspaceView.vue | 66 +++++++++++++++------------- 4 files changed, 59 insertions(+), 45 deletions(-) diff --git a/frontend/src/style.css b/frontend/src/style.css index a485355b..31814834 100644 --- a/frontend/src/style.css +++ b/frontend/src/style.css @@ -98,7 +98,7 @@ } .card { - @apply bg-white rounded-2xl border border-slate-100 shadow-soft hover:shadow-lg transition-all duration-300; + @apply bg-white rounded-2xl border border-slate-100 shadow-soft hover:shadow-lg transition-all duration-300 dark:bg-slate-800 dark:border-slate-700; } /* Mobile-first layout tokens for consistent spacing and density. */ diff --git a/frontend/src/views/AdminView.vue b/frontend/src/views/AdminView.vue index 9ce8778b..7bfa2b76 100644 --- a/frontend/src/views/AdminView.vue +++ b/frontend/src/views/AdminView.vue @@ -241,6 +241,10 @@ const route = useRoute(); // 当前左侧菜单激活的模块:dashboard / agents / permissions const activeModule = ref<'dashboard' | 'agents' | 'announcements' | 'permissions' | 'requests' | 'reports' | 'approvals' | 'users' | 'departments' | 'questions' | 'wecom' | 'schedules' | 'knowledge_base'>('dashboard'); +const adminSidebarNavActive = + 'bg-brand-50 text-brand-700 shadow-sm dark:bg-brand-500/15 dark:text-brand-300 dark:shadow-none dark:ring-1 dark:ring-inset dark:ring-brand-500/25'; +const adminSidebarNavInactive = + 'text-slate-600 hover:bg-slate-50 hover:text-slate-900 dark:text-slate-400 dark:hover:bg-slate-800/80 dark:hover:text-slate-200'; const expandedReports = ref(true); // agents:管理员视角下的所有 Agent 列表 @@ -3463,28 +3467,29 @@ const handlePermissionImport = async (event: Event) => { v-for="item in sidebarItems" :key="item.id" class="group px-4 py-3 text-left text-sm font-medium rounded-xl transition-all flex items-center gap-3 relative overflow-hidden whitespace-nowrap flex-shrink-0" - :class="activeModule === item.id ? 'bg-brand-50 text-brand-700' : 'text-slate-600 dark:text-slate-300 hover:bg-slate-50 dark:hover:bg-slate-800 hover:text-slate-900 dark:hover:text-slate-100'" + :class="activeModule === item.id ? adminSidebarNavActive : adminSidebarNavInactive" @click="activeModule = item.id as any; activeReportTabId = null" :title="isSidebarCollapsed ? item.label : ''" > - + {{ item.label }} {{ item.badge }} -
+
diff --git a/frontend/src/views/ChatView.vue b/frontend/src/views/ChatView.vue index ad7e7a65..df9fbdcd 100644 --- a/frontend/src/views/ChatView.vue +++ b/frontend/src/views/ChatView.vue @@ -972,8 +972,11 @@ const extractLeaveInfoFromIntent = (content: string): ExtractedLeaveInfo | null const parseDateStr = (m: RegExpMatchArray | null, groupOffset: number): Date | null => { if (!m) return null; - const mo = parseInt(m[groupOffset], 10); - const da = parseInt(m[groupOffset + 1], 10); + const rawMo = m[groupOffset]; + const rawDa = m[groupOffset + 1]; + if (!rawMo || !rawDa) return null; + const mo = parseInt(rawMo, 10); + const da = parseInt(rawDa, 10); if (Number.isNaN(mo) || Number.isNaN(da) || mo < 1 || mo > 12 || da < 1 || da > 31) return null; return new Date(thisYear, mo - 1, da, 9, 0); }; @@ -996,8 +999,8 @@ const extractLeaveInfoFromIntent = (content: string): ExtractedLeaveInfo | null if (rangeM) { const s = parseDateStr(rangeM, 1); if (rangeM[3] && rangeM[3].length <= 2 && rangeM[4] && rangeM[4].length <= 2) { - const eMo = parseInt(rangeM[3], 10); - const eDa = parseInt(rangeM[4], 10); + const eMo = parseInt(rangeM[3]!, 10); + const eDa = parseInt(rangeM[4]!, 10); if (!Number.isNaN(eMo) && eMo >= 1 && eMo <= 12 && !Number.isNaN(eDa) && eDa >= 1 && eDa <= 31) { endDay = new Date(thisYear, eMo - 1, eDa, 18, 0); } else if (!Number.isNaN(eDa) && eDa >= 1 && eDa <= 31 && s) { @@ -1014,7 +1017,7 @@ const extractLeaveInfoFromIntent = (content: string): ExtractedLeaveInfo | null if (s) { startDay = s; const dayUnitM = normalized.match(/(\d+\.?\d*)\s*[天日]/); - if (dayUnitM) { + if (dayUnitM?.[1]) { const days = parseFloat(dayUnitM[1]); if (days > 1) endDay = new Date(s.getFullYear(), s.getMonth(), s.getDate() + Math.ceil(days) - 1, 18, 0); else endDay = new Date(s.getFullYear(), s.getMonth(), s.getDate(), 18, 0); @@ -1026,7 +1029,7 @@ const extractLeaveInfoFromIntent = (content: string): ExtractedLeaveInfo | null } const hourM = normalized.match(/(\d+\.?\d*)\s*小时/); - if (hourM) { + if (hourM?.[1]) { durationHours = parseFloat(hourM[1]); if (startDay && !endDay) { endDay = new Date(startDay.getTime() + durationHours * 3600000); @@ -1034,7 +1037,7 @@ const extractLeaveInfoFromIntent = (content: string): ExtractedLeaveInfo | null } const dayM = normalized.match(/(\d+\.?\d*)\s*[天日]/); - if (dayM && !hourM) { + if (dayM?.[1] && !hourM) { const days = parseFloat(dayM[1]); durationHours = days * 8; if (startDay && !endDay) { diff --git a/frontend/src/views/WorkspaceView.vue b/frontend/src/views/WorkspaceView.vue index 0fe8008e..7f9d43b4 100644 --- a/frontend/src/views/WorkspaceView.vue +++ b/frontend/src/views/WorkspaceView.vue @@ -773,6 +773,10 @@ const handleRegister = async () => { }; const activeSidebarItem = ref<'profile' | 'applications' | 'feedback' | 'updates' | 'knowledge_base' | 'schedule_runs' | 'history'>('applications'); +const workspaceSidebarNavActive = + 'bg-brand-50 text-brand-700 shadow-sm dark:bg-brand-500/15 dark:text-brand-300 dark:shadow-none dark:ring-1 dark:ring-inset dark:ring-brand-500/25'; +const workspaceSidebarNavInactive = + 'text-slate-600 hover:bg-slate-50 hover:text-slate-900 dark:text-slate-400 dark:hover:bg-slate-800/80 dark:hover:text-slate-200'; const isProfileLoading = ref(false); const isProfileSaving = ref(false); const isProfileEditing = ref(false); @@ -1553,15 +1557,15 @@ onMounted(async () => {
-
+