feat(脑图): 脑图批量删除

This commit is contained in:
baiqi 2024-08-01 10:45:01 +08:00 committed by 刘瑞斌
parent 00b0df2c33
commit 122c54691a
3 changed files with 42 additions and 13 deletions

View File

@ -15,8 +15,7 @@
:can-show-float-menu="canShowFloatMenu"
:can-show-delete-menu="canShowDeleteMenu"
:disabled="!hasEditPermission"
:can-show-batch-delete="true"
can-show-more-batch-menu
:can-show-batch-delete="canShowBatchDelete"
custom-priority
single-tag
tag-enable
@ -346,8 +345,10 @@
canShowDeleteMenu.value = true;
}
} else {
canShowFloatMenu.value = data.id === 'root';
canShowExecuteMethodMenu.value = data.id === 'root';
nextTick(() => {
canShowFloatMenu.value = node.data.id === 'root';
canShowExecuteMethodMenu.value = node.data.id === 'root';
});
showAssociateCaseMenu.value = false;
showConfigMenu.value = false;
extraVisible.value = false;
@ -663,6 +664,29 @@
configFormUnsaved.value = false;
}
/**
* 是否可以显示批量删除
*/
const canShowBatchDelete = ref(false);
watch(
() => minderStore.event.eventId,
async () => {
if (window.minder) {
const selectedNodes: MinderJsonNode[] = window.minder.getSelectedNodes();
if (
minderStore.event.name === MinderEventName.DRAG_FINISH ||
minderStore.event.name === MinderEventName.NODE_UNSELECT ||
minderStore.event.name === MinderEventName.NODE_SELECT
) {
canShowBatchDelete.value = selectedNodes.every((node) => node.data?.level === 2);
}
}
},
{
immediate: true,
}
);
/**
* 处理节点选中
* @param node 节点

View File

@ -41,8 +41,13 @@
</template>
</a-dropdown>
<slot name="batchMenu"></slot>
<a-tooltip v-if="onlyDelete" :content="t('common.delete')">
<MsButton type="icon" class="ms-minder-node-float-menu-icon-button" @click="handleMinderMenuSelect('delete')">
<MsIcon type="icon-icon_delete-trash_outlined1" class="text-[var(--color-text-4)]" />
</MsButton>
</a-tooltip>
<a-dropdown
v-if="props.canShowMoreBatchMenu"
v-else-if="props.canShowMoreBatchMenu"
v-model:popup-visible="moreMenuVisible"
class="ms-minder-dropdown"
:popup-translate="[0, -4]"
@ -133,7 +138,8 @@
const selectedNodes: MinderJsonNode[] = window.minder.getSelectedNodes();
if (
minderStore.event.name === MinderEventName.DRAG_FINISH ||
minderStore.event.name === MinderEventName.NODE_UNSELECT
minderStore.event.name === MinderEventName.NODE_UNSELECT ||
minderStore.event.name === MinderEventName.NODE_SELECT
) {
batchMenuVisible.value = selectedNodes.length > 1;
}
@ -144,6 +150,10 @@
}
);
const onlyDelete = computed(() => {
return props.canShowBatchDelete && !props.canShowBatchCopy && !props.canShowBatchCut && !props.canShowBatchExpand;
});
/**
* 处理快捷菜单选择
* @param type 选择的菜单项

View File

@ -134,13 +134,8 @@
}
},
delete: () => {
if (
(props.canShowDeleteMenu || (props.canShowMoreMenu && props.canShowMoreMenuNodeOperation)) &&
!props.disabled
) {
const selectedNodes: MinderJsonNode[] = window.minder.getSelectedNodes();
minderDelete(selectedNodes);
}
},
expand: () => {
const selectedNodes: MinderJsonNode[] = window.minder.getSelectedNodes();