feat
This commit is contained in:
@@ -107,6 +107,20 @@ const ruleColumns = [
|
||||
{ title: '告警级别', dataIndex: 'severity_code', width: 100 },
|
||||
]
|
||||
|
||||
// 解析 JSON 字符串字段
|
||||
const parseJsonField = (field: any): any[] => {
|
||||
if (!field) return []
|
||||
if (typeof field === 'string') {
|
||||
try {
|
||||
const parsed = JSON.parse(field)
|
||||
return Array.isArray(parsed) ? parsed : []
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
}
|
||||
return Array.isArray(field) ? field : []
|
||||
}
|
||||
|
||||
// 监听visible变化,加载详情
|
||||
watch(
|
||||
() => props.visible,
|
||||
@@ -116,7 +130,14 @@ watch(
|
||||
try {
|
||||
const res: any = await fetchTemplateDetail(props.templateId)
|
||||
if (res.code === 0) {
|
||||
detail.value = res.details
|
||||
// 解析可能为 JSON 字符串的字段
|
||||
const data = res.details
|
||||
detail.value = {
|
||||
...data,
|
||||
rules: parseJsonField(data.rules),
|
||||
channels: parseJsonField(data.channels),
|
||||
suppression_rule_ids: parseJsonField(data.suppression_rule_ids),
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取模板详情失败:', error)
|
||||
|
||||
@@ -204,7 +204,7 @@ const tableColumns = computed(() => [
|
||||
{
|
||||
title: '操作',
|
||||
dataIndex: 'operations',
|
||||
width: 220,
|
||||
width: 280,
|
||||
slotName: 'operations',
|
||||
fixed: 'right' as const,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user