arrow.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <GeoTeleport :menus="menus" class="geo-teleport-use">
  3. <template v-slot="{ data }">
  4. <template v-if="data.key === 'color'">
  5. <ui-input type="color" class="geo-input" v-model="color" />
  6. <span class="color" :style="{backgroundColor: color}"></span>
  7. </template>
  8. <ui-icon type="del" class="icon" v-if="data.key === 'del'" />
  9. <ui-icon type="del" class="icon" v-if="data.key === 'copy'" />
  10. </template>
  11. </GeoTeleport>
  12. </template>
  13. <script setup lang="ts">
  14. import GeoTeleport from "@/views/graphic/geos/geo-teleport.vue";
  15. import UiInput from "@/components/base/components/input/index.vue";
  16. import UiIcon from "@/components/base/components/icon/index.vue";
  17. import {drawRef, FocusVector, uiType, UIType} from '@/hook/useGraphic'
  18. import {computed, ref, watch, watchEffect} from "vue";
  19. import {dataService} from "@/graphic/Service/DataService";
  20. import GeoActions from "@/graphic/enum/GeoActions"
  21. import {debounce} from "@/utils";
  22. const props = defineProps<{geo: FocusVector}>()
  23. const vector = computed(() => dataService.getLine(props.geo.vectorId))
  24. const color = ref("#000000")
  25. watchEffect(() => {
  26. color.value = vector.value.arrowColor
  27. })
  28. watch(
  29. () => [color.value],
  30. debounce(([color]) => {
  31. vector.value.setArrowColor(color)
  32. drawRef.value.renderer.autoRedraw()
  33. }, 500)
  34. )
  35. const menus = [
  36. {
  37. key: 'color',
  38. text: "颜色"
  39. },
  40. {
  41. key: 'copy',
  42. text: "复制",
  43. onClick: () => {
  44. drawRef.value.uiControl.handleGeo(GeoActions.CopyAction)
  45. uiType.change(UIType.Copy)
  46. }
  47. },
  48. {
  49. key: 'del',
  50. text: "删除",
  51. onClick: () => {
  52. drawRef.value.uiControl.handleGeo(GeoActions.DeleteAction)
  53. uiType.change(UIType.Delete)
  54. }
  55. }
  56. ]
  57. </script>
  58. <style scoped lang="scss">
  59. .color {
  60. width: 18px;
  61. height: 18px;
  62. border: 2px solid #fff;
  63. border-radius: 50%;
  64. }
  65. .icon {
  66. font-size: 16px;
  67. }
  68. .geo-input {
  69. position: absolute;
  70. left: 0;
  71. right: 0;
  72. top: 0;
  73. bottom: 0;
  74. z-index: 1;
  75. opacity: 0;
  76. }
  77. </style>
  78. <style lang="scss">
  79. .select-floating.select-float.dire-top {
  80. margin-top: -10px;
  81. }
  82. </style>