GraphProp.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <div class="graph-prop">
  3. <div class="prop-title">节点属性:</div>
  4. <ul>
  5. <Li>
  6. <span>ID:</span><span>{{showProp.id}}</span>
  7. </Li>
  8. <Li>
  9. <span>描述:</span><span>{{showProp.description}}</span>
  10. </Li>
  11. </ul>
  12. </div>
  13. </template>
  14. <script>
  15. import {mapGetters} from 'vuex'
  16. export default {
  17. data () {
  18. return {
  19. showProp: {
  20. id: '',
  21. description: ''
  22. }
  23. }
  24. },
  25. computed: {
  26. ...mapGetters([
  27. 'graphState'
  28. ])
  29. },
  30. methods: {
  31. showSelectedProp: function (type, data) {
  32. var prop = {}
  33. if (type === 'node') {
  34. prop.description = data.name
  35. } else {
  36. prop.description = '由 ' + data.source.name + ' 指向 ' + data.target.name
  37. }
  38. this.showProp = Object.assign(prop, data)
  39. }
  40. },
  41. watch: {
  42. 'graphState.selectedNode': function (curr, old) {
  43. if (!curr) {
  44. return false
  45. }
  46. this.showSelectedProp('node', curr)
  47. },
  48. 'graphState.selectedEdge': function (curr, old) {
  49. if (!curr) {
  50. return false
  51. }
  52. this.showSelectedProp('edge', curr)
  53. }
  54. }
  55. }
  56. </script>
  57. <style scoped>
  58. .graph-prop {
  59. height: 20%;
  60. }
  61. ul {
  62. margin: 0;
  63. padding: 0;
  64. }
  65. ul li {
  66. list-style-type: none;
  67. margin-bottom: 4px;
  68. padding: 4px 6px;
  69. border-bottom: 1px solid #cbd8f3;
  70. }
  71. ul li span {
  72. display: inline-block;
  73. width: 40%;
  74. color: gray;
  75. }
  76. ul li span:first-of-type {
  77. width: 20%;
  78. }
  79. .prop-title {
  80. line-height: 40px;
  81. padding-left: 6px;
  82. border-top: 1px solid #6e94e0;
  83. text-align: middle;
  84. background-color: #d7dfef;;
  85. }
  86. </style>