|
|
|
@ -14,6 +14,8 @@ import { checkIllegalStrings } from "@core/index";
|
|
|
|
|
@store(MaintainFormModel) |
|
|
|
|
export class MaintainForm extends BI.Widget { |
|
|
|
|
static xtype = 'dec.dcm.maintain.form'; |
|
|
|
|
static TESTCONNECTION = 'EVENT_TEST_CONNECTION'; |
|
|
|
|
static EVENTNOTEST = 'EVENT_HIDE_TEST_CONNECTION'; |
|
|
|
|
|
|
|
|
|
props = { |
|
|
|
|
connectionType: '', |
|
|
|
@ -29,34 +31,25 @@ export class MaintainForm extends BI.Widget {
|
|
|
|
|
|
|
|
|
|
watch = { |
|
|
|
|
saveEvent: () => { |
|
|
|
|
if (!this.testValue()) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (this.connectionName && !this.model.isCopy) { |
|
|
|
|
const value = this.form.getSubmitValue(); |
|
|
|
|
(value.connectionData as ConnectionJDBC).creator = BI.get(this.getFormData(), 'creator'); |
|
|
|
|
// DEC-10155 为了适配插件的数据连接,在外层也加一个creator字段
|
|
|
|
|
value.creator = BI.get(this.getFormData(), 'creator'); |
|
|
|
|
this.store.updateConnection(this.connectionName, value).then(result => { |
|
|
|
|
if (result.errorCode) { |
|
|
|
|
if (result.errorCode === DecCst.ErrorCode.NO_IP_AUTHORIZED) { |
|
|
|
|
BI.Msg.toast(BI.i18nText("Dec-Basic_Save_Fail"), { |
|
|
|
|
level: "error", |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
this.showError(result); |
|
|
|
|
|
|
|
|
|
return; |
|
|
|
|
const sonSave = this.form.save?.(); |
|
|
|
|
if (sonSave) { |
|
|
|
|
sonSave().then((success: Boolean) => { |
|
|
|
|
if (success) { |
|
|
|
|
BI.Msg.toast(BI.i18nText("Dec-Basic_Save_Success"), { |
|
|
|
|
level: "success", |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
BI.Msg.toast(BI.i18nText("Dec-Basic_Save_Fail"), { |
|
|
|
|
level: "error", |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
this.store.goFirstPage(); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
const form = this.form.getSubmitValue(); |
|
|
|
|
form.connectionId = this.connectionName; |
|
|
|
|
// DEC-10155 为了适配插件的数据连接,在外层也加一个creator字段
|
|
|
|
|
form.creator = Dec ? Dec.personal.username : ''; |
|
|
|
|
this.addConnection(form); |
|
|
|
|
|
|
|
|
|
if (this.form.preventParentSave()) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
this.save(); |
|
|
|
|
}, |
|
|
|
|
testEvent: () => { |
|
|
|
|
this.testConnection(); |
|
|
|
@ -77,10 +70,15 @@ export class MaintainForm extends BI.Widget {
|
|
|
|
|
this.form = _ref; |
|
|
|
|
}, |
|
|
|
|
listeners: [{ |
|
|
|
|
eventName: 'EVENT_TEST_CONNECTION', |
|
|
|
|
eventName: MaintainForm.TESTCONNECTION, |
|
|
|
|
action: () => { |
|
|
|
|
this.testConnection(); |
|
|
|
|
}, |
|
|
|
|
}, { |
|
|
|
|
eventName: MaintainForm.EVENTNOTEST, |
|
|
|
|
action: (value: boolean) => { |
|
|
|
|
this.model.noTestConnection = value; |
|
|
|
|
} |
|
|
|
|
}], |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
@ -295,4 +293,35 @@ export class MaintainForm extends BI.Widget {
|
|
|
|
|
this.store.setIsCopy(false); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private save() { |
|
|
|
|
if (!this.testValue()) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (this.connectionName && !this.model.isCopy) { |
|
|
|
|
const value = this.form.getSubmitValue(); |
|
|
|
|
(value.connectionData as ConnectionJDBC).creator = BI.get(this.getFormData(), 'creator'); |
|
|
|
|
// DEC-10155 为了适配插件的数据连接,在外层也加一个creator字段
|
|
|
|
|
value.creator = BI.get(this.getFormData(), 'creator'); |
|
|
|
|
this.store.updateConnection(this.connectionName, value).then(result => { |
|
|
|
|
if (result.errorCode) { |
|
|
|
|
if (result.errorCode === DecCst.ErrorCode.NO_IP_AUTHORIZED) { |
|
|
|
|
BI.Msg.toast(BI.i18nText("Dec-Basic_Save_Fail"), { |
|
|
|
|
level: "error", |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
this.showError(result); |
|
|
|
|
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
this.store.goFirstPage(); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
const form = this.form.getSubmitValue(); |
|
|
|
|
form.connectionId = this.connectionName; |
|
|
|
|
// DEC-10155 为了适配插件的数据连接,在外层也加一个creator字段
|
|
|
|
|
form.creator = Dec ? Dec.personal.username : ''; |
|
|
|
|
this.addConnection(form); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|