LinePool.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <div class="line-pool">
  3. <div class="category" v-for="(item, i) in LINE_LIST" :key="item.type">
  4. <div class="category-name">{{item.type}}</div>
  5. <div class="line-list">
  6. <div class="line-item" v-for="(line, j) in item.children" :key="j">
  7. <div class="line-content" @click="selectLine(line)">
  8. <svg
  9. overflow="visible"
  10. width="20"
  11. height="20"
  12. >
  13. <defs>
  14. <LinePointMarker
  15. class="line-marker"
  16. v-if="line.points[0]"
  17. :id="`preset-line-${i}-${j}`"
  18. position="start"
  19. :type="line.points[0]"
  20. color="currentColor"
  21. :baseSize="2"
  22. />
  23. <LinePointMarker
  24. class="line-marker"
  25. v-if="line.points[1]"
  26. :id="`preset-line-${i}-${j}`"
  27. position="end"
  28. :type="line.points[1]"
  29. color="currentColor"
  30. :baseSize="2"
  31. />
  32. </defs>
  33. <path
  34. class="line-path"
  35. :d="line.path"
  36. stroke="currentColor"
  37. fill="none"
  38. stroke-width="2"
  39. :stroke-dasharray="line.style === 'solid' ? '0, 0' : '4, 1'"
  40. :marker-start="line.points[0] ? `url(#${`preset-line-${i}-${j}`}-${line.points[0]}-start)` : ''"
  41. :marker-end="line.points[1] ? `url(#${`preset-line-${i}-${j}`}-${line.points[1]}-end)` : ''"
  42. ></path>
  43. </svg>
  44. </div>
  45. </div>
  46. </div>
  47. </div>
  48. </div>
  49. </template>
  50. <script lang="ts" setup>
  51. import { LINE_LIST, type LinePoolItem } from '@/configs/lines'
  52. import LinePointMarker from '@/views/components/element/LineElement/LinePointMarker.vue'
  53. const emit = defineEmits<{
  54. (event: 'select', payload: LinePoolItem): void
  55. }>()
  56. const selectLine = (line: LinePoolItem) => {
  57. emit('select', line)
  58. }
  59. </script>
  60. <style lang="scss" scoped>
  61. .line-pool {
  62. width: 220px;
  63. overflow: auto;
  64. margin-bottom: -12px;
  65. margin-right: -12px;
  66. padding-right: 12px;
  67. }
  68. .category-name {
  69. width: 100%;
  70. font-size: 12px;
  71. margin-bottom: 10px;
  72. border-left: 4px solid #bbb;
  73. background-color: #f1f1f1;
  74. padding: 3px 0 3px 8px;
  75. color: #555;
  76. }
  77. .line-list {
  78. @include flex-grid-layout();
  79. margin-bottom: 10px;
  80. }
  81. .line-item {
  82. @include flex-grid-layout-children(5, 19%);
  83. height: 0;
  84. padding-bottom: 19%;
  85. flex-shrink: 0;
  86. position: relative;
  87. cursor: pointer;
  88. }
  89. .line-content {
  90. @include absolute-0();
  91. display: flex;
  92. justify-content: center;
  93. align-items: center;
  94. color: #999;
  95. &:hover {
  96. color: $themeColor;
  97. }
  98. svg:not(:root) {
  99. overflow: visible;
  100. }
  101. }
  102. </style>