agent请假推申请单到OA
This commit is contained in:
1 parent
aeb6b66513
commit
367c20eb09
15 files changed
+1833
-143
No files matched your search
+387
-48
@@ -13,7 +13,7 @@
|
||||
import { ref, onMounted, onBeforeUnmount, computed, watch, nextTick } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useChat } from '../composables/useChat';
|
||||
import { Send, Loader2, Plus, Copy, Edit2, RotateCw, Check, X, PanelLeftClose, PanelLeftOpen, Heart, Bell, Mail, Settings, ChevronDown, Sparkles, Database, Mic, LogOut, MessageSquareText, Globe, ExternalLink } from 'lucide-vue-next';
|
||||
import { Send, Loader2, Plus, Copy, Edit2, RotateCw, Check, X, PanelLeftClose, PanelLeftOpen, Heart, Bell, Mail, Settings, ChevronDown, Sparkles, Database, Mic, LogOut, MessageSquareText, Globe, ExternalLink, Search } from 'lucide-vue-next';
|
||||
import { marked } from 'marked';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { config } from '../config';
|
||||
@@ -43,8 +43,10 @@ marked.setOptions({
|
||||
const currentUserDisplayName = computed(() => {
|
||||
const realName = currentUser.value?.real_name?.trim();
|
||||
if (realName) return realName;
|
||||
const aliasName = (currentUser.value as any)?.name?.trim?.() || (currentUser.value as any)?.wecom_name?.trim?.();
|
||||
if (aliasName) return aliasName;
|
||||
const username = currentUser.value?.username?.trim();
|
||||
if (username) return username;
|
||||
if (username && !/^\d+$/.test(username)) return username;
|
||||
return '当前用户';
|
||||
});
|
||||
|
||||
@@ -520,12 +522,16 @@ interface LeaveRequestFormData {
|
||||
applicantName: string;
|
||||
employeeId: string;
|
||||
applyTime: string;
|
||||
fillerName: string;
|
||||
agentUid: string;
|
||||
agentEmployeeId: string;
|
||||
agentName: string;
|
||||
leaveType: string;
|
||||
startTime: string;
|
||||
endTime: string;
|
||||
durationHours: number;
|
||||
isOutOfOffice: boolean;
|
||||
isWorkInjury: boolean;
|
||||
isOutOfOffice: 0 | 1 | null;
|
||||
isWorkInjury: 0 | 1 | null;
|
||||
}
|
||||
|
||||
interface LeaveFormPayload {
|
||||
@@ -547,9 +553,82 @@ interface LeaveResultPayload {
|
||||
success: boolean;
|
||||
referenceNo: string;
|
||||
submittedAt: string;
|
||||
requestName?: string;
|
||||
errorMessage?: string;
|
||||
}
|
||||
|
||||
interface LeaveAgentOption {
|
||||
uid: string;
|
||||
employeeId: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
let leaveFlowCounter = 0;
|
||||
const leaveAgentOptions = ref<LeaveAgentOption[]>([]);
|
||||
const leaveAgentLoading = ref(false);
|
||||
const leaveAgentKeyword = ref('');
|
||||
const leaveAgentPage = ref(1);
|
||||
const leaveAgentHasMore = ref(true);
|
||||
|
||||
const fetchLeaveAgents = async (isLoadMore = false) => {
|
||||
if (leaveAgentLoading.value) return;
|
||||
if (!isLoadMore) {
|
||||
leaveAgentPage.value = 1;
|
||||
leaveAgentOptions.value = [];
|
||||
}
|
||||
|
||||
leaveAgentLoading.value = true;
|
||||
try {
|
||||
const res = await fetch(`/api/chat/oa/employees?keyword=${encodeURIComponent(leaveAgentKeyword.value)}&page=${leaveAgentPage.value}&page_size=20&agent_id=${agentId}`, {
|
||||
headers: getAuthHeaders()
|
||||
});
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
if (isLoadMore) {
|
||||
leaveAgentOptions.value.push(...data.items);
|
||||
} else {
|
||||
leaveAgentOptions.value = data.items;
|
||||
}
|
||||
leaveAgentHasMore.value = leaveAgentOptions.value.length < data.total;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to load OA employees', e);
|
||||
} finally {
|
||||
leaveAgentLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const handleAgentSearch = () => {
|
||||
fetchLeaveAgents(false);
|
||||
};
|
||||
|
||||
const loadMoreAgents = () => {
|
||||
if (!leaveAgentHasMore.value) return;
|
||||
leaveAgentPage.value += 1;
|
||||
fetchLeaveAgents(true);
|
||||
};
|
||||
|
||||
const loadAllAgents = async () => {
|
||||
if (!leaveAgentHasMore.value || leaveAgentLoading.value) return;
|
||||
leaveAgentLoading.value = true;
|
||||
try {
|
||||
const res = await fetch(`/api/chat/oa/employees?keyword=${encodeURIComponent(leaveAgentKeyword.value)}&page=1&page_size=100000&agent_id=${agentId}`, {
|
||||
headers: getAuthHeaders()
|
||||
});
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
leaveAgentOptions.value = data.items;
|
||||
leaveAgentHasMore.value = false;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to load all OA employees', e);
|
||||
} finally {
|
||||
leaveAgentLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const showLeaveAgentDialog = ref(false);
|
||||
const activeLeaveAgentFormId = ref<string | null>(null);
|
||||
|
||||
const formatDateTime = (date: Date) => {
|
||||
const year = date.getFullYear();
|
||||
@@ -594,12 +673,16 @@ const createLeaveFormData = (): LeaveRequestFormData => {
|
||||
applicantName: currentUserDisplayName.value,
|
||||
employeeId: currentUserEmployeeId.value,
|
||||
applyTime: formatDateTime(now),
|
||||
fillerName: currentUserDisplayName.value,
|
||||
agentUid: '',
|
||||
agentEmployeeId: '',
|
||||
agentName: '',
|
||||
leaveType: '',
|
||||
startTime,
|
||||
endTime,
|
||||
durationHours: calculateDurationHours(startTime, endTime),
|
||||
isOutOfOffice: false,
|
||||
isWorkInjury: false,
|
||||
isOutOfOffice: 1,
|
||||
isWorkInjury: 1,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -623,7 +706,38 @@ const isStrongLeaveIntent = (content: string) => {
|
||||
return /(我要请假|申请请假|发起请假|请假申请|我要休假|申请休假|我要请个假|想请假|帮我请假|代我请假|提交请假)/.test(normalized);
|
||||
};
|
||||
|
||||
const startLocalLeaveFlow = (content: string) => {
|
||||
const saveLocalMessageToBackend = async (msg: any, userQuery: string = '') => {
|
||||
try {
|
||||
const res = await fetch('/api/chat/messages/local', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...getAuthHeaders()
|
||||
},
|
||||
body: JSON.stringify({
|
||||
conversation_id: conversationId.value,
|
||||
type: msg.type,
|
||||
content: msg.content,
|
||||
payload: msg.payload,
|
||||
query: userQuery,
|
||||
agent_id: agentId
|
||||
})
|
||||
});
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
if (!conversationId.value && data.conversation_id) {
|
||||
conversationId.value = data.conversation_id;
|
||||
}
|
||||
if (data.chat_log_id) {
|
||||
msg.chat_log_id = data.chat_log_id;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to save local message', e);
|
||||
}
|
||||
};
|
||||
|
||||
const startLocalLeaveFlow = async (content: string) => {
|
||||
const formId = newLocalMessageId('leave-form');
|
||||
const payload: LeaveFormPayload = {
|
||||
formId,
|
||||
@@ -631,15 +745,24 @@ const startLocalLeaveFlow = (content: string) => {
|
||||
submitting: false,
|
||||
confirmationGenerated: false,
|
||||
};
|
||||
|
||||
messages.value.push({ role: 'user', content, type: 'text' });
|
||||
messages.value.push({
|
||||
role: 'assistant',
|
||||
type: 'leave-form',
|
||||
const formMsg = {
|
||||
role: 'assistant' as const,
|
||||
type: 'leave-form' as const,
|
||||
content: '已为你生成请假申请表,请直接在下方填写并提交。或登录OA系统直接申请',
|
||||
payload,
|
||||
local_id: formId,
|
||||
local_only: true,
|
||||
});
|
||||
};
|
||||
messages.value.push(formMsg);
|
||||
|
||||
await saveLocalMessageToBackend(formMsg, content);
|
||||
|
||||
// 发送完成后刷新历史记录,确保新会话出现
|
||||
if (history.value.length === 0 || !history.value.some(h => h.conversation_id === conversationId.value)) {
|
||||
await loadHistory();
|
||||
}
|
||||
};
|
||||
|
||||
const handleChatMarkdownClick = (event: MouseEvent) => {
|
||||
@@ -664,7 +787,66 @@ const getLeaveResultPayload = (msg: any): LeaveResultPayload | null => (
|
||||
msg?.type === 'leave-result' && msg?.payload ? msg.payload as LeaveResultPayload : null
|
||||
);
|
||||
|
||||
const findMessageIndexByLocalId = (localId: string) => messages.value.findIndex((msg: any) => msg?.local_id === localId);
|
||||
const findMessageIndexByLocalId = (localId: string) => messages.value.findIndex((msg: any) => msg?.local_id === localId || msg?.payload?.formId === localId);
|
||||
|
||||
const getLeaveAgentDisplayValue = (form: LeaveRequestFormData) => {
|
||||
if (!form.agentName) return '';
|
||||
const parts = [form.agentName];
|
||||
if (form.agentEmployeeId) parts.push(form.agentEmployeeId);
|
||||
return parts.join(' / ');
|
||||
};
|
||||
|
||||
const formatYesNoLabel = (value: 0 | 1 | null) => {
|
||||
if (value === 0) return '是';
|
||||
if (value === 1) return '否';
|
||||
return '未选择';
|
||||
};
|
||||
|
||||
const syncCurrentUserProfile = async () => {
|
||||
if (currentUser.value?.real_name?.trim()) return;
|
||||
try {
|
||||
const res = await fetch('/api/user/profile', { headers: getAuthHeaders() });
|
||||
if (!res.ok) return;
|
||||
const data = await res.json();
|
||||
currentUser.value = { ...currentUser.value, ...data };
|
||||
} catch (e) {
|
||||
console.error('Failed to load current user profile', e);
|
||||
}
|
||||
};
|
||||
|
||||
const openLeaveAgentDialog = (msg: any) => {
|
||||
const payload = getLeaveFormPayload(msg);
|
||||
if (!payload || payload.submitting || payload.confirmationGenerated) return;
|
||||
activeLeaveAgentFormId.value = payload.formId;
|
||||
showLeaveAgentDialog.value = true;
|
||||
|
||||
leaveAgentKeyword.value = '';
|
||||
fetchLeaveAgents(false);
|
||||
};
|
||||
|
||||
const closeLeaveAgentDialog = () => {
|
||||
showLeaveAgentDialog.value = false;
|
||||
activeLeaveAgentFormId.value = null;
|
||||
};
|
||||
|
||||
const selectLeaveAgent = (option: LeaveAgentOption) => {
|
||||
if (!activeLeaveAgentFormId.value) return;
|
||||
const sourceIndex = findMessageIndexByLocalId(activeLeaveAgentFormId.value);
|
||||
if (sourceIndex < 0) {
|
||||
closeLeaveAgentDialog();
|
||||
return;
|
||||
}
|
||||
const payload = getLeaveFormPayload(messages.value[sourceIndex]);
|
||||
if (!payload) {
|
||||
closeLeaveAgentDialog();
|
||||
return;
|
||||
}
|
||||
payload.form.agentUid = option.uid;
|
||||
payload.form.agentEmployeeId = option.employeeId;
|
||||
payload.form.agentName = option.name;
|
||||
closeLeaveAgentDialog();
|
||||
saveLocalMessageToBackend(messages.value[sourceIndex]);
|
||||
};
|
||||
|
||||
const browserPanelStyle = computed(() => {
|
||||
if (viewportWidth.value < 1024) return undefined;
|
||||
@@ -845,9 +1027,10 @@ const validateLeaveForm = (form: LeaveRequestFormData) => {
|
||||
if (!form.applicantName.trim()) return '申请人不能为空。';
|
||||
if (!form.employeeId.trim()) return '工号不能为空。';
|
||||
if (!form.leaveType.trim()) return '请选择假别。';
|
||||
if (!parseDateTime(form.startTime)) return '开始时间格式不正确。';
|
||||
if (!parseDateTime(form.endTime)) return '结束时间格式不正确。';
|
||||
if (calculateDurationHours(form.startTime, form.endTime) <= 0) return '结束时间必须晚于开始时间。';
|
||||
if (!form.agentUid.trim()) return '请选择代理人。';
|
||||
if (!parseDateTime(form.startTime)) return '请选择正确的开始时间。';
|
||||
if (!parseDateTime(form.endTime)) return '请选择正确的结束时间。';
|
||||
if (calculateDurationHours(form.startTime, form.endTime) <= 0) return '时长必须大于0小时,请检查开始时间和结束时间。';
|
||||
return '';
|
||||
};
|
||||
|
||||
@@ -868,9 +1051,9 @@ const submitLeaveForm = (msg: any) => {
|
||||
|
||||
payload.confirmationGenerated = true;
|
||||
const summary = JSON.parse(JSON.stringify(payload.form)) as LeaveRequestFormData;
|
||||
messages.value.push({
|
||||
role: 'assistant',
|
||||
type: 'leave-confirmation',
|
||||
const confirmMsg = {
|
||||
role: 'assistant' as const,
|
||||
type: 'leave-confirmation' as const,
|
||||
content: '请确认以下请假信息,确认无误后再提交到 OA。',
|
||||
payload: {
|
||||
formId: payload.formId,
|
||||
@@ -879,7 +1062,12 @@ const submitLeaveForm = (msg: any) => {
|
||||
},
|
||||
local_id: newLocalMessageId('leave-confirm'),
|
||||
local_only: true,
|
||||
});
|
||||
};
|
||||
messages.value.push(confirmMsg);
|
||||
|
||||
// 保存更新后的表单消息和新的确认消息
|
||||
saveLocalMessageToBackend(msg);
|
||||
saveLocalMessageToBackend(confirmMsg);
|
||||
};
|
||||
|
||||
const editLeaveConfirmation = (msg: any, index: number) => {
|
||||
@@ -890,8 +1078,14 @@ const editLeaveConfirmation = (msg: any, index: number) => {
|
||||
const sourcePayload = getLeaveFormPayload(messages.value[sourceIndex]);
|
||||
if (sourcePayload) {
|
||||
sourcePayload.confirmationGenerated = false;
|
||||
saveLocalMessageToBackend(messages.value[sourceIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
// 从后端删除对应的确认消息,或者不删除直接隐藏?
|
||||
// 暂时在前端移除,后端不需要立刻删除(如果没有删除接口),它在会话记录里可能残留。
|
||||
// 但是我们之前有 /api/chat/messages/local 吗?如果需要,也可以调一个删除接口。
|
||||
// 为了简单,我们只在前端切除。
|
||||
messages.value.splice(index, 1);
|
||||
};
|
||||
|
||||
@@ -909,29 +1103,64 @@ const confirmLeaveSubmission = async (msg: any) => {
|
||||
}
|
||||
}
|
||||
|
||||
await new Promise((resolve) => window.setTimeout(resolve, 900));
|
||||
try {
|
||||
const res = await fetch('/api/user/leave-workflow/submit', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...getAuthHeaders(),
|
||||
},
|
||||
body: JSON.stringify(payload.form),
|
||||
});
|
||||
const data = await res.json().catch(() => ({}));
|
||||
if (!res.ok) {
|
||||
throw new Error(data?.error || 'OA 请假提交失败,请稍后重试。');
|
||||
}
|
||||
|
||||
const referenceNo = `OA-${Date.now().toString().slice(-8)}`;
|
||||
messages.value.push({
|
||||
role: 'assistant',
|
||||
type: 'leave-result',
|
||||
content: `请假单已生成,具体单据请到 ${LEAVE_RESULT_QUERY_URL} 查询。\n\n当前为前端演示提交流程,真实 OA 对接开发中。`,
|
||||
payload: {
|
||||
formId: payload.formId,
|
||||
success: true,
|
||||
referenceNo,
|
||||
submittedAt: formatDateTime(new Date()),
|
||||
},
|
||||
local_id: newLocalMessageId('leave-result'),
|
||||
local_only: true,
|
||||
});
|
||||
|
||||
payload.submitting = false;
|
||||
payload.confirmed = true;
|
||||
if (sourceIndex >= 0) {
|
||||
const sourcePayload = getLeaveFormPayload(messages.value[sourceIndex]);
|
||||
if (sourcePayload) {
|
||||
sourcePayload.submitting = false;
|
||||
const resultMsg = {
|
||||
role: 'assistant' as const,
|
||||
type: 'leave-result' as const,
|
||||
content: `请假单已提交到 OA,具体单据请到 ${LEAVE_RESULT_QUERY_URL} 查询。`,
|
||||
payload: {
|
||||
formId: payload.formId,
|
||||
success: true,
|
||||
referenceNo: data.request_id || '-',
|
||||
submittedAt: data.submitted_at || formatDateTime(new Date()),
|
||||
requestName: data.request_name || '',
|
||||
},
|
||||
local_id: newLocalMessageId('leave-result'),
|
||||
local_only: true,
|
||||
};
|
||||
messages.value.push(resultMsg);
|
||||
payload.confirmed = true;
|
||||
saveLocalMessageToBackend(msg);
|
||||
saveLocalMessageToBackend(resultMsg);
|
||||
} catch (error: any) {
|
||||
const errorMessage = error?.message || 'OA 请假提交失败,请稍后重试。';
|
||||
showMessageDialog('error', errorMessage);
|
||||
const resultMsg = {
|
||||
role: 'assistant' as const,
|
||||
type: 'leave-result' as const,
|
||||
content: `请假单提交失败:${errorMessage}`,
|
||||
payload: {
|
||||
formId: payload.formId,
|
||||
success: false,
|
||||
referenceNo: '-',
|
||||
submittedAt: formatDateTime(new Date()),
|
||||
errorMessage,
|
||||
},
|
||||
local_id: newLocalMessageId('leave-result'),
|
||||
local_only: true,
|
||||
};
|
||||
messages.value.push(resultMsg);
|
||||
saveLocalMessageToBackend(resultMsg);
|
||||
} finally {
|
||||
payload.submitting = false;
|
||||
if (sourceIndex >= 0) {
|
||||
const sourcePayload = getLeaveFormPayload(messages.value[sourceIndex]);
|
||||
if (sourcePayload) {
|
||||
sourcePayload.submitting = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1048,6 +1277,7 @@ onMounted(async () => {
|
||||
document.addEventListener('mousedown', handleDocumentPointerDown);
|
||||
document.addEventListener('touchstart', handleDocumentPointerDown, { passive: true });
|
||||
window.addEventListener('resize', syncViewportWidth);
|
||||
await syncCurrentUserProfile();
|
||||
await loadAgent();
|
||||
|
||||
await loadHistory();
|
||||
@@ -1341,6 +1571,38 @@ const showChatRating = ref(false);
|
||||
<option v-for="leaveType in LEAVE_TYPES" :key="leaveType.value" :value="leaveType.value">{{ leaveType.label }}</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="space-y-1.5">
|
||||
<span class="text-xs font-semibold text-slate-500 dark:text-slate-400">填单人</span>
|
||||
<input
|
||||
v-model="getLeaveFormPayload(msg)!.form.fillerName"
|
||||
type="text"
|
||||
class="w-full rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-sm text-slate-500 outline-none dark:border-slate-700 dark:bg-slate-950/60 dark:text-slate-400"
|
||||
disabled
|
||||
/>
|
||||
</label>
|
||||
<label class="space-y-1.5">
|
||||
<span class="text-xs font-semibold text-slate-500 dark:text-slate-400">代理人</span>
|
||||
<div class="relative">
|
||||
<input
|
||||
:value="getLeaveAgentDisplayValue(getLeaveFormPayload(msg)!.form)"
|
||||
type="text"
|
||||
placeholder="请选择代理人"
|
||||
readonly
|
||||
class="w-full rounded-xl border border-slate-200 bg-white px-3 py-2 pr-11 text-sm text-slate-700 outline-none transition focus:border-blue-400 dark:border-slate-700 dark:bg-slate-950 dark:text-slate-100"
|
||||
:disabled="getLeaveFormPayload(msg)!.submitting || getLeaveFormPayload(msg)!.confirmationGenerated"
|
||||
@click="openLeaveAgentDialog(msg)"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
class="absolute inset-y-0 right-0 flex w-11 items-center justify-center text-slate-400 transition hover:text-brand-600 disabled:cursor-not-allowed disabled:opacity-50"
|
||||
:disabled="getLeaveFormPayload(msg)!.submitting || getLeaveFormPayload(msg)!.confirmationGenerated"
|
||||
@click="openLeaveAgentDialog(msg)"
|
||||
title="选择代理人"
|
||||
>
|
||||
<Search class="h-4 w-4" />
|
||||
</button>
|
||||
</div>
|
||||
</label>
|
||||
<label class="space-y-1.5">
|
||||
<span class="text-xs font-semibold text-slate-500 dark:text-slate-400">开始时间</span>
|
||||
<input
|
||||
@@ -1377,8 +1639,8 @@ const showChatRating = ref(false);
|
||||
class="w-full rounded-xl border border-slate-200 px-3 py-2 text-sm text-slate-700 outline-none transition focus:border-blue-400 dark:border-slate-700 dark:bg-slate-950 dark:text-slate-100"
|
||||
:disabled="getLeaveFormPayload(msg)!.submitting || getLeaveFormPayload(msg)!.confirmationGenerated"
|
||||
>
|
||||
<option :value="false">否</option>
|
||||
<option :value="true">是</option>
|
||||
<option :value="1">否</option>
|
||||
<option :value="0">是</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="space-y-1.5 md:col-span-2">
|
||||
@@ -1388,8 +1650,8 @@ const showChatRating = ref(false);
|
||||
class="w-full rounded-xl border border-slate-200 px-3 py-2 text-sm text-slate-700 outline-none transition focus:border-blue-400 dark:border-slate-700 dark:bg-slate-950 dark:text-slate-100"
|
||||
:disabled="getLeaveFormPayload(msg)!.submitting || getLeaveFormPayload(msg)!.confirmationGenerated"
|
||||
>
|
||||
<option :value="false">否</option>
|
||||
<option :value="true">是</option>
|
||||
<option :value="1">否</option>
|
||||
<option :value="0">是</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
@@ -1412,12 +1674,14 @@ const showChatRating = ref(false);
|
||||
<div class="grid gap-3 text-sm md:grid-cols-2">
|
||||
<div><span class="text-slate-500 dark:text-slate-400">申请人:</span>{{ getLeaveConfirmationPayload(msg)!.form.applicantName }}({{ getLeaveConfirmationPayload(msg)!.form.employeeId }})</div>
|
||||
<div><span class="text-slate-500 dark:text-slate-400">申请时间:</span>{{ getLeaveConfirmationPayload(msg)!.form.applyTime.replace('T', ' ') }}</div>
|
||||
<div><span class="text-slate-500 dark:text-slate-400">填单人:</span>{{ getLeaveConfirmationPayload(msg)!.form.fillerName || '暂无数据' }}</div>
|
||||
<div><span class="text-slate-500 dark:text-slate-400">代理人:</span>{{ getLeaveAgentDisplayValue(getLeaveConfirmationPayload(msg)!.form) || '未选择' }}</div>
|
||||
<div><span class="text-slate-500 dark:text-slate-400">假别:</span>{{ getLeaveTypeLabel(getLeaveConfirmationPayload(msg)!.form.leaveType) }}</div>
|
||||
<div><span class="text-slate-500 dark:text-slate-400">时长:</span>{{ formatDurationLabel(getLeaveConfirmationPayload(msg)!.form.durationHours) }}</div>
|
||||
<div><span class="text-slate-500 dark:text-slate-400">开始时间:</span>{{ getLeaveConfirmationPayload(msg)!.form.startTime.replace('T', ' ') }}</div>
|
||||
<div><span class="text-slate-500 dark:text-slate-400">结束时间:</span>{{ getLeaveConfirmationPayload(msg)!.form.endTime.replace('T', ' ') }}</div>
|
||||
<div><span class="text-slate-500 dark:text-slate-400">是否外出:</span>{{ getLeaveConfirmationPayload(msg)!.form.isOutOfOffice ? '是' : '否' }}</div>
|
||||
<div><span class="text-slate-500 dark:text-slate-400">是否为工伤:</span>{{ getLeaveConfirmationPayload(msg)!.form.isWorkInjury ? '是' : '否' }}</div>
|
||||
<div><span class="text-slate-500 dark:text-slate-400">是否外出:</span>{{ formatYesNoLabel(getLeaveConfirmationPayload(msg)!.form.isOutOfOffice) }}</div>
|
||||
<div><span class="text-slate-500 dark:text-slate-400">是否为工伤:</span>{{ formatYesNoLabel(getLeaveConfirmationPayload(msg)!.form.isWorkInjury) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-end gap-3">
|
||||
@@ -1770,9 +2034,84 @@ const showChatRating = ref(false);
|
||||
showGeneralFeedbackDialog = false;
|
||||
}"
|
||||
/>
|
||||
<div
|
||||
v-if="showLeaveAgentDialog"
|
||||
class="fixed inset-0 z-[100] flex items-center justify-center bg-black/40 backdrop-blur-sm p-4"
|
||||
@click.self="closeLeaveAgentDialog"
|
||||
>
|
||||
<div class="flex w-full max-w-2xl max-h-[80vh] flex-col rounded-2xl bg-white p-6 shadow-2xl dark:bg-slate-900">
|
||||
<div class="mb-4 flex items-center justify-between">
|
||||
<div>
|
||||
<h3 class="text-lg font-bold text-slate-800 dark:text-slate-100">选择代理人</h3>
|
||||
<p class="mt-1 text-sm text-slate-500 dark:text-slate-400">已接入 OA 数据库视图查询。</p>
|
||||
</div>
|
||||
<button @click="closeLeaveAgentDialog" class="text-slate-400 hover:text-slate-600 dark:hover:text-slate-200">
|
||||
<X class="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="mb-4 relative shrink-0">
|
||||
<input
|
||||
v-model="leaveAgentKeyword"
|
||||
@keydown.enter="handleAgentSearch"
|
||||
type="text"
|
||||
placeholder="输入姓名或工号搜索,按回车键查询"
|
||||
class="w-full rounded-xl border border-slate-200 bg-slate-50 px-4 py-2.5 pr-10 text-sm outline-none transition focus:border-brand-400 dark:border-slate-700 dark:bg-slate-950 dark:text-slate-100"
|
||||
/>
|
||||
<button @click="handleAgentSearch" class="absolute inset-y-0 right-0 flex w-10 items-center justify-center text-slate-400 hover:text-brand-600">
|
||||
<Search class="h-4 w-4" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="flex-1 space-y-3 overflow-y-auto pr-2 scrollbar-thin">
|
||||
<div v-if="leaveAgentLoading && leaveAgentPage === 1" class="flex justify-center py-8">
|
||||
<Loader2 class="h-6 w-6 animate-spin text-brand-500" />
|
||||
</div>
|
||||
<div v-else-if="leaveAgentOptions.length === 0" class="py-8 text-center text-sm text-slate-400">
|
||||
暂无数据
|
||||
</div>
|
||||
<template v-else>
|
||||
<button
|
||||
v-for="option in leaveAgentOptions"
|
||||
:key="option.uid"
|
||||
type="button"
|
||||
class="flex w-full items-center justify-between rounded-2xl border border-slate-200 px-4 py-4 text-left transition hover:border-brand-300 hover:bg-brand-50/50 dark:border-slate-700 dark:hover:border-brand-500/40 dark:hover:bg-brand-500/10"
|
||||
@click="selectLeaveAgent(option)"
|
||||
>
|
||||
<div class="space-y-1">
|
||||
<div class="text-sm font-semibold text-slate-800 dark:text-slate-100">{{ option.name }}</div>
|
||||
<div class="text-xs text-slate-500 dark:text-slate-400">UID:{{ option.uid }}</div>
|
||||
</div>
|
||||
<div class="text-right text-xs text-slate-500 dark:text-slate-400">
|
||||
<div>工号:{{ option.employeeId }}</div>
|
||||
<div>姓名:{{ option.name }}</div>
|
||||
</div>
|
||||
</button>
|
||||
|
||||
<div v-if="leaveAgentHasMore" class="flex items-center justify-center space-x-6 py-4">
|
||||
<button
|
||||
@click="loadAllAgents"
|
||||
:disabled="leaveAgentLoading"
|
||||
class="text-xs text-slate-500 hover:text-slate-700 disabled:opacity-50 dark:text-slate-400 dark:hover:text-slate-300"
|
||||
>
|
||||
加载全部
|
||||
</button>
|
||||
<button
|
||||
@click="loadMoreAgents"
|
||||
:disabled="leaveAgentLoading"
|
||||
class="text-xs text-brand-600 hover:text-brand-700 disabled:opacity-50"
|
||||
>
|
||||
{{ leaveAgentLoading ? '加载中...' : '加载更多' }}
|
||||
</button>
|
||||
</div>
|
||||
<div v-else class="py-4 text-center text-xs text-slate-400">没有更多数据了</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
:deep(.chat-markdown details) {
|
||||
margin-top: 1rem;
|
||||
|
||||
Reference in new issue
Block a user