| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- <template>
- <FixPointPanel
- v-for="point in (fixPoints as FixPoint[])"
- :key="point.id"
- :data="point"
- :active="point === customMap.activeFixPoint && !selectMeasure"
- @change-pos="(pos) => changePos(point, pos)"
- @focus="(isRaw) => select(point, false, isRaw)"
- @blur="(isRaw) => unSelect(point, false, isRaw)"
- @focus-measure="select(point, true, true)"
- @blur-measure="unSelect(point, true, true)"
- />
- <div ref="menu" @touchstart.stop class="action-menus">
- <!-- <ActionsPanel :menus="activeActionMenus" v-show="customMap.activeFixPoint" />-->
- <ActionMenus
- v-if="drawstatus !== DrawStatus.ing && customMap.activeFixPoint"
- :menus="activeActionMenus"
- :type="0"
- :active-key="edit ? 'edit' : null"
- dire="row"
- />
- <Confirm
- v-if="drawstatus === DrawStatus.ing"
- :ok="() => (drawstatus = DrawStatus.complete)"
- :cancel="() => (drawstatus = DrawStatus.quit)"
- :dis-ok="!ready"
- />
- <!-- <ActionMenus
- v-if="ingActionMenus"
- :type="0"
- :menus="ingActionMenus"
- :active-key="null"
- dire="row"
- /> -->
- </div>
- <EditFixPoint
- v-if="edit"
- @quit="edit = null"
- v-model:text="edit.text"
- ref="dom"
- :key="edit.id"
- />
- </template>
- <script setup lang="ts">
- import { fixPoints, FixPoint } from "@/store/fixPoint";
- import FixPointPanel from "./fixPoint.vue";
- import Confirm from "../../graphic/confirm.vue";
- import { computed, ref, toRaw, watch, watchEffect } from "vue";
- import { customMap } from "@/hook";
- import ActionMenus from "@/components/group-button/index.vue";
- import EditFixPoint from "@/components/edit-fix-point/index.vue";
- import {
- delFix3d,
- changePos,
- quitMeasure,
- drawstatus,
- DrawStatus,
- drawingFix3d,
- selectFix3d,
- } from "../fixManage";
- const edit = ref<FixPoint>();
- watchEffect(() => {
- if (edit.value !== customMap.activeFixPoint) {
- edit.value = null;
- }
- });
- const selectMeasure = ref(false);
- const select = (point: FixPoint, onMeasure: boolean = false, onRaw: boolean = false) => {
- selectMeasure.value = onMeasure;
- customMap.activeFixPoint = point;
- if (!onRaw) {
- fixPoints.value.forEach((item) => {
- console.log("select", toRaw(item) === toRaw(point));
- selectFix3d(point, toRaw(item) === toRaw(point));
- });
- }
- };
- const unSelect = (
- point: FixPoint,
- onMeasure: boolean = false,
- onRaw: boolean = false
- ) => {
- selectMeasure.value = onMeasure;
- customMap.activeFixPoint =
- customMap.activeFixPoint === point ? null : customMap.activeFixPoint;
- if (!onRaw) {
- selectFix3d(point, false);
- }
- };
- const activeActionMenus = computed(() =>
- selectMeasure.value
- ? [
- {
- key: "delete",
- icon: "del",
- text: "删除",
- color: "#FF4D4F",
- iconColor: "#fff",
- onClick() {
- quitMeasure(customMap.activeFixPoint);
- },
- },
- ]
- : [
- {
- key: "edit",
- icon: "edit",
- text: "编辑",
- color: "#161A1A",
- iconColor: "#2F8FFF",
- onClick() {
- edit.value =
- edit.value === customMap.activeFixPoint ? null : customMap.activeFixPoint;
- },
- },
- {
- key: "delete",
- icon: "del",
- text: "删除",
- color: "#FF4D4F",
- iconColor: "#fff",
- onClick() {
- if (delFix3d(customMap.activeFixPoint)) {
- customMap.activeFixPoint = null;
- edit.value = null;
- }
- },
- },
- ]
- );
- const ready = ref(false);
- watchEffect(() => {
- if (drawstatus.value === DrawStatus.ing) {
- ready.value = false;
- drawingFix3d.value[0].bus.on(
- "graphChange",
- (data) => (ready.value = data.path.length > 1)
- );
- }
- });
- const dom = ref<HTMLDivElement>();
- const menu = ref<HTMLDivElement>();
- watchEffect((onCleanup) => {
- if (edit.value && dom.value) {
- const handler = (ev) => {
- if (!dom.value.contains(ev.target) && !menu.value.contains(ev.target)) {
- edit.value = null;
- }
- };
- // document.documentElement.addEventListener("click", handler)
- document.documentElement.addEventListener("touchstart", handler);
- onCleanup(() => {
- // document.documentElement.removeEventListener("click", handler)
- document.documentElement.removeEventListener("touchstart", handler);
- });
- }
- });
- </script>
- <style lang="scss" scoped>
- .action-menus {
- position: absolute;
- bottom: var(--boundMargin);
- left: 50%;
- transform: translateX(-50%);
- display: flex;
- z-index: 2;
- .menus {
- position: static;
- }
- }
- </style>
- <style>
- .action-menus .menu.active {
- background: none;
- }
- .search-fix.ui-input .text.suffix input {
- padding-right: 50px;
- }
- </style>
|