MappingNodeItem.vue
3.01 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<template>
<div class="nodeItem" :style="nodeCoordinate">
<div class="nodeHeader" :style="setHeaderColor(node.type)">
<ht-icon
name="component"
v-if="node.flowType == 'main'"
title="主流程业务对象"
/>
<ht-icon name="block" v-else title="子流程业务对象" />
{{ node.comment }}({{ node.name }})
</div>
<ul :id="`${node.id}${minus}cols`" class="cols">
<li
v-for="col in node.columns"
:key="`${node.type}${minus}${node.name}${minus}${col.name}`"
:id="`${node.type}${minus}${node.name}${minus}${col.name}`"
@click="handleColumnClick(col)"
:class="['col', {current: isCurrentNode && col == currentColumn}]"
>
<p :title="col.comment">
{{ col.comment }}
</p>
<span :title="col.name">({{ col.name }})</span>
<ht-icon
v-if="col == creatorFollowColumn"
title="发起人账号字段"
class="col-user-icon"
name="user"
/>
</li>
</ul>
</div>
</template>
<script>
import {tbType} from './tbType.js'
export default {
name: 'MappingNodeItem',
props: {
node: Object,
creatorFollowColumn: Object,
currentNode: Object,
currentColumn: Object
},
data() {
return {
tbType: tbType,
minus: '-' //表名和列名的分割符号
}
},
methods: {
setHeaderColor(type) {
for (let key in tbType) {
if (type === key) {
return {
backgroundColor: tbType[key].color
}
}
}
},
handleColumnClick(column) {
if (this.node && this.node.type != 'RS') {
return
}
this.$emit('column-click', this.node, column)
}
},
computed: {
nodeCoordinate: {
get() {
return {
top: this.node.top + 'px',
left: this.node.left + 'px'
}
}
},
isCurrentNode() {
return this.node == this.currentNode
}
}
}
</script>
<style lang="scss" scoped>
.nodeItem {
position: absolute;
display: felx;
border: 1px solid #b7b6b6;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
justify-items: center;
align-items: center;
z-index: 9995;
.nodeHeader {
cursor: move;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
padding: 12px;
background-color: #91c051;
color: white;
font-size: 12px;
}
.col {
display: flex;
align-items: center;
list-style: none;
background-color: #fff;
padding: 5px 10px;
font-size: smaller;
cursor: default;
&:hover,
&.current {
background-color: #f8f8f8;
outline: 1px solid #ccc;
}
p {
max-width: 100px;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
span {
max-width: 80px;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
margin-right: 25px;
}
svg.col-user-icon {
position: absolute;
right: 10px;
color: #999;
}
}
}
</style>