Merge pull request #6309 from dataease/pr@dev@fix_plugin_view

fix: 视图插件类型选项出现重复#6220
This commit is contained in:
fit2cloud-chenyw 2023-10-23 14:30:39 +08:00 committed by GitHub
commit 81869d0fa2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 2 deletions

View File

@ -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

View File

@ -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 = {}