|
@@ -11,6 +11,7 @@
|
|
|
:data="data"
|
|
|
:target="shape"
|
|
|
@change="emit('updateShape', { ...data })"
|
|
|
+ @delete="emit('delShape')"
|
|
|
/>
|
|
|
<Operate
|
|
|
:target="shape"
|
|
@@ -36,12 +37,12 @@ import { MathUtils } from "three";
|
|
|
import {
|
|
|
useCustomTransformer,
|
|
|
useGetTransformerOperType,
|
|
|
+ useTransformer,
|
|
|
} from "@/core/hook/use-transformer.ts";
|
|
|
import { copy, getResizeCorsur } from "@/utils/shared.ts";
|
|
|
import { computed, ref, watch, watchEffect } from "vue";
|
|
|
import { Group } from "konva/lib/Group";
|
|
|
import { DC } from "@/deconstruction.js";
|
|
|
-import { Minus, Plus } from "@element-plus/icons-vue";
|
|
|
import { Rect } from "konva/lib/shapes/Rect";
|
|
|
import { setShapeTransform } from "@/utils/shape.ts";
|
|
|
import { Text } from "konva/lib/shapes/Text";
|
|
@@ -50,7 +51,7 @@ import {
|
|
|
useMouseShapeStatus,
|
|
|
} from "@/core/hook/use-mouse-status.ts";
|
|
|
import { useCursor, usePointerPos } from "@/core/hook/use-global-vars.ts";
|
|
|
-import { numEq, Pos } from "@/utils/math.ts";
|
|
|
+import { Pos } from "@/utils/math.ts";
|
|
|
|
|
|
const props = defineProps<{ data: TableData }>();
|
|
|
const emit = defineEmits<{
|
|
@@ -117,9 +118,6 @@ watch(
|
|
|
onCleanup(() => {
|
|
|
inter = null;
|
|
|
pop();
|
|
|
- // if (isActive) {
|
|
|
- // shapesStatus.actives = [...shapesStatus.actives, $shape];
|
|
|
- // }
|
|
|
});
|
|
|
}
|
|
|
},
|
|
@@ -139,50 +137,7 @@ const matToData = (data: TableData, mat: Transform, initData?: TableData) => {
|
|
|
}
|
|
|
const dec = mat.decompose();
|
|
|
if (!inter || (!~inter.colBorderNdx && !~inter.rowBorderNdx)) {
|
|
|
- const oldData = copy(data);
|
|
|
- data.height = dec.scaleY * initData.height;
|
|
|
- data.width = dec.scaleX * initData.width;
|
|
|
-
|
|
|
- let w = 0;
|
|
|
- let h = 0;
|
|
|
- data.content.forEach((row, rndx) => {
|
|
|
- row.forEach((col, cndx) => {
|
|
|
- const initCol = initData.content[rndx][cndx];
|
|
|
- const minSize = getColMinSize(initCol);
|
|
|
- col.width = Math.max(minSize.w, data.width * (initCol.width / initData.width));
|
|
|
- col.height = Math.max(
|
|
|
- minSize.h,
|
|
|
- data.height * (initCol.height / initData.height)
|
|
|
- );
|
|
|
- if (rndx === 0) {
|
|
|
- w += col.width;
|
|
|
- }
|
|
|
- if (cndx === 0) {
|
|
|
- h += col.height;
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- const eqW = numEq(w, data.width);
|
|
|
- const eqH = numEq(h, data.height);
|
|
|
-
|
|
|
- if (!eqW || !eqH) {
|
|
|
- const type = getOperType();
|
|
|
- if (type) {
|
|
|
- Object.assign(data, oldData);
|
|
|
- } else {
|
|
|
- data.width = w;
|
|
|
- data.height = h;
|
|
|
- const initDec = new Transform(initData.mat).decompose();
|
|
|
- data.mat = new Transform()
|
|
|
- .translate(eqW ? dec.x : initDec.x, eqH ? dec.y : initDec.y)
|
|
|
- .rotate(MathUtils.degToRad(dec.rotation)).m;
|
|
|
- }
|
|
|
- } else {
|
|
|
- data.mat = new Transform()
|
|
|
- .translate(dec.x, dec.y)
|
|
|
- .rotate(MathUtils.degToRad(dec.rotation)).m;
|
|
|
- }
|
|
|
- return data;
|
|
|
+ return matResponse({ data, mat, operType: getOperType()! }, initData);
|
|
|
}
|
|
|
|
|
|
const initDec = new Transform(initData.mat).decompose();
|
|
@@ -235,6 +190,7 @@ const matToData = (data: TableData, mat: Transform, initData?: TableData) => {
|
|
|
};
|
|
|
|
|
|
let repShape: Rect | null;
|
|
|
+const transformer = useTransformer();
|
|
|
const sync = (data: TableData) => {
|
|
|
if (repShape) {
|
|
|
repShape.width(data.width);
|
|
@@ -242,6 +198,7 @@ const sync = (data: TableData) => {
|
|
|
const tf = new Transform(data.mat);
|
|
|
setShapeTransform(repShape, tf);
|
|
|
initData = copy(data);
|
|
|
+ transformer.forceUpdate();
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -342,7 +299,6 @@ const menuShowHandler = () => {
|
|
|
addMenu = [];
|
|
|
if (!data.value.notaddRow) {
|
|
|
addMenu.push({
|
|
|
- icon: Plus,
|
|
|
label: "插入行",
|
|
|
handler: () => {
|
|
|
const temprow = data.value.content[config.rowNdx];
|
|
@@ -360,7 +316,6 @@ const menuShowHandler = () => {
|
|
|
const canDelRaw = data.value.content[config.rowNdx].every((item) => !item.notdel);
|
|
|
if (canDelRaw) {
|
|
|
addMenu.push({
|
|
|
- icon: Minus,
|
|
|
label: "删除行",
|
|
|
handler: () => {
|
|
|
const temprow = data.value.content[config.rowNdx];
|
|
@@ -378,7 +333,6 @@ const menuShowHandler = () => {
|
|
|
|
|
|
if (!data.value.notaddCol) {
|
|
|
addMenu.push({
|
|
|
- icon: Plus,
|
|
|
label: "插入列",
|
|
|
handler: () => {
|
|
|
const tempCol = data.value.content[0][config.colNdx];
|
|
@@ -396,7 +350,6 @@ const menuShowHandler = () => {
|
|
|
const canDelCol = data.value.content.every((items) => !items[config.colNdx].notdel);
|
|
|
if (canDelCol) {
|
|
|
addMenu.push({
|
|
|
- icon: Minus,
|
|
|
label: "删除列",
|
|
|
handler: () => {
|
|
|
const tempCol = data.value.content[0][config.colNdx];
|