feat(gerp): 员工档案填写自动带出部门员工关联并隐藏该字段
用户详情页「点击填写/编辑」档案时,按本页 UserUUID 查该员工的主「部门员工关联」自动填充(取值即落库,后端解析出员工与部门),并隐藏表单里的选择器;查不到时(该员工尚未挂靠部门)仍显示选择器供手动选。
This commit is contained in:
1 parent
6bb1edba88
commit
bf94cecea6
1 file changed
+54
-5
@@ -255,7 +255,9 @@ const profileFormColumns = computed(() =>
|
||||
c.type !== 'divider' &&
|
||||
c.type !== 'html' &&
|
||||
c.field !== 'EmployeeProfileUUID' &&
|
||||
c.field !== 'UserUUID',
|
||||
c.field !== 'UserUUID' &&
|
||||
// 部门员工关联:按本页员工自动带出后隐藏(查不到时才显示让用户手动选)
|
||||
!(profilePickerHidden.value && c.field === 'UserRoleDepartmentUUID'),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -329,21 +331,68 @@ async function loadProfile(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
/** 「点击填写」:新建档案(UserUUID 由本页上下文注入,表单内不出现该字段) */
|
||||
function openProfileCreate(): void {
|
||||
/** 本页员工的「部门员工关联」(UserRoleDepartment):档案归属自动带出,取值即落库 */
|
||||
const profileDeptEmployee = ref<{ uuid: string; label: string } | null>(null)
|
||||
|
||||
/** 表单里是否隐藏「部门员工关联」:已按本页员工自动带出时无需用户再选 */
|
||||
const profilePickerHidden = computed(() => !!profileDeptEmployee.value)
|
||||
|
||||
/**
|
||||
* 拉取该员工的主「部门员工关联」:档案归属由本页员工决定,无需用户在表单里再选。
|
||||
* 查不到(该员工尚未挂靠任何部门)时返回 null —— 此时表单仍显示选择器让用户手动选。
|
||||
*/
|
||||
async function loadProfileDeptEmployee(): Promise<void> {
|
||||
profileDeptEmployee.value = null
|
||||
if (!userUUID.value) return
|
||||
try {
|
||||
const res = await formApi.list<Record<string, any>>('UserRoleDepartment', {
|
||||
UserUUID: userUUID.value,
|
||||
page: 1,
|
||||
pageSize: 1,
|
||||
})
|
||||
const list = Array.isArray(res)
|
||||
? res
|
||||
: ((res as { records?: Record<string, any>[]; list?: Record<string, any>[] })?.records
|
||||
?? (res as { list?: Record<string, any>[] })?.list
|
||||
?? [])
|
||||
const row = list[0]
|
||||
if (!row?.UserRoleDepartmentUUID) return
|
||||
const dept = String(row.DeptUUID_label ?? '')
|
||||
const user = String(row.UserUUID_label ?? '')
|
||||
profileDeptEmployee.value = {
|
||||
uuid: String(row.UserRoleDepartmentUUID),
|
||||
label: dept && user ? `${dept} · ${user}` : dept || user || String(row.UserRoleDepartmentUUID),
|
||||
}
|
||||
} catch {
|
||||
// 查询失败不阻塞填写:表单里的「部门员工关联」选择器仍在,用户可手动选
|
||||
}
|
||||
}
|
||||
|
||||
/** 「点击填写」:新建档案(UserUUID 由本页上下文注入;部门员工关联自动带出后隐藏) */
|
||||
async function openProfileCreate(): Promise<void> {
|
||||
if (!canEditProfile.value) return
|
||||
Object.keys(profileForm).forEach((k) => delete profileForm[k])
|
||||
profileForm.UserUUID = userUUID.value
|
||||
await loadProfileDeptEmployee()
|
||||
if (profileDeptEmployee.value) {
|
||||
profileForm.UserRoleDepartmentUUID = profileDeptEmployee.value.uuid
|
||||
profileForm.UserRoleDepartmentUUID_label = profileDeptEmployee.value.label
|
||||
}
|
||||
profileIsEdit.value = false
|
||||
profileDialogVisible.value = true
|
||||
}
|
||||
|
||||
/** 「编辑」:回填现有档案 */
|
||||
function openProfileEdit(): void {
|
||||
/** 「编辑」:回填现有档案(同样自动带出部门员工关联并隐藏该字段) */
|
||||
async function openProfileEdit(): Promise<void> {
|
||||
if (!canEditProfile.value || !profileRecord.value) return
|
||||
Object.keys(profileForm).forEach((k) => delete profileForm[k])
|
||||
Object.assign(profileForm, profileRecord.value)
|
||||
profileForm.UserUUID = userUUID.value
|
||||
await loadProfileDeptEmployee()
|
||||
if (profileDeptEmployee.value && !profileForm.UserRoleDepartmentUUID) {
|
||||
profileForm.UserRoleDepartmentUUID = profileDeptEmployee.value.uuid
|
||||
profileForm.UserRoleDepartmentUUID_label = profileDeptEmployee.value.label
|
||||
}
|
||||
profileIsEdit.value = true
|
||||
profileDialogVisible.value = true
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user