From 940147a687b3d5a95ca4b81f77b3f07761ec9aba Mon Sep 17 00:00:00 2001 From: taojinlong Date: Mon, 20 Dec 2021 16:46:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=A2=9E=E5=8A=A0=E6=88=96=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=95=B0=E6=8D=AE=E6=BA=90=EF=BC=8C=E5=8F=AA=E6=9C=89?= =?UTF-8?q?=E4=B8=80=E6=9D=A1=E6=95=B0=E6=8D=AE=E6=97=B6=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E5=AE=8C=E9=9C=80=E8=A6=81=E5=88=B7=E6=96=B0=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=89=8D=E4=BC=9A=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/system/datasource/DsTree.vue | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/frontend/src/views/system/datasource/DsTree.vue b/frontend/src/views/system/datasource/DsTree.vue index 0eb2d25e51..4ac6672f37 100644 --- a/frontend/src/views/system/datasource/DsTree.vue +++ b/frontend/src/views/system/datasource/DsTree.vue @@ -140,14 +140,26 @@ export default { let typeData = [] listDatasourceByType(datasource.type).then(res => { typeData = this.buildTree(res.data) - for (let index = 0; index < this.tData.length; index++) { - if (typeData[0].id === this.tData[index].id) { - this.tData[index].children = typeData[0].children + if(typeData.length === 0){ + let index = this.tData.findIndex(item => { + if ( item.id === datasource.type) { + return true; + } + }) + this.tData.splice(index,1) + }else { + let find = false; + for (let index = 0; index < this.tData.length; index++) { + if (typeData[0].id === this.tData[index].id) { + this.tData[index].children = typeData[0].children + find = true + } + } + if(!find){ + this.tData.push(typeData[0]) } } }) - - }, buildTree(array) { const types = {}