roadEdge.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. const props = defineProps<{ geo: FocusVector }>();
  16. const vector = computed(() => dataService.getRoadEdge(props.geo.vectorId));
  17. console.error(vector.value);
  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. // hide: props.geo.type === VectorType.CurveRoadEdge,
  36. // key: VectorStyle.DoubleSolidLine,
  37. // icon: "line_df",
  38. // text: "双实线",
  39. // onClick: clickHandlerFactory(VectorStyle.DoubleSolidLine),
  40. // },
  41. // {
  42. // hide: props.geo.type === VectorType.CurveRoadEdge,
  43. // key: VectorStyle.DoubleDashedLine,
  44. // icon: "line_dd",
  45. // text: "双虚线",
  46. // onClick: clickHandlerFactory(VectorStyle.DoubleDashedLine),
  47. // },
  48. // {
  49. // hide: props.geo.type === VectorType.CurveRoadEdge,
  50. // key: VectorStyle.BrokenLine,
  51. // icon: "line_broken",
  52. // text: "折线",
  53. // onClick: clickHandlerFactory(VectorStyle.BrokenLine),
  54. // },
  55. {
  56. key: VectorStyle.PointDrawLine,
  57. icon: "line_dot",
  58. text: "点画线",
  59. onClick: clickHandlerFactory(VectorStyle.PointDrawLine),
  60. },
  61. // {key: VectorStyle.Greenbelt, icon: "treelawn", text: "绿化带 ", onClick: clickHandlerFactory(VectorStyle.Greenbelt)},
  62. ];
  63. const lineWidthMenu = [
  64. {
  65. key: VectorWeight.Bold,
  66. icon: "l_thick",
  67. text: "宽度",
  68. onClick: () => {
  69. clickHandlerFactory(VectorWeight.Thinning)();
  70. menus.value[1] = lineWidthMenu[1];
  71. },
  72. },
  73. {
  74. key: VectorWeight.Thinning,
  75. icon: "l_thin",
  76. text: "宽度",
  77. onClick: () => {
  78. clickHandlerFactory(VectorWeight.Bold)();
  79. menus.value[1] = lineWidthMenu[0];
  80. },
  81. },
  82. ];
  83. const appendMenus =
  84. props.geo.type === VectorType.CurveRoadEdge
  85. ? [
  86. // {
  87. // key: VectorEvents.AddCrossPoint,
  88. // icon: "control_a",
  89. // text: "加控制点",
  90. // onClick: clickHandlerFactory(VectorEvents.AddCrossPoint)
  91. // },
  92. // {
  93. // key: VectorEvents.MinusCrossPoint,
  94. // icon: "control_d",
  95. // text: "减控制点",
  96. // onClick: clickHandlerFactory(VectorEvents.MinusCrossPoint)
  97. // },
  98. ]
  99. : [];
  100. const childMenus = ref<UnwrapRef<typeof menus>>();
  101. // console.log(vector.value)
  102. const menus = ref([
  103. {
  104. key: UITypeExtend.lineType,
  105. text: "单实线",
  106. icon: "line",
  107. onClick() {
  108. childMenus.value = toRaw(childMenus.value) === lineTypeMenu ? null : lineTypeMenu;
  109. },
  110. },
  111. vector.value?.weight === VectorWeight.Bold ? lineWidthMenu[0] : lineWidthMenu[1],
  112. ...appendMenus,
  113. ]);
  114. const active = computed(() =>
  115. toRaw(childMenus.value) === lineTypeMenu
  116. ? menus.value[0]
  117. : toRaw(childMenus.value) === lineWidthMenu
  118. ? menus.value[1]
  119. : null
  120. );
  121. </script>
  122. <style scoped lang="scss">
  123. .color {
  124. width: 18px;
  125. height: 18px;
  126. border: 2px solid #fff;
  127. border-radius: 50%;
  128. }
  129. .icon {
  130. font-size: 16px;
  131. }
  132. .geo-input {
  133. position: absolute;
  134. left: 0;
  135. right: 0;
  136. top: 0;
  137. bottom: 0;
  138. z-index: 1;
  139. opacity: 0;
  140. }
  141. .type-geo {
  142. margin-bottom: 74px;
  143. }
  144. </style>
  145. <style lang="scss">
  146. .select-floating.select-float.dire-top {
  147. margin-top: -10px;
  148. }
  149. </style>