diff --git a/src/components/Dict/DictLabel.vue b/src/components/Dict/DictLabel.vue index 61ab570..8391618 100644 --- a/src/components/Dict/DictLabel.vue +++ b/src/components/Dict/DictLabel.vue @@ -32,25 +32,47 @@ const getLabelAndTagByValue = async (dictCode: string, value: any) => { // 按需加载字典数据 await dictStore.loadDictItems(dictCode) // 从缓存中获取字典数据 - const dictItems = dictStore.getDictItems(dictCode) + const response: any = dictStore.getDictItems(dictCode) + + // 处理API响应格式 + let dictItems = [] + if (Array.isArray(response)) { + dictItems = response + } else if (response && typeof response === 'object' && Array.isArray(response.data)) { + dictItems = response.data + } else { + console.warn(`Dictionary items for code "${dictCode}" is not in expected format:`, response) + return { + label: '', + tagType: undefined + } + } + // 查找对应的字典项 - const dictItem = dictItems.find((item) => item.value == value) + const dictItem = dictItems.find((item: any) => item.value == value) return { label: dictItem?.label || '', tagType: dictItem?.tagType } } + /** * 更新 label 和 tagType */ const updateLabelAndTag = async () => { if (!props.code || props.modelValue === undefined) return - const { label: newLabel, tagType: newTagType } = await getLabelAndTagByValue( - props.code, - props.modelValue - ) - label.value = newLabel - tagType.value = newTagType as typeof tagType.value + try { + const { label: newLabel, tagType: newTagType } = await getLabelAndTagByValue( + props.code, + props.modelValue + ) + label.value = newLabel + tagType.value = newTagType as typeof tagType.value + } catch (error) { + console.error('Failed to update dict label:', error) + label.value = '' + tagType.value = undefined + } } // 初始化或code变化时更新标签和标签样式 diff --git a/src/components/Notification/ApprovalForm.vue b/src/components/Notification/ApprovalForm.vue new file mode 100644 index 0000000..3bc9985 --- /dev/null +++ b/src/components/Notification/ApprovalForm.vue @@ -0,0 +1,59 @@ + + + + + diff --git a/src/components/Notification/index.vue b/src/components/Notification/index.vue index 3db62d7..ee5083e 100644 --- a/src/components/Notification/index.vue +++ b/src/components/Notification/index.vue @@ -10,19 +10,20 @@