chat聊天OA请假优化
This commit is contained in:
1 parent
3b31867319
commit
05abffc5f0
5 files changed
+67
-25
No files matched your search
@@ -666,11 +666,38 @@ const formatDurationLabel = (hours: number) => {
|
||||
return `${hours} 小时`;
|
||||
};
|
||||
|
||||
const createLeaveFormData = (): LeaveRequestFormData => {
|
||||
const extractLeaveTypeFromIntent = (content: string) => {
|
||||
if (!content) return '';
|
||||
const map: Record<string, string> = {
|
||||
'事假': '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;
|
||||
}
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
const createLeaveFormData = (content?: string): 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 || '');
|
||||
return {
|
||||
applicantName: currentUserDisplayName.value,
|
||||
employeeId: currentUserEmployeeId.value,
|
||||
@@ -680,7 +707,7 @@ const createLeaveFormData = (): LeaveRequestFormData => {
|
||||
agentUid: '',
|
||||
agentEmployeeId: '',
|
||||
agentName: '',
|
||||
leaveType: '',
|
||||
leaveType: initialLeaveType,
|
||||
startTime,
|
||||
endTime,
|
||||
durationHours: calculateDurationHours(startTime, endTime),
|
||||
@@ -705,8 +732,8 @@ const isStrongLeaveIntent = (content: string) => {
|
||||
// 弱意图(咨询流程/步骤)应走正常问答,不触发表单分流。
|
||||
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 = '') => {
|
||||
@@ -744,7 +771,7 @@ const startLocalLeaveFlow = async (content: string) => {
|
||||
const formId = newLocalMessageId('leave-form');
|
||||
const payload: LeaveFormPayload = {
|
||||
formId,
|
||||
form: createLeaveFormData(),
|
||||
form: createLeaveFormData(content),
|
||||
submitting: false,
|
||||
confirmationGenerated: false,
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user