feat(feat):
deploy-hxtesting / build-and-deploy (push) Successful in 1m14s

1.将职称角色中的“从OA同步企微账号”及设置角色、“员工与部门在「组织架构」中统一维护,此处仅配置职称角色”迁移到组织架构页面中,
2.平台新增成员自动添加到“组织架构”页面自动匹配对应部门;
3.在“组织架构”页面可直接设置角色
4.“组织架构”页面职称按名称、工号、部门查找员工
5.新增成员默认放在最上面按时间倒序排列
6.所有登录平台的用户直接默认打开AI对话页面
7.页面3、4中的”AIDO“改为”和信智汇学院“
This commit is contained in:
runny committed 2026-11-24 14:38:20 +08:00
1 parent 196478114c
commit 8f225ecea9
26 files changed
+644 -406

No files matched your search

@@ -1,323 +0,0 @@
<template>
<div class="member-panel">
<!-- 员工档案(名册来自组织架构)+ 职称角色 -->
<div class="panel-box member-layout__members">
<div class="panel-box__header">
<span class="panel-box__title">员工档案</span>
<div class="member-panel__hint">
员工与部门在「<a class="member-panel__link" @click="goOrgCenter">组织架构</a>」中统一维护,此处仅配置职称角色
<t-button variant="outline" theme="primary" size="small" :loading="syncing" class="oa-sync-btn" @click="onPreviewSync">
从OA同步企微账号
</t-button>
</div>
</div>
<t-table :data="members" :columns="memberColumns" row-key="id" size="small" :loading="loading">
<template #user_name="{ row }">
<t-tooltip :content="memberName(row)" :disabled="!memberName(row)">
<span class="member-name">{{ memberName(row) || '-' }}</span>
</t-tooltip>
</template>
<template #dept_name="{ row }">{{ row.dept_name || '-' }}</template>
<template #wecom_userid="{ row }">
<span :class="row.wecom_userid ? '' : 'wecom-missing'">{{ row.wecom_userid || '未绑定' }}</span>
</template>
<template #roles="{ row }">
<t-tag v-for="r in row.roles || []" :key="r" variant="light" size="small" class="role-tag">{{ roleText(r) }}</t-tag>
</template>
<template #op="{ row }">
<t-button variant="text" theme="primary" size="small" @click="openWecom(row)">企微账号</t-button>
<t-button variant="text" theme="primary" size="small" @click="openRoles(row)">设置角色</t-button>
</template>
</t-table>
</div>
<t-dialog v-model:visible="wecomVisible" header="绑定企微账号" width="460">
<t-input v-model="wecomInput" placeholder="企微 userid(管理后台→通讯录→成员详情→账号)" />
<div class="form-hint">培训提醒推送到该企微账号;留空保存即解绑。</div>
<template #footer>
<t-button theme="primary" :loading="savingWecom" @click="onSaveWecom">保存</t-button>
</template>
</t-dialog>
<!-- OA 同步预览:统计 + 冲突清单 + 待写入样本;无冲突才允许确认写入 -->
<t-dialog v-model:visible="syncVisible" header="OA 企微账号同步" width="640" :footer="false">
<template v-if="syncSummary">
<div class="sync-stats">
<span>本地员工 {{ syncSummary.local_candidates }}</span>
<span>OA 命中 {{ syncSummary.local_matched }}</span>
<span>已一致 {{ syncSummary.already_bound }}</span>
<span class="sync-stats__main">待写入 {{ syncSummary.would_update }}</span>
<span :class="syncSummary.conflict_count ? 'sync-stats__danger' : ''">冲突 {{ syncSummary.conflict_count }}</span>
<span>OA 未找到 {{ syncSummary.local_missing }}</span>
</div>
<div v-if="syncSummary.conflict_count" class="sync-section sync-section--danger">
<div class="sync-section__title">冲突({{ syncSummary.conflict_count }})——存在冲突时不写入</div>
<div v-for="(cf, i) in syncSummary.conflicts" :key="i" class="sync-row">
{{ cf.employee_no }} {{ cf.user_name || '' }}:
{{ conflictText(cf) }}
</div>
</div>
<div v-if="syncSummary.would_update" class="sync-section">
<div class="sync-section__title">将写入(最多展示 20 条)</div>
<div v-for="(p, i) in syncSummary.pending_updates" :key="i" class="sync-row">
{{ p.employee_no }} {{ p.user_name || p.name }} → 企微账号 {{ p.wecom_userid }}
</div>
</div>
<div v-if="!syncSummary.conflict_count && !syncSummary.would_update" class="sync-section">
无需更新:绑定已一致或 OA 无匹配数据。
</div>
<div class="sync-footer">
<t-button :disabled="syncSummary.conflict_count > 0 || syncSummary.would_update === 0"
theme="primary" :loading="syncing" @click="onApplySync">
确认写入
</t-button>
<t-button variant="outline" @click="syncVisible = false">关闭</t-button>
</div>
</template>
</t-dialog>
<t-dialog v-model:visible="rolesVisible" header="设置职称角色" width="460">
<!-- 选项来自配置中心角色字典(role_dict):系统角色 + 自定义角色 -->
<t-select v-model="roleSelection" multiple style="width: 100%">
<t-option v-for="r in roleDict" :key="r.key" :value="r.key" :label="r.label" />
</t-select>
<div class="form-hint">学员角色为全员默认,无需选择;角色与权限在「配置中心」维护。</div>
<template #footer>
<t-button theme="primary" :loading="saving" @click="onSaveRoles">保存</t-button>
</template>
</t-dialog>
</div>
</template>
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
import { MessagePlugin } from 'tdesign-vue-next'
import {
fetchRoleDict,
listMembers,
listPlatformUsers,
roleLabelOf,
updateMemberRoles,
updateMemberWecomUserid,
applyWecomUseridSync,
previewWecomUseridSync,
type PlatformUser,
type TrainingMember,
type TrainingRoleDef,
type WecomSyncConflict,
type WecomSyncSummary,
unwrap,
} from '@/api/training'
const router = useRouter()
const loading = ref(false)
const saving = ref(false)
const members = ref<TrainingMember[]>([])
const platformUsers = ref<PlatformUser[]>([])
// 角色字典(配置中心 role_dict):弹窗选项与角色标签文案的来源
const roleDict = ref<TrainingRoleDef[]>([])
const rolesVisible = ref(false)
const activeMember = ref<TrainingMember | null>(null)
const roleSelection = ref<string[]>([])
// 企微账号绑定(培训提醒推送目标)
const wecomVisible = ref(false)
const activeWecomMember = ref<TrainingMember | null>(null)
const wecomInput = ref('')
const savingWecom = ref(false)
// OA 同步(工号 → 企微 userid,预览→写入两段式)
const syncVisible = ref(false)
const syncing = ref(false)
const syncSummary = ref<WecomSyncSummary | null>(null)
const conflictText = (cf: WecomSyncConflict) => {
switch (cf.reason) {
case 'duplicate_workcode_in_oa':
return `OA 中存在重复工号(企微账号 ${cf.new_wecom_userid}),请先在 OA 侧处理`
case 'bound_to_different_userid':
return `已绑定 ${cf.existing_wecom_userid},与 OA(${cf.new_wecom_userid})不一致,需人工确认`
case 'userid_occupied':
return `企微账号 ${cf.new_wecom_userid} 已被 ${cf.occupied_by_employee || '其他员工'} 占用`
default:
return cf.reason
}
}
const onPreviewSync = async () => {
syncing.value = true
try {
const res = await previewWecomUseridSync()
syncSummary.value = unwrap(res) ?? null
syncVisible.value = true
} catch (err: any) {
MessagePlugin.error(err?.response?.data?.message || 'OA 连接失败,请检查 OA_SQLSERVER_* 配置')
} finally {
syncing.value = false
}
}
const onApplySync = async () => {
syncing.value = true
try {
const res = await applyWecomUseridSync()
const summary = unwrap(res)
MessagePlugin.success(`已写入 ${summary?.updated ?? 0} 条企微绑定`)
syncVisible.value = false
loadAll()
} catch (err: any) {
MessagePlugin.error(err?.response?.data?.message || '写入失败')
} finally {
syncing.value = false
}
}
const memberColumns = [
{ colKey: 'employee_no', title: '工号', width: 100 },
{ colKey: 'user_name', title: '姓名' },
{ colKey: 'dept_name', title: '部门', width: 110 },
{ colKey: 'post', title: '岗位', width: 140 },
{ colKey: 'wecom_userid', title: '企微账号', width: 120 },
{ colKey: 'roles', title: '职称角色', width: 260 },
{ colKey: 'op', title: '操作', width: 170 },
]
// 角色 tag 文案取字典短名,字典外(trainee/已删角色)回退固定文案或 key
const roleText = (r: string) => roleLabelOf(r, roleDict.value, true)
// 跳转组织架构页(部门/员工档案的唯一维护入口)
const goOrgCenter = () => router.push('/platform/org-center')
// 姓名 = 真实姓名(来自 OIDC displayName claim):优先取后端联查的 user_name,
// 再用平台用户表的 display_name / username 兜底;都取不到展示「-」,不再回退展示用户ID。
const userNameMap = computed(() => {
const m: Record<string, string> = {}
for (const u of platformUsers.value) m[u.id] = u.display_name?.trim() || u.username
return m
})
const memberName = (row: TrainingMember) => row.user_name || userNameMap.value[row.user_id] || ''
const loadAll = async () => {
loading.value = true
try {
// 平台用户一并拉取,用于姓名兜底联查(user_id → 用户名)。
const [m, u] = await Promise.all([
listMembers({ page_size: 500 }),
listPlatformUsers().catch(() => null),
])
members.value = unwrap(m)?.items || []
platformUsers.value = unwrap(u) || []
} finally {
loading.value = false
}
}
const openRoles = (row: TrainingMember) => {
activeMember.value = row
roleSelection.value = (row.roles || []).filter((r) => r !== 'trainee')
rolesVisible.value = true
}
const openWecom = (row: TrainingMember) => {
activeWecomMember.value = row
wecomInput.value = row.wecom_userid || ''
wecomVisible.value = true
}
const onSaveWecom = async () => {
if (!activeWecomMember.value) return
savingWecom.value = true
try {
await updateMemberWecomUserid(activeWecomMember.value.id, wecomInput.value.trim())
MessagePlugin.success('企微账号已更新')
wecomVisible.value = false
loadAll()
} catch (err: any) {
MessagePlugin.error(err?.response?.data?.message || '保存失败')
} finally {
savingWecom.value = false
}
}
const onSaveRoles = async () => {
if (!activeMember.value) return
saving.value = true
try {
await updateMemberRoles(activeMember.value.id, [...roleSelection.value, 'trainee'])
MessagePlugin.success('角色已更新')
rolesVisible.value = false
loadAll()
} catch (err: any) {
MessagePlugin.error(err?.response?.data?.message || '保存失败')
} finally {
saving.value = false
}
}
onMounted(() => {
loadAll()
fetchRoleDict().then((d) => {
roleDict.value = d
})
})
</script>
<style lang="less" scoped>
@import (reference) '../training.less';
.panel-box {
.training-panel-box();
}
.member-panel__hint {
color: var(--td-text-color-placeholder);
font-size: var(--app-text-sm);
}
.member-panel__link {
color: var(--td-brand-color);
cursor: pointer;
}
.role-tag { margin-right: 4px; }
.wecom-missing { color: var(--td-text-color-placeholder); }
.oa-sync-btn { margin-left: 12px; }
.sync-stats {
display: flex;
gap: 14px;
flex-wrap: wrap;
margin-bottom: 12px;
color: var(--td-text-color-secondary);
.sync-stats__main { color: var(--td-brand-color); font-weight: 600; }
.sync-stats__danger { color: var(--td-error-color); font-weight: 600; }
}
.sync-section {
margin-bottom: 12px;
max-height: 180px;
overflow: auto;
.sync-section__title { font-weight: 600; margin-bottom: 6px; }
.sync-row { padding: 2px 0; font-size: var(--app-text-sm); color: var(--td-text-color-secondary); }
&.sync-section--danger .sync-section__title { color: var(--td-error-color); }
}
.sync-footer { display: flex; gap: 8px; justify-content: flex-end; }
.form-hint {
margin-top: 8px;
color: var(--td-text-color-placeholder);
font-size: var(--app-text-sm);
}
// 姓名列:最多展示 2 行,超出省略(悬停 tooltip 看全名)
.member-name {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
word-break: break-all;
line-height: 1.4;
}
</style>