yx %!s(int64=4) %!d(string=hai) anos
pai
achega
2ec7952046

+ 9 - 8
src/components/edit/equipmentAttr.vue

@@ -28,8 +28,8 @@
             </div>
         </div>
         <!-- 添加信息点 信息 -->
-        <div class="row">
-            <a-button @click="addInfo">添加信息点</a-button>
+        <div class='row'>
+            <a-button @click='addInfo'>添加信息点</a-button>
         </div>
     </div>
 </template>
@@ -74,19 +74,20 @@ export default {
     },
     mounted() {},
     methods: {
-        addInfo(){
+        addInfo() {
             this.info.push('')
         },
         init() {
             // 设置设备名称
-            this.equipmentData = this.focusItemList.itemList[0]
-            this.equipmentName = this.equipmentData.name
-            this.InfoList = this.focusItemList.itemList[0]._epData.InfoList
+            window._focusItem =  this.focusItemList.itemList[0]
+            this.equipmentData = this.focusItemList.itemList[0].toData()
+            this.equipmentName = this.equipmentData.Name
+            this.InfoList = this.equipmentData.InfoList
             this.info = []
             this.InfoList.map((item) => {
                 this.info.push(item.Name)
             })
-            console.log(this.focusItemList.itemList[0]._epData.InfoList)
+            // console.log(this.equipmentData)
         },
         changeEquipmentName() {
             bus.$emit('changeEquipmentName', this.equipmentName)
@@ -94,7 +95,7 @@ export default {
         // 更改信息点名称
         changeInfoName(index) {
             let name = this.info[index]
-            console.log(index,name)
+            console.log(index, name)
             bus.$emit('changeInfoName', { index, name })
         },
     },

+ 10 - 6
src/components/mapClass/EditScence.ts

@@ -684,15 +684,19 @@ export class EditScence extends SGraphScene {
      * @param val string border类型
      */
     updateEquipmentName(val: string): void {
-        this.focusItem!.name = val;
+        console.log(this.focusItem)
+        this.focusItem && (this.focusItem!.name = val)
     }
+    /**
+     * 信息点修改
+     * @param val 修改的信息点
+     */
     updateEquipmentInfoName(val: object): void {
         console.log(val)
-        // @ts-ignore
-        // this.focusItem.textArr[index + 1].text = name
-        // @ts-ignore
-        // this.focusItem.epData.InfoList[index].Name = name
-        this.focusItem.info = val
+        if (this.focusItem){
+            // @ts-ignore
+            this.focusItem.info = val
+        }
     }
 
     /**

+ 42 - 16
src/lib/items/SEquipmentItem.ts

@@ -50,6 +50,7 @@ export class SEquipmentItem extends SObjectItem {
     }
     set textArr(v) {
         this._textArr = v
+        this.update();
     }
     // 将EquipmentData保存起来,以便修改status时,可以找到StatusImage
     get epData(): EquipmentData {
@@ -57,7 +58,7 @@ export class SEquipmentItem extends SObjectItem {
     }
     set epData(v: EquipmentData) {
         this._epData = v;
-
+        this.update();
 
     }
     // 修改设备名称
@@ -69,21 +70,41 @@ export class SEquipmentItem extends SObjectItem {
         if (this.textArr && this.textArr.length) {
             this.textArr[0].text = v
         }
+        if (this.epData) {
+            this.epData.Name = v;
+        }
+        this.update();
     }
     _info: any[] = []
     // 修改信息点名称
     get info(): [] {
         return this._info
     }
-    set info({ index, name }) {
-        if (this.textArr && this.textArr.length > 1) {
-            if (this.textArr[index + 1]){
-
-                this.textArr[index + 1].text = name
-            }else{
-                this.textArr[index + 1] = 
-            }
+    set info(data) {
+        let { index, name } = data
+        // 更新信息点名称
+        // 新增
+        /* if (this.epData && index === this.textArr.length) {
+            let lastText = this.epData.InfoList[index - 1]
+            this.epData.InfoList.push(Object.assign({}, lastText, { Name: name }))
+            console.log(this.epData)
+            let textItem = new STextItem(this);
+            textItem.backgroundColor = new SColor(lastText.Background);
+            textItem.width = lastText.Width;
+            textItem.height = lastText.Height;
+            textItem.text = name;
+            textItem.font.size = lastText.FontSize;
+            textItem.color = new SColor(lastText.Color);
+            textItem.pos.x = lastText.X;
+            textItem.pos.y = lastText.Y + 20;
+            this.textArr.push(textItem)
+        } */
+         if (this.epData && index < this.epData.InfoList.length) {
+            this.textArr[index + 1].text = name
+            this.epData.InfoList[index + 1].Name = name
         }
+        this.update();
+
     }
 
     /**
@@ -149,6 +170,11 @@ export class SEquipmentItem extends SObjectItem {
         this.textArr.push(nameItem);
         // 信息点
         let { InfoList } = epData;
+        console.log('===================')
+        console.log('===================')
+        console.log('===================')
+        console.log(InfoList)
+        console.log('===================')
         InfoList.map(({ Name, X, Y, Width, Height, FontSize, Background, Color, TextAlign }) => {
             let textItem = new STextItem(this);
             textItem.backgroundColor = new SColor(Background);
@@ -209,19 +235,19 @@ export class SEquipmentItem extends SObjectItem {
     } // Function boundingRect()
     toData(): EquipmentData {
         //  更新相关数据
-        let data = this.epData;
-        data.Pos.X = this.x;
-        data.Pos.Y = this.y;
-        data.Size.Width = this.width;
-        data.Size.Height = this.height;
+        this.epData.Name = this.name;
+        this.epData.Pos.X = this.x;
+        this.epData.Pos.Y = this.y;
+        this.epData.Size.Width = this.width;
+        this.epData.Size.Height = this.height;
         // @ts-ignore
         // infoList中坐标,名称处理
-        data.InfoList.map((item, index, arr) => {
+        this.epData.InfoList.map((item, index, arr) => {
             arr[index].X = this.textArr[index + 1].pos.x;
             arr[index].Y = this.textArr[index + 1].pos.y;
             arr[index].Name = this.textArr[index + 1].text;
         });
-        return data;
+        return this.epData;
     }
 
     /**