fix(sign): 补齐模板查询院区参数

This commit is contained in:
xy
2026-09-28 21:04:03 +08:00
parent b6775a66c7
commit f7804d476d
5 changed files with 45 additions and 12 deletions
+1 -1
View File
@@ -91,7 +91,7 @@ medical-sign/
## 签署接口契约
- 模板版本的 `formFields` 保存文书字段定义,`signatureFields` 单独保存患者签名在 PDF 中的页码、坐标、宽高和坐标系;编辑器中的坐标单位为 PDF point。发布模板前必须配置 `signature` 字段的位置。
- `GET /api/v1/templates/available-versions` 返回 `formFields` 和 `needConfirm`。创建任务时将人工填写值放入 `staffAnswers`,并传入 `signerType`、`signerName`、`signerRelation`;患者、性别、年龄、就诊号和电话等已知字段仍由后端快照覆盖。
- `GET /api/v1/templates/available-versions` 必须传入当前选择的 `campusId`,并返回 `formFields` 和 `needConfirm`。创建任务时将人工填写值放入 `staffAnswers`,并传入 `signerType`、`signerName`、`signerRelation`;患者、性别、年龄、就诊号和电话等已知字段仍由后端快照覆盖。
- H5 先调用 `POST /api/v1/sign-deliveries/token/consume`,再用返回的 `taskId`、`deliveryId`、`uploadToken` 调用 `POST /api/v1/sign-deliveries/token/context`。上传使用 `POST /api/v1/sign-deliveries/{taskId}/signature` multipart,包含 `file`、`metadata` 和 `signer` JSON 部分,并复用 `Idempotency-Key` 安全重试。
- 患者签署后,任务可能处于 `GENERATING`、`WAITING_CONFIRM` 或 `SIGNED`。刷新结果页时 H5 使用只读 context 查询恢复服务端状态,不能将这些状态退回为可重复签署。
+4 -6
View File
@@ -1146,12 +1146,10 @@ export async function getPatientProfile(keyword: string): Promise<PatientProfile
return Promise.resolve(patient ? clonePatient(patient) : null)
}
export async function getSigningTemplates(
query: {
campusId?: string
departmentId?: string
} = {},
): Promise<SigningTemplate[]> {
export async function getSigningTemplates(query: {
campusId: string
departmentId?: string
}): Promise<SigningTemplate[]> {
if (!useMockData) {
const response = await request.get<
ApiResponseOf<
@@ -70,6 +70,7 @@ const {
visits,
} = useSigningTaskForm({
campus: computed(() => appStore.selectedCampus),
campusId: computed(() => appStore.selectedCampusId),
initialTemplate,
})
@@ -165,6 +166,14 @@ watch(
return
}
await appStore.loadCampuses()
if (!appStore.selectedCampusId) {
ElMessage.error(
appStore.campusLoadFailed ? '院区加载失败,无法加载文书模板' : '当前没有可用院区',
)
return
}
resetForm()
await loadTemplates()
await nextTick()
@@ -23,6 +23,7 @@ import type {
export interface UseSigningTaskFormOptions {
campus: MaybeRefOrGetter<WorkbenchCampus>
campusId: MaybeRefOrGetter<string>
initialTemplate?: MaybeRefOrGetter<SigningTemplate | null | undefined>
}
@@ -85,6 +86,7 @@ export function useSigningTaskForm(options: UseSigningTaskFormOptions) {
/** 左列选中的科室与分类(原型 ntDeptSel / ntCatSel) */
const selectedDepartment = ref('')
const selectedCategory = ref('')
let loadedTemplateCampusId = ''
const errors = reactive({
patient: '',
@@ -382,11 +384,26 @@ export function useSigningTaskForm(options: UseSigningTaskFormOptions) {
}
async function loadTemplates() {
if (!templates.value.length) {
const campusId = toValue(options.campusId)
if (!campusId) {
templates.value = []
loadedTemplateCampusId = ''
ElMessage.error('请先选择院区,再加载文书模板')
return
}
if (loadedTemplateCampusId !== campusId) {
if (loadedTemplateCampusId) {
selectedTemplateId.value = ''
selectedDepartment.value = ''
selectedCategory.value = ''
}
loadingTemplates.value = true
try {
templates.value = await getSigningTemplates()
templates.value = await getSigningTemplates({ campusId })
loadedTemplateCampusId = campusId
} catch {
ElMessage.error('文档模板加载失败,请稍后重试')
} finally {
@@ -234,8 +234,14 @@ function syncFilterFromRoute() {
}
async function loadTemplates() {
const campusId = appStore.selectedCampusId
if (!campusId) {
templates.value = []
return
}
try {
templates.value = await getSigningTemplates()
templates.value = await getSigningTemplates({ campusId })
} catch {
ElMessage.error('文档模板加载失败,请稍后重试')
}
@@ -1088,9 +1094,12 @@ watch(
/** 切换全局院区:列表跟着换(院区不再是筛选条里的一个下拉,见 syncFilterFromRoute) */
watch(
() => appStore.selectedCampus,
() => {
() => appStore.selectedCampusId,
(campusId, previousCampusId) => {
page.value = 1
if (campusId && previousCampusId) {
void loadTemplates()
}
void loadTasks()
},
)