feat(sign): 支持多位置签名并优化坐标识别与模板版本校验
This commit is contained in:
@@ -273,6 +273,7 @@ export function useSigningTaskForm(options: UseSigningTaskFormOptions) {
|
||||
const initialTemplate = getInitialTemplate()
|
||||
|
||||
if (
|
||||
isSigningMockEnabled &&
|
||||
initialTemplate &&
|
||||
!templates.value.some((template) => template.id === initialTemplate.id)
|
||||
) {
|
||||
@@ -396,23 +397,24 @@ export function useSigningTaskForm(options: UseSigningTaskFormOptions) {
|
||||
return
|
||||
}
|
||||
|
||||
if (loadedTemplateCampusId !== campusId) {
|
||||
if (loadedTemplateCampusId) {
|
||||
selectedTemplateId.value = ''
|
||||
selectedDepartment.value = ''
|
||||
selectedCategory.value = ''
|
||||
}
|
||||
if (loadedTemplateCampusId && loadedTemplateCampusId !== campusId) {
|
||||
selectedTemplateId.value = ''
|
||||
selectedDepartment.value = ''
|
||||
selectedCategory.value = ''
|
||||
}
|
||||
|
||||
loadingTemplates.value = true
|
||||
|
||||
try {
|
||||
templates.value = await getSigningTemplates({ campusId })
|
||||
loadedTemplateCampusId = campusId
|
||||
} catch {
|
||||
ElMessage.error('文档模板加载失败,请稍后重试')
|
||||
} finally {
|
||||
loadingTemplates.value = false
|
||||
}
|
||||
loadingTemplates.value = true
|
||||
try {
|
||||
// Publishing replaces the available version even within the same campus.
|
||||
const available = await getSigningTemplates({ campusId })
|
||||
if (toValue(options.campusId) !== campusId) return
|
||||
templates.value = available
|
||||
loadedTemplateCampusId = campusId
|
||||
} catch {
|
||||
templates.value = []
|
||||
ElMessage.error('文档模板加载失败,请稍后重试')
|
||||
} finally {
|
||||
loadingTemplates.value = false
|
||||
}
|
||||
|
||||
includeInitialTemplate()
|
||||
@@ -526,7 +528,7 @@ export function useSigningTaskForm(options: UseSigningTaskFormOptions) {
|
||||
return true
|
||||
}
|
||||
|
||||
return collectFieldDefs(template.contentHtml).some((field) => field.id === 'signature')
|
||||
return collectFieldDefs(template.contentHtml).some((field) => field.kind === 'signature')
|
||||
}
|
||||
|
||||
const signatureMissingMessage = '该文书没有签名占位符,请先在文档库中补上签名位再发起'
|
||||
@@ -651,6 +653,28 @@ export function useSigningTaskForm(options: UseSigningTaskFormOptions) {
|
||||
submitting.value = true
|
||||
|
||||
try {
|
||||
if (!isSigningMockEnabled) {
|
||||
const selected = selectedTemplate.value
|
||||
const campusId = toValue(options.campusId)
|
||||
if (!campusId) throw new Error('请先选择院区')
|
||||
const available = await getSigningTemplates({ campusId })
|
||||
if (
|
||||
toValue(options.campusId) !== campusId ||
|
||||
selectedTemplate.value?.versionId !== selected.versionId
|
||||
)
|
||||
throw new Error('院区或文书选择已变化,请核对后重新提交')
|
||||
const current = available.find((template) => template.id === selected.id)
|
||||
if (!current || current.versionId !== selected.versionId) {
|
||||
templates.value = available
|
||||
Object.keys(staffAnswers).forEach((key) => delete staffAnswers[key])
|
||||
createTaskIdempotencyKey = newIdempotencyKey()
|
||||
errors.document = current
|
||||
? `文书已更新为 ${current.version},请核对新版正文并重新填写后再发起签署。`
|
||||
: '该文书已停用或暂无可用版本,请重新选择文书。'
|
||||
ElMessage.warning(errors.document)
|
||||
return null
|
||||
}
|
||||
}
|
||||
const task = await createSigningTask({
|
||||
campus: toValue(options.campus),
|
||||
patientId: patient.value.id,
|
||||
|
||||
Reference in New Issue
Block a user