From ba6dfb1792262e4da2399baf50f8268f0524b7ca Mon Sep 17 00:00:00 2001 From: zsmj1994 Date: Thu, 1 Apr 2021 20:13:35 +0800 Subject: [PATCH 1/2] =?UTF-8?q?DEC-17991=20chore:=20=E7=94=98=E8=80=81?= =?UTF-8?q?=E5=B8=88=E6=8F=92=E4=BB=B6=E6=8E=A5=E5=8F=A3=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E5=8F=8D=E9=A6=88--=E6=95=B0=E6=8D=AE=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=88=9B=E5=BB=BA=E6=97=B6=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?connectionname?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../maintain/forms/components/form.plugin.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/modules/pages/maintain/forms/components/form.plugin.ts b/src/modules/pages/maintain/forms/components/form.plugin.ts index ae9646e..d36ba2c 100644 --- a/src/modules/pages/maintain/forms/components/form.plugin.ts +++ b/src/modules/pages/maintain/forms/components/form.plugin.ts @@ -11,24 +11,28 @@ export class FormPlugin extends BI.Widget { plugin: any; render() { - const { connectionType } = this.options.formData; - + const { connectionType, connectionId, connectionName, connectionData } = this.options.formData; + return { type: getPluginWidgetEdit(connectionType), ref: (_ref: any) => { this.plugin = _ref; }, - value: this.options.formData.connectionData, + value: connectionData, // 兼容 + connectionData, + connectionId, + connectionType, + connectionName, }; } public getSubmitValue(): Connection { - const { connectionType, connectionId, connectionName } = this.options.formData; - + const { connectionType, connectionId } = this.options.formData; + return { connectionId, connectionType, - connectionName, + connectionName: this.plugin.getName ? this.plugin.getName() : '', connectionData: this.plugin.getValue(), }; } From bb96a1920aab623a3d424087fdf26e25e07d1766 Mon Sep 17 00:00:00 2001 From: zsmj1994 Date: Thu, 1 Apr 2021 20:13:44 +0800 Subject: [PATCH 2/2] update demo --- README.md | 343 +++++++++++++++++++++++++++--------------------------- 1 file changed, 169 insertions(+), 174 deletions(-) diff --git a/README.md b/README.md index 5474677..1756d0c 100644 --- a/README.md +++ b/README.md @@ -36,185 +36,180 @@ ConstantName名称为`dec.constant.database.conf.connect.form.${name}.show`, ### 示例 ``` -const ConstantRedisType = 'dec.constant.database.conf.connect.types'; -const ConstantRedisShow = 'dec.constant.database.conf.connect.form.Redis.show'; -const ConstantRedisEdit = 'dec.constant.database.conf.connect.form.Redis.edit'; - -BI.DOM.ready(() => { - BI.config(ConstantRedisType, datas => [...datas, { - text: 'Redis', - databaseType: 'Redis', - }]); - - const RedisShowName = 'dec.dcm.connection.plugin.redis.show'; - const RedisShow = BI.inherit(BI.Widget, { - props: { - formData: { - url: '', - port: '6379', - password: '', - }, - }, - render() { - const o = this.options; - - return { - type: 'bi.vertical', - hgap: 15, - vgap: 10, - items: [ - { - type: 'bi.left', - items: [ - { - type: 'bi.label', - cls: 'bi-font-bold', - width: 100, - textAlign: 'left', - text: '数据库地址', - }, - { - type: 'bi.label', - text: o.formData.url, - }, - ], - }, - { - type: 'bi.left', - items: [ - { - type: 'bi.label', - cls: 'bi-font-bold', - width: 100, - textAlign: 'left', - text: '端口号', - }, - { - type: 'bi.label', - text: o.formData.port, - }, - ], - }, - { - type: 'bi.left', - items: [ - { - type: 'bi.label', - cls: 'bi-font-bold', - width: 100, - textAlign: 'left', - text: '密码', - }, - { - type: 'bi.label', - text: o.formData.password, - }, - ], - }, - ], - }; - }, +const DataBaseConfigProvider = 'dec.connection.provider.datebase'; + +const RedisShowName = 'dec.dcm.connection.plugin.redis.show'; +const RedisEditName = 'dec.dcm.connection.plugin.redis.edit'; +BI.config(DataBaseConfigProvider, function (provider) { + provider.registerDatabaseType({ + text: "Redis", + databaseType: "Redis", + edit: "dec.dcm.connection.plugin.demo.edit", + show: "dec.dcm.connection.plugin.demo.show", }); +}); - BI.shortcut(RedisShowName, RedisShow); - BI.constant(ConstantRedisShow, RedisShowName); - - - const RedisEditName = 'dec.dcm.connection.plugin.redis.edit'; - const RedisEdit = BI.inherit(BI.Widget, { - props: { - formData: { - url: '', - port: '6379', - password: '', - }, +const RedisShow = BI.inherit(BI.Widget, { + props: { + formData: { + url: '', + port: '6379', + password: '', }, - render() { - const o = this.options; - - return { - type: 'bi.vertical', - hgap: 15, - vgap: 10, - items: [ - { - type: 'bi.left', - items: [ - { - type: 'bi.label', - cls: 'bi-font-bold', - width: 100, - textAlign: 'left', - text: '数据库地址', - }, - { - type: 'bi.text_editor', - width: 300, - allowBlank: true, - ref: _ref => { - this.url = _ref; - }, - text: o.formData.url, - }, - ], - }, - { - type: 'bi.left', - items: [ - { - type: 'bi.label', - cls: 'bi-font-bold', - width: 100, - textAlign: 'left', - text: '端口号', - }, - { - type: 'bi.text_editor', - width: 300, - allowBlank: true, - ref: _ref => { - this.port = _ref; - }, - text: o.formData.port, + }, + render() { + const o = this.options; + + return { + type: 'bi.vertical', + hgap: 15, + vgap: 10, + items: [ + { + type: 'bi.left', + items: [ + { + type: 'bi.label', + cls: 'bi-font-bold', + width: 100, + textAlign: 'left', + text: '数据库地址', + }, + { + type: 'bi.label', + text: o.formData.url, + }, + ], + }, + { + type: 'bi.left', + items: [ + { + type: 'bi.label', + cls: 'bi-font-bold', + width: 100, + textAlign: 'left', + text: '端口号', + }, + { + type: 'bi.label', + text: o.formData.port, + }, + ], + }, + { + type: 'bi.left', + items: [ + { + type: 'bi.label', + cls: 'bi-font-bold', + width: 100, + textAlign: 'left', + text: '密码', + }, + { + type: 'bi.label', + text: o.formData.password, + }, + ], + }, + ], + }; + }, +}); +BI.shortcut(RedisShowName, RedisShow); + +const RedisEdit = BI.inherit(BI.Widget, { + props: { + formData: { + url: '', + port: '6379', + password: '', + }, + }, + render() { + const o = this.options; + + return { + type: 'bi.vertical', + hgap: 15, + vgap: 10, + items: [ + { + type: 'bi.left', + items: [ + { + type: 'bi.label', + cls: 'bi-font-bold', + width: 100, + textAlign: 'left', + text: '数据库地址', + }, + { + type: 'bi.text_editor', + width: 300, + allowBlank: true, + ref: _ref => { + this.url = _ref; }, - ], - }, - { - type: 'bi.left', - items: [ - { - type: 'bi.label', - cls: 'bi-font-bold', - width: 100, - textAlign: 'left', - text: '密码', + text: o.formData.url, + }, + ], + }, + { + type: 'bi.left', + items: [ + { + type: 'bi.label', + cls: 'bi-font-bold', + width: 100, + textAlign: 'left', + text: '端口号', + }, + { + type: 'bi.text_editor', + width: 300, + allowBlank: true, + ref: _ref => { + this.port = _ref; }, - { - type: 'bi.text_editor', - width: 300, - allowBlank: true, - inputType: 'password', - ref: _ref => { - this.password = _ref; - }, - text: o.formData.password, + text: o.formData.port, + }, + ], + }, + { + type: 'bi.left', + items: [ + { + type: 'bi.label', + cls: 'bi-font-bold', + width: 100, + textAlign: 'left', + text: '密码', + }, + { + type: 'bi.text_editor', + width: 300, + allowBlank: true, + inputType: 'password', + ref: _ref => { + this.password = _ref; }, - ], - }, - ], - }; - }, - getSubmitValue() { - return { - url: this.url.getValue(), - port: this.port.getValue(), - password: this.password.getValue(), - }; - }, - }); - - BI.shortcut(RedisEditName, RedisEdit); - BI.constant(ConstantRedisEdit, RedisEditName); + text: o.formData.password, + }, + ], + }, + ], + }; + }, + getSubmitValue() { + return { + url: this.url.getValue(), + port: this.port.getValue(), + password: this.password.getValue(), + }; + }, }); +BI.shortcut(RedisEditName, RedisEdit); -``` \ No newline at end of file +```