From 35db7db401c5e74423a9bd3cacea1e435efbab89 Mon Sep 17 00:00:00 2001 From: alan Date: Fri, 11 Oct 2019 14:14:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20DEC-10299=20=E8=A7=A3=E5=86=B3=E6=96=B0?= =?UTF-8?q?=E5=BB=BA=E6=8F=92=E4=BB=B6=E6=95=B0=E6=8D=AE=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=EF=BC=8C=E5=90=8D=E7=A7=B0=E9=87=8D=E5=A4=8D=E6=97=B6=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/constants/env.ts | 10 +++++-- src/modules/pages/maintain/forms/form.ts | 38 ++++++++++++++++++------ 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/src/modules/constants/env.ts b/src/modules/constants/env.ts index 3ddd37c..8095b92 100644 --- a/src/modules/constants/env.ts +++ b/src/modules/constants/env.ts @@ -3,9 +3,15 @@ export const ReqPrefix = `${fineServletURL}/v10/config/connection`; export const ImgPrefix = `${fineServletURL}/resources?path=/com/fr/web/resources/dist/images/2x/icon/database/`; export const PluginImgPrefix = `${fineServletURL}/resources?path=`; -export const connectionType = DecCst.Connect.ConnectionType; +export const connectionType: { + JDBC: string; + JNDI: string; +} = DecCst.Connect.ConnectionType; -export const editStatusEvent = DecCst.Connect.EditStatusEvent; +export const editStatusEvent: { + OPEN: string; + SHUTDOWN: string; +} = DecCst.Connect.EditStatusEvent; export const errorCode: { CONNECTION_DELETED: string; diff --git a/src/modules/pages/maintain/forms/form.ts b/src/modules/pages/maintain/forms/form.ts index 704be55..0952894 100644 --- a/src/modules/pages/maintain/forms/form.ts +++ b/src/modules/pages/maintain/forms/form.ts @@ -46,15 +46,7 @@ export class MaintainForm extends BI.Widget { form.connectionId = this.connectionName; // DEC-10155 为了适配插件的数据连接,在外层也加一个creator字段 form.creator = Dec ? Dec.personal.username : ''; - this.store.addConnection(form).then(result => { - if (result.errorCode) { - this.showError(result); - - return; - } - this.store.goFirstPage(); - this.store.setIsCopy(false); - }); + this.addConnection(form); } }, testEvent: () => { @@ -252,4 +244,32 @@ export class MaintainForm extends BI.Widget { this.form.setSchemas(re); }); } + + private addConnection(form: Connection) { + this.store.addConnection(form).then(result => { + if (result.errorCode) { + if (result.errorCode === errorCode.DUPLICATE_NAMES) { + if (form.connectionType !== connectionType.JDBC && form.connectionType !== connectionType.JNDI) { + // 如果不是jdbc或jndi,即如果是插件,名称重复的时候需要修改名字重新提交给后台 + const newName = `${form.connectionName}${Math.floor(Math.random() * 10)}`; + form.connectionName = newName; + if (!this.model.isCopy) { + form.connectionId = newName; + } + this.addConnection(form); + } else { + this.setFromError(result.errorMsg); + } + } else { + BI.Msg.toast(BI.i18nText(result.errorMsg), { + level: 'error', + }); + } + + return; + } + this.store.goFirstPage(); + this.store.setIsCopy(false); + }); + } }