|
<template>
<div class="custom-node">
<common-icon
v-if="nodeInfo?.isStartNode"
class="identification"
name="flow-start-icon"
:size="16"
></common-icon>
<common-icon
v-if="nodeInfo.type !== 'process'"
:name="nodeInfo?.icon"
:size="32"
></common-icon>
<img v-else class="img" :src="nodeInfo?.icon" alt="" />
<span class="title">{{ nodeInfo?.label }}</span>
</div>
</template>
<script>
export default {
name: 'CustomNode',
inject: ['getNode'],
data() {
return {
node: this.getNode(),
nodeInfo: this.getNode().getData()
};
},
computed: {},
watch: {
flowTargetData: {
handler(val) {
console.log(val);
},
deep: true
}
},
created() {
// console.log(this.node);
// debugger;
this.node.on('change:data', this.setDataFromNode);
},
mounted() {},
methods: {
// 设置节点数据
setDataFromNode() {
const data = this.node.getData();
this.nodeInfo = data;
}
}
};
</script>
<style scoped lang="scss">
.custom-node {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
margin-top: 10px;
cursor: move;
position: relative;
.title {
margin-top: 6px;
color: rgba(0, 0, 0, 0.65);
font-size: 14px;
word-wrap: break-word;
word-break: break-all;
text-align: center;
}
.img {
width: 32px;
height: 32px;
}
.identification {
position: absolute;
top: -10px;
right: 15px;
z-index: 1;
}
}
</style>
|