|
@@ -25,7 +25,7 @@ import {
|
|
|
// import { SFloorParser } from "@persagy-web/big/lib";
|
|
|
import topoTooltip from "./topoTooltip.vue";
|
|
|
import { mapState, mapMutations } from "vuex";
|
|
|
-import base64ToFile from "@/utils/base64ToFile"
|
|
|
+import base64ToFile from "@/utils/base64ToFile";
|
|
|
import { v1 as uuidv1 } from "uuid";
|
|
|
import bus from "@/bus/bus";
|
|
|
import {
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
getImageGroup,
|
|
|
readPubGroup,
|
|
|
} from "@/api/editer";
|
|
|
-import { publishGraph } from "@/api/home"
|
|
|
+import { publishGraph } from "@/api/home";
|
|
|
export default {
|
|
|
components: { topoTooltip },
|
|
|
data() {
|
|
@@ -118,71 +118,76 @@ export default {
|
|
|
//初始化bus绑定事件
|
|
|
initBusEvent() {
|
|
|
// 改变样式
|
|
|
- bus.$off('updateStyle');
|
|
|
+ bus.$off("updateStyle");
|
|
|
bus.$on("updateStyle", (type, val) => {
|
|
|
this.scene.updateStyle(type, val);
|
|
|
});
|
|
|
// 撤销
|
|
|
- bus.$off('topoUndo');
|
|
|
+ bus.$off("topoUndo");
|
|
|
bus.$on("topoUndo", (val) => {
|
|
|
this.scene.undo();
|
|
|
});
|
|
|
// 重做
|
|
|
- bus.$off('topoRedo');
|
|
|
+ bus.$off("topoRedo");
|
|
|
bus.$on("topoRedo", (val) => {
|
|
|
this.scene.redo();
|
|
|
});
|
|
|
// 删除
|
|
|
- bus.$off('deleteItem');
|
|
|
+ bus.$off("deleteItem");
|
|
|
bus.$on("deleteItem", (val) => {
|
|
|
this.scene.deleteItem();
|
|
|
});
|
|
|
// 复制
|
|
|
- bus.$off('copy');
|
|
|
+ bus.$off("copy");
|
|
|
bus.$on("copy", (val) => {
|
|
|
this.scene.copy();
|
|
|
});
|
|
|
// 粘贴
|
|
|
- bus.$off('paste');
|
|
|
+ bus.$off("paste");
|
|
|
bus.$on("paste", (val) => {
|
|
|
this.scene.paste();
|
|
|
});
|
|
|
// 保存
|
|
|
- bus.$off('saveTopo');
|
|
|
+ bus.$off("saveTopo");
|
|
|
bus.$on("saveTopo", (val) => {
|
|
|
- this.saveTopoDraft()
|
|
|
+ this.saveTopoDraft();
|
|
|
});
|
|
|
// 设置实例置顶置底
|
|
|
- bus.$off('setOrder');
|
|
|
+ bus.$off("setOrder");
|
|
|
bus.$on("setOrder", (val) => {
|
|
|
this.scene.setOrder(val);
|
|
|
});
|
|
|
// 设置实例status状态
|
|
|
- bus.$off('setItemStatus');
|
|
|
+ bus.$off("setItemStatus");
|
|
|
bus.$on("setItemStatus", (val) => {
|
|
|
this.scene.setItemStatus();
|
|
|
});
|
|
|
// 下载图片
|
|
|
- bus.$off('saveTopoImg');
|
|
|
+ bus.$off("saveTopoImg");
|
|
|
bus.$on("saveTopoImg", () => {
|
|
|
// 隐藏选择器
|
|
|
this.scene.selectContainer.clear();
|
|
|
setTimeout(() => {
|
|
|
this.view.saveImage(`${this.topoContent.name}.png`, "png");
|
|
|
- },80)
|
|
|
+ }, 80);
|
|
|
});
|
|
|
// 发布图片
|
|
|
- bus.$off('issueTopo');
|
|
|
+ bus.$off("issueTopo");
|
|
|
bus.$on("issueTopo", () => {
|
|
|
this.saveTopoDraft().then(() => {
|
|
|
- this.issueDraft()
|
|
|
- })
|
|
|
+ this.issueDraft();
|
|
|
+ });
|
|
|
});
|
|
|
// 手动添加设备实例
|
|
|
- bus.$off('addEquipment');
|
|
|
+ bus.$off("addEquipment");
|
|
|
bus.$on("addEquipment", (val) => {
|
|
|
this.addEquipmentList(val);
|
|
|
});
|
|
|
+ // 更改设备信息点
|
|
|
+ bus.$off('changeEquipMsgPoint');
|
|
|
+ bus.$on("changeEquipMsgPoint", (val) => {
|
|
|
+ this.scene.changeEquipMsgPoint(val)
|
|
|
+ });
|
|
|
},
|
|
|
// 读取拓扑图
|
|
|
readtopoMsg() {
|
|
@@ -203,7 +208,7 @@ export default {
|
|
|
},
|
|
|
// 读图成功回调
|
|
|
getDataSuc(res) {
|
|
|
- if(res.result == "failure") return;
|
|
|
+ if (res.result == "failure") return;
|
|
|
this.SETCATEGROY(res.content.categoryId);
|
|
|
this.topoContent = res.content;
|
|
|
const parse = new PTopoParser();
|
|
@@ -223,11 +228,13 @@ export default {
|
|
|
this.view.fitSceneToView();
|
|
|
},
|
|
|
// 保存草稿
|
|
|
- saveTopoDraft(){
|
|
|
+ saveTopoDraft() {
|
|
|
const uuid = uuidv1();
|
|
|
- return Promise.all([this.generateSnap(uuid), this.saveDraft(uuid)]).then(vals => {
|
|
|
- this.$message.success(`保存成功${vals[1].version}`);
|
|
|
- })
|
|
|
+ return Promise.all([this.generateSnap(uuid), this.saveDraft(uuid)]).then(
|
|
|
+ (vals) => {
|
|
|
+ this.$message.success(`保存成功${vals[1].version}`);
|
|
|
+ }
|
|
|
+ );
|
|
|
},
|
|
|
// 生成快照
|
|
|
generateSnap(uuid) {
|
|
@@ -235,7 +242,7 @@ export default {
|
|
|
this.scene.selectContainer.clear();
|
|
|
setTimeout(() => {
|
|
|
// base64数据
|
|
|
- const data = this.view.imageUrl('png');
|
|
|
+ const data = this.view.imageUrl("png");
|
|
|
// 根据base64生成file
|
|
|
const file = base64ToFile(data);
|
|
|
const reader = new FileReader();
|
|
@@ -245,25 +252,28 @@ export default {
|
|
|
reader.onloadend = function () {
|
|
|
// 这个事件在读取结束后,无论成功或者失败都会触发
|
|
|
if (reader.error) {
|
|
|
- console.log('reader error', reader.error);
|
|
|
- reject(reader.error)
|
|
|
+ console.log("reader error", reader.error);
|
|
|
+ reject(reader.error);
|
|
|
} else {
|
|
|
// 构造 XMLHttpRequest 对象,发送文件 Binary 数据
|
|
|
const xhr = new XMLHttpRequest();
|
|
|
- xhr.open("POST", `/image-service/common/image_upload?systemId=dataPlatform&secret=9e0891a7a8c8e885&overwrite=true&key=${uuid}.${imgType}`);
|
|
|
+ xhr.open(
|
|
|
+ "POST",
|
|
|
+ `/image-service/common/image_upload?systemId=dataPlatform&secret=9e0891a7a8c8e885&overwrite=true&key=${uuid}.${imgType}`
|
|
|
+ );
|
|
|
xhr.send(reader.result);
|
|
|
xhr.onreadystatechange = function () {
|
|
|
if (xhr.readyState == 4) {
|
|
|
if (xhr.status == 200) {
|
|
|
- resolve(xhr)
|
|
|
+ resolve(xhr);
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
}
|
|
|
};
|
|
|
reader.readAsArrayBuffer(file);
|
|
|
- })
|
|
|
- },80)
|
|
|
+ });
|
|
|
+ }, 80);
|
|
|
},
|
|
|
// 保存草稿
|
|
|
saveDraft(uuid) {
|
|
@@ -313,25 +323,25 @@ export default {
|
|
|
},
|
|
|
});
|
|
|
}
|
|
|
- resolve(res.entityList[0])
|
|
|
+ resolve(res.entityList[0]);
|
|
|
});
|
|
|
- })
|
|
|
+ });
|
|
|
},
|
|
|
// 发布草稿
|
|
|
- issueDraft(){
|
|
|
+ issueDraft() {
|
|
|
const pa = {
|
|
|
graphId: this.graphId,
|
|
|
- id: this.id
|
|
|
- }
|
|
|
- publishGraph(pa).then(res => {
|
|
|
- this.$message.success('发布成功');
|
|
|
- })
|
|
|
+ id: this.id,
|
|
|
+ };
|
|
|
+ publishGraph(pa).then((res) => {
|
|
|
+ this.$message.success("发布成功");
|
|
|
+ });
|
|
|
},
|
|
|
// 手动添加设备
|
|
|
addEquipmentList(list) {
|
|
|
const parse = new PTopoParser();
|
|
|
list.forEach((item, i) => {
|
|
|
- const x = (i + 1) * 100;
|
|
|
+ const x = (i + 1) * 100;
|
|
|
let data = {
|
|
|
/** 名称 */
|
|
|
name: "基础设备",
|
|
@@ -345,6 +355,7 @@ export default {
|
|
|
/** 由应用自己定义 */
|
|
|
properties: {
|
|
|
type: "BaseEquipment",
|
|
|
+ classCode: item.classCode, // 设备类型
|
|
|
},
|
|
|
style: {
|
|
|
default: {
|