From efb4893fbfe4008ca4bdd693a8d3b711e0811dcf Mon Sep 17 00:00:00 2001 From: zhf <1204297681@qq.com> Date: Tue, 5 Nov 2024 20:22:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=AE=9E=E4=BD=93?= =?UTF-8?q?=E9=83=A8=E4=BB=B6=E6=9C=AA=E5=88=B7=E6=96=B0=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../view-design-entity-control.scss | 6 --- .../view-design-entity-control.tsx | 50 +++++++++++++++++-- 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/packages/view-design/src/components/panel-item-widgets/widgets/view-design-entity-control/view-design-entity-control.scss b/packages/view-design/src/components/panel-item-widgets/widgets/view-design-entity-control/view-design-entity-control.scss index 9c25e5a8..9e2967a4 100644 --- a/packages/view-design/src/components/panel-item-widgets/widgets/view-design-entity-control/view-design-entity-control.scss +++ b/packages/view-design/src/components/panel-item-widgets/widgets/view-design-entity-control/view-design-entity-control.scss @@ -77,12 +77,6 @@ @include b(view-design-entity-control-ctrl-pos-mask-actions) { display: none; - - @include b(view-design-entity-control-ctrl-pos-action) { - &:first-child { - display: none; - } - } } @include b(view-design-entity-control-ctrl-pos-actions) { diff --git a/packages/view-design/src/components/panel-item-widgets/widgets/view-design-entity-control/view-design-entity-control.tsx b/packages/view-design/src/components/panel-item-widgets/widgets/view-design-entity-control/view-design-entity-control.tsx index dcfcf66e..f004afe6 100644 --- a/packages/view-design/src/components/panel-item-widgets/widgets/view-design-entity-control/view-design-entity-control.tsx +++ b/packages/view-design/src/components/panel-item-widgets/widgets/view-design-entity-control/view-design-entity-control.tsx @@ -54,9 +54,20 @@ export default defineComponent({ }); // 部件id - const ctrlId = computed(() => { - return getCtrlIdByType(props.data.data?.ctrltype, props.data.data); - }); + const ctrlId = ref(''); + + watch( + () => props.data, + () => { + const type = props.data?.data?.ctrltype; + if (type) { + ctrlId.value = getCtrlIdByType(type, props.data.data); + } else { + ctrlId.value = ''; + } + }, + { immediate: true }, + ); watch( () => ctrlId.value, @@ -126,6 +137,32 @@ export default defineComponent({ // 部件占位内容元素尺寸变化监听器 let resizeObserver: ResizeObserver; + // 事件对象 + const rootEvent = panelDesignContext.rootEvent as IData; + + // 定时器标识 + let timer: number | undefined; + + // 重新加载部件占位 + const reloadCtrlPos = () => { + ctrlId.value = ''; + if (timer) { + window.clearTimeout(timer); + } + timer = window.setTimeout(() => { + const type = props.data?.data?.ctrltype; + if (type) { + ctrlId.value = getCtrlIdByType(type, props.data.data); + } else { + ctrlId.value = ''; + } + timer = undefined; + }, 0); + }; + + // 监听重新加载部件占位 + rootEvent.on('onReloadCtrlPos', reloadCtrlPos); + onMounted(() => { if (ctrlPosContent.value) { resizeObserver = new ResizeObserver(() => { @@ -144,6 +181,10 @@ export default defineComponent({ if (resizeObserver) { resizeObserver.disconnect(); } + rootEvent.off('onReloadCtrlPos', reloadCtrlPos); + if (timer) { + window.clearTimeout(timer); + } }); // 绘制部件 @@ -200,6 +241,9 @@ export default defineComponent({ ]} > {actions.map(action => { + if (action.tag === 'ctrlDesign' && !ctrlId.value) { + return; + } return (