roadEdge.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <GeoTeleport :menus="menus" class="geo-teleport-use" :active="active" />
  3. <GeoTeleport :menus="childMenus" v-if="childMenus" class="type-geo" />
  4. {{ showChange }}
  5. <VRange
  6. v-if="showChange"
  7. :max="100"
  8. :min="10"
  9. :step="1"
  10. unit="mm"
  11. v-model:value="(lineWidthMenu[2].desc as number)"
  12. />
  13. </template>
  14. <script setup lang="ts">
  15. import GeoTeleport from "@/views/graphic/geos/geo-teleport.vue";
  16. import { drawRef, FocusVector } from "@/hook/useGraphic";
  17. import { computed, reactive, ref, toRaw, UnwrapRef, watchEffect } from "vue";
  18. import { dataService } from "@/graphic/Service/DataService";
  19. import { UITypeExtend } from "@/views/graphic/menus";
  20. import VectorStyle from "@/graphic/enum/VectorStyle";
  21. import VectorWeight from "@/graphic/enum/VectorWeight";
  22. import VRange from "@/components/vrange/index.vue";
  23. const props = defineProps<{ geo: FocusVector }>();
  24. const vector = computed(() => dataService.getGeo(props.geo.type, props.geo.vectorId));
  25. const style = ref(vector.value.style || VectorStyle.SingleSolidLine);
  26. const clickHandlerFactory = (key) => {
  27. return () => drawRef.value.uiControl.updateVectorForSelectUI(key);
  28. };
  29. const showChange = ref(false);
  30. const lineTypeMenu = reactive([
  31. {
  32. key: VectorStyle.SingleSolidLine,
  33. icon: "line_sf",
  34. text: "单实线",
  35. onClick: () => {
  36. clickHandlerFactory(VectorStyle.SingleSolidLine)();
  37. style.value = VectorStyle.SingleSolidLine;
  38. },
  39. },
  40. {
  41. key: VectorStyle.SingleDashedLine,
  42. icon: "line_sd",
  43. text: "单虚线",
  44. onClick: () => {
  45. clickHandlerFactory(VectorStyle.SingleDashedLine)();
  46. style.value = VectorStyle.SingleDashedLine;
  47. },
  48. },
  49. {
  50. key: VectorStyle.PointDrawLine,
  51. icon: "line_dot",
  52. text: "点画线",
  53. onClick: () => {
  54. clickHandlerFactory(VectorStyle.PointDrawLine)();
  55. style.value = VectorStyle.PointDrawLine;
  56. },
  57. },
  58. {
  59. key: VectorStyle.RoadSide,
  60. icon: "l_thin",
  61. text: "路缘线",
  62. onClick: () => {
  63. clickHandlerFactory(VectorStyle.RoadSide)();
  64. style.value = VectorStyle.RoadSide;
  65. },
  66. },
  67. ]);
  68. const lineWidthMenu = reactive([
  69. {
  70. key: VectorWeight.Bold,
  71. icon: "l_thick",
  72. text: "宽度",
  73. onClick: () => {
  74. clickHandlerFactory(VectorWeight.Thinning)();
  75. menus.value[1] = lineWidthMenu[1];
  76. },
  77. },
  78. {
  79. key: VectorWeight.Thinning,
  80. icon: "l_thin",
  81. text: "宽度",
  82. onClick: () => {
  83. clickHandlerFactory(VectorWeight.Bold)();
  84. menus.value[1] = lineWidthMenu[0];
  85. },
  86. },
  87. {
  88. key: "setRoadEdageWidth",
  89. icon: "l_thin",
  90. text: "宽度",
  91. desc: 0,
  92. onClick: () => {
  93. showChange.value = !showChange.value;
  94. },
  95. },
  96. ]);
  97. const childMenus = ref<UnwrapRef<typeof menus>>();
  98. const menus = ref([
  99. {
  100. key: UITypeExtend.lineType,
  101. text: computed(() => lineTypeMenu.find((item) => item.key === style.value).text),
  102. icon: computed(() => lineTypeMenu.find((item) => item.key === style.value).icon),
  103. onClick() {
  104. childMenus.value = toRaw(childMenus.value) === lineTypeMenu ? null : lineTypeMenu;
  105. },
  106. },
  107. vector.value?.weight === VectorWeight.Bold ? lineWidthMenu[0] : lineWidthMenu[1],
  108. ]);
  109. watchEffect(() => {
  110. if (style.value === VectorStyle.RoadSide) {
  111. menus.value[1] = lineWidthMenu[2];
  112. lineWidthMenu[2].desc = vector.value.roadSide.width;
  113. } else {
  114. showChange.value = false;
  115. }
  116. });
  117. watchEffect(() => {
  118. if (style.value === VectorStyle.RoadSide) {
  119. vector.value.setRoadSideWidth(lineWidthMenu[2].desc);
  120. }
  121. });
  122. const active = computed(() =>
  123. toRaw(childMenus.value) === lineTypeMenu
  124. ? menus.value[0]
  125. : toRaw(childMenus.value) === lineWidthMenu
  126. ? menus.value[1]
  127. : null
  128. );
  129. </script>
  130. <style scoped lang="scss">
  131. .color {
  132. width: 18px;
  133. height: 18px;
  134. border: 2px solid #fff;
  135. border-radius: 50%;
  136. }
  137. .icon {
  138. font-size: 16px;
  139. }
  140. .geo-input {
  141. position: absolute;
  142. left: 0;
  143. right: 0;
  144. top: 0;
  145. bottom: 0;
  146. z-index: 1;
  147. opacity: 0;
  148. }
  149. .type-geo {
  150. margin-bottom: 74px;
  151. }
  152. </style>
  153. <style lang="scss">
  154. .select-floating.select-float.dire-top {
  155. margin-top: -10px;
  156. }
  157. </style>