From e7a0a9ea8abb2d68339adc2c2baee75eaef03085 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Mon, 23 Oct 2023 14:27:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=86=E5=9B=BE=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E9=80=89=E9=A1=B9=E5=87=BA=E7=8E=B0=E9=87=8D?= =?UTF-8?q?=E5=A4=8D#6220?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/frontend/src/views/chart/group/Group.vue | 12 +++++++++++- core/frontend/src/views/chart/view/ChartEdit.vue | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/core/frontend/src/views/chart/group/Group.vue b/core/frontend/src/views/chart/group/Group.vue index 422b5c4f5c..75196e3707 100644 --- a/core/frontend/src/views/chart/group/Group.vue +++ b/core/frontend/src/views/chart/group/Group.vue @@ -687,12 +687,22 @@ export default { this.getChartGroupTree() }, methods: { + distinctArray(arr, key) { + const m = new Map() + for (const item of arr) { + if (!m.has(item[key])) { + m.set(item[key], item) + } + } + return [...m.values()] + }, loadPluginType() { const plugins = localStorage.getItem('plugin-views') && JSON.parse(localStorage.getItem('plugin-views')) || [] const pluginOptions = plugins.filter(plugin => !this.renderOptions.some(option => option.value === plugin.render)).map(plugin => { return { name: plugin.render, value: plugin.render } }) - this.pluginRenderOptions = [...this.renderOptions, ...pluginOptions] + const tempList = [...this.renderOptions, ...pluginOptions] + this.pluginRenderOptions = this.distinctArray(tempList, 'value') }, clickAdd(param) { this.currGroup = param.data diff --git a/core/frontend/src/views/chart/view/ChartEdit.vue b/core/frontend/src/views/chart/view/ChartEdit.vue index f3562bb26e..4c716111d0 100644 --- a/core/frontend/src/views/chart/view/ChartEdit.vue +++ b/core/frontend/src/views/chart/view/ChartEdit.vue @@ -2098,7 +2098,17 @@ export default { const pluginOptions = plugins.filter(plugin => !this.renderOptions.some(option => option.value === plugin.render)).map(plugin => { return { name: plugin.render, value: plugin.render } }) - this.pluginRenderOptions = [...this.renderOptions, ...pluginOptions] + const tempList = [...this.renderOptions, ...pluginOptions] + this.pluginRenderOptions = this.distinctArray(tempList, 'value') + }, + distinctArray(arr, key) { + const m = new Map() + for (const item of arr) { + if (!m.has(item[key])) { + m.set(item[key], item) + } + } + return [...m.values()] }, emptyTableData(id) { this.table = {}