123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <template>
- <TempLine
- :data="tData"
- :ref="(v: any) => shape = v?.shape"
- :id="data.id"
- @update:position="updatePosition"
- @update="emit('updateShape', { ...data })"
- @deletePoint="deletePoint"
- @addPoint="addPoint"
- canEdit
- />
- <PropertyUpdate
- :describes="describes"
- :data="data"
- :target="shape"
- @change="emit('updateShape', { ...data })"
- @delete="emit('delShape')"
- />
- <Operate :target="shape" :menus="operateMenus" />
- </template>
- <script lang="ts" setup>
- import { SLineData, getMouseStyle, defaultStyle, matResponse } from "./index.ts";
- import { useComponentStatus } from "@/core/hook/use-component.ts";
- import { PropertyUpdate, Operate } from "../../html-mount/propertys/index.ts";
- import TempLine from "./temp-line.vue";
- import { useInteractiveDrawShapeAPI } from "@/core/hook/use-draw.ts";
- import { useStore } from "@/core/store/index.ts";
- import { Pos } from "@/utils/math.ts";
- const props = defineProps<{ data: SLineData }>();
- const emit = defineEmits<{
- (e: "updateShape", value: SLineData): void;
- (e: "addShape", value: SLineData): void;
- (e: "delShape"): void;
- }>();
- const { shape, tData, data, operateMenus, describes } = useComponentStatus({
- emit,
- props,
- getMouseStyle,
- transformType: "line",
- // alignment(data, mat) {
- // return matResponse({ mat, data, increment: true });
- // },
- // type: "line",
- defaultStyle,
- copyHandler(mat, data) {
- return matResponse({ mat, data, increment: true });
- },
- propertys: [
- "stroke",
- "strokeWidth",
- // "dash",
- "opacity",
- // "ref", "zIndex"
- ],
- });
- const updatePosition = ({ ndx, val }: { ndx: number; val: Pos }) => {
- Object.assign(data.value.points[ndx], val);
- shape.value?.getNode().fire("bound-change");
- };
- const deletePoint = (ndx: number) => {
- data.value.points.splice(ndx, 1);
- if (data.value.points.length <= 1) {
- emit("delShape");
- } else {
- shape.value?.getNode().fire("bound-change");
- }
- };
- const addPoint = ({ ndx, val }: { ndx: number; val: Pos }) => {
- data.value.points.splice(ndx + 1, 0, val);
- shape.value?.getNode().fire("bound-change");
- };
- const draw = useInteractiveDrawShapeAPI();
- const store = useStore();
- operateMenus.push({
- label: "钢笔编辑",
- handler() {
- draw.enterDrawShape("sequentLine", {
- ...props.data,
- getMessages: () => {
- const line = store.getItemById(props.data.id) as SLineData;
- return line ? line.points : [];
- },
- });
- },
- });
- </script>
|