修复清空设计器画布时未同步清除组件refList的错误。

This commit is contained in:
vdpAdmin 2023-02-20 15:51:27 +08:00
parent 299e7c7506
commit 52b3b33043
8 changed files with 13 additions and 9 deletions

View File

@ -92,6 +92,7 @@ export function createDesigner(vueInstance) {
let modifiedFlag = false let modifiedFlag = false
if (!!formJson && !!formJson.widgetList) { if (!!formJson && !!formJson.widgetList) {
this.formWidget.clearWidgetRefList()
this.widgetList = formJson.widgetList this.widgetList = formJson.widgetList
modifiedFlag = true modifiedFlag = true
} }

View File

@ -68,6 +68,7 @@ export default {
removeWidget() { removeWidget() {
if (!!this.parentList) { if (!!this.parentList) {
const widgetRefName = this.designer.selectedWidgetName
let nextSelected = null let nextSelected = null
if (this.parentList.length === 1) { if (this.parentList.length === 1) {
if (!!this.parentWidget) { if (!!this.parentWidget) {
@ -81,10 +82,9 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.parentList.splice(this.indexOfParentList, 1) this.parentList.splice(this.indexOfParentList, 1)
//if (!!nextSelected) {
this.designer.setSelected(nextSelected) this.designer.setSelected(nextSelected)
//}
this.designer.formWidget.deleteWidgetRef(widgetRefName) //删除组件ref
this.designer.emitHistoryChange() this.designer.emitHistoryChange()
}) })
} }

View File

@ -188,6 +188,7 @@
removeFieldWidget() { removeFieldWidget() {
if (!!this.parentList) { if (!!this.parentList) {
const fieldRefName = this.designer.selectedWidgetName
let nextSelected = null let nextSelected = null
if (this.parentList.length === 1) { if (this.parentList.length === 1) {
if (!!this.parentWidget) { if (!!this.parentWidget) {
@ -201,10 +202,9 @@
this.$nextTick(() => { this.$nextTick(() => {
this.parentList.splice(this.indexOfParentList, 1) this.parentList.splice(this.indexOfParentList, 1)
//if (!!nextSelected) {
this.designer.setSelected(nextSelected) this.designer.setSelected(nextSelected)
//}
this.designer.formWidget.deleteWidgetRef(fieldRefName) //ref
this.designer.emitHistoryChange() this.designer.emitHistoryChange()
}) })
} }

View File

@ -107,6 +107,7 @@
removeFieldWidget() { removeFieldWidget() {
if (!!this.parentList) { if (!!this.parentList) {
const fieldRefName = this.designer.selectedWidgetName
let nextSelected = null let nextSelected = null
if (this.parentList.length === 1) { if (this.parentList.length === 1) {
if (!!this.parentWidget) { if (!!this.parentWidget) {
@ -120,10 +121,9 @@
this.$nextTick(() => { this.$nextTick(() => {
this.parentList.splice(this.indexOfParentList, 1) this.parentList.splice(this.indexOfParentList, 1)
//if (!!nextSelected) {
this.designer.setSelected(nextSelected) this.designer.setSelected(nextSelected)
//}
this.designer.formWidget.deleteWidgetRef(fieldRefName) //ref
this.designer.emitHistoryChange() this.designer.emitHistoryChange()
}) })
} }

View File

@ -184,6 +184,10 @@
}) })
}, },
deleteWidgetRef(widgetRefName) {
delete this.widgetRefList[widgetRefName]
},
} }
} }
</script> </script>

View File

@ -290,7 +290,6 @@
} }
if (modifiedFlag) { if (modifiedFlag) {
this.$refs.formRef.clearWidgetRefList()
this.designer.emitHistoryChange() this.designer.emitHistoryChange()
} }
} }
@ -305,7 +304,6 @@
clearDesigner() { clearDesigner() {
this.$refs.toolbarRef.clearFormWidget() this.$refs.toolbarRef.clearFormWidget()
this.$refs.formRef.clearWidgetRefList()
}, },

View File

@ -444,6 +444,7 @@
clearFormWidget() { clearFormWidget() {
this.designer.clearDesigner() this.designer.clearDesigner()
this.designer.formWidget.clearWidgetRefList()
}, },
previewForm() { previewForm() {

View File

@ -352,7 +352,7 @@ export function getDefaultFormConfig() {
size: '', size: '',
labelAlign: 'label-left-align', labelAlign: 'label-left-align',
cssCode: '', cssCode: '',
customClass: '', customClass: [],
functions: '', //全局函数 functions: '', //全局函数
layoutType: 'PC', layoutType: 'PC',
jsonVersion: 3, jsonVersion: 3,