增加addEC/hasEC/getEC三个API方法,以便v-form-render可以跟外部组件交互。

master
vdpAdmin 2022-05-03 09:46:41 +08:00
parent 66c0a696ad
commit 287ee91791
2 changed files with 35 additions and 2 deletions

View File

@ -246,8 +246,11 @@
computed: { computed: {
formJson() { formJson() {
return { return {
widgetList: this.designer.widgetList, // widgetList: this.designer.widgetList,
formConfig: this.designer.formConfig // formConfig: this.designer.formConfig
widgetList: deepClone(this.designer.widgetList),
formConfig: deepClone(this.designer.formConfig)
} }
}, },

View File

@ -96,9 +96,12 @@
formDataModel: { formDataModel: {
// //
}, },
widgetRefList: {}, widgetRefList: {},
subFormRefList: {}, subFormRefList: {},
formId: null, //Idv-form-render formId: null, //Idv-form-render
externalComponents: {}, //
} }
}, },
computed: { computed: {
@ -656,6 +659,33 @@
return !!widgetList ? getAllContainerWidgets(widgetList) : getAllContainerWidgets(this.formJsonObj.widgetList) 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 ------------------// //--------------------- API end ------------------//
}, },