mainBody.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <template>
  2. <!-- 正常竖版 -->
  3. <foreignObject v-if="isVertical()" width="180" height="30" >
  4. <body xmlns="http://www.w3.org/1999/xhtml" style="margin: 0;background: transparent;" >
  5. <div>
  6. <div :style="item.nodeStyle" :class="choice.paneNode.indexOf(item.id) !== -1 ? 'pane-node-content selected' : 'pane-node-content'">
  7. <i
  8. @dblclick="$emit('nodesPersonalEvent', 'dbClickNodeIcon', item.id)"
  9. :style="item.iconStyle" :class="`${item.iconClassName || 'el-icon-coin'} icon icon-data`"></i>
  10. <input
  11. type="text" class="name"
  12. v-model="item.name"
  13. @change="$emit('changeNodeName', item)">
  14. </div>
  15. <p v-if="choice.paneNode.indexOf(item.id) !== -1" class="node-pop">{{item.nameDescribe || item.name}}</p>
  16. <div :class="currentEvent === 'dragLink' ? 'pane-node-parent-hl' : 'pane-node-parent' ">
  17. <div v-for="(poi, nth) in item.in_ports" :key="'__' + nth" :style="{width: `${ 100 / (item.in_ports.length + 1)}%`}">
  18. <span
  19. class="space"
  20. @mouseup="$emit('linkEnd', i, nth)"></span>
  21. </div>
  22. </div>
  23. <div class="pane-node-children">
  24. <div v-for="(poi, nth) in item.out_ports" :key="'___' + nth" :style="{width: `${ 100 / (item.out_ports.length + 1)}%`}">
  25. <span
  26. class="space"
  27. @mousedown="$emit('linkPre', $event, i, nth)"></span>
  28. </div>
  29. </div>
  30. </div>
  31. </body>
  32. </foreignObject>
  33. <!-- 横版 -->
  34. <foreignObject v-else width="180" height="30" >
  35. <body xmlns="http://www.w3.org/1999/xhtml" style="margin: 0" >
  36. <div>
  37. <div :style="item.nodeStyle" :class="choice.paneNode.indexOf(item.id) !== -1 ? 'pane-node-content selected' : 'pane-node-content'">
  38. <i
  39. @dblclick="$emit('nodesPersonalEvent', 'dbClickNodeIcon', item.id)"
  40. :style="item.iconStyle" :class="`${item.iconClassName || 'el-icon-coin'} icon icon-data`"></i>
  41. <input
  42. type="text" class="name"
  43. v-model="item.name"
  44. @change="$emit('changeNodeName', item)">
  45. </div>
  46. <p v-if="choice.paneNode.indexOf(item.id) !== -1" class="node-pop">{{item.nameDescribe || item.name}}</p>
  47. <div id="parent-cross" :class="currentEvent === 'dragLink' ? 'pane-node-parent-hl' : 'pane-node-parent' ">
  48. <div v-for="(poi, nth) in item.in_ports" :key="'__' + nth" :style="{width: `${ 100 / (item.in_ports.length + 1)}%`}">
  49. <span
  50. class="space"
  51. @mouseup="$emit('linkEnd', i, nth)"></span>
  52. </div>
  53. </div>
  54. <div id="children-cross" class="pane-node-children">
  55. <div v-for="(poi, nth) in item.out_ports" :key="'___' + nth" :style="{width: `${ 100 / (item.out_ports.length + 1)}%`}">
  56. <span
  57. class="space"
  58. @mousedown="$emit('linkPre', $event, i, nth)"></span>
  59. </div>
  60. </div>
  61. </div>
  62. </body>
  63. </foreignObject>
  64. </template>
  65. <script>
  66. export default {
  67. props: {
  68. item: {
  69. type: Object,
  70. default: () => {}
  71. },
  72. choice: {
  73. type: Object,
  74. default: () => {}
  75. },
  76. currentEvent: {
  77. type: String,
  78. default: () => ''
  79. },
  80. i: {
  81. type: Number,
  82. default: () => 0
  83. }
  84. },
  85. data() {
  86. return {
  87. }
  88. },
  89. methods: {
  90. isVertical() {
  91. let GlobalConfig = { isVertical: true }
  92. let _GlobalConfig = localStorage.getItem('GlobalConfig')
  93. if (_GlobalConfig && _GlobalConfig.length > 0) {
  94. GlobalConfig = Object.assign(GlobalConfig, JSON.parse(_GlobalConfig))
  95. }
  96. return GlobalConfig.isVertical
  97. }
  98. }
  99. }
  100. </script>
  101. <style scoped>
  102. foreignObject {
  103. overflow: visible;
  104. }
  105. .pane-node-content {
  106. box-sizing: border-box;
  107. width: 180px;
  108. height: 30px;
  109. background-color: hsla(0, 0%, 100%, 0.9);
  110. border: 1px solid #289de9;
  111. border-radius: 15px;
  112. font-size: 12px;
  113. -webkit-transition: background-color 0.2s;
  114. transition: background-color 0.2s;
  115. }
  116. .pane-node-content .icon {
  117. width: 26px;
  118. height: 26px;
  119. margin: 1px;
  120. border-radius: 100%;
  121. float: left;
  122. color: #fff;
  123. font-size: 26px;
  124. background-color: #289de9;
  125. cursor: pointer;
  126. }
  127. .pane-node-content .parentLink {
  128. font-size: 0;
  129. height: 12px;
  130. width: 12px;
  131. position: absolute;
  132. top: 0;
  133. left: 90px;
  134. transform: translateX(-50%);
  135. border-top: 6px solid black;
  136. border-left: 6px solid transparent;
  137. border-right: 6px solid transparent;
  138. }
  139. .pane-node-content .childLink {
  140. height: 10px;
  141. width: 10px;
  142. position: absolute;
  143. bottom: 0;
  144. left: 90px;
  145. transform: translate(-50%, 50%);
  146. border-radius: 50%;
  147. background: #ffffff;
  148. cursor: crosshair;
  149. }
  150. .pane-node-content .name {
  151. float: left;
  152. margin-left: 2px;
  153. width: 135px;
  154. line-height: 28px;
  155. font-size: 14px;
  156. overflow: hidden;
  157. text-overflow: ellipsis;
  158. white-space: nowrap;
  159. cursor: pointer;
  160. user-select: none;
  161. height: 26px;
  162. background: transparent;
  163. border: none;
  164. }
  165. .pane-node-parent-hl {
  166. position: fixed;
  167. top: -5px;
  168. height: 10px;
  169. width: 100%;
  170. display: flex;
  171. transform: translateX(6px);
  172. }
  173. .pane-node-parent-hl .space {
  174. width: 12px;
  175. height: 12px;
  176. border-radius: 50%;
  177. border: 1px solid gray;
  178. background: #ffffff;
  179. position: absolute;
  180. right: 0;
  181. top: 0;
  182. cursor: crosshair;
  183. }
  184. .pane-node-parent-hl .space:hover {
  185. box-shadow: 0 0 0 6px #3ddd73;
  186. }
  187. .paneSuccess {
  188. background: #3ddd73 !important;
  189. }
  190. .pane-node-parent-hl > div {
  191. position: relative;
  192. display: inline-block;
  193. }
  194. #parent-cross {
  195. top: 0px ;
  196. height: 100% ;
  197. width: 10px ;
  198. left: -10px ;
  199. }
  200. #parent-cross .space {
  201. position: absolute;
  202. left: 0;
  203. top: 50%;
  204. transform: translateY(-50%);
  205. }
  206. #children-cross {
  207. top:0px;
  208. right: 0;
  209. height: 100%;
  210. width: 10px;
  211. position: fixed;
  212. }
  213. #children-cross .space{
  214. position: absolute;
  215. left: 0;
  216. top: 50%;
  217. transform: translateY(-50%);
  218. }
  219. .node-pop {
  220. position: absolute;
  221. left: 100px;
  222. top: -100px;
  223. border: 1px solid #ccc;
  224. padding: 10px 20px;
  225. border-radius: 30px 20px;
  226. background: #fff;
  227. pointer-events: none;
  228. }
  229. .node-pop:after {
  230. content: '.';
  231. font-size: 0;
  232. height: 20px;
  233. width: 20px;
  234. background: #fff;
  235. border: 2px #ccc solid;
  236. border-top: none;
  237. border-right: none;
  238. z-index: 100;
  239. position: absolute;
  240. transform: rotate(-34deg) skew(-33deg, -1deg) scale(1.5);
  241. border-radius: 20px 0 0 0;
  242. left: -14px;
  243. top: 22px;
  244. pointer-events: none;
  245. }
  246. .pane-node-parent {
  247. position: fixed;
  248. top: -5px;
  249. height: 10px;
  250. width: 100%;
  251. display: flex;
  252. opacity: 0;
  253. transform: translateX(6px);
  254. }
  255. .pane-node-parent .space {
  256. width: 12px;
  257. height: 12px;
  258. border-radius: 50%;
  259. border: 1px solid gray;
  260. background: #ffffff;
  261. position: absolute;
  262. right: 0;
  263. top: 0;
  264. }
  265. .pane-node-parent > div {
  266. position: relative;
  267. display: inline-block;
  268. }
  269. .pane-node-children {
  270. position: fixed;
  271. bottom: 0;
  272. width: 100%;
  273. display: flex;
  274. opacity: 0;
  275. transform: translateX(6px);
  276. }
  277. .pane-node-children .space{
  278. width: 12px;
  279. height: 12px;
  280. border-radius: 50%;
  281. border: 1px solid gray;
  282. background: #ffffff;
  283. position: absolute;
  284. right: 0px;
  285. bottom: -6px;
  286. cursor: crosshair;
  287. }
  288. .pane-node-children .space {
  289. background: #cccccc;
  290. }
  291. .pane-node-children:hover {
  292. opacity: 1;
  293. }
  294. .pane-node-children > div {
  295. position: relative;
  296. display: inline-block;
  297. }
  298. .selected {
  299. background: rgba(227, 244, 255, 0.9) !important;
  300. }
  301. </style>