feat(gerp): 档案表单未解锁时身份证禁用并提示
- 新增 ColumnSchema.tip 与 CrudFormPanel 提示行渲染 - CrudTable 新增 columnOverrides:父页面可按运行态覆盖表单列属性(仅表单,不影响表格) - 档案页未解锁时身份证输入框禁用 + 提示「需验证密码才能查看/修改」,其余字段照常可改
This commit is contained in:
1 parent
e62aa86dd7
commit
e2006534be
4 files changed
+51
-1
No files matched your search
@@ -314,6 +314,8 @@ watch(
|
||||
readonly
|
||||
/>
|
||||
<!-- hidden/divider/html 不渲染表单项 -->
|
||||
<!-- 字段说明/提示:敏感字段(如身份证)未解锁时给出明确提示 -->
|
||||
<div v-if="col.tip" class="form-field-tip">{{ col.tip }}</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
@@ -323,3 +325,14 @@ watch(
|
||||
</template>
|
||||
</component>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
/* 字段说明/提示行:占满整行、灰色小字 */
|
||||
.form-field-tip {
|
||||
width: 100%;
|
||||
margin-top: 4px;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
</style>
|
||||
@@ -97,6 +97,12 @@ const props = withDefaults(defineProps<{
|
||||
* (弹窗内再叠抽屉会错位,如应用市场的"应用-职务绑定"弹窗)。
|
||||
*/
|
||||
formMode?: 'dialog' | 'drawer'
|
||||
/**
|
||||
* 表单列运行态覆盖(按字段名 → 覆盖部分列属性):
|
||||
* 父页面可按运行态调整某些字段的表单表现,如未解锁时把敏感字段 IdCard 置为
|
||||
* disabled 并加 tip 提示;仅作用于新增/编辑表单,不影响表格单元格渲染。
|
||||
*/
|
||||
columnOverrides?: Record<string, Partial<ColumnSchema>>
|
||||
}>(), {
|
||||
// editable 必须显式给默认值 true:Vue 会把「未传的 Boolean prop」强制转成 false,
|
||||
// 不给默认值时 props.editable 恒为 false,canEdit 判定失败 → 所有未传 editable 的
|
||||
@@ -208,6 +214,17 @@ const formColumns = computed(() => {
|
||||
.map((c: ColumnSchema) => (isAutoTimestampField(c.field) ? { ...c, required: false } : c))
|
||||
})
|
||||
|
||||
// 表单列叠加父页面的运行态覆盖(如未解锁时将身份证列禁用并给出提示文案):
|
||||
// 放在表单渲染前合并,表格单元格不受影响(列表仍显示后端返回的值/空)
|
||||
const effectiveFormColumns = computed(() => {
|
||||
const overrides = props.columnOverrides
|
||||
if (!overrides) return formColumns.value
|
||||
return formColumns.value.map((c) => {
|
||||
const override = overrides[c.field]
|
||||
return override ? { ...c, ...override } : c
|
||||
})
|
||||
})
|
||||
|
||||
// ===== 新增表单自动草稿(独立 composable:useDraftAutosave) =====
|
||||
// 防止误关闭/误刷新丢失录入内容;按表维度存 localStorage,
|
||||
// 再次打开"新增"时提示「恢复草稿 / 删除草稿」(空草稿直接丢弃,不打扰);提交成功后清除。
|
||||
@@ -871,7 +888,7 @@ defineExpose({
|
||||
:visible="dialogVisible"
|
||||
:title="dialogTitle"
|
||||
:submitting="submitting"
|
||||
:columns="formColumns"
|
||||
:columns="effectiveFormColumns"
|
||||
:form-model="editingRow"
|
||||
:mode="formMode"
|
||||
@update:visible="(v: boolean) => (dialogVisible = v)"
|
||||
|
||||
@@ -214,6 +214,8 @@ export interface ColumnSchema {
|
||||
defaultValue?: unknown
|
||||
/** 占位符 */
|
||||
placeholder?: string
|
||||
/** 表单控件下方的说明/提示文案(如敏感字段需解锁后才能查看/修改) */
|
||||
tip?: string
|
||||
|
||||
// === 数值约束 ===
|
||||
/** 最小值 */
|
||||
|
||||
@@ -15,6 +15,7 @@ import AdminBadge from '@/components/AdminBadge.vue'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { setPageTitle } from '@/utils/serverScope'
|
||||
import { ehrmIdCardApi } from '@/api/form'
|
||||
import type { ColumnSchema } from '@/types/api'
|
||||
|
||||
const userStore = useUserStore()
|
||||
setPageTitle('档案管理')
|
||||
@@ -29,6 +30,22 @@ const unlockDialogVisible = ref(false)
|
||||
const unlockPassword = ref('')
|
||||
const unlocking = ref(false)
|
||||
|
||||
/**
|
||||
* 未解锁时对新增/编辑表单里身份证列做运行态覆盖:
|
||||
* 禁用输入 + 明确提示「需验证密码才能查看/修改」,其它字段照常可改。
|
||||
* 解锁后返回空覆盖对象,身份证列恢复为普通可编辑文本。
|
||||
*/
|
||||
const columnOverrides = computed<Record<string, Partial<ColumnSchema>>>(() => {
|
||||
const overrides: Record<string, Partial<ColumnSchema>> = {}
|
||||
if (idCardUnlocked.value) return overrides
|
||||
overrides.IdCard = {
|
||||
disabled: true,
|
||||
placeholder: '需先验证密码才能查看/修改',
|
||||
tip: '身份证号需先点上方「查看身份证」验证密码后才能查看或修改;不验证不影响修改其它字段。',
|
||||
}
|
||||
return overrides
|
||||
})
|
||||
|
||||
/** 查询当前登录用户是否已处于解锁窗口内(页面刷新后恢复按钮状态) */
|
||||
async function loadIdCardStatus(): Promise<void> {
|
||||
try {
|
||||
@@ -80,6 +97,7 @@ onMounted(loadIdCardStatus)
|
||||
pageable
|
||||
stretch
|
||||
:selectable="isAdmin"
|
||||
:columnOverrides="columnOverrides"
|
||||
>
|
||||
<template #toolbar>
|
||||
<el-tag v-if="idCardUnlocked" type="success" effect="plain">身份证已解锁</el-tag>
|
||||
|
||||
Reference in new issue
Block a user