|
@@ -24,15 +24,22 @@
|
|
|
* *********************************************************************************************************************
|
|
|
*/
|
|
|
|
|
|
-import { SGraphDeleteListCommand, SGraphEditScene, SGraphEdit } from "@persagy-web/edit"
|
|
|
+import {
|
|
|
+ SGraphDeleteListCommand,
|
|
|
+ SGraphEditScene,
|
|
|
+ SGraphEdit
|
|
|
+} from "@persagy-web/edit";
|
|
|
import { SMouseEvent } from "@persagy-web/base/lib";
|
|
|
-import { SArrowStyleType, SPoint, SRect } from '@persagy-web/draw';
|
|
|
-import { SItemStatus, SRectSelectItem } from '@persagy-web/big/lib';
|
|
|
-import { SGraphItem, SGraphSelectContainer, SOrderSetType } from "@persagy-web/graph/lib/";
|
|
|
-import { uuid } from "./until";
|
|
|
-import { SBaseArrow, SBaseEquipment, SBaseExpainEdit, SBasePipe } from "./"
|
|
|
-import { SBaseArrowPolyEdit } from './items/SBaseArrowPolyEdit';
|
|
|
-import { SGraphAddListCommand } from '@persagy-web/edit/lib/commands/SGraphAddListCommand';
|
|
|
+import { SArrowStyleType, SPoint, SRect } from "@persagy-web/draw";
|
|
|
+import { SItemStatus, SRectSelectItem } from "@persagy-web/big/lib";
|
|
|
+import {
|
|
|
+ SGraphItem,
|
|
|
+ SGraphSelectContainer,
|
|
|
+ SOrderSetType
|
|
|
+} from "@persagy-web/graph/lib/";
|
|
|
+import { SBaseArrow, SBaseExplainEdit, SBasePipe } from "./";
|
|
|
+import { SBaseArrowPolyEdit } from "./items/SBaseArrowPolyEdit";
|
|
|
+import { SGraphAddListCommand } from "@persagy-web/edit/lib/commands/SGraphAddListCommand";
|
|
|
|
|
|
/**
|
|
|
* big-edit 场景
|
|
@@ -41,9 +48,8 @@ import { SGraphAddListCommand } from '@persagy-web/edit/lib/commands/SGraphAddLi
|
|
|
*/
|
|
|
export class SBaseEditScene extends SGraphEditScene {
|
|
|
/** 图例节点 */
|
|
|
- Nodes: any = []; // 图例节点,所有与工程信息化相关的图例(图标类型与区域)
|
|
|
- /** 图例节点 */ // 与工程信息无关的标识对象(增加文本注释,图上的图片说明)
|
|
|
- Markers: any = [];
|
|
|
+ Nodes: any = []; // 图例节点,所有与工程信息化相关的图例(图标类型与区域) // 与工程信息无关的标识对象(增加文本注释,图上的图片说明)
|
|
|
+ /** 图例节点 */ Markers: any = [];
|
|
|
/** 管线对象 */
|
|
|
Relations: any = [];
|
|
|
/** 复制的对象 */
|
|
@@ -56,7 +62,7 @@ export class SBaseEditScene extends SGraphEditScene {
|
|
|
*
|
|
|
*/
|
|
|
constructor() {
|
|
|
- super()
|
|
|
+ super();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -65,29 +71,29 @@ export class SBaseEditScene extends SGraphEditScene {
|
|
|
* @param event 鼠标事件参数
|
|
|
* @return 新增的基础类注释
|
|
|
*/
|
|
|
- addExplainItem(event: SMouseEvent): SBaseExpainEdit {
|
|
|
+ addExplainItem(event: SMouseEvent): SBaseExplainEdit {
|
|
|
const data = {
|
|
|
/** 名称 */
|
|
|
- name: '基础注释文本',
|
|
|
+ name: "基础注释文本",
|
|
|
/** 图标 */
|
|
|
type: "Text",
|
|
|
/** 位置 */
|
|
|
pos: { x: event.x, y: event.y },
|
|
|
/** 由应用自己定义 */
|
|
|
properties: {
|
|
|
- type: "BaseExplain",
|
|
|
+ type: "BaseExplain"
|
|
|
},
|
|
|
style: {
|
|
|
default: {
|
|
|
- text: '请在右侧属性栏输入文字!',
|
|
|
+ text: "请在右侧属性栏输入文字!",
|
|
|
color: "#646c73",
|
|
|
font: 14,
|
|
|
- backgroundcolor: "#f7f9facc",
|
|
|
+ backgroundcolor: "#f7f9facc"
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- const item = new SBaseExpainEdit(null, data);
|
|
|
+ const item = new SBaseExplainEdit(null, data);
|
|
|
item.moveTo(event.x, event.y);
|
|
|
item.selectable = true;
|
|
|
item.moveable = true;
|
|
@@ -106,17 +112,17 @@ export class SBaseEditScene extends SGraphEditScene {
|
|
|
*/
|
|
|
addPolyLineArrow(event: SMouseEvent): SBaseArrow {
|
|
|
const data = {
|
|
|
- name: '基础箭头',
|
|
|
+ name: "基础箭头",
|
|
|
type: "Arrow",
|
|
|
pos: { x: 0, y: 0 },
|
|
|
properties: {
|
|
|
- type: "BaseArrow",
|
|
|
+ type: "BaseArrow"
|
|
|
},
|
|
|
style: {
|
|
|
outLine: [{ x: event.x, y: event.y }],
|
|
|
- begin: SArrowStyleType.None, //开端箭头样式
|
|
|
- end: SArrowStyleType.None, //结尾箭头样式
|
|
|
- isMove: true, //是否可以移动
|
|
|
+ begin: SArrowStyleType.None, //开端箭头样式
|
|
|
+ end: SArrowStyleType.None, //结尾箭头样式
|
|
|
+ isMove: true, //是否可以移动
|
|
|
default: {}
|
|
|
}
|
|
|
};
|
|
@@ -144,7 +150,7 @@ export class SBaseEditScene extends SGraphEditScene {
|
|
|
addPolygonArrow(event: SMouseEvent): SBaseArrowPolyEdit {
|
|
|
const data = {
|
|
|
/** 名称 */
|
|
|
- name: '多边形箭头',
|
|
|
+ name: "多边形箭头",
|
|
|
/** 图标(Image),线类型(Line) */
|
|
|
type: "ArrowPolygon",
|
|
|
/** 缩放比例(Image),线类型(Line) */
|
|
@@ -155,12 +161,11 @@ export class SBaseEditScene extends SGraphEditScene {
|
|
|
pos: { x: 0, y: 0 },
|
|
|
/** 由应用自己定义 */
|
|
|
properties: {
|
|
|
- type: "BaseArrowPolygon" // 自定义类型用于区分mark与node
|
|
|
+ type: "BaseArrowPolygon" // 自定义类型用于区分mark与node
|
|
|
},
|
|
|
style: {
|
|
|
line: [{ x: event.x, y: event.y }],
|
|
|
- default: {
|
|
|
- }
|
|
|
+ default: {}
|
|
|
}
|
|
|
};
|
|
|
const item = new SBaseArrowPolyEdit(null, data);
|
|
@@ -239,23 +244,23 @@ export class SBaseEditScene extends SGraphEditScene {
|
|
|
|
|
|
// 锚点时否存在
|
|
|
if (anc) {
|
|
|
- const p = anc.mapToScene(0, 0)
|
|
|
+ const p = anc.mapToScene(0, 0);
|
|
|
anc.isConnected = true;
|
|
|
event.x = p.x;
|
|
|
event.y = p.y;
|
|
|
- };
|
|
|
+ }
|
|
|
|
|
|
const data = {
|
|
|
name: legendObj.name,
|
|
|
graphElementId: legendObj.id,
|
|
|
- lineType: '',
|
|
|
- node1Id: '',
|
|
|
- node2Id: '',
|
|
|
- anchor1Id: '',
|
|
|
- anchor2Id: '',
|
|
|
+ lineType: "",
|
|
|
+ node1Id: "",
|
|
|
+ node2Id: "",
|
|
|
+ anchor1Id: "",
|
|
|
+ anchor2Id: "",
|
|
|
pointList: [{ x: event.x, y: event.y }],
|
|
|
properties: {
|
|
|
- type: "BasePipe",
|
|
|
+ type: "BasePipe"
|
|
|
},
|
|
|
style: {
|
|
|
default: {
|
|
@@ -274,9 +279,9 @@ export class SBaseEditScene extends SGraphEditScene {
|
|
|
|
|
|
// 锚点事件绑定
|
|
|
if (anc) {
|
|
|
- anc.parent?.connect('changePos', item, item.changePos)
|
|
|
+ anc.parent?.connect("changePos", item, item.changePos);
|
|
|
item.anchor1Id = anc.id;
|
|
|
- item.node1Id = anc.parent ? anc.parent.nodeId : '';
|
|
|
+ item.node1Id = anc.parent ? anc.parent.nodeId : "";
|
|
|
}
|
|
|
|
|
|
item.connect("finishCreated", this, this.finishCreated);
|
|
@@ -292,7 +297,7 @@ export class SBaseEditScene extends SGraphEditScene {
|
|
|
*/
|
|
|
redo(): void {
|
|
|
if (this.grabItem && this.grabItem instanceof SGraphEdit) {
|
|
|
- this.grabItem.redo()
|
|
|
+ this.grabItem.redo();
|
|
|
} else {
|
|
|
this.undoStack.redo();
|
|
|
}
|
|
@@ -303,7 +308,7 @@ export class SBaseEditScene extends SGraphEditScene {
|
|
|
*/
|
|
|
undo(): void {
|
|
|
if (this.grabItem && this.grabItem instanceof SGraphEdit) {
|
|
|
- this.grabItem.undo()
|
|
|
+ this.grabItem.undo();
|
|
|
} else {
|
|
|
this.undoStack.undo();
|
|
|
}
|
|
@@ -315,26 +320,28 @@ export class SBaseEditScene extends SGraphEditScene {
|
|
|
* @return 删除的图例
|
|
|
*/
|
|
|
deleteItem(itemArr: SGraphItem[] = []): any {
|
|
|
- let itemList = null;
|
|
|
+ let itemList: SGraphItem[] = [];
|
|
|
if (itemArr && itemArr.length && itemArr[0]) {
|
|
|
- itemList = [...itemArr]
|
|
|
+ itemList = [...itemArr];
|
|
|
} else {
|
|
|
if (this.selectContainer.count == 0) {
|
|
|
- return []
|
|
|
+ return [];
|
|
|
}
|
|
|
itemList = this.selectContainer.itemList;
|
|
|
- this.undoStack.push(new SGraphDeleteListCommand(this, [...itemList]))
|
|
|
+ this.undoStack.push(
|
|
|
+ new SGraphDeleteListCommand(this, [...itemList])
|
|
|
+ );
|
|
|
}
|
|
|
// 推入 undo/redo 栈
|
|
|
itemList.forEach((element: any) => {
|
|
|
- this.removeItem(element)
|
|
|
+ this.removeItem(element);
|
|
|
});
|
|
|
|
|
|
// view 必须存在
|
|
|
if (this.view) {
|
|
|
- this.view.update()
|
|
|
+ this.view.update();
|
|
|
}
|
|
|
- return itemList
|
|
|
+ return itemList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -353,11 +360,10 @@ export class SBaseEditScene extends SGraphEditScene {
|
|
|
* @param ctrl 是否点击ctrl
|
|
|
*/
|
|
|
groupSelect(ctrl: boolean) {
|
|
|
-
|
|
|
// 判断当前图例是否为选中框
|
|
|
if (this.grabItem instanceof SRectSelectItem) {
|
|
|
const rect = this.grabItem.boundingRect();
|
|
|
- this.arrToSelect(this.root.children, rect)
|
|
|
+ this.arrToSelect(this.root.children, rect);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -375,15 +381,15 @@ export class SBaseEditScene extends SGraphEditScene {
|
|
|
if (!(t instanceof SGraphSelectContainer) && t.parent) {
|
|
|
if (t.visible) {
|
|
|
let temp = t.boundingRect();
|
|
|
- let lefttop = t.mapToScene(temp.left, temp.top)
|
|
|
- let rightbottom = t.mapToScene(temp.right, temp.bottom)
|
|
|
- let r = new SRect(lefttop, rightbottom)
|
|
|
+ let lefttop = t.mapToScene(temp.left, temp.top);
|
|
|
+ let rightbottom = t.mapToScene(temp.right, temp.bottom);
|
|
|
+ let r = new SRect(lefttop, rightbottom);
|
|
|
if (rect.isIn(r)) {
|
|
|
- this.selectContainer.toggleItem(t)
|
|
|
+ this.selectContainer.toggleItem(t);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -415,7 +421,7 @@ export class SBaseEditScene extends SGraphEditScene {
|
|
|
this.grabItem = null;
|
|
|
// view 不为空
|
|
|
if (this.view) {
|
|
|
- this.view.update()
|
|
|
+ this.view.update();
|
|
|
}
|
|
|
|
|
|
return true;
|
|
@@ -424,7 +430,7 @@ export class SBaseEditScene extends SGraphEditScene {
|
|
|
return this.grabItem.onMouseUp(event);
|
|
|
}
|
|
|
|
|
|
- return super.onMouseUp(event)
|
|
|
+ return super.onMouseUp(event);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -440,7 +446,7 @@ export class SBaseEditScene extends SGraphEditScene {
|
|
|
delete item.id;
|
|
|
delete item.graphId;
|
|
|
delete item.markerId;
|
|
|
- return item
|
|
|
+ return item;
|
|
|
});
|
|
|
|
|
|
// 删除对应得id
|
|
@@ -448,7 +454,7 @@ export class SBaseEditScene extends SGraphEditScene {
|
|
|
delete item.id;
|
|
|
delete item.graphId;
|
|
|
delete item.markerId;
|
|
|
- return item
|
|
|
+ return item;
|
|
|
});
|
|
|
|
|
|
// 删除对应得id
|
|
@@ -456,26 +462,24 @@ export class SBaseEditScene extends SGraphEditScene {
|
|
|
delete item.id;
|
|
|
delete item.graphId;
|
|
|
delete item.markerId;
|
|
|
- return item
|
|
|
+ return item;
|
|
|
});
|
|
|
|
|
|
- this.copyString = itemList
|
|
|
+ this.copyString = itemList;
|
|
|
// 获取input dom
|
|
|
- const input = document.createElement('input');
|
|
|
- input.setAttribute('id', 'COPYINPUT')
|
|
|
- input.value = JSON.stringify(this.copyString)
|
|
|
+ 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';
|
|
|
+ input.select();
|
|
|
+ document.execCommand("copy");
|
|
|
+ input.style.display = "none";
|
|
|
console.log(input.value, Date.now());
|
|
|
- document.body.removeChild(input)
|
|
|
+ document.body.removeChild(input);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 添加多个item命令
|
|
|
*
|
|
@@ -491,7 +495,7 @@ export class SBaseEditScene extends SGraphEditScene {
|
|
|
* @param type 设置类型
|
|
|
*/
|
|
|
setOrder(type: string) {
|
|
|
- this.selectContainer.setOrder(SOrderSetType[type])
|
|
|
+ this.selectContainer.setOrder(SOrderSetType[type]);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -501,7 +505,7 @@ export class SBaseEditScene extends SGraphEditScene {
|
|
|
if (this.grabItem instanceof SBasePipe) {
|
|
|
const anc = this.clickIsAnchor(event);
|
|
|
if (anc) {
|
|
|
- const p = anc.mapToScene(0, 0)
|
|
|
+ const p = anc.mapToScene(0, 0);
|
|
|
anc.isConnected = true;
|
|
|
event.x = p.x;
|
|
|
event.y = p.y;
|
|
@@ -511,19 +515,24 @@ export class SBaseEditScene extends SGraphEditScene {
|
|
|
// pointList 长度不能为空
|
|
|
if (this.grabItem.pointList.length) {
|
|
|
this.grabItem.endAnchor = anc;
|
|
|
- anc.parent?.connect('changePos', this.grabItem, this.grabItem.changePos)
|
|
|
+ anc.parent?.connect(
|
|
|
+ "changePos",
|
|
|
+ this.grabItem,
|
|
|
+ this.grabItem.changePos
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
- this.grabItem.anchor2Id = anc.id
|
|
|
- this.grabItem.node2Id = anc.parent.nodeId
|
|
|
- this.grabItem.onMouseDown(event)
|
|
|
+ this.grabItem.anchor2Id = anc.id;
|
|
|
+ this.grabItem.node2Id = anc.parent.nodeId;
|
|
|
+ this.grabItem.onMouseDown(event);
|
|
|
this.grabItem.status = SItemStatus.Normal;
|
|
|
- this.finishCreated(this.grabItem)
|
|
|
- return
|
|
|
+ this.finishCreated(this.grabItem);
|
|
|
+ return;
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- this.grabItem.onMouseDown(event)
|
|
|
+ this.grabItem.onMouseDown(event);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -533,6 +542,5 @@ export class SBaseEditScene extends SGraphEditScene {
|
|
|
* @param isAll 是否为全部item数据
|
|
|
* @returns 返回保存的数据接口
|
|
|
*/
|
|
|
- save(isAll: boolean = true): any {
|
|
|
- }
|
|
|
-}
|
|
|
+ save(isAll: boolean = true): any {}
|
|
|
+}
|