|
@@ -3,22 +3,35 @@ import { ItemOrder } from "@saga-web/big/lib";
|
|
|
import { SColor, SPainter, SRect } from "@saga-web/draw/lib";
|
|
|
import { SMouseEvent } from "@saga-web/base/lib";
|
|
|
import { EquipmentData } from "../types/EquipmentData";
|
|
|
+enum StatusType {
|
|
|
+ /** 普通态 */
|
|
|
+ Normal,
|
|
|
+ /** 编辑态 */
|
|
|
+ Edit
|
|
|
+}
|
|
|
export class SEquipmentItem extends SObjectItem {
|
|
|
// img对象
|
|
|
img: SImageItem = new SImageItem(this);
|
|
|
- textArr: STextItem[] = [];
|
|
|
+ _textArr: STextItem[] = [];
|
|
|
/** imgkey值 */
|
|
|
_imgKey: string = "";
|
|
|
- /** 设备状态值 */
|
|
|
+ /** 设备状态值,开启:关闭:故障... */
|
|
|
_status: string = "Running";
|
|
|
/**保存设备数据 */
|
|
|
_epData: EquipmentData | any = {};
|
|
|
+ /** 设备名称 */
|
|
|
+ _name: string = '';
|
|
|
+ /** 设备状态:编辑,正常 */
|
|
|
+ equipmentStatus: StatusType = StatusType.Normal;
|
|
|
+
|
|
|
get imgKey(): string {
|
|
|
return this._imgKey;
|
|
|
}
|
|
|
set imgKey(v: string) {
|
|
|
this._imgKey = v;
|
|
|
- this.img.url = `/serve/topology-wanda/Picture/query/${v}`;
|
|
|
+ // TODO:
|
|
|
+ // this.img.url = `/serve/topology-wanda/Picture/query/${v}`;
|
|
|
+ this.img.url = `http://60.205.177.43/topolImages/${v}`;
|
|
|
this.img.connect("imgLoadOver", this, () => {
|
|
|
// 抛出设备中的图片加载完成事件
|
|
|
this.$emit("equipImgLoadOver");
|
|
@@ -32,6 +45,12 @@ export class SEquipmentItem extends SObjectItem {
|
|
|
this._status = v;
|
|
|
this.updateStatus();
|
|
|
}
|
|
|
+ get textArr(): STextItem[] {
|
|
|
+ return this._textArr
|
|
|
+ }
|
|
|
+ set textArr(v) {
|
|
|
+ this._textArr = v
|
|
|
+ }
|
|
|
// 将EquipmentData保存起来,以便修改status时,可以找到StatusImage
|
|
|
get epData(): EquipmentData {
|
|
|
return this._epData;
|
|
@@ -39,6 +58,17 @@ export class SEquipmentItem extends SObjectItem {
|
|
|
set epData(v: EquipmentData) {
|
|
|
this._epData = v;
|
|
|
}
|
|
|
+ // 修改设备名称
|
|
|
+ get name(): string {
|
|
|
+ return this._name
|
|
|
+ }
|
|
|
+ set name(v: string) {
|
|
|
+ this._name = v
|
|
|
+ if (this.textArr && this.textArr.length) {
|
|
|
+ this.textArr[0].text = v
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
*
|
|
|
* @param parent 父类
|
|
@@ -91,8 +121,9 @@ export class SEquipmentItem extends SObjectItem {
|
|
|
this.img.width = epData.Size.Width;
|
|
|
this.img.height = epData.Size.Height;
|
|
|
// 名称
|
|
|
+ this.name = epData.Name
|
|
|
let nameItem = new STextItem(this);
|
|
|
- nameItem.moveable = true;
|
|
|
+ // nameItem.moveable = true;
|
|
|
nameItem.backgroundColor = SColor.Transparent;
|
|
|
nameItem.font.size = 14;
|
|
|
nameItem.text = epData.Name;
|
|
@@ -102,8 +133,6 @@ export class SEquipmentItem extends SObjectItem {
|
|
|
let { InfoList } = epData;
|
|
|
InfoList.map(({ Name, X, Y, Width, Height, FontSize, Background, Color, TextAlign }) => {
|
|
|
let textItem = new STextItem(this);
|
|
|
- textItem.moveable = true;
|
|
|
- // textItem.backgroundColor = SColor.Transparent;
|
|
|
textItem.backgroundColor = new SColor(Background);
|
|
|
textItem.width = Width;
|
|
|
textItem.height = Height;
|
|
@@ -126,6 +155,26 @@ export class SEquipmentItem extends SObjectItem {
|
|
|
this.imgKey = currentSts.ImageKey || runingSts.ImageKey;
|
|
|
}
|
|
|
/**
|
|
|
+ * 鼠标双击事件
|
|
|
+ *
|
|
|
+ * @param event 事件参数
|
|
|
+ * @return boolean
|
|
|
+ */
|
|
|
+ onDoubleClick(event: SMouseEvent): boolean {
|
|
|
+ console.log(event)
|
|
|
+ console.log(this)
|
|
|
+ // 如果位show状态 双击改对象则需改为编辑状态
|
|
|
+ if (StatusType.Normal == this.equipmentStatus) {
|
|
|
+ this.equipmentStatus = StatusType.Edit;
|
|
|
+ // this.grabItem(this);
|
|
|
+ } else if (StatusType.Edit == this.equipmentStatus) {
|
|
|
+ this.equipmentStatus = StatusType.Normal;
|
|
|
+ this.releaseItem();
|
|
|
+ }
|
|
|
+ this.update()
|
|
|
+ return true;
|
|
|
+ } // Function onDoubleClick()
|
|
|
+ /**
|
|
|
* 宽高发生变化
|
|
|
*
|
|
|
* @return SRect 所有子对象的并集
|
|
@@ -165,6 +214,12 @@ export class SEquipmentItem extends SObjectItem {
|
|
|
painter.pen.lineWidth = painter.toPx(1);
|
|
|
painter.pen.color = SColor.Black;
|
|
|
painter.brush.color = SColor.Transparent;
|
|
|
- // painter.drawRect(this.boundingRect());
|
|
|
+ if (this.equipmentStatus === StatusType.Edit) {
|
|
|
+ painter.drawRect(this.boundingRect());
|
|
|
+ this.textArr.map(item => item.moveable = true)
|
|
|
+ } else {
|
|
|
+ this.textArr.map(item => item.moveable = false)
|
|
|
+
|
|
|
+ }
|
|
|
} // Function onDraw()
|
|
|
}
|