import { SPolylineItem, ItemOrder } from '@saga-web/big/lib'; import { SPoint } from "@saga-web/draw/lib"; /** * 管道item * * */ export class TipelineItem extends SPolylineItem { constructor(parent, data) { super(parent, []); /** 起始锚点 */ this.startAnchor = null; /** 结束锚点 */ this.endAnchor = null; /** 对应的图例ID */ this._graphElementId = ""; /** 关联节点1ID */ this._node1Id = ""; /** 关联节点2ID */ this._node2Id = ""; /** 关联锚点1ID */ this._anchor1ID = ""; /** 关联锚点2ID */ this._anchor2ID = ""; /** 数据存储 */ this.data = null; this.zOrder = ItemOrder.polylineOrder; this.pointList = data.PointList.map(item => { return new SPoint(item.X, item.Y); }); this.data = data; this.id = data.ID; if (data.GraphElementId) { this._graphElementId = data.GraphElementId; } if (data.Node1ID) { this._node1Id = data.Node1ID; } if (data.Node2ID) { this._node2Id = data.Node2ID; } if (data.Anchor1ID) { this._anchor1ID = data.Anchor1ID; } if (data.Anchor2ID) { this._anchor2ID = data.Anchor2ID; } if (data.Properties && data.Properties.Color) { this.strokeColor = data.Properties.Color; } // if(data.Properties && data.Properties.LineDash){ // this.LineDash = data.Properties.LineDash // } if (data.Properties && data.Properties.LineWidth) { this.lineWidth = data.Properties.LineWidth; } } get graphElementId() { return this._graphElementId; } set graphElementId(v) { this._graphElementId = v; if (this.data) { this.data.GraphElementId = this._graphElementId; } } get node1Id() { return this._node1Id; } set node1Id(v) { this._node1Id = v; if (this.data) { this.data.Node1ID = this._node1Id; } } get node2Id() { return this._node2Id; } set node2Id(v) { this._node2Id = v; if (this.data) { this.data.Node2ID = this._node2Id; } } get anchor1ID() { return this._anchor1ID; } set anchor1ID(v) { this._anchor1ID = v; if (this.data) { this.data.Anchor1ID = this._anchor1ID; } } get anchor2ID() { return this._anchor2ID; } set anchor2ID(v) { this._anchor2ID = v; if (this.data) { this.data.Anchor2ID = this._anchor2ID; } } /** 接收事件作出修改 */ changePos() { if (this.startAnchor) { // 判断删除equip后,不移动 if (this.startAnchor.parent && this.startAnchor.parent.parent) { this.pointList[0] = this.startAnchor.mapToScene(0, 0); } } if (this.endAnchor) { // 删除equip后 if (this.endAnchor.parent && this.endAnchor.parent.parent) { this.pointList[this.pointList.length - 1] = this.endAnchor.mapToScene(0, 0); } } } /** 获取data数据 */ toData() { let pointList = this.pointList.map(item => { return { X: item.x, Y: item.y }; }); if (this.data) { this.data.PointList = pointList; this.data.Properties.LineWidth = this.lineWidth; // this.data.Properties.LineDash = this.LineDash; this.data.Properties.Color = this.strokeColor; } return this.data; } }