1.将职称角色中的“从OA同步企微账号”及设置角色、“员工与部门在「组织架构」中统一维护,此处仅配置职称角色”迁移到组织架构页面中, 2.平台新增成员自动添加到“组织架构”页面自动匹配对应部门; 3.在“组织架构”页面可直接设置角色 4.“组织架构”页面职称按名称、工号、部门查找员工 5.新增成员默认放在最上面按时间倒序排列 6.所有登录平台的用户直接默认打开AI对话页面 7.页面3、4中的”AIDO“改为”和信智汇学院“
This commit is contained in:
1 parent
196478114c
commit
8f225ecea9
26 files changed
+644
-406
No files matched your search
@@ -34,7 +34,29 @@
|
||||
<div class="panel-box org-layout__employees">
|
||||
<div class="panel-box__header">
|
||||
<span class="panel-box__title">员工档案</span>
|
||||
<div style="display: flex; gap: 8px">
|
||||
<!-- 自「职称角色」页迁入:提示 + OA 同步入口(管理角色可见) -->
|
||||
<div class="org-employees__actions">
|
||||
<span class="org-employees__hint">员工与部门在本页统一维护,职称角色与企微账号可直接配置</span>
|
||||
<t-input
|
||||
v-model="keyword"
|
||||
class="org-employees__search"
|
||||
clearable
|
||||
placeholder="按姓名 / 工号 / 部门查找"
|
||||
@enter="loadEmployees"
|
||||
@clear="loadEmployees"
|
||||
>
|
||||
<template #prefixIcon><t-icon name="search" /></template>
|
||||
</t-input>
|
||||
<t-button
|
||||
v-if="canManage"
|
||||
variant="outline"
|
||||
theme="primary"
|
||||
:loading="syncing"
|
||||
class="oa-sync-btn"
|
||||
@click="onPreviewSync"
|
||||
>
|
||||
从OA同步企微账号
|
||||
</t-button>
|
||||
<t-button variant="outline" @click="openPicker">从平台用户添加</t-button>
|
||||
<t-button theme="primary" @click="importVisible = true">批量导入</t-button>
|
||||
</div>
|
||||
@@ -46,6 +68,12 @@
|
||||
</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 #status="{ row }">
|
||||
<t-tag v-if="row.status === 'active'" theme="success" variant="light" size="small">在职</t-tag>
|
||||
<t-tag v-else-if="row.status === 'inactive'" theme="danger" variant="light" size="small">离职</t-tag>
|
||||
@@ -54,6 +82,8 @@
|
||||
<template #op="{ row }">
|
||||
<div class="op-group">
|
||||
<t-button variant="text" theme="primary" size="small" @click="onEditEmployee(row)">修改</t-button>
|
||||
<t-button v-if="canManage" variant="text" theme="primary" size="small" @click="openWecom(row)">企微账号</t-button>
|
||||
<t-button v-if="canManage" variant="text" theme="primary" size="small" @click="openRoles(row)">设置角色</t-button>
|
||||
</div>
|
||||
</template>
|
||||
</t-table>
|
||||
@@ -150,6 +180,68 @@
|
||||
<t-button theme="primary" :loading="saving" @click="onSaveEmployee">保存</t-button>
|
||||
</template>
|
||||
</t-dialog>
|
||||
|
||||
<!-- 绑定企微账号(培训提醒推送目标;自职称角色页迁入) -->
|
||||
<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>
|
||||
|
||||
<!-- 设置职称角色(自职称角色页迁入;绑定写 module_key='training') -->
|
||||
<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="savingRoles" @click="onSaveRoles">保存</t-button>
|
||||
</template>
|
||||
</t-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -157,26 +249,45 @@
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import {
|
||||
applyOrgWecomSync,
|
||||
deleteDept,
|
||||
importEmployees,
|
||||
listDepts,
|
||||
listEmployees,
|
||||
listPlatformUsers,
|
||||
ORG_MODULE_TRAINING,
|
||||
previewOrgWecomSync,
|
||||
saveDept,
|
||||
updateEmployee,
|
||||
updateOrgEmployeeRoles,
|
||||
updateOrgEmployeeWecomUserid,
|
||||
type OrgDept,
|
||||
type OrgEmployee,
|
||||
type OrgPlatformUser,
|
||||
} from '@/api/org-center'
|
||||
import { unwrap } from '@/api/training'
|
||||
import {
|
||||
expandRoles,
|
||||
fetchRoleDict,
|
||||
getMyProfile,
|
||||
roleLabelOf,
|
||||
unwrap,
|
||||
type TrainingRoleDef,
|
||||
type WecomSyncConflict,
|
||||
type WecomSyncSummary,
|
||||
} from '@/api/training'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import ResourceIcon from '@/components/icons/ResourceIcon.vue'
|
||||
|
||||
const authStore = useAuthStore()
|
||||
const loading = ref(false)
|
||||
const saving = ref(false)
|
||||
const depts = ref<OrgDept[]>([])
|
||||
const employees = ref<OrgEmployee[]>([])
|
||||
const platformUsers = ref<OrgPlatformUser[]>([])
|
||||
|
||||
// 员工查找(需求:按名称/工号/部门);keyword 走后端 ListEmployees 的过滤。
|
||||
const keyword = ref('')
|
||||
|
||||
const deptFormVisible = ref(false)
|
||||
const importVisible = ref(false)
|
||||
// id 为空表示新增,否则为修改(后端 saveDept 的 upsert 语义)。
|
||||
@@ -193,6 +304,119 @@ const pickerPost = ref('')
|
||||
const employeeFormVisible = ref(false)
|
||||
const employeeForm = ref({ id: '', user_name: '', employee_no: '', dept_id: '', post: '', status: 'active' })
|
||||
|
||||
// ---- 职称角色 / 企微账号(自培训域「职称角色」页迁入) ----
|
||||
|
||||
// 角色字典(配置中心 role_dict):弹窗选项与角色标签文案的来源
|
||||
const roleDict = ref<TrainingRoleDef[]>([])
|
||||
// 本人职称角色(权限门控口径与培训页一致:人事/经理/空间管理员可维护)
|
||||
const rawRoles = ref<string[]>([])
|
||||
const myRoles = computed(() => expandRoles(rawRoles.value, roleDict.value))
|
||||
const canManage = computed(
|
||||
() => authStore.hasRole('admin') || myRoles.value.some((r) => r === 'hr' || r === 'exec'),
|
||||
)
|
||||
|
||||
const rolesVisible = ref(false)
|
||||
const activeEmployee = ref<OrgEmployee | null>(null)
|
||||
const roleSelection = ref<string[]>([])
|
||||
const savingRoles = ref(false)
|
||||
|
||||
const wecomVisible = ref(false)
|
||||
const activeWecomEmployee = ref<OrgEmployee | 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 previewOrgWecomSync()
|
||||
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 applyOrgWecomSync()
|
||||
const summary = unwrap(res)
|
||||
MessagePlugin.success(`已写入 ${summary?.updated ?? 0} 条企微绑定`)
|
||||
syncVisible.value = false
|
||||
loadEmployees()
|
||||
} catch (err: any) {
|
||||
MessagePlugin.error(err?.response?.data?.message || '写入失败')
|
||||
} finally {
|
||||
syncing.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const openRoles = (row: OrgEmployee) => {
|
||||
activeEmployee.value = row
|
||||
roleSelection.value = (row.roles || []).filter((r) => r !== 'trainee')
|
||||
rolesVisible.value = true
|
||||
}
|
||||
|
||||
const onSaveRoles = async () => {
|
||||
if (!activeEmployee.value) return
|
||||
savingRoles.value = true
|
||||
try {
|
||||
// 学员角色为全员隐式默认,保存时总是带回去(与后端口径一致)。
|
||||
await updateOrgEmployeeRoles(activeEmployee.value.id, [...roleSelection.value, 'trainee'])
|
||||
MessagePlugin.success('角色已更新')
|
||||
rolesVisible.value = false
|
||||
loadEmployees()
|
||||
} catch (err: any) {
|
||||
MessagePlugin.error(err?.response?.data?.message || '保存失败')
|
||||
} finally {
|
||||
savingRoles.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const openWecom = (row: OrgEmployee) => {
|
||||
activeWecomEmployee.value = row
|
||||
wecomInput.value = row.wecom_userid || ''
|
||||
wecomVisible.value = true
|
||||
}
|
||||
|
||||
const onSaveWecom = async () => {
|
||||
if (!activeWecomEmployee.value) return
|
||||
savingWecom.value = true
|
||||
try {
|
||||
await updateOrgEmployeeWecomUserid(activeWecomEmployee.value.id, wecomInput.value.trim())
|
||||
MessagePlugin.success('企微账号已更新')
|
||||
wecomVisible.value = false
|
||||
loadEmployees()
|
||||
} catch (err: any) {
|
||||
MessagePlugin.error(err?.response?.data?.message || '保存失败')
|
||||
} finally {
|
||||
savingWecom.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 角色 tag 文案取字典短名,字典外(trainee/已删角色)回退固定文案或 key
|
||||
const roleText = (r: string) => roleLabelOf(r, roleDict.value, true)
|
||||
|
||||
const deptColumns = [
|
||||
{ colKey: 'name', title: '部门名称' },
|
||||
{ colKey: 'code', title: '编码', width: 140 },
|
||||
@@ -200,15 +424,18 @@ const deptColumns = [
|
||||
{ colKey: 'op', title: '操作', width: 140, fixed: 'right' },
|
||||
]
|
||||
|
||||
const employeeColumns = [
|
||||
// 管理角色额外有「企微账号/设置角色」操作,操作列随之加宽(computed 随权限就绪刷新)
|
||||
const employeeColumns = computed(() => [
|
||||
{ colKey: 'employee_no', title: '工号', width: 90 },
|
||||
{ colKey: 'user_name', title: '姓名' },
|
||||
{ colKey: 'dept_name', title: '部门', width: 110 },
|
||||
{ colKey: 'post', title: '岗位', width: 140 },
|
||||
{ colKey: 'status', title: '状态', width: 76 },
|
||||
// 列总宽超出面板宽度时固定在右侧,避免"修改"按钮被横向滚动挤出可视区
|
||||
{ colKey: 'op', title: '操作', width: 84, fixed: 'right' },
|
||||
]
|
||||
{ colKey: 'user_name', title: '姓名', width: 110 },
|
||||
{ colKey: 'dept_name', title: '部门', width: 100 },
|
||||
{ colKey: 'post', title: '岗位', width: 120 },
|
||||
{ colKey: 'wecom_userid', title: '企微账号', width: 110 },
|
||||
{ colKey: 'roles', title: '职称角色' },
|
||||
{ colKey: 'status', title: '状态', width: 70 },
|
||||
// 列总宽超出面板宽度时固定在右侧,避免操作按钮被横向滚动挤出可视区
|
||||
{ colKey: 'op', title: '操作', width: canManage.value ? 200 : 84, fixed: 'right' },
|
||||
])
|
||||
|
||||
// 姓名 = 真实姓名(来自 OIDC displayName claim):优先取后端联查的 user_name,
|
||||
// 再用平台用户表的 display_name / username 兜底;都取不到展示「-」,不回退展示用户ID。
|
||||
@@ -249,23 +476,53 @@ watch(pickerUserIds, (ids) => {
|
||||
if (deptId) pickerDeptId.value = deptId
|
||||
})
|
||||
|
||||
const loadAll = async () => {
|
||||
// 员工列表:module_key='training' 联查职称角色展示;keyword 按姓名/工号/部门过滤。
|
||||
const loadEmployees = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
// 平台用户一并拉取,用于姓名兜底联查(user_id → 用户名)。
|
||||
const [d, e, u] = await Promise.all([
|
||||
listDepts(),
|
||||
listEmployees({ page_size: 500 }),
|
||||
listPlatformUsers().catch(() => null),
|
||||
])
|
||||
depts.value = unwrap(d) || []
|
||||
const e = await listEmployees({
|
||||
module_key: ORG_MODULE_TRAINING,
|
||||
keyword: keyword.value.trim() || undefined,
|
||||
page_size: 500,
|
||||
})
|
||||
employees.value = unwrap(e)?.items || []
|
||||
platformUsers.value = unwrap(u) || []
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 输入防抖触发查找(enter/clear 立即触发由模板回调完成)
|
||||
let searchTimer: ReturnType<typeof setTimeout> | undefined
|
||||
watch(keyword, () => {
|
||||
clearTimeout(searchTimer)
|
||||
searchTimer = setTimeout(() => loadEmployees(), 300)
|
||||
})
|
||||
|
||||
const loadAll = async () => {
|
||||
// 平台用户一并拉取,用于姓名兜底联查(user_id → 用户名)。
|
||||
const [d, u] = await Promise.all([
|
||||
listDepts(),
|
||||
listPlatformUsers().catch(() => null),
|
||||
])
|
||||
depts.value = unwrap(d) || []
|
||||
platformUsers.value = unwrap(u) || []
|
||||
await loadEmployees()
|
||||
}
|
||||
|
||||
// 本人职称角色(人事/经理/空间管理员可维护;口径与培训页 canManageConfig 一致)
|
||||
const loadProfile = async () => {
|
||||
try {
|
||||
const res = await getMyProfile() as any
|
||||
const member: OrgEmployee | undefined = res?.data?.data || res?.data
|
||||
if (member) {
|
||||
rawRoles.value = (member.roles as unknown as string[]) || ['trainee']
|
||||
}
|
||||
} catch {
|
||||
// 取不到档案按纯学员兜底:仅隐藏维护入口,不影响页面其余功能。
|
||||
rawRoles.value = ['trainee']
|
||||
}
|
||||
}
|
||||
|
||||
const openCreateDept = () => {
|
||||
deptForm.value = { id: '', parent_id: '', sort: 0, name: '', code: '' }
|
||||
deptFormVisible.value = true
|
||||
@@ -349,7 +606,7 @@ const onPickImport = async () => {
|
||||
pickerVisible.value = false
|
||||
pickerUserIds.value = []
|
||||
pickerDeptId.value = ''
|
||||
loadAll()
|
||||
loadEmployees()
|
||||
} catch {
|
||||
MessagePlugin.error('添加失败')
|
||||
} finally {
|
||||
@@ -385,7 +642,7 @@ const onSaveEmployee = async () => {
|
||||
})
|
||||
MessagePlugin.success('员工档案已更新')
|
||||
employeeFormVisible.value = false
|
||||
loadAll()
|
||||
loadEmployees()
|
||||
} catch {
|
||||
MessagePlugin.error('保存失败')
|
||||
} finally {
|
||||
@@ -430,7 +687,7 @@ const onImport = async () => {
|
||||
MessagePlugin.success(`已导入 ${unwrap(res)?.imported ?? 0} 名员工`)
|
||||
importVisible.value = false
|
||||
importText.value = ''
|
||||
loadAll()
|
||||
loadEmployees()
|
||||
} catch {
|
||||
MessagePlugin.error('导入失败,请检查部门是否为已维护部门')
|
||||
} finally {
|
||||
@@ -438,7 +695,13 @@ const onImport = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(loadAll)
|
||||
onMounted(() => {
|
||||
loadAll()
|
||||
loadProfile()
|
||||
fetchRoleDict().then((d) => {
|
||||
roleDict.value = d
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
@@ -498,4 +761,51 @@ onMounted(loadAll)
|
||||
word-break: break-all;
|
||||
line-height: 1.4;
|
||||
}
|
||||
// 员工面板头部工具条:提示文案 + 查找框 + 动作按钮(窄屏折行)
|
||||
.org-employees__actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
justify-content: flex-end;
|
||||
min-width: 0;
|
||||
}
|
||||
.org-employees__hint {
|
||||
color: var(--td-text-color-placeholder);
|
||||
font-size: var(--app-text-sm);
|
||||
}
|
||||
.org-employees__search {
|
||||
width: 200px;
|
||||
}
|
||||
.oa-sync-btn {
|
||||
white-space: nowrap;
|
||||
}
|
||||
.role-tag {
|
||||
margin-right: 4px;
|
||||
}
|
||||
.wecom-missing {
|
||||
color: var(--td-text-color-placeholder);
|
||||
}
|
||||
.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;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user