|
@@ -14,7 +14,7 @@
|
|
|
import { SFloorParser, getJsonz } from "@persagy-web/big";
|
|
|
import { SImageItem, SImageShowType } from "@persagy-web/graph";
|
|
|
import { SPlanView, SPlanParser, SPlanScene, SPlanDecorator, SPlanEquipment } from "@/lib";
|
|
|
-import { SBaseEquipment } from "@/components/editClass/big-edit";
|
|
|
+import { SGraphPropertyCommand } from "@persagy-web/edit";
|
|
|
import topoTooltip from "./topoTooltip.vue";
|
|
|
import { mapState, mapMutations } from "vuex";
|
|
|
import base64ToFile from "@/utils/base64ToFile";
|
|
@@ -102,8 +102,6 @@ export default {
|
|
|
"SETPROJECT",
|
|
|
"SETCATEGROY",
|
|
|
"SETISPUB",
|
|
|
- "ADDEQUIPITEM",
|
|
|
- "EDITEQUIPITEM",
|
|
|
"SETVERSION",
|
|
|
"ADDEQUIP",
|
|
|
"DELETEQUIP",
|
|
@@ -241,6 +239,11 @@ export default {
|
|
|
},
|
|
|
//初始化bus绑定事件
|
|
|
initBusEvent() {
|
|
|
+ // 属性入栈
|
|
|
+ bus.$off("undoAttr");
|
|
|
+ bus.$on("undoAttr", (item, styletype, oldMsg, newMsg) => {
|
|
|
+ this.scene.undoStack.push(new SGraphPropertyCommand(this.scene, item, styletype, oldMsg, newMsg));
|
|
|
+ });
|
|
|
// 改变样式
|
|
|
bus.$off("updateStyle");
|
|
|
bus.$on("updateStyle", (type, val) => {
|
|
@@ -260,7 +263,7 @@ export default {
|
|
|
bus.$off("deleteItem");
|
|
|
bus.$on("deleteItem", (val) => {
|
|
|
this.scene.deleteItem([val]);
|
|
|
- this.EDITEQUIPITEM();
|
|
|
+ this.DELETEQUIP();
|
|
|
});
|
|
|
// 复制
|
|
|
bus.$off("copy");
|
|
@@ -323,16 +326,17 @@ export default {
|
|
|
graphId: this.graphId,
|
|
|
id: this.id,
|
|
|
};
|
|
|
- if (this.state === "Publish") {
|
|
|
- // 已发布
|
|
|
- pubPlanerRead(obj).then((res) => {
|
|
|
- this.getDataSuc(res);
|
|
|
- });
|
|
|
- } else {
|
|
|
+ // if (this.state === "Publish") {
|
|
|
+ // // 已发布
|
|
|
+ // pubPlanerRead(obj).then((res) => {
|
|
|
+ // this.getDataSuc(res);
|
|
|
+ // });
|
|
|
+ // } else {
|
|
|
+ // 未发布
|
|
|
planerRead(obj).then((res) => {
|
|
|
this.getDataSuc(res);
|
|
|
});
|
|
|
- }
|
|
|
+ // }
|
|
|
},
|
|
|
// 读图成功回调
|
|
|
getDataSuc(res) {
|
|
@@ -485,16 +489,12 @@ export default {
|
|
|
|
|
|
// 生成快照并保存草稿
|
|
|
saveTopoDraft() {
|
|
|
- console.time(1);
|
|
|
- const elements = this.scene.save();
|
|
|
- console.timeEnd(1);
|
|
|
- console.log(elements)
|
|
|
- // const uuid = uuidv1();
|
|
|
- // return Promise.all([this.generateSnap(uuid), this.saveDraft(uuid)]).then((vals) => {
|
|
|
- // // 重设版本号
|
|
|
- // this.SETVERSION(vals[1].version);
|
|
|
- // this.$message.success(`保存成功${vals[1].version}`);
|
|
|
- // });
|
|
|
+ const uuid = uuidv1();
|
|
|
+ return Promise.all([this.generateSnap(uuid), this.saveDraft(uuid)]).then((vals) => {
|
|
|
+ // 重设版本号
|
|
|
+ this.SETVERSION(vals[1].version);
|
|
|
+ this.$message.success(`保存成功${vals[1].version}`);
|
|
|
+ });
|
|
|
},
|
|
|
// 生成快照
|
|
|
generateSnap(uuid) {
|
|
@@ -541,37 +541,36 @@ export default {
|
|
|
const obj = {
|
|
|
elements,
|
|
|
// name: this.planContent.name, // 名称
|
|
|
- // categoryId: this.categoryId, // 图分类ID
|
|
|
// projectId: this.projectId, // 项目ID
|
|
|
// label: this.planContent.label,
|
|
|
// buildingId: "1", // 建筑ID
|
|
|
// floorId: "1", // 楼层id
|
|
|
// note: "1", // 图说明
|
|
|
+ style: this.styleMap,
|
|
|
pic: `${uuid}.png`,
|
|
|
graphId: this.graphId,
|
|
|
id: this.id,
|
|
|
- // version: this.version,
|
|
|
};
|
|
|
return new Promise((resolve, reject) => {
|
|
|
saveGroup(obj).then((res) => {
|
|
|
// 如果是从已发布跳转过来
|
|
|
- if (this.state === "Publish") {
|
|
|
- // 设置发布状态为 未发布
|
|
|
- this.SETSTATE("Draft");
|
|
|
- const gid = res.entityList[0].graphId;
|
|
|
- const id = res.entityList[0].id;
|
|
|
- // 重设图id 与 id
|
|
|
- this.SETPROJECT({ graphId: gid, id: id });
|
|
|
- // 修改url参数
|
|
|
- this.$router.push({
|
|
|
- name: "Editer",
|
|
|
- query: {
|
|
|
- graphId: gid,
|
|
|
- id: id,
|
|
|
- state: "Draft",
|
|
|
- },
|
|
|
- });
|
|
|
- }
|
|
|
+ // if (this.state === "Publish") {
|
|
|
+ // // 设置发布状态为 未发布
|
|
|
+ // this.SETSTATE("Draft");
|
|
|
+ // const gid = res.entityList[0].graphId;
|
|
|
+ // const id = res.entityList[0].id;
|
|
|
+ // // 重设图id 与 id
|
|
|
+ // this.SETPROJECT({ graphId: gid, id: id });
|
|
|
+ // // 修改url参数
|
|
|
+ // this.$router.push({
|
|
|
+ // name: "Editer",
|
|
|
+ // query: {
|
|
|
+ // graphId: gid,
|
|
|
+ // id: id,
|
|
|
+ // state: "Draft",
|
|
|
+ // },
|
|
|
+ // });
|
|
|
+ // }
|
|
|
resolve(res.entityList[0]);
|
|
|
});
|
|
|
});
|
|
@@ -593,56 +592,7 @@ export default {
|
|
|
publishGraph(pa).then((res) => {
|
|
|
this.$message.success("发布成功");
|
|
|
});
|
|
|
- },
|
|
|
- // 手动添加设备
|
|
|
- addEquipmentList(list) {
|
|
|
- const parse = new SPlanParser();
|
|
|
- list.forEach((item, i) => {
|
|
|
- const x = (i + 1) * 100 + 300;
|
|
|
- const baseUrl = "/image-service/common/image_get?systemId=dataPlatform&key=";
|
|
|
- const url = baseUrl + item.url;
|
|
|
- const svg2Base = "";
|
|
|
- const EquipHeight = this.canvasHeight - 100;
|
|
|
-
|
|
|
- const data = {
|
|
|
- nodeId: uuidv1(),
|
|
|
- /** 名称 */
|
|
|
- name: "基础设备",
|
|
|
- /** 返回物理世界对象 ID 列表 */
|
|
|
- attachObjectIds: [item.id],
|
|
|
- size: { width: 50, height: 50 },
|
|
|
- /** 图标 (Image),线类型 (Line) */
|
|
|
- type: "Image",
|
|
|
- /** 位置 */
|
|
|
- pos: { x: x, y: 100 },
|
|
|
- /** 由应用自己定义 */
|
|
|
- properties: {
|
|
|
- type: "BaseEquipment",
|
|
|
- classCode: item.classCode, // 设备类型
|
|
|
- localId: item.localId, // 本地编码
|
|
|
- localName: item.localName, //本地名称
|
|
|
- },
|
|
|
- style: {
|
|
|
- default: {
|
|
|
- strokecolor: "#c0ccda",
|
|
|
- url: url,
|
|
|
- base64Url: "",
|
|
|
- },
|
|
|
- },
|
|
|
- };
|
|
|
- parse.addNode(data);
|
|
|
- });
|
|
|
- // 添加到 scence 中
|
|
|
- parse.nodes.forEach((item) => {
|
|
|
- item.connect("finishCreated", this.scene, this.scene.finishCreated);
|
|
|
- item.connect("onContextMenu", this, this.scene.getItem);
|
|
|
- this.scene.addItem(item);
|
|
|
- // 如果为设备则存于vuex中便于联动
|
|
|
- if (item instanceof SBaseEquipment) {
|
|
|
- this.ADDEQUIPITEM(item);
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
+ }
|
|
|
},
|
|
|
watch: {
|
|
|
editCmd(val) {
|