diff --git a/src/components/form-designer/designer.js b/src/components/form-designer/designer.js index 6921ce6..db89779 100644 --- a/src/components/form-designer/designer.js +++ b/src/components/form-designer/designer.js @@ -92,6 +92,7 @@ export function createDesigner(vueInstance) { let modifiedFlag = false if (!!formJson && !!formJson.widgetList) { + this.formWidget.clearWidgetRefList() this.widgetList = formJson.widgetList modifiedFlag = true } diff --git a/src/components/form-designer/form-widget/container-widget/containerMixin.js b/src/components/form-designer/form-widget/container-widget/containerMixin.js index c9064e4..ae616b0 100644 --- a/src/components/form-designer/form-widget/container-widget/containerMixin.js +++ b/src/components/form-designer/form-widget/container-widget/containerMixin.js @@ -68,6 +68,7 @@ export default { removeWidget() { if (!!this.parentList) { + const widgetRefName = this.designer.selectedWidgetName let nextSelected = null if (this.parentList.length === 1) { if (!!this.parentWidget) { @@ -81,10 +82,9 @@ export default { this.$nextTick(() => { this.parentList.splice(this.indexOfParentList, 1) - //if (!!nextSelected) { this.designer.setSelected(nextSelected) - //} + this.designer.formWidget.deleteWidgetRef(widgetRefName) //删除组件ref!!! this.designer.emitHistoryChange() }) } diff --git a/src/components/form-designer/form-widget/field-widget/form-item-wrapper.vue b/src/components/form-designer/form-widget/field-widget/form-item-wrapper.vue index e4998e2..678791d 100644 --- a/src/components/form-designer/form-widget/field-widget/form-item-wrapper.vue +++ b/src/components/form-designer/form-widget/field-widget/form-item-wrapper.vue @@ -188,6 +188,7 @@ removeFieldWidget() { if (!!this.parentList) { + const fieldRefName = this.designer.selectedWidgetName let nextSelected = null if (this.parentList.length === 1) { if (!!this.parentWidget) { @@ -201,10 +202,9 @@ this.$nextTick(() => { this.parentList.splice(this.indexOfParentList, 1) - //if (!!nextSelected) { this.designer.setSelected(nextSelected) - //} + this.designer.formWidget.deleteWidgetRef(fieldRefName) //删除组件ref!!! this.designer.emitHistoryChange() }) } diff --git a/src/components/form-designer/form-widget/field-widget/static-content-wrapper.vue b/src/components/form-designer/form-widget/field-widget/static-content-wrapper.vue index 6620d31..8f6a039 100644 --- a/src/components/form-designer/form-widget/field-widget/static-content-wrapper.vue +++ b/src/components/form-designer/form-widget/field-widget/static-content-wrapper.vue @@ -107,6 +107,7 @@ removeFieldWidget() { if (!!this.parentList) { + const fieldRefName = this.designer.selectedWidgetName let nextSelected = null if (this.parentList.length === 1) { if (!!this.parentWidget) { @@ -120,10 +121,9 @@ this.$nextTick(() => { this.parentList.splice(this.indexOfParentList, 1) - //if (!!nextSelected) { this.designer.setSelected(nextSelected) - //} + this.designer.formWidget.deleteWidgetRef(fieldRefName) //删除组件ref!!! this.designer.emitHistoryChange() }) } diff --git a/src/components/form-designer/form-widget/index.vue b/src/components/form-designer/form-widget/index.vue index d032bd3..9a2fd7a 100644 --- a/src/components/form-designer/form-widget/index.vue +++ b/src/components/form-designer/form-widget/index.vue @@ -184,6 +184,10 @@ }) }, + deleteWidgetRef(widgetRefName) { + delete this.widgetRefList[widgetRefName] + }, + } } diff --git a/src/components/form-designer/index.vue b/src/components/form-designer/index.vue index 2a8ddf0..3ea0423 100644 --- a/src/components/form-designer/index.vue +++ b/src/components/form-designer/index.vue @@ -290,7 +290,6 @@ } if (modifiedFlag) { - this.$refs.formRef.clearWidgetRefList() this.designer.emitHistoryChange() } } @@ -305,7 +304,6 @@ clearDesigner() { this.$refs.toolbarRef.clearFormWidget() - this.$refs.formRef.clearWidgetRefList() }, diff --git a/src/components/form-designer/toolbar-panel/index.vue b/src/components/form-designer/toolbar-panel/index.vue index 02d26e1..7d86507 100644 --- a/src/components/form-designer/toolbar-panel/index.vue +++ b/src/components/form-designer/toolbar-panel/index.vue @@ -444,6 +444,7 @@ clearFormWidget() { this.designer.clearDesigner() + this.designer.formWidget.clearWidgetRefList() }, previewForm() { diff --git a/src/utils/util.js b/src/utils/util.js index 173ccf5..ad4ff38 100644 --- a/src/utils/util.js +++ b/src/utils/util.js @@ -352,7 +352,7 @@ export function getDefaultFormConfig() { size: '', labelAlign: 'label-left-align', cssCode: '', - customClass: '', + customClass: [], functions: '', //全局函数 layoutType: 'PC', jsonVersion: 3,