mirror of
				https://github.com/vform666/variant-form3-vite.git
				synced 2025-11-04 18:41:46 +08:00 
			
		
		
		
	增加addEC/hasEC/getEC三个API方法,以便v-form-render可以跟外部组件交互。
This commit is contained in:
		@@ -265,8 +265,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)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -94,9 +94,12 @@
 | 
				
			|||||||
        formDataModel: {
 | 
					        formDataModel: {
 | 
				
			||||||
          //
 | 
					          //
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        widgetRefList: {},
 | 
					        widgetRefList: {},
 | 
				
			||||||
        subFormRefList: {},
 | 
					        subFormRefList: {},
 | 
				
			||||||
        formId: null,  //表单唯一Id,用于区分页面上的多个v-form-render组件!!
 | 
					        formId: null,  //表单唯一Id,用于区分页面上的多个v-form-render组件!!
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        externalComponents:  {},  //外部组件实例集合
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    computed: {
 | 
					    computed: {
 | 
				
			||||||
@@ -629,6 +632,33 @@
 | 
				
			|||||||
        return getAllContainerWidgets(this.formJsonObj.widgetList)
 | 
					        return 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 ------------------//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user