This commit is contained in:
ygx
2026-03-28 22:06:03 +08:00
parent e218a3c9cd
commit 5bc970fb6c
2 changed files with 23 additions and 2 deletions

View File

@@ -107,6 +107,20 @@ const ruleColumns = [
{ title: '告警级别', dataIndex: 'severity_code', width: 100 }, { 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变化加载详情 // 监听visible变化加载详情
watch( watch(
() => props.visible, () => props.visible,
@@ -116,7 +130,14 @@ watch(
try { try {
const res: any = await fetchTemplateDetail(props.templateId) const res: any = await fetchTemplateDetail(props.templateId)
if (res.code === 0) { 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) { } catch (error) {
console.error('获取模板详情失败:', error) console.error('获取模板详情失败:', error)

View File

@@ -204,7 +204,7 @@ const tableColumns = computed(() => [
{ {
title: '操作', title: '操作',
dataIndex: 'operations', dataIndex: 'operations',
width: 220, width: 280,
slotName: 'operations', slotName: 'operations',
fixed: 'right' as const, fixed: 'right' as const,
}, },