normalLine.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <GeoTeleport :menus="menus" class="geo-teleport-use" :active="active"/>
  3. <GeoTeleport :menus="childMenus" v-if="childMenus" class="type-geo"/>
  4. </template>
  5. <script setup lang="ts">
  6. import GeoTeleport from "@/views/graphic/geos/geo-teleport.vue";
  7. import {drawRef, FocusVector, VectorType} from '@/hook/useGraphic'
  8. import {computed, ref, toRaw, UnwrapRef} from "vue";
  9. import {dataService} from "@/graphic/Service/DataService";
  10. import GeoActions from "@/graphic/enum/GeoActions"
  11. import {UITypeExtend} from "@/views/graphic/menus";
  12. import VectorEvents from "@/graphic/enum/VectorEvents";
  13. import VectorStyle from "@/graphic/enum/VectorStyle";
  14. import VectorWeight from "@/graphic/enum/VectorWeight";
  15. import VectorCategory from "@/graphic/enum/VectorCategory";
  16. const props = defineProps<{ geo: FocusVector }>()
  17. const vector = computed(() => dataService.getLine(props.geo.vectorId))
  18. const clickHandlerFactory = (key) => {
  19. return () => drawRef.value.uiControl.updateVectorForSelectUI(key)
  20. }
  21. const lineTypeMenu = [
  22. {
  23. key: VectorStyle.SingleSolidLine,
  24. icon: "line_sf",
  25. text: "单实线",
  26. onClick: clickHandlerFactory(VectorStyle.SingleSolidLine)
  27. },
  28. {
  29. key: VectorStyle.SingleDashedLine,
  30. icon: "line_sd",
  31. text: "单虚线",
  32. onClick: clickHandlerFactory(VectorStyle.SingleDashedLine)
  33. },
  34. {
  35. key: VectorStyle.DoubleSolidLine,
  36. icon: "line_df",
  37. text: "双实线",
  38. onClick: clickHandlerFactory(VectorStyle.DoubleSolidLine)
  39. },
  40. {
  41. key: VectorStyle.DoubleDashedLine,
  42. icon: "line_dd",
  43. text: "双虚线",
  44. onClick: clickHandlerFactory(VectorStyle.DoubleDashedLine)
  45. },
  46. {key: VectorStyle.BrokenLine, icon: "line_broken", text: "折线", onClick: clickHandlerFactory(VectorStyle.BrokenLine)},
  47. {
  48. key: VectorStyle.PointDrawLine,
  49. icon: "line_dot",
  50. text: "点画线",
  51. onClick: clickHandlerFactory(VectorStyle.PointDrawLine)
  52. },
  53. {key: VectorStyle.Greenbelt, icon: "treelawn", text: "绿化带 ", onClick: clickHandlerFactory(VectorStyle.Greenbelt)},
  54. ]
  55. const lineWidthMenu = [
  56. {
  57. key: VectorWeight.Bold,
  58. icon: 'l_thick',
  59. text: "宽度",
  60. onClick: () => {
  61. clickHandlerFactory(VectorWeight.Bold)()
  62. menus.value[1] = lineWidthMenu[1]
  63. }
  64. },
  65. {
  66. key: VectorWeight.Thinning,
  67. icon: 'l_thin',
  68. text: "宽度",
  69. onClick: () => {
  70. clickHandlerFactory(VectorWeight.Thinning)()
  71. menus.value[1] = lineWidthMenu[0]
  72. }
  73. },
  74. ]
  75. const appendMenus = props.geo.category === VectorCategory.Line.NormalLine
  76. ? [
  77. {
  78. key: VectorEvents.AddCrossPoint,
  79. icon: "control_a",
  80. text: "加控制点",
  81. onClick: clickHandlerFactory(VectorEvents.AddCrossPoint)
  82. },
  83. {
  84. key: VectorEvents.MinusCrossPoint,
  85. icon: "control_d",
  86. text: "减控制点",
  87. onClick: clickHandlerFactory(VectorEvents.MinusCrossPoint)
  88. },
  89. ]
  90. : []
  91. const childMenus = ref<UnwrapRef<typeof menus>>()
  92. const menus = ref([
  93. {
  94. key: UITypeExtend.lineType,
  95. text: "单实线",
  96. icon: "line",
  97. onClick() {
  98. childMenus.value = toRaw(childMenus.value) === lineTypeMenu ? null : lineTypeMenu
  99. }
  100. },
  101. vector.value?.style === VectorWeight.Bold ? lineWidthMenu[0] : lineWidthMenu[1],
  102. ...appendMenus,
  103. {
  104. key: 'copy',
  105. icon: 'copy',
  106. text: "复制",
  107. onClick: () => {
  108. drawRef.value.uiControl.handleGeo(GeoActions.CopyAction)
  109. }
  110. },
  111. {
  112. key: 'del',
  113. icon: 'del',
  114. text: "删除",
  115. onClick: () => {
  116. drawRef.value.uiControl.handleGeo(GeoActions.DeleteAction)
  117. }
  118. }
  119. ])
  120. const active = computed(() =>
  121. toRaw(childMenus.value) === lineTypeMenu ? menus.value[0]
  122. : toRaw(childMenus.value) === lineWidthMenu ? menus.value[1] : null
  123. )
  124. </script>
  125. <style scoped lang="scss">
  126. .color {
  127. width: 18px;
  128. height: 18px;
  129. border: 2px solid #fff;
  130. border-radius: 50%;
  131. }
  132. .icon {
  133. font-size: 16px;
  134. }
  135. .geo-input {
  136. position: absolute;
  137. left: 0;
  138. right: 0;
  139. top: 0;
  140. bottom: 0;
  141. z-index: 1;
  142. opacity: 0;
  143. }
  144. .type-geo {
  145. margin-bottom: 74px;
  146. }
  147. </style>
  148. <style lang="scss">
  149. .select-floating.select-float.dire-top {
  150. margin-top: -10px;
  151. }
  152. </style>