|
@@ -34,6 +34,8 @@ import { SGraphAddCommand } from "@persagy-web/edit";
|
|
|
import { SColor, SFont, SArrowStyleType } from "@persagy-web/draw";
|
|
|
import { SPlanEquipment, SPlanParser, SPlanZone } from "./";
|
|
|
import { SPlanBackgroundImage } from "@/lib/item/SPlanBackgroundImage";
|
|
|
+import { imgBaseUrl } from "@/api/imageservice";
|
|
|
+
|
|
|
/**
|
|
|
* 平面图场景类
|
|
|
*
|
|
@@ -46,6 +48,8 @@ export class SPlanScene extends SBaseEditScene {
|
|
|
public imgServeUrl: string = "";
|
|
|
/** 判断是否为苹果电脑 */
|
|
|
public isMac = /macintosh|mac os x/i.test(navigator.userAgent);
|
|
|
+ /** 复制的对象 */
|
|
|
+ copyString: any[] = [];
|
|
|
constructor() {
|
|
|
super();
|
|
|
// 选择绑定选额item事件
|
|
@@ -374,6 +378,7 @@ export class SPlanScene extends SBaseEditScene {
|
|
|
if (item instanceof SGraphEdit && !(item instanceof SGraphSelectContainer)) {
|
|
|
// 添加节点数据
|
|
|
if (item.data && Marktype.includes(item.data.properties.type)) {
|
|
|
+ console.log(item.toData());
|
|
|
markers.push(item.toData());
|
|
|
}
|
|
|
|
|
@@ -465,10 +470,48 @@ export class SPlanScene extends SBaseEditScene {
|
|
|
}
|
|
|
return itemList;
|
|
|
}
|
|
|
+ copy(): void {
|
|
|
+ const itemList = this.save(false);
|
|
|
+ if (itemList) {
|
|
|
+ // 删除对应得id
|
|
|
+ itemList.markers.map((item: any) => {
|
|
|
+ delete item.id;
|
|
|
+ delete item.graphId;
|
|
|
+ delete item.markerId;
|
|
|
+ return item;
|
|
|
+ });
|
|
|
+ // itemList.nodes.map((item: any) => {
|
|
|
+ // delete item.id;
|
|
|
+ // delete item.graphId;
|
|
|
+ // delete item.markerId;
|
|
|
+ // return item;
|
|
|
+ // });
|
|
|
+ itemList.relations.map((item: any) => {
|
|
|
+ delete item.id;
|
|
|
+ delete item.graphId;
|
|
|
+ delete item.markerId;
|
|
|
+ return item;
|
|
|
+ });
|
|
|
+
|
|
|
+ this.copyString = itemList;
|
|
|
+ // 获取input dom
|
|
|
+ const input = document.createElement("input");
|
|
|
+ input.setAttribute("id", "COPYINPUT");
|
|
|
+ input.value = JSON.stringify(this.copyString);
|
|
|
+ sessionStorage.setItem("copyString", input.value);
|
|
|
+ document.body.appendChild(input);
|
|
|
+ input.select();
|
|
|
+ document.execCommand("copy");
|
|
|
+ input.style.display = "none";
|
|
|
+ console.log(input.value, Date.now());
|
|
|
+ document.body.removeChild(input);
|
|
|
+ }
|
|
|
+ }
|
|
|
/**
|
|
|
* 粘贴
|
|
|
*/
|
|
|
paste(): void {
|
|
|
+ debugger;
|
|
|
const copyList = JSON.parse(JSON.stringify(this.copyString));
|
|
|
const parserData = new SPlanParser();
|
|
|
const graphItemList: SGraphEdit[] = [];
|
|
@@ -480,11 +523,43 @@ export class SPlanScene extends SBaseEditScene {
|
|
|
item.pos.x += 10 / this.view.scale;
|
|
|
item.pos.y += 10 / this.view.scale;
|
|
|
}
|
|
|
+ // 基础图片,修改url
|
|
|
+ if (item.data.properties.type == "BaseImage") {
|
|
|
+ item.showSelect = false;
|
|
|
+ item.isTransform = false;
|
|
|
+ if (item.data.style?.default?.url) {
|
|
|
+ item.url = imgBaseUrl + item.data.style.default.url;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 背景图片,修改url
|
|
|
+ if (item.data.properties.type == "BgImage") {
|
|
|
+ if (item.data.style?.default?.url) {
|
|
|
+ item.url = imgBaseUrl + item.data.style.default.url;
|
|
|
+ }
|
|
|
+ }
|
|
|
this.addItem(item);
|
|
|
graphItemList.push(item);
|
|
|
});
|
|
|
-
|
|
|
- this.addListCommand(graphItemList);
|
|
|
- this.view ? this.view.update() : "";
|
|
|
+ // 有复制的元素
|
|
|
+ if (graphItemList?.length) {
|
|
|
+ this.addListCommand(graphItemList);
|
|
|
+ this.view?.update();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 置顶/置底
|
|
|
+ *
|
|
|
+ * @param val 置顶
|
|
|
+ */
|
|
|
+ setItemOrder(val: string): void {
|
|
|
+ const itemList = this.selectContainer?.itemList;
|
|
|
+ if (itemList?.length) {
|
|
|
+ itemList.forEach((item) => {
|
|
|
+ const oldV = item.zOrder;
|
|
|
+ this.setOrder(val);
|
|
|
+ const newV = item.zOrder;
|
|
|
+ this.undoStack.push(new SGraphPropertyCommand(this, item, "zOrder", oldV, newV));
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
}
|