From f429b5f75f663fc656dfc4eced24ae091928db26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Fri, 29 May 2026 17:16:00 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E7=9F=A5=E5=85=AC=E5=91=8A=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuthon_ai_agent/models/ai_agent.py | 16 +++++++++++----- yuthon_ai_agent/static/src/js/ai_floating.js | 10 ++++++++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/yuthon_ai_agent/models/ai_agent.py b/yuthon_ai_agent/models/ai_agent.py index 869dce283..f69570c61 100644 --- a/yuthon_ai_agent/models/ai_agent.py +++ b/yuthon_ai_agent/models/ai_agent.py @@ -493,16 +493,22 @@ class AiConversation(models.Model): ('user_id', '=', self.env.uid) ], limit=1) if employee and employee.wecom_userid: - self.sudo().env["wecom.apps"].sync_send_message_textcard( - category='oa', + push_result = self.sudo().env["wecom.apps"].sync_send_message_textcard( + category='notice', touser=employee.wecom_userid, title=f"📊 {report_name}", description=f"数据来源:{model_name}\n生成时间:{fields.Datetime.now().strftime('%Y-%m-%d %H:%M')}\n点击下方按钮查看详细报表", url=url, btntxt="查看报表", ) - result['wecom_sent'] = True - _logger.info(f"报表 {report.id} 已推送到用户 {employee.name} 的企微") + if push_result and push_result[0]: + result['wecom_sent'] = True + _logger.info(f"报表 {report.id} 已推送到用户 {employee.name} 的企微") + else: + err_msg = push_result[1] if push_result else '推送返回为空' + result['wecom_sent'] = False + result['wecom_msg'] = f'企微推送失败: {err_msg}' + _logger.warning(f"报表 {report.id} 企微推送失败: {err_msg}") else: result['wecom_sent'] = False result['wecom_msg'] = '当前用户未绑定企微账号,无法推送' @@ -510,7 +516,7 @@ class AiConversation(models.Model): except Exception as we: _logger.exception(f"推送报表到企微失败: {we}") result['wecom_sent'] = False - result['wecom_msg'] = f'企微推送失败: {we}' + result['wecom_msg'] = f'企微推送异常: {we}' return result except Exception as e: diff --git a/yuthon_ai_agent/static/src/js/ai_floating.js b/yuthon_ai_agent/static/src/js/ai_floating.js index eddb18fd6..4ab4715ee 100644 --- a/yuthon_ai_agent/static/src/js/ai_floating.js +++ b/yuthon_ai_agent/static/src/js/ai_floating.js @@ -228,8 +228,17 @@ async function sendMsg() { msgsEl.scrollTop = msgsEl.scrollHeight; } + // 5秒后如果还在加载,提示用户 + const loadingTimer = setTimeout(() => { + const el = document.getElementById("yuthon_loading"); + if (el) { + el.innerHTML = ' 正在处理,请稍候...'; + } + }, 5000); + try { const res = await rpcCall("/ai/chat/send", { conversation_id: id, message: text }); + clearTimeout(loadingTimer); const content = res.error || res.content || "无响应"; document.getElementById("yuthon_loading")?.remove(); if (msgsEl) { @@ -247,6 +256,7 @@ async function sendMsg() { if (titleEl) titleEl.textContent = convName; } } catch (e) { + clearTimeout(loadingTimer); document.getElementById("yuthon_loading")?.remove(); if (msgsEl) { msgsEl.innerHTML += `