欢迎语:加部门职务姓名前缀,点选后自动发送
This commit is contained in:
@@ -47,6 +47,12 @@
|
|||||||
chatBotClearUrl: "{{ route('chatbot.clear') }}",
|
chatBotClearUrl: "{{ route('chatbot.clear') }}",
|
||||||
chatBotEnabled: {{ \App\Models\Sysparam::getValue('chatbot_enabled', '0') === '1' ? 'true' : 'false' }},
|
chatBotEnabled: {{ \App\Models\Sysparam::getValue('chatbot_enabled', '0') === '1' ? 'true' : 'false' }},
|
||||||
hasPosition: {{ Auth::user()->activePosition || Auth::user()->user_level >= $superLevel ? '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
|
myMaxReward: @php
|
||||||
if (Auth::id() === 1) {
|
if (Auth::id() === 1) {
|
||||||
// 超级管理员(id=1)无需职务,直接拥有不限量奖励权
|
// 超级管理员(id=1)无需职务,直接拥有不限量奖励权
|
||||||
|
|||||||
@@ -130,23 +130,29 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将选中的欢迎语模板填入输入框,{name} 替换为当前选中的聊天对象
|
* 将选中的欢迎语模板填入输入框,{name} 替换为当前选中的聊天对象,
|
||||||
|
* 并在前面加上「部门 职务 姓名:」前缀,然后自动发送
|
||||||
*
|
*
|
||||||
* @param {string} tpl 欢迎语模板,含 {name} 占位符
|
* @param {string} tpl 欢迎语模板,含 {name} 占位符
|
||||||
*/
|
*/
|
||||||
function sendWelcomeTpl(tpl) {
|
function sendWelcomeTpl(tpl) {
|
||||||
const toUser = document.getElementById('to_user')?.value || '大家';
|
const toUser = document.getElementById('to_user')?.value || '大家';
|
||||||
const name = toUser === '大家' ? '大家' : toUser;
|
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');
|
const input = document.getElementById('content');
|
||||||
if (input) {
|
if (input) {
|
||||||
input.value = msg;
|
input.value = msg;
|
||||||
input.focus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const menu = document.getElementById('welcome-menu');
|
const menu = document.getElementById('welcome-menu');
|
||||||
if (menu) { menu.style.display = 'none'; }
|
if (menu) { menu.style.display = 'none'; }
|
||||||
|
|
||||||
|
// 自动触发发送
|
||||||
|
sendMessage(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 点击页面任意位置,关闭欢迎语浮层
|
// 点击页面任意位置,关闭欢迎语浮层
|
||||||
|
|||||||
Reference in New Issue
Block a user