From ca415cceef9343bf698fb3d50fd002cb97347b9d Mon Sep 17 00:00:00 2001 From: lkddi Date: Tue, 17 Mar 2026 21:19:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AC=A2=E8=BF=8E=E8=AF=AD=EF=BC=9A=E5=8A=A0?= =?UTF-8?q?=E9=83=A8=E9=97=A8=E8=81=8C=E5=8A=A1=E5=A7=93=E5=90=8D=E5=89=8D?= =?UTF-8?q?=E7=BC=80=EF=BC=8C=E7=82=B9=E9=80=89=E5=90=8E=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8F=91=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/views/chat/frame.blade.php | 6 ++++++ resources/views/chat/partials/scripts.blade.php | 12 +++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/resources/views/chat/frame.blade.php b/resources/views/chat/frame.blade.php index 9737a45..612b253 100644 --- a/resources/views/chat/frame.blade.php +++ b/resources/views/chat/frame.blade.php @@ -47,6 +47,12 @@ chatBotClearUrl: "{{ route('chatbot.clear') }}", chatBotEnabled: {{ \App\Models\Sysparam::getValue('chatbot_enabled', '0') === '1' ? 'true' : 'false' }}, hasPosition: {{ Auth::user()->activePosition || Auth::user()->user_level >= $superLevel ? 'true' : 'false' }}, + @php + $activePos = Auth::user()->activePosition; + $deptName = $activePos?->position?->department?->name ?? ''; + $posName = $activePos?->position?->name ?? ''; + @endphp + welcomePrefix: "{{ $deptName ? "{$deptName} {$posName} {$user->username}" : $user->username }}", myMaxReward: @php if (Auth::id() === 1) { // 超级管理员(id=1)无需职务,直接拥有不限量奖励权 diff --git a/resources/views/chat/partials/scripts.blade.php b/resources/views/chat/partials/scripts.blade.php index 7063228..b59035c 100644 --- a/resources/views/chat/partials/scripts.blade.php +++ b/resources/views/chat/partials/scripts.blade.php @@ -130,23 +130,29 @@ } /** - * 将选中的欢迎语模板填入输入框,{name} 替换为当前选中的聊天对象 + * 将选中的欢迎语模板填入输入框,{name} 替换为当前选中的聊天对象, + * 并在前面加上「部门 职务 姓名:」前缀,然后自动发送 * * @param {string} tpl 欢迎语模板,含 {name} 占位符 */ function sendWelcomeTpl(tpl) { const toUser = document.getElementById('to_user')?.value || '大家'; const name = toUser === '大家' ? '大家' : toUser; - const msg = tpl.replace(/\{name\}/g, name); + const prefix = window.chatContext?.welcomePrefix || window.chatContext?.username || ''; + const body = tpl.replace(/\{name\}/g, name); + // 拼接格式:「部门 职务 姓名:欢迎语」 + const msg = `${prefix}:${body}`; const input = document.getElementById('content'); if (input) { input.value = msg; - input.focus(); } const menu = document.getElementById('welcome-menu'); if (menu) { menu.style.display = 'none'; } + + // 自动触发发送 + sendMessage(null); } // 点击页面任意位置,关闭欢迎语浮层