通知公告优化

This commit is contained in:
李鹏宇
2026-05-29 17:16:00 +08:00
parent 0198747c96
commit f429b5f75f
2 changed files with 21 additions and 5 deletions
+11 -5
View File
@@ -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:
@@ -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 = '<i class="fa fa-spinner fa-spin"></i> 正在处理,请稍候...';
}
}, 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 += `