feat(workbench): 接入签署投递与产物管理
This commit is contained in:
@@ -1,7 +1,13 @@
|
||||
import { computed, reactive, ref, toValue, type MaybeRefOrGetter } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
|
||||
import { createSigningTask, getPatientProfile, getSigningTemplates } from '@/api/workbench/signing'
|
||||
import { sendSigningSms } from '@/api/workbench/deliveries'
|
||||
import {
|
||||
createSigningTask,
|
||||
getPatientProfile,
|
||||
getSigningTemplates,
|
||||
isSigningMockEnabled,
|
||||
} from '@/api/workbench/signing'
|
||||
import type {
|
||||
PatientProfile,
|
||||
PatientVisit,
|
||||
@@ -35,6 +41,7 @@ export function useSigningTaskForm(options: UseSigningTaskFormOptions) {
|
||||
const selectedTemplateId = ref('')
|
||||
const selectedVisitId = ref('')
|
||||
const method = ref<SigningMethod>('pad')
|
||||
const smsDestination = ref('')
|
||||
const loadingTemplates = ref(false)
|
||||
const locating = ref(false)
|
||||
const submitting = ref(false)
|
||||
@@ -43,6 +50,7 @@ export function useSigningTaskForm(options: UseSigningTaskFormOptions) {
|
||||
patient: '',
|
||||
visit: '',
|
||||
document: '',
|
||||
sms: '',
|
||||
})
|
||||
|
||||
const selectedVisit = computed(
|
||||
@@ -104,6 +112,7 @@ export function useSigningTaskForm(options: UseSigningTaskFormOptions) {
|
||||
errors.patient = ''
|
||||
errors.visit = ''
|
||||
errors.document = ''
|
||||
errors.sms = ''
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
@@ -116,6 +125,7 @@ export function useSigningTaskForm(options: UseSigningTaskFormOptions) {
|
||||
selectedTemplateId.value = initialTemplate?.id ?? ''
|
||||
selectedVisitId.value = ''
|
||||
method.value = initialTemplate?.supportedMethods[0] ?? 'pad'
|
||||
smsDestination.value = ''
|
||||
clearErrors()
|
||||
}
|
||||
|
||||
@@ -125,7 +135,9 @@ export function useSigningTaskForm(options: UseSigningTaskFormOptions) {
|
||||
documentSearch.value = ''
|
||||
selectedTemplateId.value = initialTemplate?.id ?? ''
|
||||
method.value = initialTemplate?.supportedMethods[0] ?? method.value
|
||||
smsDestination.value = ''
|
||||
errors.document = ''
|
||||
errors.sms = ''
|
||||
}
|
||||
|
||||
async function loadTemplates() {
|
||||
@@ -228,6 +240,15 @@ export function useSigningTaskForm(options: UseSigningTaskFormOptions) {
|
||||
valid = false
|
||||
}
|
||||
|
||||
if (!isSigningMockEnabled && method.value === 'sms') {
|
||||
const destination = smsDestination.value.trim().replace(/\s+/g, '')
|
||||
|
||||
if (!/^\+?[1-9]\d{6,14}$/.test(destination)) {
|
||||
errors.sms = '请输入完整的手机号或 E.164 地址,才能发送短信'
|
||||
valid = false
|
||||
}
|
||||
}
|
||||
|
||||
return valid
|
||||
}
|
||||
|
||||
@@ -239,7 +260,7 @@ export function useSigningTaskForm(options: UseSigningTaskFormOptions) {
|
||||
submitting.value = true
|
||||
|
||||
try {
|
||||
return await createSigningTask({
|
||||
const task = await createSigningTask({
|
||||
campus: toValue(options.campus),
|
||||
patientId: patient.value.id,
|
||||
visitId: selectedVisit.value.id,
|
||||
@@ -251,6 +272,15 @@ export function useSigningTaskForm(options: UseSigningTaskFormOptions) {
|
||||
visitNo: selectedVisit.value.visitNo,
|
||||
department: selectedVisit.value.department,
|
||||
})
|
||||
|
||||
if (!isSigningMockEnabled && method.value === 'sms') {
|
||||
await sendSigningSms(task.id, {
|
||||
destination: smsDestination.value.trim().replace(/\s+/g, ''),
|
||||
templateCode: 'SIGN_LINK',
|
||||
})
|
||||
}
|
||||
|
||||
return task
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
@@ -277,6 +307,7 @@ export function useSigningTaskForm(options: UseSigningTaskFormOptions) {
|
||||
selectedTemplateId,
|
||||
selectedVisit,
|
||||
selectedVisitId,
|
||||
smsDestination,
|
||||
submit,
|
||||
submitting,
|
||||
templates,
|
||||
|
||||
Reference in New Issue
Block a user