tooltipCom.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <div class="container" ref="container" @mouseover="nodeMouseEnter" @mouseout="nodeMouseOut"
  3. @click="nodeClick">
  4. <el-tooltip :content="currentLang==='en'?(data.RuleTitleEn||data.RuleTitle):data.RuleTitle" placement="top" ref="antvTooltip"
  5. class="container-input">
  6. <span ref="containerText">{{currentLang==='en'?(data.EdbNameEn||data.EdbName):data.EdbName}}</span>
  7. </el-tooltip>
  8. <i :class="data.fold?'el-icon-circle-plus':'el-icon-remove'" v-if="!data.isLeaf"
  9. class="fold-icon" @click="flodApi" v-show="show"></i>
  10. <img src="~@/assets/img/icons/edb-stopping.png" class="stop-mark" v-if="data.isStop==1" />
  11. </div>
  12. </template>
  13. <script>
  14. export default {
  15. name:"toolTipCom",
  16. inject: ["getGraph", "getNode"],
  17. data() {
  18. return {
  19. node:{},
  20. data:{
  21. fold:false,
  22. routeQuery:{}
  23. },
  24. graph:{},
  25. show:false
  26. };
  27. },
  28. props:{
  29. params:{
  30. type:Object,
  31. default:()=>{
  32. return {
  33. stopNodeClick:false
  34. }
  35. }
  36. }
  37. },
  38. mounted() {
  39. this.initNode()
  40. },
  41. computed: {
  42. currentLang() {
  43. return this.$store.state.lang
  44. }
  45. },
  46. methods: {
  47. initNode(){
  48. this.node = this.getNode();
  49. this.graph= this.getGraph()
  50. this.node.data = this.node.data?{...this.data,...this.node.data}:this.data
  51. this.data = this.node.data
  52. let {style} = this.data
  53. this.initStyle(style)
  54. },
  55. initStyle(style){
  56. // !important 是有的节点 :hover不变色
  57. if(style){
  58. // 背景色
  59. if(style.backgroundColor && style.backgroundColor.indexOf("!important")!=-1){
  60. let value = style.backgroundColor.split("!")[0]
  61. this.$refs.containerText.style.setProperty('background-color',value,'important')
  62. }else{
  63. this.$refs.container.style.backgroundColor = style.backgroundColor?style.backgroundColor:
  64. this.data.isRoot?'#0052d9': "#f2f6fa"
  65. }
  66. // 字体颜色
  67. if(style.color && style.color.indexOf("!important")!=-1){
  68. let value = style.color.split("!")[0]
  69. this.$refs.containerText.style.setProperty('color',value,'important')
  70. }else{
  71. this.$refs.container.style.color = style.color?style.color:
  72. this.data.isRoot?'#ffffff': "#000000"
  73. }
  74. this.$refs.containerText.style.color = style.color
  75. }
  76. },
  77. flodApi(event){
  78. event.stopPropagation()
  79. const succ = this.graph.getSuccessors(this.node)
  80. if (succ) {
  81. succ.forEach((node,index) => {
  82. node.setVisible(this.data.fold)
  83. if(this.data.fold){
  84. node.toBack()
  85. requestAnimationFrame(()=>{
  86. let edge = this.graph.getIncomingEdges(node) || []
  87. edge[0].toBack()
  88. })
  89. }
  90. node.data.fold=!this.data.fold
  91. })
  92. }
  93. this.data.fold=!this.data.fold
  94. },
  95. nodeMouseEnter(){
  96. this.show=true
  97. },
  98. nodeMouseOut(){
  99. this.show=false
  100. },
  101. nodeClick(){
  102. if(this.params.stopNodeClick) return
  103. //EdbInfoType 1:跳预测指标详情 0:跳指标库详情
  104. const { ClassifyId, UniqueCode, EdbInfoId, EdbInfoType } = this.data.routeQuery
  105. let { href } =
  106. this.$router.resolve({ path: EdbInfoType === 1 ? '/predictEdb' : '/database', query: { code: UniqueCode, id:
  107. EdbInfoId, classifyId: ClassifyId } });
  108. window.open(href, '_blank');
  109. }
  110. },
  111. };
  112. </script>
  113. <style lang="scss" scoped>
  114. .container{
  115. display: flex;
  116. align-items: center;
  117. justify-content: center;
  118. padding: 20px;
  119. height: 100%;
  120. width: 100%;
  121. box-sizing: border-box;
  122. background-color: #0052d9;
  123. box-shadow: 0 1px 5px rgba(0,0,0,0.15);
  124. display: flex;
  125. cursor: pointer;
  126. position: relative;
  127. border-radius: 4px;
  128. .container-input{
  129. text-align: center;
  130. font-size: 16px;
  131. color: #ffffff;
  132. font-weight: 400;
  133. word-break: break-all;
  134. }
  135. &:hover{
  136. background-color: #ecf5ff;
  137. .container-input{
  138. color: #0052d9!important;
  139. text-decoration: underline;
  140. }
  141. }
  142. .fold-icon{
  143. position: absolute;
  144. font-size: 24px;
  145. color: #666666;
  146. bottom: -24px;
  147. left: 50%;
  148. transform: translateX(-50%);
  149. }
  150. .stop-mark{
  151. height: 48px;
  152. width: 48px;
  153. position: absolute;
  154. right: -1px;
  155. top: 0;
  156. pointer-events: none;
  157. }
  158. }
  159. </style>