Browse Source

fix: DEC-10299 解决新建插件数据连接,名称重复时的问题

qufenxi
alan 5 years ago
parent
commit
35db7db401
  1. 10
      src/modules/constants/env.ts
  2. 38
      src/modules/pages/maintain/forms/form.ts

10
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;

38
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);
});
}
}

Loading…
Cancel
Save