From 287ee9179146cb268a652b624bd10eb149ba645a Mon Sep 17 00:00:00 2001 From: vdpAdmin Date: Tue, 3 May 2022 09:46:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0addEC/hasEC/getEC=E4=B8=89?= =?UTF-8?q?=E4=B8=AAAPI=E6=96=B9=E6=B3=95=EF=BC=8C=E4=BB=A5=E4=BE=BFv-form?= =?UTF-8?q?-render=E5=8F=AF=E4=BB=A5=E8=B7=9F=E5=A4=96=E9=83=A8=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E4=BA=A4=E4=BA=92=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form-designer/toolbar-panel/index.vue | 7 +++-- src/components/form-render/index.vue | 30 +++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/components/form-designer/toolbar-panel/index.vue b/src/components/form-designer/toolbar-panel/index.vue index b900e6c..b825af5 100644 --- a/src/components/form-designer/toolbar-panel/index.vue +++ b/src/components/form-designer/toolbar-panel/index.vue @@ -246,8 +246,11 @@ computed: { formJson() { return { - widgetList: this.designer.widgetList, - formConfig: this.designer.formConfig + // widgetList: this.designer.widgetList, + // formConfig: this.designer.formConfig + + widgetList: deepClone(this.designer.widgetList), + formConfig: deepClone(this.designer.formConfig) } }, diff --git a/src/components/form-render/index.vue b/src/components/form-render/index.vue index e69ba05..ad8631a 100644 --- a/src/components/form-render/index.vue +++ b/src/components/form-render/index.vue @@ -96,9 +96,12 @@ formDataModel: { // }, + widgetRefList: {}, subFormRefList: {}, formId: null, //表单唯一Id,用于区分页面上的多个v-form-render组件!! + + externalComponents: {}, //外部组件实例集合 } }, computed: { @@ -656,6 +659,33 @@ return !!widgetList ? getAllContainerWidgets(widgetList) : getAllContainerWidgets(this.formJsonObj.widgetList) }, + /** + * 增加外部组件引用,可通过getEC()方法获取外部组件,以便在VForm内部调用外部组件方法 + * @param componentName 外部组件名称 + * @param externalComponent 外部组件实例 + */ + addEC(componentName, externalComponent) { + this.externalComponents[componentName] = externalComponent + }, + + /** + * 判断外部组件是否可获取 + * @param componentName 外部组件名称 + * @returns {boolean} + */ + hasEC(componentName) { + return this.externalComponents.hasOwnProperty(componentName) + }, + + /** + * 获取外部组件实例 + * @param componentName + * @returns {*} + */ + getEC(componentName) { + return this.externalComponents[componentName] + }, + //--------------------- 以上为组件支持外部调用的API方法 end ------------------// },