diff --git a/README.md b/README.md index 5f46124..ac03007 100644 --- a/README.md +++ b/README.md @@ -216,21 +216,6 @@ const RedisShow = BI.inherit(BI.Widget, { }, ], }, - mounted() { - this.fireEvent('EVENT_HIDE_TEST_CONNECTION', true);//可以触发隐藏测试按钮 - }, - //可以触发组件的数据save方法,不需要则可不写 - async save() { - let result = 0; - await Promise.resolve().then(() => {result = 1}); - //要求返回是否成功的boolean变量 - return result; - }, - //可以阻止触发平台保存数据的方法 - preventParentSave() { - return true; - } - }, }); BI.shortcut(RedisShowName, RedisShow); @@ -325,6 +310,13 @@ const RedisEdit = BI.inherit(BI.Widget, { password: this.password.getValue(), }; }, + //可以触发组件的数据save方法,不需要则可不写 + async save() { + let result = false; + await Promise.resolve().then(() => {result = true}); + //要求返回是否成功的boolean变量 + return result; + }, }); BI.shortcut(RedisEditName, RedisEdit); @@ -349,7 +341,11 @@ BI.config('dec.constant.connection.list', function (value) { #### 1. 添加分类DEMO ```js BI.config('dec.constant.database.filter.type', (value) => { - value.push({text:"DEMO", value:"DEMO_VALUE"});return value; + value.push({ + text:"DEMO", + value:"DEMO_VALUE" + }); + return value; }); ``` #### 2. 添加数据连接类型进DEMO @@ -358,6 +354,8 @@ BI.config('dec.constant.database.filter.type', (value) => { text: "Redis",//必填 databaseType: "Redis",//唯一值 marker: 'DEMO_VALUE',//marker对标dec.constant.database.filter.type常量item的value,用于过滤 + isHideConnection: true, //是否隐藏测试连接按钮 + isNoSave: true,//是否不执行平台的保存逻辑 iconUrl:'https://work.fineres.com/secure/projectavatar?pid=10301&avatarId=10011', driver: 'com.amazon.redshift.jdbc41.Driver', drivers: ['com.amazon.redshift.jdbc4.Driver', 'com.amazon.redshift.jdbc41.Driver'], diff --git a/src/modules/pages/connection/connection.model.ts b/src/modules/pages/connection/connection.model.ts index ea7db71..97daf69 100644 --- a/src/modules/pages/connection/connection.model.ts +++ b/src/modules/pages/connection/connection.model.ts @@ -13,13 +13,14 @@ export class ConnectionModel extends Model<{ connectionSelected: AppModel['TYPE']['connectionSelected']; connectionSelectedOne: AppModel['TYPE']['connectionSelectedOne']; datebaseTypeSelected: AppModel['TYPE']['datebaseTypeSelected']; + noTestConnection: AppModel['TYPE']['noTestConnection']; }, childContext: ConnectionModel['childContext']; context: ConnectionModel['context']; }> { static xtype = 'dec.dcm.model.connection'; - context = ['pageIndex', 'connectionSelected', 'connectionSelectedOne', 'datebaseTypeSelected', 'connectionLicInfo']; + context = ['pageIndex', 'connectionSelected', 'connectionSelectedOne', 'datebaseTypeSelected', 'connectionLicInfo', 'noTestConnection']; actions = { initConnectionLicInfo: (cb: Function) => { @@ -58,6 +59,9 @@ export class ConnectionModel extends Model<{ } return api.getConnectionStatus(this.model.connectionSelected); }, + setNoTestConnection(value: boolean) { + this.model.noTestConnection = value; + }, checkConnectionLic() { return this.model.connectionLicInfo.currentConnectionNum > this.model.connectionLicInfo.maxConnectionNum; }, diff --git a/src/modules/pages/connection/connection.ts b/src/modules/pages/connection/connection.ts index d540199..6b1094c 100644 --- a/src/modules/pages/connection/connection.ts +++ b/src/modules/pages/connection/connection.ts @@ -138,7 +138,10 @@ export class Connection extends BI.Widget { handler: () => { this.store.getConnectionStatus() .then(() => { + const databaseType = this.model.connectionSelectedOne.connectionType; + const database = BI.find(getAllDatabaseTypes(), (_index, value) => value.databaseType === databaseType); this.setMaintainPage(); + this.store.setNoTestConnection(database.isHideConnection); }) .catch(() => { }); diff --git a/src/modules/pages/database/database.constant.ts b/src/modules/pages/database/database.constant.ts index 0926244..12f2af8 100644 --- a/src/modules/pages/database/database.constant.ts +++ b/src/modules/pages/database/database.constant.ts @@ -1,6 +1,5 @@ import { DATEBASE_FILTER_TYPE } from "@constants/constant"; -console.log('contant'); BI.constant('dec.constant.database.filter.type', [ { text: BI.i18nText('Dec-Dcm_Connection_Commonly'), diff --git a/src/modules/pages/database/database_type/database_type.model.ts b/src/modules/pages/database/database_type/database_type.model.ts index cb51507..483b700 100644 --- a/src/modules/pages/database/database_type/database_type.model.ts +++ b/src/modules/pages/database/database_type/database_type.model.ts @@ -6,11 +6,13 @@ export class DatebaseTypeModel extends Model< types: { datebaseTypeSelected: AppModel['TYPE']['datebaseTypeSelected']; pageIndex: AppModel['TYPE']['pageIndex']; + noTestConnection: AppModel['TYPE']['noTestConnection']; + datebaseTypeSelectedOne: AppModel['TYPE']['datebaseTypeSelectedOne']; }, context: DatebaseTypeModel['context']; }> { static xtype = 'dec.dcm.model.datebase.type'; - context = ['datebaseTypeSelected', 'pageIndex']; + context = ['datebaseTypeSelected', 'pageIndex', 'noTestConnection', 'datebaseTypeSelectedOne']; actions = { setDatebaseTypeSelected: (datebaseTypeSelected: string) => { @@ -19,5 +21,8 @@ export class DatebaseTypeModel extends Model< setPageIndex: (index: string) => { this.model.pageIndex = index; }, + setNoTestConnection: (value: boolean) => { + this.model.noTestConnection = value; + } } } diff --git a/src/modules/pages/database/database_type/database_type.ts b/src/modules/pages/database/database_type/database_type.ts index 3170b3b..2741408 100644 --- a/src/modules/pages/database/database_type/database_type.ts +++ b/src/modules/pages/database/database_type/database_type.ts @@ -70,6 +70,7 @@ export class DatebaseType extends BI.BasicButton { const { value } = this.options; this.store.setDatebaseTypeSelected(value); this.store.setPageIndex(PAGE_INDEX.MAINTAIN); + this.store.setNoTestConnection(this.model.datebaseTypeSelectedOne.isHideConnection); } mounted() { diff --git a/src/modules/pages/maintain/forms/components/form.plugin.ts b/src/modules/pages/maintain/forms/components/form.plugin.ts index b3eba0c..881089a 100644 --- a/src/modules/pages/maintain/forms/components/form.plugin.ts +++ b/src/modules/pages/maintain/forms/components/form.plugin.ts @@ -5,8 +5,6 @@ import { getPluginWidgetEdit } from '../../../../app.service'; @shortcut() export class FormPlugin extends BI.Widget { static xtype = 'dec.dcm.maintain_plugin'; - static EVENTNOTEST = 'EVENT_HIDE_TEST_CONNECTION'; - static PREVENTPARENTSAVE = 'EVENT_PREVENT_PARENT_SAVE'; props = { formData: {} as Connection, }; @@ -26,12 +24,6 @@ export class FormPlugin extends BI.Widget { connectionId, connectionType, connectionName, - listeners: [{ - eventName: FormPlugin.EVENTNOTEST, - action: (value: boolean) => { - this.fireEvent(FormPlugin.EVENTNOTEST, value); - } - }] }; } @@ -46,11 +38,7 @@ export class FormPlugin extends BI.Widget { }; } - public save() { + public getSaveFn() { return this.plugin.save; } - - public preventParentSave() { - return this.plugin.preventParentSave ? this.plugin.preventParentSave() : false; - } } diff --git a/src/modules/pages/maintain/forms/form.model.ts b/src/modules/pages/maintain/forms/form.model.ts index ec76932..3bbc66e 100644 --- a/src/modules/pages/maintain/forms/form.model.ts +++ b/src/modules/pages/maintain/forms/form.model.ts @@ -31,7 +31,6 @@ export class MaintainFormModel extends Model<{ 'testEvent', 'connections', 'isCopy', - 'noTestConnection', ]; actions = { diff --git a/src/modules/pages/maintain/forms/form.ts b/src/modules/pages/maintain/forms/form.ts index a48bfc5..2740f54 100644 --- a/src/modules/pages/maintain/forms/form.ts +++ b/src/modules/pages/maintain/forms/form.ts @@ -6,7 +6,7 @@ import { FormPlugin } from './components/form.plugin'; import { connectionType, errorCode } from '@constants/env'; import { ConnectionJDBC, Connection, ResultType } from 'src/modules/crud/crud.typings'; import { DEFAULT_JNDI_DATA, DEFAULT_JDBC_POOL, DATEBASE_FILTER_TYPE } from '@constants/constant'; -import { getJdbcDatabaseType, getChartLength } from '../../../app.service'; +import { getJdbcDatabaseType, getChartLength, getAllDatabaseTypes } from '../../../app.service'; import { NAME_MAX_LENGTH } from '../../../app.constant'; import { checkIllegalStrings } from "@core/index"; @@ -14,8 +14,7 @@ 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'; + static EVENT_TESTCONNECTION = 'EVENT_TEST_CONNECTION'; props = { connectionType: '', @@ -31,9 +30,9 @@ export class MaintainForm extends BI.Widget { watch = { saveEvent: () => { - const sonSave = this.form.save?.(); + const sonSave = this.form.getSaveFn?.(); if (sonSave) { - sonSave().then((success: Boolean) => { + sonSave().then((success: boolean) => { if (success) { BI.Msg.toast(BI.i18nText("Dec-Basic_Save_Success"), { level: "success", @@ -45,8 +44,19 @@ export class MaintainForm extends BI.Widget { } }); - if (this.form.preventParentSave()) { - return; + + //只有外来插件才可以使用是否不执行平台的保存逻辑 + if (this.model.datebaseTypeSelected) { + const isPluginDatabase = BI.some(BI.Providers.getProvider('dec.connection.provider.datebase').customDatabaseType, (_index, value) => value.databaseType === this.model.datebaseTypeSelected); + if (isPluginDatabase && this.model.datebaseTypeSelectedOne.isNoSave) { + return; + } + } else { + const databaseType = this.model.connectionSelectedOne.connectionType; + const database = BI.find(getAllDatabaseTypes(), (_index, value) => value.databaseType === databaseType); + if (this.model.connectionSelectedOne.pluginConnection && database?.isNoSave) { + return; + } } } this.save(); @@ -70,15 +80,10 @@ export class MaintainForm extends BI.Widget { this.form = _ref; }, listeners: [{ - eventName: MaintainForm.TESTCONNECTION, + eventName: MaintainForm.EVENT_TESTCONNECTION, action: () => { this.testConnection(); }, - }, { - eventName: MaintainForm.EVENTNOTEST, - action: (value: boolean) => { - this.model.noTestConnection = value; - } }], }; } diff --git a/src/modules/title/title.model.ts b/src/modules/title/title.model.ts index 6cb2fe8..737c324 100644 --- a/src/modules/title/title.model.ts +++ b/src/modules/title/title.model.ts @@ -6,13 +6,12 @@ export class TitleModel extends Model<{ types: { pageIndex: AppModel['TYPE']['pageIndex']; datebaseTypeSelected: AppModel['TYPE']['datebaseTypeSelected']; - noTestConnection: AppModel['TYPE']['noTestConnection']; }, context: TitleModel['context']; }> { static xtype = 'dec.dcm.model.title'; - context = ['pageIndex', 'datebaseTypeSelected', 'noTestConnection'] + context = ['pageIndex', 'datebaseTypeSelected'] actions = { setPageIndex: (index: string) => { diff --git a/src/modules/title/title_maintain/title_maintain.ts b/src/modules/title/title_maintain/title_maintain.ts index 7107fe9..2f3c48f 100644 --- a/src/modules/title/title_maintain/title_maintain.ts +++ b/src/modules/title/title_maintain/title_maintain.ts @@ -10,13 +10,6 @@ export class TitleMaintain extends BI.Widget { store: TitleMaintainModel['store']; model: TitleMaintainModel['model']; - testConnectionBtn: Button; - - watch = { - noTestConnection: function (value) { - this.testConnectionBtn.setVisible(!value); - } - } render() { return { @@ -42,6 +35,7 @@ export class TitleMaintain extends BI.Widget { ref: (_ref) => { this.testConnectionBtn = _ref; }, + invisible: () => this.model.noTestConnection, _rgap: 16, $value: 'title-maintain-connection-test', text: BI.i18nText('Dec-Dcm_Connection_Test'), @@ -69,6 +63,5 @@ export class TitleMaintain extends BI.Widget { window.onunload = () => { this.store.shutdownConnectionStatus(); }; - this.testConnectionBtn.setVisible(!this.model.noTestConnection); } }