list.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <template>
  2. <template v-for="(path, index) in paths" :key="path.id">
  3. <Sign
  4. v-if="getPathIsShow(path) && false"
  5. @delete="deletePath(path)"
  6. @updatePoints="(data) => updatePosition(index, data)"
  7. @updateLinePosition="(data) => updateLinePosition(index, data)"
  8. :ref="(node: any) => nodes[index] = ({ node, id: path.id })"
  9. :path="path"
  10. :key="path.id"
  11. />
  12. </template>
  13. </template>
  14. <script lang="ts" setup>
  15. import { reactive, watchEffect } from "vue";
  16. import Sign from "./sign.vue";
  17. import { getPathIsShow, Path } from "@/store";
  18. import { PathsNode } from "@/sdk/association/path";
  19. const props = defineProps<{ paths: Path[] }>();
  20. const nodes = reactive([]) as PathsNode;
  21. watchEffect(() => (nodes.length = props.paths.length));
  22. const deletePath = (path: Path) => {
  23. const index = props.paths.indexOf(path);
  24. props.paths.splice(index, 1);
  25. };
  26. const updatePosition = (ndx: number, data: Path["points"]) => {
  27. props.paths[ndx].points = data;
  28. };
  29. const updateLinePosition = (ndx: number, linePosition: Path["linePosition"]) => {
  30. props.paths[ndx].linePosition = linePosition;
  31. };
  32. defineExpose(nodes);
  33. </script>