rectangle.vue 1013 B

1234567891011121314151617181920212223242526272829303132333435
  1. <template>
  2. <TempLine :data="tData" :ref="(v: any) => shape = v?.shape" :id="data.id" />
  3. <PropertyUpdate
  4. :describes="describes"
  5. :data="data"
  6. :target="shape"
  7. @change="emit('updateShape', { ...data })"
  8. />
  9. <Operate :target="shape" :menus="operateMenus" />
  10. </template>
  11. <script lang="ts" setup>
  12. import { RectangleData, getMouseStyle, defaultStyle } from "./index.ts";
  13. import { PropertyUpdate, Operate } from "../../propertys";
  14. import TempLine from "./temp-rectangle.vue";
  15. import { useComponentStatus } from "@/core/hook/use-component.ts";
  16. const props = defineProps<{ data: RectangleData }>();
  17. const emit = defineEmits<{
  18. (e: "updateShape", value: RectangleData): void;
  19. (e: "addShape", value: RectangleData): void;
  20. (e: "delShape"): void;
  21. }>();
  22. const { shape, tData, data, operateMenus, describes } = useComponentStatus({
  23. emit,
  24. props,
  25. getMouseStyle,
  26. defaultStyle,
  27. copyHandler(tf, data) {
  28. data.points = data.points.map((v) => tf.point(v));
  29. return data;
  30. },
  31. });
  32. </script>