schangxiang@126.com
2025-05-07 cace264ad9d86a7831099810b079da1141957add
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import { HtmlNodeModel, HtmlNode } from '@logicflow/core'
import { h, createApp, defineComponent } from 'vue'
import styles from './index.module.scss'
import Icon from '@/components/Icon/Icon'
import { injectStore, emitter } from '../../core/store'
 
export default defineComponent({
  name: 'BaseNode',
  props: {
    node: {
      type: Object,
      default: () => ({}),
    },
    color: {
      type: String,
      default: '#000',
    },
    background: {
      type: String,
      default: '#fff',
    },
    icon: {
      type: String,
    },
    width: {
      type: [String, Number],
      default: '101px',
    },
    height: {
      type: [String, Number],
      default: '33px',
    },
    borderColor: {
      type: String,
      default: '#ccc',
    },
    type: {
      type: String,
      default: 'base',
    },
  },
  emits: ['view'],
  setup(props, { emit }) {
    const { selected, onSelectNode } = injectStore()
    const onClickDetail = () => {
      emitter.emit('view', props.node)
    }
    return () => {
      const style = {
        background: props.background,
        color: props.color,
        width: props.width,
        height: props.height,
        borderColor: props.borderColor,
      }
      const node = props.node
      return (
        <div
          onClick={(event: Event) => onSelectNode(node, event)}
          class={styles.baseNodeContent}
        >
          <div
            class={{
              [styles.baseNode]: true,
              [styles.baseNodeSelected]: node.id === selected.value,
            }}
            style={style}
          >
            {props.type === 'node' ? (
              <Icon
                class={styles.detail}
                icon="detail"
                width={15}
                height={15}
                onClick={onClickDetail}
              />
            ) : null}
            <Icon icon={props.icon} width={25} height={25} />
            <div class={styles.nodeText}>{node?.Name}</div>
          </div>
        </div>
      )
    }
  },
})