feat(signing): 勾选项默认不带名称并支持空名称字段
This commit is contained in:
@@ -88,7 +88,20 @@ const AUTO_FILL_LABELS = ['患者姓名', '性别', '年龄', '就诊号', '与
|
||||
* kind 必须逐项写死:这三项在目录里都查不到,兜底出来的类型不会自己变成想要的那个
|
||||
* (findPreset 只认目录与签名),一律兜成 checkbox 会让填写项插出来是个勾选框。
|
||||
*/
|
||||
const MANUAL_BUTTONS: Array<{ label: string; kind: SigningFieldKind; title: string }> = [
|
||||
const MANUAL_BUTTONS: Array<{
|
||||
/** 按钮文案(也是 findPreset 的查找键) */
|
||||
label: string
|
||||
kind: SigningFieldKind
|
||||
title: string
|
||||
/**
|
||||
* 插入时的默认字段名。
|
||||
*
|
||||
* 勾选项刻意给空串:正文里就只显示一个方框,不挂名称——这一处在勾什么由旁边的
|
||||
* 文字交代(表格的其它列、正文的上一句),自带名称只会把版面挤开。想写名字时
|
||||
* 在「填写项配置」里填即可(见 applyFieldDraft 对选择类放开名称校验)。
|
||||
*/
|
||||
fieldLabel?: string
|
||||
}> = [
|
||||
{
|
||||
label: '签名',
|
||||
kind: 'signature',
|
||||
@@ -97,7 +110,8 @@ const MANUAL_BUTTONS: Array<{ label: string; kind: SigningFieldKind; title: stri
|
||||
{
|
||||
label: '勾选项',
|
||||
kind: 'checkbox',
|
||||
title: '签署时由患者逐项勾选;点正文里的胶囊可配置多个选项',
|
||||
title: '签署时由患者逐项勾选;默认不带名称,点正文里的胶囊可配名称与多个选项',
|
||||
fieldLabel: '',
|
||||
},
|
||||
{
|
||||
label: '填写项',
|
||||
@@ -127,12 +141,12 @@ const autoFillButtons = computed(() =>
|
||||
)
|
||||
|
||||
const manualButtons = computed(() =>
|
||||
MANUAL_BUTTONS.map(({ label, kind, title }) => ({
|
||||
MANUAL_BUTTONS.map(({ label, kind, title, fieldLabel }) => ({
|
||||
label,
|
||||
title,
|
||||
field: findPreset(label) ?? {
|
||||
id: `custom:${label}`,
|
||||
label,
|
||||
id: `custom:${fieldLabel ?? label}`,
|
||||
label: fieldLabel ?? label,
|
||||
kind,
|
||||
required: false,
|
||||
options: [],
|
||||
@@ -313,7 +327,12 @@ function insertField(field: SigningFieldDef) {
|
||||
required: false,
|
||||
}
|
||||
: field.id.startsWith('custom:')
|
||||
? { ...field, id: allocateCustomFieldId(valueHtml.value, field.label) }
|
||||
? {
|
||||
...field,
|
||||
// 空名称(勾选项默认无名)也要有一个可读、唯一的字段键做身份:用类型名兜底,
|
||||
// 避免落成 `custom:` 这种空键——读回时容易被当成名称,也说不清是哪一项。
|
||||
id: allocateCustomFieldId(valueHtml.value, field.label || field.kind),
|
||||
}
|
||||
: field
|
||||
|
||||
paneRef.value?.insertField(target)
|
||||
@@ -336,7 +355,9 @@ function applyFieldDraft() {
|
||||
|
||||
const label = fieldDraft.label.trim()
|
||||
|
||||
if (!label) {
|
||||
// 勾选 / 选择类允许无名(正文里只显示一个方框);文本、日期、签名仍必须有名,
|
||||
// 否则签署端根本认不出这一项是什么。
|
||||
if (!label && !isOptionKind.value) {
|
||||
setMessage('请填写填写项名称', 'warn')
|
||||
return false
|
||||
}
|
||||
@@ -376,7 +397,10 @@ function applyFieldDraft() {
|
||||
}
|
||||
|
||||
if (fieldDraft.kind === 'choice' && options.length < 2) {
|
||||
setMessage(`选择项「${label}」至少需要两个选项`, 'warn')
|
||||
setMessage(
|
||||
`选择项「${label || SIGNING_FIELD_KIND_LABELS[fieldDraft.kind]}」至少需要两个选项`,
|
||||
'warn',
|
||||
)
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -397,7 +421,8 @@ function applyFieldDraft() {
|
||||
})
|
||||
|
||||
if (!changed) {
|
||||
setMessage(`正文里已经没有「${field.label}」了,请重新选择要修改的填写项`, 'warn')
|
||||
const name = field.label || SIGNING_FIELD_KIND_LABELS[field.kind]
|
||||
setMessage(`正文里已经没有「${name}」了,请重新选择要修改的填写项`, 'warn')
|
||||
selectedFieldId.value = ''
|
||||
return false
|
||||
}
|
||||
@@ -423,7 +448,8 @@ function removeField() {
|
||||
const changed = paneRef.value?.removeField(field.id) ?? 0
|
||||
|
||||
selectedFieldId.value = ''
|
||||
setMessage(`已删除「${field.label}」(正文里 ${changed} 处)`, 'ok')
|
||||
const name = field.label || SIGNING_FIELD_KIND_LABELS[field.kind]
|
||||
setMessage(`已删除「${name}」(正文里 ${changed} 处)`, 'ok')
|
||||
}
|
||||
|
||||
/** 正文字数与填写项个数(原型 deStat) */
|
||||
@@ -447,7 +473,8 @@ function validate(requireSignaturePosition = true): string | null {
|
||||
)
|
||||
|
||||
if (broken) {
|
||||
return `「${broken.label}」只配了一个选项,勾选类至少要两个(或删掉选项改成单个勾选框)`
|
||||
const name = broken.label || SIGNING_FIELD_KIND_LABELS[broken.kind]
|
||||
return `「${name}」只配了一个选项,勾选类至少要两个(或删掉选项改成单个勾选框)`
|
||||
}
|
||||
|
||||
const signatures = detectedFields.value.filter((field) => field.kind === 'signature')
|
||||
|
||||
Reference in New Issue
Block a user