This commit is contained in:
李志鹏
2026-01-09 17:05:46 +08:00
parent 3058adfdb7
commit 7b071bc585
2 changed files with 66 additions and 14 deletions

View File

@@ -21,6 +21,7 @@
>
</button>
<button @click.stop="onDelete(item.id)">删除</button>
</div>
<div>
<span>偏移X</span>
@@ -80,6 +81,7 @@
/>
</div>
</div>
<button @click="onAdd">添加</button>
<div class="box">
<pingpu
:list="list"
@@ -94,9 +96,10 @@
import { ref, onMounted, watch } from "vue";
import pingpu from "./pingpu.vue";
const ACTIONS = {
SELECT: "select",
ADD: "add",
UPDATE: "update",
DELETE: "delete",
SELECT: "select",
SORT: "sort",
};
@@ -211,6 +214,49 @@
},
]);
};
const onDelete = (id) => {
list.value = list.value.filter((v) => v.id !== id);
pingpuRef.value.updataList([
{
id: id,
action: ACTIONS.DELETE,
},
]);
};
const onAdd = () => {
const obj = {
id: Date.now().toString(),
ifSingle: false,
level2Type: "Pattern",
designType: "Library",
path: "/src/assets/images/canvas/yinhua1.jpg",
location: [0, 0],
scale: [1, 1],
angle: 0,
name: "Print" + (list.value.length + 1),
priority: 1,
object: {
top: 0,
left: 0,
scaleX: 1,
scaleY: 1,
opacity: 1,
angle: 0,
flipX: false,
flipY: false,
blendMode: "multiply",
gapX: 10,
gapY: 20,
},
};
list.value.push(obj);
pingpuRef.value.updataList([
{
action: ACTIONS.ADD,
data: obj,
},
]);
};
watch(
() => list.value,
() => updateList(),