refactor(frontend): 重构前端第二版

This commit is contained in:
sophie committed 2026-06-11 13:47:06 +08:00
1 parent 2631f78b00
commit 4b562cfa82
205 files changed
+15399 -12015

No files matched your search

@@ -0,0 +1,34 @@
/**
* 请假:leave-form / leave-confirmation / leave-result payload 读取。
*/
import type { ChatMessage } from '../types/chat.types';
import type {
LeaveConfirmationPayload,
LeaveFormPayload,
LeaveRequestFormData,
LeaveResultPayload,
} from '../types/leave.types';
import type { Ref } from 'vue';
export function getLeaveFormPayload(chatMsg: ChatMessage): LeaveFormPayload | null {
return chatMsg?.type === 'leave-form' && chatMsg?.payload ? chatMsg.payload as LeaveFormPayload : null;
}
export function getLeaveConfirmationPayload(chatMsg: ChatMessage): LeaveConfirmationPayload | null {
return chatMsg?.type === 'leave-confirmation' && chatMsg?.payload ? chatMsg.payload as LeaveConfirmationPayload : null;
}
export function getLeaveResultPayload(chatMsg: ChatMessage): LeaveResultPayload | null {
return chatMsg?.type === 'leave-result' && chatMsg?.payload ? chatMsg.payload as LeaveResultPayload : null;
}
export function findMessageIndexByLocalId(messages: Ref<ChatMessage[]>, localId: string): number {
return messages.value.findIndex((m) => m?.local_id === localId || (m?.payload as LeaveFormPayload | undefined)?.formId === localId);
}
export function getLeaveAgentDisplayValue(form: LeaveRequestFormData): string {
if (!form.agentName) return '';
const parts = [form.agentName];
if (form.agentEmployeeId) parts.push(form.agentEmployeeId);
return parts.join(' / ');
}