fix(sign): 补齐模板查询院区参数
This commit is contained in:
@@ -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()
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user