fix(培训课程):优化培训课程

This commit is contained in:
runny committed 2026-11-17 08:21:59 +08:00
1 parent e378e8b7fd
commit aae041a0b4
19 files changed
+777 -188

No files matched your search

+85 -5
View File
@@ -48,8 +48,14 @@
<template #dept_name="{ row }">{{ row.dept_name || '-' }}</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>
<t-tag v-else theme="default" variant="light" size="small">{{ row.status || '-' }}</t-tag>
</template>
<template #op="{ row }">
<div class="op-group">
<t-button variant="text" theme="primary" size="small" @click="onEditEmployee(row)">修改</t-button>
</div>
</template>
</t-table>
</div>
</div>
@@ -114,6 +120,36 @@
<t-button theme="primary" :loading="saving" :disabled="!pickerUserIds.length || !pickerDeptId" @click="onPickImport">添加到名册</t-button>
</template>
</t-dialog>
<!-- 修改员工档案:部门/岗位/状态可编辑;姓名与工号随平台账号只读展示 -->
<t-dialog v-model:visible="employeeFormVisible" header="修改员工档案" width="460">
<t-form label-width="80">
<t-form-item label="姓名">
<t-input :value="employeeForm.user_name || '-'" readonly />
</t-form-item>
<t-form-item label="工号">
<t-input :value="employeeForm.employee_no || '-'" readonly />
</t-form-item>
<t-form-item label="部门" required>
<t-select v-model="employeeForm.dept_id" filterable placeholder="必选,请从左侧部门中选择" style="width: 100%">
<t-option v-for="d in depts" :key="d.id" :value="d.id" :label="d.name" />
</t-select>
</t-form-item>
<t-form-item label="岗位">
<t-input v-model="employeeForm.post" placeholder="如 设备技师" />
</t-form-item>
<t-form-item label="状态">
<t-select v-model="employeeForm.status" style="width: 100%">
<t-option value="active" label="在职" />
<t-option value="inactive" label="离职" />
</t-select>
</t-form-item>
</t-form>
<div class="form-hint">姓名与工号随平台账号维护,不在修改范围。</div>
<template #footer>
<t-button theme="primary" :loading="saving" @click="onSaveEmployee">保存</t-button>
</template>
</t-dialog>
</div>
</template>
@@ -127,6 +163,7 @@ import {
listEmployees,
listPlatformUsers,
saveDept,
updateEmployee,
type OrgDept,
type OrgEmployee,
type OrgPlatformUser,
@@ -152,18 +189,25 @@ const pickerUserIds = ref<string[]>([])
const pickerDeptId = ref('')
const pickerPost = ref('')
// 员工档案修改(姓名/工号随平台账号,只读;部门/岗位/状态可编辑)
const employeeFormVisible = ref(false)
const employeeForm = ref({ id: '', user_name: '', employee_no: '', dept_id: '', post: '', status: 'active' })
const deptColumns = [
{ colKey: 'name', title: '部门名称' },
{ colKey: 'code', title: '编码', width: 140 },
{ colKey: 'op', title: '操作', width: 140 },
// 窄屏下列宽超出面板时操作列随滚动固定在右侧,保证可见可点
{ colKey: 'op', title: '操作', width: 140, fixed: 'right' },
]
const employeeColumns = [
{ colKey: 'employee_no', title: '工号', width: 100 },
{ colKey: 'employee_no', title: '工号', width: 90 },
{ colKey: 'user_name', title: '姓名' },
{ colKey: 'dept_name', title: '部门', width: 120 },
{ colKey: 'post', title: '岗位', width: 150 },
{ colKey: 'status', title: '状态', width: 80 },
{ colKey: 'dept_name', title: '部门', width: 110 },
{ colKey: 'post', title: '岗位', width: 140 },
{ colKey: 'status', title: '状态', width: 76 },
// 列总宽超出面板宽度时固定在右侧,避免"修改"按钮被横向滚动挤出可视区
{ colKey: 'op', title: '操作', width: 84, fixed: 'right' },
]
// 姓名 = 真实姓名(来自 OIDC displayName claim):优先取后端联查的 user_name,
@@ -283,6 +327,42 @@ const onPickImport = async () => {
}
}
// 修改员工档案:回填当前行(姓名经 employeeName 联查兜底)。
const onEditEmployee = (row: OrgEmployee) => {
employeeForm.value = {
id: row.id,
user_name: employeeName(row),
employee_no: row.employee_no || '',
dept_id: row.dept_id || '',
post: row.post || '',
status: row.status || 'active',
}
employeeFormVisible.value = true
}
const onSaveEmployee = async () => {
// 部门必填,且必须命中左侧部门(与导入同规)。
if (!employeeForm.value.dept_id) {
MessagePlugin.warning('请选择部门')
return
}
saving.value = true
try {
await updateEmployee(employeeForm.value.id, {
dept_id: employeeForm.value.dept_id,
post: employeeForm.value.post.trim(),
status: employeeForm.value.status,
})
MessagePlugin.success('员工档案已更新')
employeeFormVisible.value = false
loadAll()
} catch {
MessagePlugin.error('保存失败')
} finally {
saving.value = false
}
}
// 按名称/编码/ID 把导入行里的部门解析成部门列表的 dept id。
const resolveDeptId = (raw?: string) => {
const key = (raw || '').trim()