Merge branch 'dev' into test

This commit is contained in:
sophie committed 2026-09-18 14:09:51 +08:00
commit fe8659c62e
16 files changed
+285 -93

No files matched your search

+6 -4
View File
@@ -553,10 +553,12 @@ class Config:
WECOM_NOTIFY_ENABLED = os.getenv('WECOM_NOTIFY_ENABLED', 'true').lower() == 'true'
WECOM_NOTIFY_BASE_URL = os.getenv('WECOM_NOTIFY_BASE_URL')
WECOM_NOTIFY_EVENTS = os.getenv('WECOM_NOTIFY_EVENTS', 'task_completed,schedule_completed,password_reset,contract_payment_warning,training_lean_overdue,training_lean_task_initial,training_lean_targeted_reminder,training_overseas_thailand_guidelines')
# 精益培训企微提醒卡片跳转的员工培训聊天页 agent id(前端路由 /chat/<id>,默认 27=员工培训)。
# 注意:默认值必须指向 content_profile=training 的培训 agent;历史默认 16 实为「通用入口」,
# 会导致卡片落地非培训 agent、前端精益页签深链不消费([FIX] 2026-09-11)。
WECOM_LEAN_TRAINING_JUMP_AGENT_ID = int(os.getenv('WECOM_LEAN_TRAINING_JUMP_AGENT_ID', '27'))
# 精益培训企微提醒卡片跳转的员工培训聊天页 agent id(前端路由 /chat/<id>)。
# 缺省 0 = 不显式指定,由后端按 handler_config.content_profile='training' 动态解析各环境的培训 Agent
# (测试/正式环境 Agent ID 不同,动态解析保证卡片均可定位「员工培训-精益管理」);
# 仅当某环境需要固定指向特定 Agent 时才配置此项。历史默认 27 曾在部分环境错指「通用入口」导致深链失效
# ([FIX] 2026-09-18 改为动态解析,27 仅保留为解析失败时的兼容兜底)。
WECOM_LEAN_TRAINING_JUMP_AGENT_ID = int(os.getenv('WECOM_LEAN_TRAINING_JUMP_AGENT_ID', '0'))
WECOM_FEEDBACK_NOTIFY_ENABLED = os.getenv('WECOM_FEEDBACK_NOTIFY_ENABLED', 'true').lower() == 'true'
WECOM_FEEDBACK_NOTIFY_BASE_URL = os.getenv('WECOM_FEEDBACK_NOTIFY_BASE_URL')
WECOM_FEEDBACK_BOT_WEBHOOK = os.getenv('WECOM_FEEDBACK_BOT_WEBHOOK')
@@ -11,13 +11,15 @@ from __future__ import annotations
import uuid
from datetime import datetime, timezone
from flask import current_app
from sqlalchemy import select
from sqlalchemy.exc import IntegrityError
from app.extensions import db
from app.models import LeanTrainingCompletion, LeanTrainingReminder, LeanTrainingWeeklyTask, User
from app.services.lean_training_service import target_user_ids_for_task
from app.services.lean_training_service import (
resolve_lean_training_jump_agent_id,
target_user_ids_for_task,
)
from app.services.wecom_notify import send_wecom_event_message
from app.services.schedule.timezone_util import resolve_schedule_tzinfo, utc_now_naive
@@ -52,10 +54,11 @@ def _send_reminder(
db.session.flush()
except IntegrityError:
return "skipped"
# [STEP] 企微卡片跳转地址:指向员工培训聊天页(默认 agent 27,content_profile=training),
# [STEP] 企微卡片跳转地址:动态解析各环境「员工培训」聊天页(content_profile=training),
# 由前端 TrainingWorkspacePanel 消费 training_type=lean_management 自动展开精益页签;
# agent id 走配置(app_settings/env 覆盖),便于多环境调整,避免硬编码。
jump_agent_id = int(current_app.config.get("WECOM_LEAN_TRAINING_JUMP_AGENT_ID") or 27)
# 支持 WECOM_LEAN_TRAINING_JUMP_AGENT_ID 显式覆盖,动态解析失败回退历史默认 27([FIX] 2026-09-18
# 历史固定默认 27 在部分环境实为其它 Agent,导致卡片落地后无法定位精益模块)。
jump_agent_id = resolve_lean_training_jump_agent_id()
result = send_wecom_event_message(
event_type=event_type,
user=recipient,
@@ -19,6 +19,7 @@ from sqlalchemy import func, or_, select
from app.core.errors import NotFoundError, ValidationError
from app.extensions import db
from app.models import (
Agent,
LeanTrainingCompletion,
LeanTrainingWeeklyTask,
TrainingConfig,
@@ -30,6 +31,36 @@ from app.services.schedule.timezone_util import resolve_schedule_tzinfo, to_utc_
LEAN_TRAINING_TYPE = "lean_management"
MIN_SUMMARY_LENGTH = 50
# 精益提醒/推送企微卡片跳转 Agent 的历史默认值;仅当动态解析失败(系统内无培训 Agent)时兜底
LEGACY_LEAN_JUMP_AGENT_ID = 27
def resolve_lean_training_jump_agent_id() -> int:
"""
解析精益提醒/推送企微卡片落地聊天页的「员工培训」Agent ID。
用途:卡片须跳 /chat/<培训agent>?training_type=lean_management,由前端 TrainingWorkspacePanel
自动展开精益页签;前端仅在目标 Agent 是培训 Agent 时才消费深链参数,
因此 Agent ID 指错环境会导致卡片落地后无法定位精益模块。
核心逻辑:各环境培训 Agent ID 不同,禁止依赖固定值——优先取 WECOM_LEAN_TRAINING_JUMP_AGENT_ID
显式配置覆盖,否则在启用 Agent 中按 handler_config.content_profile='training' 动态解析;
均不可用时回退历史默认 27 保持兼容。
Returns:
培训 Agent ID。
"""
from flask import current_app
override = int(current_app.config.get("WECOM_LEAN_TRAINING_JUMP_AGENT_ID") or 0)
if override > 0:
return override
agents = db.session.execute(
select(Agent).where(Agent.is_active.is_(True)).order_by(Agent.sort_order, Agent.id)
).scalars().all()
for agent in agents:
handler_config = agent.handler_config if isinstance(agent.handler_config, dict) else {}
if str(handler_config.get("content_profile") or "").strip() == "training":
return int(agent.id)
return LEGACY_LEAN_JUMP_AGENT_ID
def _format_dashboard_datetime(value: str | None) -> str:
@@ -84,7 +84,7 @@
- 所有提醒经 `LeanTrainingReminder`(`weekly_task_id + recipient_user_id + event_key` 唯一约束)幂等,同批重推/补发不会重复打扰。
- **例外**:定向提醒由 HR 手动触发,每次点击都应真实触达员工,因此 `event_key` 每次唯一化(`targeted-<uuid>`),不参与幂等去重;其余事件键保持稳定,保证重推/补发不重复打扰。
- 全部提醒卡片消息发送至企微「和信AI智能工作台」应用会话,点击卡片跳转员工培训聊天页并自动展开精益管理页签:跳转路径 `/chat/<agentId>?training_type=lean_management&weekly_task_id=<id>`,agent id 由配置 `WECOM_LEAN_TRAINING_JUMP_AGENT_ID`(默认 16)控制;前端由 [TrainingWorkspacePanel.vue](../../../frontend/src/features/chat/components/TrainingWorkspacePanel.vue) 消费 query 参数自动展开(管理员进管理端精益看板、学员进学员侧精益学习页)。
- 全部提醒卡片消息发送至企微「和信AI智能工作台」应用会话,点击卡片跳转员工培训聊天页并自动展开精益管理页签:跳转路径 `/chat/<agentId>?training_type=lean_management&weekly_task_id=<id>`,agent id **按环境动态解析**:优先取配置 `WECOM_LEAN_TRAINING_JUMP_AGENT_ID` 显式覆盖,否则按启用 Agent 中 `handler_config.content_profile='training'` 自动定位「员工培训」(测试/正式环境 Agent ID 不同,动态解析保证均可直达精益页签;解析失败回退历史默认 27);前端由 [TrainingWorkspacePanel.vue](../../../frontend/src/features/chat/components/TrainingWorkspacePanel.vue) 消费 query 参数自动展开(管理员进管理端精益看板、学员进学员侧精益学习页)。
- "已延期"判定:当前时间 > 任务 `due_at` 且该用户未提交(`LeanTrainingCompletion.status != 'completed'`)的在职受训人员,与管理端看板"已延期"状态口径一致。
实现:`_send_reminder()` / `notify_overdue_users_after_push()`([lean_training_reminder_service.py](../../../backend/app/services/lean_training_reminder_service.py))。
+1 -1
View File
@@ -68,7 +68,7 @@
| 管理端培训模式配置 | 已实现 | Agent 管理表单支持显式开启培训工作区;平台应用说明页支持上传并标记“员工培训视频 / 员工培训试题 PDF”,并可直接把试题 PDF 解析导入题库表单;扫描件 PDF 在 OCR 依赖齐备时也可回退识别 |
| 首页培训推荐入口 | 前端已实现 | 当 Agent 开启培训模式后,工作台首页会在应用列表上方展示培训强入口卡片 |
| 培训记录后端落库 | 已实现 | 已新增培训记录模型、迁移与用户/管理端 API,考试进度、结果、统计与导出均可走后端数据源 |
| 培训配置管理 | 已实现 | `TrainingConfigResource` 增加 `training_level`;管理端按公司级、部门级、班组级卡片独立增删资料;知识库候选仅允许“员工培训”分组内未删除文档的当前版本;员工端按 `safetyStage` 动态展示当前级别资料 |
| 培训配置管理 | 已实现 | `TrainingConfigResource` 增加 `training_level`;管理端按公司级、部门级、班组级卡片独立增删资料;知识库候选仅允许“员工培训”分组内未删除文档的当前版本;员工端按 `safetyStage` 动态展示当前级别资料;培训资料区直接上传的视频列表超过 3 条时默认收起(仅展示前 3 条),底部可展开查看全部/收起,切换培训类型恢复收起、上传新视频后自动展开 |
| 精益培训对象化任务与提醒 | 已实现 | HR 按系统角色或指定用户(并集)发布精益周任务;任务、看板和提醒只处理冻结对象,首次发布与定向催学均复用企微提醒审计幂等去重。学员端“精益管理”按时间树展示全部已发布任务(按任务周期倒序、最新在上),每期任务带状态徽章(进行中/已延期/已完成,由服务端按截止时间与完成记录判定)、任务周期区间与视频缩略图(点击弹窗播放,须播放到结尾才判定观看完成并由服务端持久化,提前关闭或拖拽跳过不计);提交学习感悟前校验:未观看全部已推送视频或感悟字数不达标时拦截并友好提示;任务"已完成"仅在感悟提交后落定。 |
| 精益周任务规则化推送 | 已实现 | 任务周(周一)与截止时间默认按当周计算且**支持修改**(可指定任意自然周与截止时刻,须为周一且截止不早于所选周周一;修改后【发布周任务】/【立即新增任务补推】均作用于所选周任务);培训视频列表分页展示(4 条/页),已推送视频默认勾选、不可取消并带"第X周 MM-DD至MM-DD"周次标签,推过的视频不重复推直至全部推完(跨任务按已推送前缀并集去重,手动新建下一期任务同样继承历史推送游标、绝不从 0 重推首批);【发布周任务】对所选周任务发布并仅当继承游标为 0 时自动推首批,【立即新增任务补推】按游标对所选周任务增推(点击时若表单勾选/规则与已保存任务不一致,自动先保存再推送,避免按旧冻结清单推送误报全部推完);平台排程每周一 09:00(Asia/Shanghai)自动滚动创建当周任务(模板取严格早于当周的最近一期,游标继承进度,并自动追加配置新增视频到冻结列表末尾,前缀与游标不变、从断点只推新视频)并推送下一批,无需人工维护;每批推送成功后立即向受训人员发送企微通知,并对"已延期"(过截止未提交)人员立即发送延期提醒(event_key 幂等防重);学员端任务期号统一采用后端 week_index 口径。规则手册见 [docs/features/training/精益管理周任务规则手册.md](features/training/精益管理周任务规则手册.md) |
| 培训分享入口 | 前端已实现 | 员工培训页培训类型页签行右侧新增分享按钮,仅具备 `training_hr_manage`(培训管理)权限的用户可见;点击弹出分享弹窗,支持复制链接或下载二维码,链接指向 `/chat/<agentId>?training_type=<当前培训类型>` 深链,接收者点击或扫码后在登录页登录,登录成功自动回跳员工培训页并定位到对应培训类型(如“出国规章培训”);文案覆盖 zh-CN/zh-TW/en/th 四语言 |
+38
View File
@@ -0,0 +1,38 @@
版本:V26.9.1
更新周期:2026-08-22 ~ 2026-09-18
————————————————————
【面向用户】
————————————————————
本次更新亮点:
1. 货代发货 Agent:帮助业务人员把客户发来的发货指令(邮件、微信文字、PDF、Word 等)转成可执行的发货动作,解析与复核发货通知并载入库存。
2. 精益 / 员工培训:新增精益培训视频与周任务管理,支持企微定向推送与卡片深链直达培训页;出国规则培训完成可推送企微通知;培训配置与考试交互持续完善。
3. 采购合同付款预警 Agent:新增付款预警能力,可按申请人等条件关注合同付款计划风险。
5. 在途仓自动调拨 Agent:上线在途仓自动调拨一期能力,覆盖调拨相关作业闭环。
6. 其它优化:修复若干已知问题。
————————————————————
【面向开发者】
————————————————————
本次更新亮点:
1. 货代发货履约:收敛订单处理状态与履约门禁;统一复核/库存准备事实来源与项次模型;完善 XFA 模板映射、客户三层识别、邮件分配表解析与 STP 草稿锁定;批次中心常驻与会话标题按附件派生;进度信号统一为 15 个 stage 契约码并透传阻断原因;我的待办表格+抽屉与已完成明细报表
2. 库存与 RPA:完善库存源聚合、RPA 调度与按需 trigger;导出取数回源 OT 冻结候选;Worker 本机磁盘清理与 Crane 报表超时调整;Excel 连接级自动上传全链路;滚动履约与通用解析性能优化
3. 培训与企微深链:精益周任务视频推送与游标滚动防重复;企微卡片深链登录回跳(redirect 安全校验);出国规则培训完成通知与跳转通用入口修复;培训模块/配置改造与状态丢失修复
4. 立账凭证与合同付款:invoice-check 对话页迁移、收件人配置、ERP/TGHX PO 反查与生成;contract-payment 付款预警上线并迁至 Agent 页,补充申请人过滤与迁移健壮性
5. 在途调拨与集成:in-transit-transfer Agent 一期完整功能;集成连接器管理后台(关键字段拆列配置)
6. 平台与体验:附件预览与订单提取交互;知识库下载命名;改密同密码不退出登录;个人中心查看修复;HTTP 内网 crypto.randomUUID 兼容;Vite 部署 chunk 缓存问题修复
7. 工程与基建:scripts/rpa 目录与命名重构;货代前端投影与事实边界收口;排程/发货相关 bugfix 与测试更新;迁移错误修复与 funclist 冲突清理
@@ -10,7 +10,9 @@ import { useI18n } from 'vue-i18n';
import {
BookOpen,
CheckCircle2,
ChevronDown,
ChevronRight,
ChevronUp,
ClipboardCheck,
Edit,
FileQuestion,
@@ -105,6 +107,19 @@ const directVideoResources = computed(() => contentResources.value.filter((resou
resource.resource_type === 'agent_guide'
&& videoGuideCandidates.value.some((guide) => guide.id === resource.agent_guide_id)
)));
// 培训视频上传列表默认收起:超过阈值仅展示前 N 条,底部按钮可展开查看全部,避免视频过多时页面过长
const DIRECT_VIDEO_PREVIEW_COUNT = 3;
const isDirectVideoExpanded = ref(false);
const hasMoreDirectVideos = computed(() => directVideoResources.value.length > DIRECT_VIDEO_PREVIEW_COUNT);
const directVideoVisibleResources = computed(() => (
hasMoreDirectVideos.value && !isDirectVideoExpanded.value
? directVideoResources.value.slice(0, DIRECT_VIDEO_PREVIEW_COUNT)
: directVideoResources.value
));
/** 切换培训视频上传列表展开/收起:收起仅保留前 N 条,其余视频仍在表单资源中参与保存。 */
const toggleDirectVideoExpanded = () => {
isDirectVideoExpanded.value = !isDirectVideoExpanded.value;
};
const contentResources = computed(() => form.value.resources.filter((resource) => resource.resource_type !== 'inline_questions'));
const trainingLevels: TrainingLevel[] = ['company', 'department', 'team'];
const guideGroups = computed(() => {
@@ -452,6 +467,8 @@ const selectConfig = (config: TrainingConfig) => {
questionJsonText.value = JSON.stringify(questions, null, 2);
questionSourceVersionId.value = null;
questionParseMeta.value = null;
// 切换培训类型时培训视频上传列表恢复默认收起,避免上一配置的展开状态带入
isDirectVideoExpanded.value = false;
void loadLeanTask();
};
@@ -740,6 +757,8 @@ const uploadTrainingVideo = async (event: Event) => {
required_duration: 0,
sort_order: form.value.resources.length,
});
// 新上传的视频排在列表末尾,自动展开避免用户以为上传失败找不到新视频
isDirectVideoExpanded.value = true;
msg.success(t('admin.trainingConfig.messages.videoUploaded'));
} catch (error) {
msg.error(error instanceof Error ? error.message : t('admin.trainingConfig.messages.videoUploadFailed'));
@@ -945,11 +964,19 @@ onMounted(() => void load());
</div>
<div class="space-y-3 p-4 md:p-5">
<div v-if="!directVideoResources.length" class="rounded-xl border border-dashed border-default bg-surface-soft/50 px-3 py-8 text-center text-xs text-muted">{{ t('admin.trainingConfig.directVideo.empty') }}</div>
<div v-for="(resource, index) in directVideoResources" v-else :key="resource.id || `direct-video-${index}`" class="grid gap-3 rounded-xl border border-default bg-white p-4 md:grid-cols-[minmax(0,1fr)_180px_auto] md:items-end">
<div class="flex min-w-0 items-center gap-2 text-sm font-medium text-primary"><Video class="h-4 w-4 shrink-0 text-violet-500" /><span class="truncate">{{ resource.title || videoGuideCandidates.find((guide) => guide.id === resource.agent_guide_id)?.file_name || t('admin.trainingConfig.directVideo.unnamed') }}</span></div>
<label class="label-field">{{ t('admin.trainingConfig.fields.requiredDuration') }}<input v-model.number="resource.required_duration" type="number" min="0" class="input-field mt-2" /></label>
<button class="btn-danger btn-sm" type="button" @click="removeResource(resource)"><Trash2 class="h-4 w-4" />{{ t('admin.delete') }}</button>
</div>
<!-- 培训视频上传列表默认收起:超过阈值仅展示前 N 条,底部可展开查看全部 -->
<template v-else>
<div v-for="(resource, index) in directVideoVisibleResources" :key="resource.id || `direct-video-${index}`" class="grid gap-3 rounded-xl border border-default bg-white p-4 md:grid-cols-[minmax(0,1fr)_180px_auto] md:items-end">
<div class="flex min-w-0 items-center gap-2 text-sm font-medium text-primary"><Video class="h-4 w-4 shrink-0 text-violet-500" /><span class="truncate">{{ resource.title || videoGuideCandidates.find((guide) => guide.id === resource.agent_guide_id)?.file_name || t('admin.trainingConfig.directVideo.unnamed') }}</span></div>
<label class="label-field">{{ t('admin.trainingConfig.fields.requiredDuration') }}<input v-model.number="resource.required_duration" type="number" min="0" class="input-field mt-2" /></label>
<button class="btn-danger btn-sm" type="button" @click="removeResource(resource)"><Trash2 class="h-4 w-4" />{{ t('admin.delete') }}</button>
</div>
<button v-if="hasMoreDirectVideos" class="flex w-full items-center justify-center gap-1.5 rounded-xl border border-dashed border-default bg-surface-soft/50 px-3 py-2.5 text-xs font-medium text-secondary transition hover:bg-surface-soft" type="button" @click="toggleDirectVideoExpanded">
<ChevronDown v-if="!isDirectVideoExpanded" class="h-4 w-4" />
<ChevronUp v-else class="h-4 w-4" />
{{ isDirectVideoExpanded ? t('admin.trainingConfig.directVideo.collapseList') : t('admin.trainingConfig.directVideo.expandAll', { count: directVideoResources.length }) }}
</button>
</template>
</div>
</article>
<article
@@ -1,16 +1,57 @@
<script setup lang="ts">
/**
* features/user/views/UserProfilePage.vue
* 閻劑鈧棑绱扮仦鏇犮仛閸滃瞼绱潏鎴濈秼閸撳秶鏁ら幋鐤カ閺傛瑣鈧浇顕㈢懛鈧?娑撳顣介崑蹇撱偨閿涘苯鑻熼幓鎰返娣囶喗鏁肩€靛棛鐖滈崗銉ュ經閵? * 娓氭繆绂嗛敍姝秙er-profile.context閵嗕勾ucide 閸ョ偓鐖i妴涔倁e i18n閵? * 闁槒绶敍姘矝閻?/workspace/profile 鐠侯垳鏁遍幍鑳祰閿涘奔绲炬い鐢告桨閸滃奔绗熼崝鈥崇秺鐏?user feature閵? */
import { inject } from 'vue';
* 用途:工作台个人中心,展示与编辑当前用户资料、语言/主题偏好,并提供修改密码入口。
* 依赖:workspace.context(WORKSPACE_KEY)、lucide 图标、vue-i18n。
* 逻辑:路由 /workspace/profile 懒加载本页;资料状态由 useWorkspaceProfile 经工作台注入,避免与工作台分叉。
*/
import { computed, inject } from 'vue';
import { useI18n } from 'vue-i18n';
import {
User, Mail, Building, CreditCard, Globe, Save, Palette,
} from 'lucide-vue-next';
import { WORKSPACE_KEY } from '@/features/workspace/composables/workspace.context';
// 个人资料与改密状态由工作台 useWorkspaceProfile 编排,经 WORKSPACE_KEY 注入。
// 这里复用同一份 ws 上下文(含 profileUser/主题/移动端/登出能力),避免与工作台状态分叉。
const { t } = useI18n();
const userProfile = inject(WORKSPACE_KEY)!;
/** 只读字段值:与 input-field 同高,正文统一 14px。 */
const fieldValueClass = 'flex min-h-11 items-center rounded-xl border border-default bg-surface-soft px-4 text-sm font-medium text-secondary';
/** 表单标签:与分区标题区分层级,全页统一 14px。 */
const fieldLabelClass = 'mb-1.5 flex items-center gap-1.5 text-sm font-medium text-muted';
/**
* 头像字母:取姓名或用户名首字,供身份卡展示。
*/
const avatarLetter = computed(() => {
const source = userProfile.profileUser.real_name || userProfile.profileUser.username || 'U';
return source.charAt(0).toUpperCase();
});
/**
* 身份主标题:优先真实姓名,缺失时回退用户名。
*/
const displayName = computed(() => {
return userProfile.profileUser.real_name || userProfile.profileUser.username || '-';
});
/**
* 角色展示文案。
*/
const roleLabel = computed(() => {
return userProfile.profileUser.role === 'admin' ? t('profile.roleAdmin') : t('profile.roleUser');
});
/**
* 身份副标题:用户名(与主标题不同时)、部门、角色用间隔点拼接,空项省略。
*/
const identityMeta = computed(() => {
const username = userProfile.profileUser.username;
const showUsername = Boolean(username && username !== displayName.value);
return [showUsername ? username : '', userProfile.profileUser.department, roleLabel.value]
.filter(Boolean)
.join(' · ');
});
</script>
<template>
@@ -19,151 +60,186 @@ const userProfile = inject(WORKSPACE_KEY)!;
</div>
<div v-else class="space-y-6">
<div class="rounded-3xl border border-default bg-surface px-6 py-6 shadow-sm md:px-8">
<div class="flex flex-col gap-6 lg:flex-row lg:items-start lg:justify-between">
<div class="flex flex-1 flex-col gap-6 sm:flex-row sm:items-center sm:justify-start">
<div class="flex h-24 w-24 shrink-0 items-center justify-center rounded-full bg-brand-100 text-4xl font-bold text-brand-600" :class="userProfile.isMobile ? 'h-14 w-14 text-2xl' : ''">
{{ (userProfile.profileUser.real_name || userProfile.profileUser.username || 'U').charAt(0).toUpperCase() }}
<div class="rounded-2xl border border-default bg-surface px-5 py-5 shadow-sm md:px-6">
<div class="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
<div class="flex min-w-0 items-center gap-4">
<div
class="flex h-14 w-14 shrink-0 items-center justify-center rounded-full bg-brand-100 text-xl font-semibold text-brand-600 md:h-16 md:w-16 md:text-2xl"
>
{{ avatarLetter }}
</div>
<div class="grid flex-1 text-left" :class="userProfile.isMobile ? 'grid-cols-2 gap-x-4 gap-y-1' : 'grid-cols-1 gap-x-12 gap-y-3 sm:grid-cols-2'">
<div :class="userProfile.isMobile ? '' : ''">
<div :class="userProfile.isMobile ? 'text-xs text-muted' : 'text-lg font-semibold text-primary'">{{ userProfile.isMobile ? $t('profile.realName') : (userProfile.profileUser.username || '-') }}</div>
<div v-if="userProfile.isMobile" class="text-sm font-medium text-primary truncate">{{ userProfile.profileUser.real_name || userProfile.profileUser.username || '-' }}</div>
</div>
<div>
<div :class="userProfile.isMobile ? 'text-xs text-muted' : 'text-lg font-semibold text-primary'">{{ userProfile.isMobile ? $t('profile.employeeId') : (userProfile.profileUser.employee_id || '-') }}</div>
<div v-if="userProfile.isMobile" class="text-sm font-medium text-primary truncate">{{ userProfile.profileUser.employee_id || '-' }}</div>
</div>
<div>
<div :class="userProfile.isMobile ? 'text-xs text-muted' : 'text-lg font-semibold text-primary'">{{ userProfile.isMobile ? $t('profile.department') : (userProfile.profileUser.department || '-') }}</div>
<div v-if="userProfile.isMobile" class="text-sm font-medium text-primary truncate">{{ userProfile.profileUser.department || '-' }}</div>
</div>
<div>
<div :class="userProfile.isMobile ? 'text-xs text-muted' : 'text-lg font-semibold text-primary'">{{ userProfile.isMobile ? $t('profile.role') : (userProfile.profileUser.role === 'admin' ? ($t('profile.roleAdmin') || 'Administrator') : ($t('profile.roleUser') || 'User')) }}</div>
<div v-if="userProfile.isMobile" class="text-sm font-medium text-primary truncate">{{ userProfile.profileUser.role === 'admin' ? ($t('profile.roleAdmin') || 'Administrator') : ($t('profile.roleUser') || 'User') }}</div>
</div>
<div :class="userProfile.isMobile ? 'col-span-2' : 'sm:col-span-2'">
<div :class="userProfile.isMobile ? 'text-xs text-muted' : 'break-all text-lg font-semibold text-primary'">{{ userProfile.isMobile ? $t('profile.email') : (userProfile.profileUser.email || '-') }}</div>
<div v-if="userProfile.isMobile" class="text-sm font-medium text-primary truncate">{{ userProfile.profileUser.email || '-' }}</div>
<div class="min-w-0 space-y-0.5">
<div class="truncate text-lg font-semibold text-primary">{{ displayName }}</div>
<div v-if="identityMeta" class="truncate text-sm text-muted">{{ identityMeta }}</div>
<div v-if="userProfile.profileUser.email" class="break-all text-sm text-muted">
{{ userProfile.profileUser.email }}
</div>
</div>
</div>
<div v-if="!userProfile.isMobile" class="flex shrink-0 items-center gap-2 self-start lg:ml-6">
<button @click="userProfile.handleChangePasswordClick" class="btn-primary px-6 py-3 text-base">
<div v-if="!userProfile.isMobile" class="shrink-0">
<button type="button" class="btn-primary btn-sm" @click="userProfile.handleChangePasswordClick">
{{ $t('profile.changePassword') }}
</button>
</div>
</div>
<div v-if="userProfile.isMobile" class="mt-4 flex items-center justify-center gap-4">
<button @click="userProfile.handleChangePasswordClick" class="btn-primary flex-1 py-2.5 text-sm text-center">
<div v-if="userProfile.isMobile" class="mt-4 flex items-center gap-3">
<button
type="button"
class="btn-primary btn-sm flex-1"
@click="userProfile.handleChangePasswordClick"
>
{{ $t('profile.changePassword') }}
</button>
<button @click="userProfile.handleLogout" class="btn-secondary flex-1 py-2.5 text-sm text-center text-red-600 hover:bg-red-50">
<button
type="button"
class="btn-secondary btn-sm flex-1 text-red-600 hover:bg-red-50"
@click="userProfile.handleLogout"
>
{{ $t('workspace.nav.logout') }}
</button>
</div>
</div>
<div class="space-y-6">
<div class="rounded-3xl border border-default bg-surface p-8 shadow-sm" :class="userProfile.isMobile ? 'p-4' : ''">
<div class="mb-8 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between" :class="userProfile.isMobile ? 'mb-4 gap-2' : ''">
<div class="flex items-center" :class="userProfile.isMobile ? 'w-full justify-center gap-2' : ''">
<h3 class="flex items-center gap-3 text-3xl font-bold text-primary" :class="userProfile.isMobile ? 'text-lg gap-2' : ''">
<User class="h-6 w-6 text-brand-500" :class="userProfile.isMobile ? 'h-4 w-4' : ''" />
<div class="rounded-2xl border border-default bg-surface p-5 shadow-sm md:p-6">
<div class="mb-5 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
<div class="flex items-center gap-2" :class="userProfile.isMobile ? 'w-full justify-between' : ''">
<h3 class="section-title flex items-center gap-2">
<User class="h-5 w-5 text-brand-500" />
{{ $t('profile.basicInfo') }}
</h3>
<button v-if="userProfile.isMobile && !userProfile.isProfileEditing" @click="userProfile.startProfileEditing" class="btn-secondary px-3 py-1 text-xs">
<button
v-if="userProfile.isMobile && !userProfile.isProfileEditing"
type="button"
class="btn-secondary btn-sm"
@click="userProfile.startProfileEditing"
>
{{ $t('profile.edit') }}
</button>
</div>
<p v-if="!userProfile.isMobile" class="mt-2 text-sm text-muted">
<p v-if="!userProfile.isMobile" class="section-desc">
{{ userProfile.isProfileEditing ? $t('profile.directEditHint') : $t('profile.switchEditHint') }}
</p>
<div v-if="!userProfile.isMobile" class="flex items-center gap-2">
<button v-if="!userProfile.isProfileEditing" @click="userProfile.startProfileEditing" class="btn-secondary px-5 py-2.5 text-sm">
<button
v-if="!userProfile.isProfileEditing"
type="button"
class="btn-secondary btn-sm"
@click="userProfile.startProfileEditing"
>
{{ $t('profile.edit') }}
</button>
<template v-else>
<button @click="userProfile.cancelProfileEditing" class="btn-secondary px-5 py-2.5 text-sm">
{{ $t('profile.cancel') || 'Cancel' }}
<button type="button" class="btn-secondary btn-sm" @click="userProfile.cancelProfileEditing">
{{ $t('profile.cancel') }}
</button>
<button
@click="userProfile.saveProfile"
type="button"
class="btn-primary btn-sm disabled:cursor-not-allowed disabled:opacity-50"
:disabled="userProfile.isProfileSaving || !userProfile.hasProfileUnsavedChanges"
class="btn-primary px-5 py-2.5 text-sm disabled:opacity-50 disabled:cursor-not-allowed"
@click="userProfile.saveProfile"
>
<Save class="w-4 h-4" />
<Save class="h-4 w-4" />
<span>{{ userProfile.isProfileSaving ? $t('profile.saving') : $t('workspace.save') }}</span>
</button>
</template>
</div>
</div>
<div class="grid grid-cols-1 gap-5 md:grid-cols-2" :class="userProfile.isMobile ? 'gap-3' : ''">
<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
<div>
<label class="mb-2 flex items-center gap-2 text-sm font-medium text-muted" :class="userProfile.isMobile ? 'text-xs mb-1' : ''">
<label :class="fieldLabelClass">
<User class="h-4 w-4" /> {{ $t('profile.username') }}
</label>
<div class="rounded-2xl border border-default bg-surface-soft px-4 py-4 text-lg font-medium text-secondary" :class="userProfile.isMobile ? 'px-3 py-2 text-sm rounded-xl' : ''">
<div :class="fieldValueClass">
{{ userProfile.profileUser.username || '-' }}
</div>
</div>
<div>
<label class="mb-2 flex items-center gap-2 text-sm font-medium text-muted" :class="userProfile.isMobile ? 'text-xs mb-1' : ''">
<label :class="fieldLabelClass">
<CreditCard class="h-4 w-4" /> {{ $t('profile.employeeId') }}
</label>
<input v-if="userProfile.isProfileEditing" v-model="userProfile.profileUser.employee_id" type="text" class="input-field" :class="userProfile.isMobile ? 'h-10 text-sm' : 'h-[58px]'" />
<div v-else class="rounded-2xl border border-default bg-surface-soft px-4 py-4 text-lg font-medium text-secondary" :class="userProfile.isMobile ? 'px-3 py-2 text-sm rounded-xl' : ''">
<input
v-if="userProfile.isProfileEditing"
v-model="userProfile.profileUser.employee_id"
type="text"
class="input-field text-sm"
>
<div v-else :class="fieldValueClass">
{{ userProfile.profileUser.employee_id || '-' }}
</div>
</div>
<div>
<label class="mb-2 flex items-center gap-2 text-sm font-medium text-muted" :class="userProfile.isMobile ? 'text-xs mb-1' : ''">
<label :class="fieldLabelClass">
<User class="h-4 w-4" /> {{ $t('profile.realName') }}
</label>
<input v-if="userProfile.isProfileEditing" v-model="userProfile.profileUser.real_name" type="text" class="input-field" :class="userProfile.isMobile ? 'h-10 text-sm' : 'h-[58px]'" />
<div v-else class="rounded-2xl border border-default bg-surface-soft px-4 py-4 text-lg font-medium text-secondary" :class="userProfile.isMobile ? 'px-3 py-2 text-sm rounded-xl' : ''">
<input
v-if="userProfile.isProfileEditing"
v-model="userProfile.profileUser.real_name"
type="text"
class="input-field text-sm"
>
<div v-else :class="fieldValueClass">
{{ userProfile.profileUser.real_name || '-' }}
</div>
</div>
<div>
<label class="mb-2 flex items-center gap-2 text-sm font-medium text-muted" :class="userProfile.isMobile ? 'text-xs mb-1' : ''">
<label :class="fieldLabelClass">
<Building class="h-4 w-4" /> {{ $t('profile.department') }}
</label>
<input v-if="userProfile.isProfileEditing" v-model="userProfile.profileUser.department" type="text" class="input-field" :class="userProfile.isMobile ? 'h-10 text-sm' : 'h-[58px]'" />
<div v-else class="rounded-2xl border border-default bg-surface-soft px-4 py-4 text-lg font-medium text-secondary" :class="userProfile.isMobile ? 'px-3 py-2 text-sm rounded-xl' : ''">
<input
v-if="userProfile.isProfileEditing"
v-model="userProfile.profileUser.department"
type="text"
class="input-field text-sm"
>
<div v-else :class="fieldValueClass">
{{ userProfile.profileUser.department || '-' }}
</div>
</div>
<div>
<label class="mb-2 flex items-center gap-2 text-sm font-medium text-muted" :class="userProfile.isMobile ? 'text-xs mb-1' : ''">
<label :class="fieldLabelClass">
<Mail class="h-4 w-4" /> {{ $t('profile.email') }}
</label>
<input v-if="userProfile.isProfileEditing" v-model="userProfile.profileUser.email" type="email" class="input-field" :class="userProfile.isMobile ? 'h-10 text-sm' : 'h-[58px]'" />
<div v-else class="rounded-2xl border border-default bg-surface-soft px-4 py-4 text-lg font-medium text-secondary" :class="userProfile.isMobile ? 'px-3 py-2 text-sm rounded-xl' : ''">
<input
v-if="userProfile.isProfileEditing"
v-model="userProfile.profileUser.email"
type="email"
class="input-field text-sm"
>
<div v-else :class="fieldValueClass">
{{ userProfile.profileUser.email || '-' }}
</div>
</div>
<div>
<label class="mb-2 flex items-center gap-2 text-sm font-medium text-muted" :class="userProfile.isMobile ? 'text-xs mb-1' : ''">
<label :class="fieldLabelClass">
<Globe class="h-4 w-4" /> {{ $t('profile.phoneNumber') }}
</label>
<input v-if="userProfile.isProfileEditing" v-model="userProfile.profileUser.phone_number" type="text" class="input-field" :class="userProfile.isMobile ? 'h-10 text-sm' : 'h-[58px]'" />
<div v-else class="rounded-2xl border border-default bg-surface-soft px-4 py-4 text-lg font-medium text-secondary" :class="userProfile.isMobile ? 'px-3 py-2 text-sm rounded-xl' : ''">
<input
v-if="userProfile.isProfileEditing"
v-model="userProfile.profileUser.phone_number"
type="text"
class="input-field text-sm"
>
<div v-else :class="fieldValueClass">
{{ userProfile.profileUser.phone_number || '-' }}
</div>
</div>
</div>
</div>
<div class="rounded-3xl border border-default bg-surface p-8 shadow-sm">
<h3 class="mb-6 flex items-center gap-3 text-2xl font-bold text-primary">
<div class="rounded-2xl border border-default bg-surface p-5 shadow-sm md:p-6">
<h3 class="section-title mb-5 flex items-center gap-2">
<Palette class="h-5 w-5 text-brand-500" />
{{ $t('profile.preferences') }}
</h3>
<div class="grid grid-cols-1 gap-6 md:grid-cols-2">
<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
<div>
<label class="mb-2 block text-sm font-medium text-muted">{{ $t('workspace.languageLabel') }}</label>
<select v-model="userProfile.profileUser.language" :disabled="!userProfile.isProfileEditing" class="input-field h-[58px]">
<label class="mb-1.5 block text-sm font-medium text-muted">{{ $t('workspace.languageLabel') }}</label>
<select
v-model="userProfile.profileUser.language"
class="select-field text-sm"
:disabled="!userProfile.isProfileEditing"
>
<option value="en">English</option>
<option value="zh-CN">{{ $t('workspace.lang.zhCN') }}</option>
<option value="zh-TW">{{ $t('workspace.lang.zhTW') }}</option>
@@ -171,7 +247,7 @@ const userProfile = inject(WORKSPACE_KEY)!;
</select>
</div>
<div>
<label class="mb-2 block text-sm font-medium text-muted">{{ $t('profile.theme') }}</label>
<label class="mb-1.5 block text-sm font-medium text-muted">{{ $t('profile.theme') }}</label>
<div
class="segment-control segment-control--cols-3 segment-control--md"
role="radiogroup"
@@ -182,9 +258,9 @@ const userProfile = inject(WORKSPACE_KEY)!;
:key="item.value"
type="button"
role="radio"
class="segment-item"
:aria-checked="userProfile.profileUser.theme_preference === item.value"
:disabled="!userProfile.isProfileEditing"
class="segment-item"
:class="userProfile.profileUser.theme_preference === item.value ? 'segment-item--active' : ''"
@click="userProfile.profileUser.theme_preference = item.value"
>
@@ -194,7 +270,6 @@ const userProfile = inject(WORKSPACE_KEY)!;
</div>
</div>
</div>
</div>
</div>
</template>
+3 -1
View File
@@ -5063,7 +5063,9 @@
"upload": "Upload Video",
"uploading": "Uploading...",
"empty": "No training videos uploaded",
"unnamed": "Unnamed video"
"unnamed": "Unnamed video",
"expandAll": "Expand all videos ({count})",
"collapseList": "Collapse list"
},
"lean": {
"weekKey": "Task week (Monday)",
+2
View File
@@ -10,8 +10,10 @@
"email": "Email",
"phoneNumber": "Phone Number",
"theme": "Theme",
"role": "Role",
"roleAdmin": "Administrator",
"roleUser": "User",
"saving": "Saving...",
"unsavedChanges": "You have unsaved changes",
"editHint": "Switch to edit mode to update profile details",
"switchEditHint": "Switch to edit mode to update profile details",
+3 -1
View File
@@ -4932,7 +4932,9 @@
"upload": "อัปโหลดวิดีโอ",
"uploading": "กำลังอัปโหลด...",
"empty": "ยังไม่มีวิดีโอการฝึกอบรม",
"unnamed": "วิดีโอไม่มีชื่อ"
"unnamed": "วิดีโอไม่มีชื่อ",
"expandAll": "แสดงวิดีโอทั้งหมด ({count})",
"collapseList": "ย่อรายการ"
},
"lean": {
"weekKey": "สัปดาห์ภารกิจ (วันจันทร์)",
+2
View File
@@ -10,8 +10,10 @@
"email": "อีเมล",
"phoneNumber": "เบอร์โทรศัพท์",
"theme": "ธีม",
"role": "บทบาท",
"roleAdmin": "ผู้ดูแลระบบ",
"roleUser": "ผู้ใช้",
"saving": "กำลังบันทึก...",
"unsavedChanges": "คุณมีการเปลี่ยนแปลงที่ยังไม่ได้บันทึก",
"editHint": "สลับไปที่โหมดแก้ไขเพื่ออัปเดตรายละเอียดโปรไฟล์",
"switchEditHint": "สลับไปที่โหมดแก้ไขเพื่ออัปเดตรายละเอียดโปรไฟล์",
+3 -1
View File
@@ -5090,7 +5090,9 @@
"upload": "上传视频",
"uploading": "上传中...",
"empty": "暂未上传培训视频",
"unnamed": "未命名视频"
"unnamed": "未命名视频",
"expandAll": "展开全部视频(共 {count} 个)",
"collapseList": "收起列表"
},
"lean": {
"weekKey": "任务周(周一)",
+2
View File
@@ -10,8 +10,10 @@
"email": "邮箱",
"phoneNumber": "手机号",
"theme": "主题",
"role": "角色",
"roleAdmin": "管理员",
"roleUser": "普通用户",
"saving": "保存中...",
"unsavedChanges": "您有未保存的更改",
"editHint": "切换到编辑模式以更新个人资料",
"switchEditHint": "切换到编辑模式以更新个人资料",
+3 -1
View File
@@ -4937,7 +4937,9 @@
"upload": "上傳影片",
"uploading": "上傳中...",
"empty": "尚未上傳培訓影片",
"unnamed": "未命名影片"
"unnamed": "未命名影片",
"expandAll": "展開全部影片(共 {count} 個)",
"collapseList": "收合列表"
},
"lean": {
"weekKey": "任務週(週一)",
+2
View File
@@ -10,8 +10,10 @@
"email": "郵箱",
"phoneNumber": "手機號",
"theme": "主題",
"role": "角色",
"roleAdmin": "管理員",
"roleUser": "用戶",
"saving": "儲存中...",
"unsavedChanges": "您有尚未保存的變更",
"editHint": "切換到編輯模式以更新個人資料",
"switchEditHint": "切換到編輯模式以更新個人資料",