diff --git a/src/components/RendererDom.vue b/src/components/RendererDom.vue index 5caec4c..5ea9cf1 100644 --- a/src/components/RendererDom.vue +++ b/src/components/RendererDom.vue @@ -24,7 +24,6 @@ if (props['itemData']['category'] == 'formItem') { } } - // 选中元素节点 const handleSelectDom = (activeId: any) => { const fatherDom = handleFindDomById(widgetJson['subDomList'], activeId, false) @@ -48,9 +47,32 @@ const handleFindLastDom = () => { widgetJson['activeConfig']['activeDisplayName'] = "" } } -// 移除组件 -const handleDelDom = () => { +// 移除指定ID的组件 +const handleDelDom = (node: any = widgetJson) => { + if (!node || !Array.isArray(node.subDomList)) return; + const deleteFromList = (list: any) => { + for (let i = list.length - 1; i >= 0; i--) { + const item = list[i]; + if (Array.isArray(item)) { + // 如果是二维数组,递归删除内部元素 + deleteFromList(item); + // 如果内部数组为空,删除整个空数组 + if (item.length === 0) { + list.splice(i, 1); + } + } else if (item && item.id === widgetJson['activeConfig']['activeId']) { + // 找到匹配项,删除它 + list.splice(i, 1); + } else if (item && item.subDomList) { + // 递归子节点 + handleDelDom(item); + } + } + }; + + deleteFromList(node.subDomList); } + diff --git a/src/utils/table.ts b/src/utils/table.ts index 00374b7..4c76828 100644 --- a/src/utils/table.ts +++ b/src/utils/table.ts @@ -38,8 +38,10 @@ export const addTable = (widgetJson: IWidgetJson, addItemTypeName: any) => { widgetJson['subDomList'].push(addItemData) } } - widgetJson['activeConfig']['activeId'] = activeId - widgetJson['activeConfig']['activeDisplayName'] = activeDisplayName + widgetJson['activeConfig']['activeId'] = tableCol['activeId'] + widgetJson['activeConfig']['activeDisplayName'] = tableCol['activeDisplayName'] + // widgetJson['activeConfig']['activeId'] = activeId + // widgetJson['activeConfig']['activeDisplayName'] = activeDisplayName } diff --git a/src/views/Home/subCom/MainWrapper.vue b/src/views/Home/subCom/MainWrapper.vue index 66de69e..4256363 100644 --- a/src/views/Home/subCom/MainWrapper.vue +++ b/src/views/Home/subCom/MainWrapper.vue @@ -38,6 +38,50 @@ provide('docForm', docForm) td { border: 1px dashed var(--el-color-primary); + position: relative; + + .moreBox { + position: relative; + + &:hover { + .actionBox { + display: block; + } + } + + .actionBox { + // display: none; + position: absolute; + top: 20px; + left: 50%; + transform: translateX(-50%); + padding-top: 12px; + + ul { + + list-style: none; + padding-left: 0; + background-color: #fff; + border: 1px solid #c1c1c1; + padding-bottom: 2px; + + li { + list-style: none; + white-space: nowrap; + color: #666; + font-size: 12px; + padding: 4px 8px; + + &:hover { + background-color: #c9effd; + color: var(--el-color-primary); + } + } + } + } + + } + } }