diff --git a/src/views/dashboard/List.vue b/src/views/dashboard/List.vue index 57537f91..893d3aef 100644 --- a/src/views/dashboard/List.vue +++ b/src/views/dashboard/List.vue @@ -44,7 +44,7 @@ limitations under the License. --> @selection-change="handleSelectionChange" > - + @@ -90,6 +90,7 @@ limitations under the License. --> (""); const loading = ref(false); const multipleTableRef = ref>(); const multipleSelection = ref([]); +const dashboardFile = ref>(null); // # - os-linux // # - k8s // # - general(agent-installed) @@ -148,6 +151,16 @@ async function setList() { } async function importTemplates(event: any) { const arr: any = await readFile(event); + for (const item of arr) { + const { layer, name, entity } = item.configuration; + const index = dashboardStore.dashboards.findIndex( + (d: DashboardItem) => + d.name === name && d.entity === entity && d.layer === layer + ); + if (index > -1) { + return ElMessage.error("The dashboard name cannot be duplicate."); + } + } loading.value = true; for (const item of arr) { const { layer, name, entity, isRoot, children } = item.configuration; @@ -170,8 +183,7 @@ async function importTemplates(event: any) { } dashboards.value = dashboardStore.dashboards; loading.value = false; - const el: any = document.getElementById("dashboard-file"); - el!.value = ""; + dashboardFile.value = null; } function exportTemplates() { const arr = multipleSelection.value.sort( @@ -186,6 +198,9 @@ function exportTemplates() { }); const name = `dashboards.json`; saveFile(templates, name); + setTimeout(() => { + multipleTableRef.value!.clearSelection(); + }, 2000); } function handleView(row: DashboardItem) { dashboardStore.setCurrentDashboard(row); @@ -373,8 +388,9 @@ function searchDashboards() { } .input-label { - display: inline; - line-height: inherit; + line-height: 30px; + height: 30px; + width: 220px; cursor: pointer; }