<template>
|
<div
|
:style="{ maxHeight: `${maxHeight}px`, maxWidth: `${maxWidth}px`, minHeight: `${minHeight}px`, minWidth: minWidth }"
|
class="order-2 rounded-lg border-solid border-gray-100 bg-white p-3 shadow-md relative hover:border-blue-500 group h-fit"
|
>
|
<div
|
class="group-hover:visible invisible flex absolute divide-y-[1.5px] divide-solid divide-gray-100 rounded-lg right-0 -top-0.5 translate-y-[-100%]"
|
style="box-shadow: 0 0 15px #dbdee6"
|
>
|
<el-tooltip effect="dark" content="复制" placement="top">
|
<div
|
class="flex content-center items-center border-x-0 p-1 hover:bg-gray-200 active:bg-gray-300 cursor-pointer"
|
@click="handleClickDuplicateBtn"
|
>
|
<span class="ywifont !text-[20px] mb-1 p-1.5 ywicon-copy"></span>
|
</div>
|
</el-tooltip>
|
<el-tooltip effect="dark" content="删除" placement="top">
|
<div
|
@click="clickDeleteBtn"
|
class="flex content-center items-center border-x-0 p-1 hover:bg-gray-200 active:bg-gray-300 hover:text-red-400 cursor-pointer"
|
>
|
<span class="ywifont !text-[20px] mb-1 p-1.5 ywicon-shanchu"></span>
|
</div>
|
</el-tooltip>
|
</div>
|
<div class="flex flex-col gap-y-2">
|
<div class="flex flex-col flex-0 gap-1.5 border">
|
<div class="flex items-center gap-x-2">
|
<YWIcon
|
:name="VueFlowConfig.nodeStyleMap.get(type).icon"
|
:fontSize="VueFlowConfig.nodeStyleMap.get(type).fontSize"
|
:color="VueFlowConfig.nodeStyleMap.get(type).color"
|
class="rounded-lg p-1.5 h-fit"
|
:class="VueFlowConfig.nodeStyleMap.get(type).class"
|
/>
|
<p v-if="!titleIsEdit" class="text-medium font-bold" @click="titleIsEdit = true">{{ title }}</p>
|
<el-input v-elInputFocus="false" class="nodrag" v-else v-model="title" @blur="() => (titleIsEdit = false)"></el-input>
|
</div>
|
<p v-if="description" class="text-extra-small text-secondary">
|
{{ description }}
|
</p>
|
</div>
|
|
<div
|
v-if="$slots.default"
|
class="flex-auto !overflow-x-auto gap-y-2 flex-col flex nodrag"
|
:class="[showOffset ? 'border border-solid border-x-0 border-b-0 pt-3 border-color-default' : '']"
|
>
|
<slot></slot>
|
</div>
|
</div>
|
</div>
|
</template>
|
|
<script setup lang="ts">
|
import { useNode, useVueFlow } from '@vue-flow/core';
|
import { ref } from 'vue';
|
|
import type { PropType } from 'vue';
|
import { VueFlowHelper } from '../../../VueFlowHelper';
|
import type { NodeType } from '../../../vueFlowEnum';
|
import { VueFlowConfig } from '../../VueFlowConfig';
|
import { deepClone } from '/@/utils/other';
|
|
// defineOptions({
|
// inheritAttrs: false,
|
// });
|
const titleIsEdit = ref(false);
|
|
const props = defineProps({
|
maxWidth: { type: Number },
|
maxHeight: { type: Number },
|
minWidth: { type: Number },
|
minHeight: { type: Number },
|
type: { type: String as PropType<NodeType>, required: true },
|
description: { type: String },
|
showOffset: {
|
type: Boolean,
|
default: true,
|
},
|
});
|
|
const title = defineModel('title', {
|
type: String,
|
});
|
const { removeNodes, nodes, addNodes } = useVueFlow();
|
const node = useNode();
|
function handleClickDuplicateBtn() {
|
const { type, position, data } = node.node;
|
const newNode = {
|
id: VueFlowHelper.genGeometryId(),
|
type,
|
position: {
|
x: position.x + 100,
|
y: position.y + 100,
|
},
|
data: deepClone(data),
|
};
|
addNodes(newNode);
|
}
|
const clickDeleteBtn = () => {
|
removeNodes(node.id);
|
};
|
</script>
|
<style scoped lang="scss"></style>
|