setting.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <ui-confirm title="设置" ok-text="保存" :func="handler" v-if="!trackMode">
  3. <template v-slot:content>
  4. <div class="setting-layout">
  5. <div>
  6. <p>
  7. <span>默认单车道宽度</span>
  8. <span>单位: mm</span>
  9. </p>
  10. <ui-input
  11. :modelValue="data.singleRoadWidth * 1000"
  12. @update:modelValue="(val) => (data.singleRoadWidth = val / 1000)"
  13. width="100%"
  14. >
  15. <template v-slot:icon>
  16. <ui-icon
  17. type="measure"
  18. ctrl
  19. @click="setSceneSingleRoadWidth"
  20. class="measure_icon"
  21. />
  22. </template>
  23. </ui-input>
  24. </div>
  25. <div>
  26. <p>
  27. <span>默认隔离带宽度</span>
  28. <span>单位: mm</span>
  29. </p>
  30. <ui-input
  31. :modelValue="data.roadQuarantineWidth * 1000"
  32. @update:modelValue="(val) => (data.roadQuarantineWidth = val / 1000)"
  33. width="100%"
  34. >
  35. <template v-slot:icon>
  36. <ui-icon
  37. type="measure"
  38. ctrl
  39. @click="setSceneRoadQuarantineWidth"
  40. class="measure_icon"
  41. />
  42. </template>
  43. </ui-input>
  44. </div>
  45. <div>
  46. <p>
  47. <span>基本线宽 b</span>
  48. <span>单位: mm</span>
  49. </p>
  50. <div class="select-boxs">
  51. <span
  52. v-for="option in lineWidthOption"
  53. :key="option.value"
  54. :class="{ active: option.value === data.lineWidth }"
  55. @click="data.lineWidth = option.value"
  56. >
  57. {{ option.label }}
  58. </span>
  59. </div>
  60. </div>
  61. </div>
  62. </template>
  63. </ui-confirm>
  64. </template>
  65. <script setup lang="ts">
  66. import UiConfirm from "@/components/base/components/dialog/Confirm.vue";
  67. import UiInput from "@/components/base/components/input/index.vue";
  68. import { ref } from "vue";
  69. import UiIcon from "@/components/base/components/icon/index.vue";
  70. import { trackMeasureWidth, trackMode } from "@/views/scene/trackMeasureWidth";
  71. import { drawRef } from "@/hook/useGraphic";
  72. import UiButton from "@/components/base/components/button/index.vue";
  73. const props = defineProps<{ close?: () => void }>();
  74. const data = ref({ ...drawRef.value.uiControl.getDefaultSetting() });
  75. const lineWidthOption = [
  76. { label: 2, value: 2 },
  77. { label: 1.4, value: 1.4 },
  78. { label: 1, value: 1 },
  79. { label: 0.7, value: 0.7 },
  80. { label: 0.5, value: 0.5 },
  81. { label: 0.35, value: 0.35 },
  82. ];
  83. console.log(data);
  84. const setSceneSingleRoadWidth = async () => {
  85. const width = await trackMeasureWidth();
  86. if (width !== null) {
  87. data.value.singleRoadWidth = width;
  88. }
  89. };
  90. const setSceneRoadQuarantineWidth = async () => {
  91. data.value.roadQuarantineWidth = await trackMeasureWidth();
  92. };
  93. const handler = (label) => {
  94. if (label === "ok") {
  95. drawRef.value.uiControl.setDefaultSetting({ ...data.value });
  96. }
  97. props.close && props.close();
  98. };
  99. </script>
  100. <style lang="scss" scoped>
  101. .setting-layout {
  102. width: 440px;
  103. > div {
  104. margin-bottom: 24px;
  105. p {
  106. margin-bottom: 14px;
  107. display: flex;
  108. justify-content: space-between;
  109. font-size: 14px;
  110. }
  111. }
  112. }
  113. .select-boxs {
  114. display: flex;
  115. gap: 8px;
  116. span {
  117. flex: 1;
  118. text-align: center;
  119. height: 32px;
  120. line-height: 32px;
  121. color: #fff;
  122. font-size: 14px;
  123. background: rgba(255, 255, 255, 0.1);
  124. border-radius: 4px;
  125. &.active {
  126. background: rgba(47, 143, 255, 0.5);
  127. }
  128. }
  129. }
  130. .measure_icon {
  131. padding: 10px;
  132. }
  133. </style>