point-input.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <el-dialog
  3. :model-value="visible"
  4. @update:model-value="(val) => emit('update:visible', val)"
  5. title="测点信息"
  6. width="500"
  7. >
  8. <el-form label-width="auto">
  9. <el-form-item label="坐标" v-if="coordInfo">
  10. <el-input :value="coordInfo" readonly type="textarea" rows="3" disabled />
  11. </el-form-item>
  12. <el-form-item label="测点类型" required>
  13. <el-select v-model="ivalue.type" placeholder="测点类型">
  14. <el-option :label="type" :value="type" v-for="type in typeOptions" />
  15. </el-select>
  16. </el-form-item>
  17. <el-form-item label="测点说明" required>
  18. <el-input
  19. v-model.trim="ivalue.name"
  20. :maxlength="100"
  21. rows="4"
  22. show-word-limit
  23. placeholder="请输入"
  24. type="textarea"
  25. />
  26. </el-form-item>
  27. <el-form-item label="备注">
  28. <el-input
  29. v-model.trim="ivalue.remark"
  30. :maxlength="100"
  31. show-word-limit
  32. placeholder="请输入"
  33. />
  34. </el-form-item>
  35. </el-form>
  36. <template #footer>
  37. <div class="dialog-footer">
  38. <el-button @click="emit('update:visible', false)">取消</el-button>
  39. <el-button type="primary" @click="submit"> 确定 </el-button>
  40. </div>
  41. </template>
  42. </el-dialog>
  43. </template>
  44. <script setup lang="ts">
  45. import { ElMessage } from "element-plus";
  46. import { ref, watchEffect, computed, watch } from "vue";
  47. import { ScenePoint } from "@/store/scene";
  48. import { PointTypeEnum } from "drawing-board";
  49. import { toDegrees } from "@/util";
  50. const props = defineProps<{
  51. visible: boolean;
  52. value: ScenePoint;
  53. updateValue: (value: ScenePoint) => void;
  54. }>();
  55. const typeOptions = [
  56. PointTypeEnum.border,
  57. PointTypeEnum.center,
  58. PointTypeEnum.marker,
  59. PointTypeEnum.other,
  60. ];
  61. const coordInfo = computed(() => {
  62. const point = ivalue.value.pos;
  63. if (!(!point || point.length === 0 || point.some((i) => !i))) {
  64. return `经度:${toDegrees(ivalue.value.pos[0])}
  65. 纬度:${toDegrees(ivalue.value.pos[1])}
  66. 高程:${ivalue.value.pos[2]}`;
  67. }
  68. });
  69. const emit = defineEmits<{
  70. (e: "update:visible", visible: boolean): void;
  71. }>();
  72. const ivalue = ref<ScenePoint>();
  73. watchEffect(() => {
  74. ivalue.value = { ...props.value, name: props.value.name || "" };
  75. });
  76. watch(
  77. () => props.value?.type,
  78. (type) => {
  79. ivalue.value.type = type || PointTypeEnum.other;
  80. },
  81. { immediate: true }
  82. );
  83. const submit = async () => {
  84. if (ivalue.value.name.trim().length === 0) {
  85. return ElMessage.error(`测点说明不能为空!`);
  86. }
  87. await props.updateValue(ivalue.value);
  88. emit("update:visible", false);
  89. };
  90. </script>