|
@@ -1,14 +1,18 @@
|
|
|
|
+import { pick, set } from "lodash";
|
|
import { Exception, queenApi } from "queenjs";
|
|
import { Exception, queenApi } from "queenjs";
|
|
import { EditorModule } from "..";
|
|
import { EditorModule } from "..";
|
|
import { DesignComp } from "../../objects/DesignTemp/DesignComp";
|
|
import { DesignComp } from "../../objects/DesignTemp/DesignComp";
|
|
-import { ICompKeys } from "../../typings";
|
|
|
|
-import { pick } from "lodash";
|
|
|
|
|
|
+import { ICompKeys, Layout } from "../../typings";
|
|
|
|
|
|
export const editActions = EditorModule.action({
|
|
export const editActions = EditorModule.action({
|
|
// 添加组件到画布
|
|
// 添加组件到画布
|
|
async addCompToDesign(compKey: ICompKeys, index?: number) {
|
|
async addCompToDesign(compKey: ICompKeys, index?: number) {
|
|
let compId: string;
|
|
let compId: string;
|
|
- if (index === undefined && this.store.currComp?.compKey === "Container") {
|
|
|
|
|
|
+ if (
|
|
|
|
+ index === undefined &&
|
|
|
|
+ this.store.currComp?.compKey === "Container" &&
|
|
|
|
+ this.store.pageCompIds.includes(this.store.currComp.id)
|
|
|
|
+ ) {
|
|
compId = await this.store.insertCompContainer(
|
|
compId = await this.store.insertCompContainer(
|
|
compKey,
|
|
compKey,
|
|
this.store.currComp
|
|
this.store.currComp
|
|
@@ -38,12 +42,12 @@ export const editActions = EditorModule.action({
|
|
removeComp(compId: string) {
|
|
removeComp(compId: string) {
|
|
if (this.helper.isCompCanDelete(compId)) {
|
|
if (this.helper.isCompCanDelete(compId)) {
|
|
if (compId === this.store.currCompId) {
|
|
if (compId === this.store.currCompId) {
|
|
- this.store.setCurrComp("");
|
|
|
|
|
|
+ this.store.setCurrComp("root");
|
|
}
|
|
}
|
|
this.store.deleteComp(compId);
|
|
this.store.deleteComp(compId);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- // 移动组件
|
|
|
|
|
|
+ // 移动组件顺序
|
|
moveComp(selIndex: number, targetIndex: number) {
|
|
moveComp(selIndex: number, targetIndex: number) {
|
|
if (selIndex === targetIndex) return;
|
|
if (selIndex === targetIndex) return;
|
|
this.store.moveComp(selIndex, targetIndex);
|
|
this.store.moveComp(selIndex, targetIndex);
|
|
@@ -97,6 +101,15 @@ export const editActions = EditorModule.action({
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ // 设置组件变换
|
|
|
|
+ setCompTransform(comp: DesignComp, transform: Layout["transform"]) {
|
|
|
|
+ comp.layout.transform = transform;
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ updateCompDataByForm(comp: DesignComp, path: string, value: any) {
|
|
|
|
+ set(comp, path, value);
|
|
|
|
+ },
|
|
|
|
+
|
|
// 设置组件显示隐藏
|
|
// 设置组件显示隐藏
|
|
setCompPosition(comp: DesignComp) {
|
|
setCompPosition(comp: DesignComp) {
|
|
comp.layout.position =
|
|
comp.layout.position =
|