merge: 合并远程更新并保留签名与报表接入

This commit is contained in:
xy
2026-09-30 18:31:36 +08:00
14 changed files with 577 additions and 512 deletions
@@ -1,4 +1,4 @@
import { computed, reactive, ref, toValue, watch, type MaybeRefOrGetter } from 'vue'
import { computed, reactive, ref, toValue, type MaybeRefOrGetter } from 'vue'
import { ElMessage } from 'element-plus'
import { sendSigningSms } from '@/api/workbench/deliveries'
@@ -15,7 +15,6 @@ import type {
PatientProfile,
PatientVisit,
SigningMethod,
SigningFormField,
SigningTaskRecord,
SigningTemplate,
WorkbenchCampus,
@@ -70,10 +69,6 @@ export function useSigningTaskForm(options: UseSigningTaskFormOptions) {
const selectedVisitId = ref('')
const method = ref<SigningMethod>('pad')
const smsDestination = ref('')
const staffAnswers = reactive<Record<string, string>>({})
const signerType = ref<'SELF' | 'FAMILY'>('SELF')
const signerName = ref('')
const signerRelation = ref('')
const loadingTemplates = ref(false)
const locating = ref(false)
const submitting = ref(false)
@@ -93,8 +88,6 @@ export function useSigningTaskForm(options: UseSigningTaskFormOptions) {
visit: '',
document: '',
sms: '',
staffAnswers: '',
signer: '',
})
/** 演示候选患者(真实模式为空数组,候选下拉自然不出现) */
@@ -108,30 +101,6 @@ export function useSigningTaskForm(options: UseSigningTaskFormOptions) {
() => templates.value.find((template) => template.id === selectedTemplateId.value) ?? null,
)
const manualFormFields = computed(() => {
const systemFields = new Set([
'patient',
'sex',
'age',
'visit',
'phone',
'doctor',
'signedDate',
])
return (selectedTemplate.value?.formFields ?? []).filter(
(field) =>
field.kind !== 'signature' &&
field.kind !== 'checkbox' &&
field.kind !== 'choice' &&
!systemFields.has(field.id),
)
})
watch(selectedTemplateId, () => {
Object.keys(staffAnswers).forEach((key) => delete staffAnswers[key])
errors.staffAnswers = ''
})
/** 关联处方:随选中就诊带出(仅演示数据) */
const prescription = computed<LinkedPrescription | null>(() =>
isSigningMockEnabled ? buildLinkedPrescription(selectedVisit.value) : null,
@@ -341,8 +310,6 @@ export function useSigningTaskForm(options: UseSigningTaskFormOptions) {
errors.visit = ''
errors.document = ''
errors.sms = ''
errors.staffAnswers = ''
errors.signer = ''
}
function resetForm() {
@@ -356,10 +323,6 @@ export function useSigningTaskForm(options: UseSigningTaskFormOptions) {
selectedVisitId.value = ''
method.value = initialTemplate?.supportedMethods[0] ?? 'pad'
smsDestination.value = ''
Object.keys(staffAnswers).forEach((key) => delete staffAnswers[key])
signerType.value = 'SELF'
signerName.value = ''
signerRelation.value = ''
phonePlain.value = false
suggestionOpen.value = false
selectedDepartment.value = ''
@@ -377,10 +340,6 @@ export function useSigningTaskForm(options: UseSigningTaskFormOptions) {
selectedTemplateId.value = initialTemplate?.id ?? ''
method.value = initialTemplate?.supportedMethods[0] ?? method.value
smsDestination.value = ''
Object.keys(staffAnswers).forEach((key) => delete staffAnswers[key])
signerType.value = 'SELF'
signerName.value = ''
signerRelation.value = ''
errors.document = ''
errors.sms = ''
createTaskIdempotencyKey = newIdempotencyKey()
@@ -583,18 +542,6 @@ export function useSigningTaskForm(options: UseSigningTaskFormOptions) {
return `${value.slice(0, 3)}****${value.slice(-4)}`
}
function toggleStaffAnswerOption(fieldId: string, option: string, checked: boolean) {
const selected = (staffAnswers[fieldId] ?? '').split('、').filter(Boolean)
const next = checked
? [...new Set([...selected, option])]
: selected.filter((item) => item !== option)
staffAnswers[fieldId] = next.join('、')
}
function staffAnswerHasOption(fieldId: string, option: string) {
return (staffAnswers[fieldId] ?? '').split('、').includes(option)
}
function validate() {
clearErrors()
let valid = true
@@ -626,22 +573,6 @@ export function useSigningTaskForm(options: UseSigningTaskFormOptions) {
}
}
const missingField = manualFormFields.value.find(
(field: SigningFormField) => field.required && !staffAnswers[field.id]?.trim(),
)
if (missingField) {
errors.staffAnswers = `请填写必填项:${missingField.label}`
valid = false
}
if (
signerType.value === 'FAMILY' &&
(!signerName.value.trim() || !signerRelation.value.trim())
) {
errors.signer = '家属代签必须填写签署人姓名和与患者关系'
valid = false
}
return valid
}
@@ -689,10 +620,11 @@ export function useSigningTaskForm(options: UseSigningTaskFormOptions) {
documentContentHtml: selectedTemplate.value.contentHtml,
// 需科室确认由文书模板标记带出(原型 V6.9 起弹窗里不再让人选)
needConfirm: selectedTemplate.value.needConfirm ?? false,
staffAnswers: { ...staffAnswers },
signerType: signerType.value,
signerName: signerType.value === 'FAMILY' ? signerName.value.trim() : patient.value.name,
signerRelation: signerType.value === 'FAMILY' ? signerRelation.value.trim() : '本人',
// 签署人固定为患者本人:发起弹窗不再采集签署人 / 代签信息,
// 后端仍按这三个字段接收(接口中均为可选)。
signerType: 'SELF',
signerName: patient.value.name,
signerRelation: '本人',
idempotencyKey: createTaskIdempotencyKey,
})
@@ -750,13 +682,6 @@ export function useSigningTaskForm(options: UseSigningTaskFormOptions) {
selectedVisit,
selectedVisitId,
smsDestination,
staffAnswers,
manualFormFields,
signerType,
signerName,
signerRelation,
staffAnswerHasOption,
toggleStaffAnswerOption,
submit,
submitting,
suggestionOpen,