editArea.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <g v-if="isEditAreaShow.value">
  3. <foreignObject width="100%" height="100%" style="position: relative" @click="click_menu_cover($event)">
  4. <body xmlns="http://www.w3.org/1999/xhtml" :style="get_menu_style()" style="width:150px;height: auto;border-radius: 5px;">
  5. <div class="menu_contain">
  6. <span @click="delEdges">删 除</span>
  7. <!-- <span @click="changePort('in_ports')">ADD IN PORT</span>
  8. <span @click="changePort('out_ports')">ADD OUT PORT</span> -->
  9. <span v-if="isEditAreaShow.detail" @click="editNode">EDIT IT</span>
  10. <span v-for="item in isEditAreaShow.rightClickEvent" @click="handlePersonalThs(item.eventName)" :key="item.label">{{ item.label }}</span>
  11. </div>
  12. </body>
  13. </foreignObject>
  14. </g>
  15. </template>
  16. <script>
  17. export default {
  18. props: {
  19. isEditAreaShow: {
  20. type: Object,
  21. default: () => {
  22. return {
  23. value: false,
  24. x: -9999,
  25. y: -9999,
  26. id: null
  27. }
  28. }
  29. }
  30. },
  31. mounted() {
  32. console.log('isEditAreaShow', this.isEditAreaShow)
  33. },
  34. methods: {
  35. click_menu_cover(e) {
  36. this.$emit('close_click_nodes')
  37. e.preventDefault();
  38. e.cancelBubble = true;
  39. e.stopPropagation();
  40. },
  41. get_menu_style() {
  42. let left = this.isEditAreaShow.x;
  43. let top = this.isEditAreaShow.y;
  44. return {
  45. position: "absolute",
  46. left: left + 'px',
  47. top: top + 'px'
  48. }
  49. },
  50. delEdges() {
  51. let _this = this
  52. let params = {
  53. // eslint-disable-next-line no-mixed-spaces-and-tabs
  54. model_id: sessionStorage['newGraph'],
  55. // eslint-disable-next-line no-mixed-spaces-and-tabs
  56. id: _this.isEditAreaShow.id
  57. }
  58. this.$confirm('此操作将永久删除节点, 是否继续?', '提示', {
  59. confirmButtonText: '确定',
  60. cancelButtonText: '取消',
  61. type: 'warning'
  62. }).then(() => {
  63. _this.$emit('delNode', params)
  64. _this.$emit('close_click_nodes')
  65. console.log(params)
  66. this.$message({
  67. type: 'success',
  68. message: '删除成功!'
  69. });
  70. }).catch(() => {
  71. this.$message({
  72. type: 'info',
  73. message: '已取消删除'
  74. });
  75. });
  76. },
  77. changePort(action) {
  78. this.$emit('changePort', action, this.isEditAreaShow.id)
  79. },
  80. editNode() {
  81. this.$emit('editNodeDetails', this.isEditAreaShow)
  82. },
  83. handlePersonalThs(eventName) {
  84. this.$emit('nodesPersonalEvent', eventName, this.isEditAreaShow.id)
  85. }
  86. }
  87. };
  88. </script>
  89. <style scoped>
  90. .connector {
  91. stroke: hsla(0, 0%, 50%, 0.6);
  92. stroke-width: 2px;
  93. fill: none;
  94. }
  95. .menu_cover {
  96. position: fixed;
  97. left: 0;
  98. top: 0;
  99. right: 0;
  100. bottom: 0;
  101. }
  102. .connector-hl {
  103. stroke: hsla(0, 0%, 50%, 0.4);
  104. stroke-width: 5px;
  105. fill: none;
  106. }
  107. .menu_contain {
  108. width: 150px;
  109. border: 1px solid rgba(1, 1, 1, 0.3);
  110. background: #ffffff;
  111. border-radius: 5px;
  112. padding: 3px;
  113. }
  114. .menu_contain span{
  115. width: 100%;
  116. display: inline-block;
  117. }
  118. .menu_contain span:hover {
  119. background-color: rgba(40, 157, 233, 0.3);
  120. cursor: pointer;
  121. }
  122. </style>