|
@@ -53,6 +53,7 @@ export default {
|
|
|
changeScaleByClick: false, //区分滚轮,点击 事件改变的缩放比例
|
|
|
initScale: 1,
|
|
|
planLoading: true, //平面图顶部loading提示
|
|
|
+ parser: null, //底图解析后的数据
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
@@ -107,7 +108,6 @@ export default {
|
|
|
this.$once("hook:beforeDestroy", () => {
|
|
|
clearInterval(this.autoSave);
|
|
|
});
|
|
|
-
|
|
|
},
|
|
|
methods: {
|
|
|
...mapMutations([
|
|
@@ -123,6 +123,7 @@ export default {
|
|
|
"INITSTYLE",
|
|
|
"INITRULELIST",
|
|
|
"INITOBJEXTINFO",
|
|
|
+ "ADDSTYLE",
|
|
|
]),
|
|
|
|
|
|
// 清空画布
|
|
@@ -140,13 +141,14 @@ export default {
|
|
|
init() {
|
|
|
this.clearImg();
|
|
|
this.view ? (this.view.scene = this.scene) : null;
|
|
|
- // 判断是否有楼层底图,有则获取数据并解析
|
|
|
- if (this.floorMap) this.getMapBlob();
|
|
|
// 读取平面图数据
|
|
|
- this.readPlanMsg();
|
|
|
+ this.readPlanMsg().then((showBaseMap) => {
|
|
|
+ // 判断是否有楼层底图,有则获取数据并解析
|
|
|
+ if (this.floorMap) this.getMapBlob(showBaseMap);
|
|
|
+ });
|
|
|
},
|
|
|
// 请求获取地图的压缩包
|
|
|
- getMapBlob() {
|
|
|
+ getMapBlob(showBaseMap) {
|
|
|
if (this.floorMap.includes("png") || this.floorMap.includes("jpg")) {
|
|
|
const url = `/image-service/common/image_get?systemId=dataPlatform&key=${this.floorMap}`;
|
|
|
this.getImage(url);
|
|
@@ -154,7 +156,7 @@ export default {
|
|
|
const url = `/image-service/common/file_get?systemId=revit&key=${this.floorMap}`;
|
|
|
getJsonz(url).then((data) => {
|
|
|
// 解析数据并放入压缩包中
|
|
|
- this.parserData(data);
|
|
|
+ this.parserData(data, showBaseMap);
|
|
|
});
|
|
|
}
|
|
|
},
|
|
@@ -170,12 +172,22 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
// 解析数据并注入 scene 类中
|
|
|
- parserData(data) {
|
|
|
+ parserData(data, showBaseMap) {
|
|
|
+ // 修改 vuex 底图显隐
|
|
|
+ this.ADDSTYLE({
|
|
|
+ id: "defaultMapStyle",
|
|
|
+ style: {
|
|
|
+ ...this.styleMap.defaultMapStyle,
|
|
|
+ showBaseMap, //显隐值
|
|
|
+ },
|
|
|
+ });
|
|
|
const parser = new SFloorParser();
|
|
|
parser.parseData(data);
|
|
|
+ this.parser = parser;
|
|
|
parser.spaceList.forEach((t) => {
|
|
|
//是否显示空间
|
|
|
// t.visible = this.isSpaceSelectable;
|
|
|
+ t.visible = showBaseMap;
|
|
|
//设置样式
|
|
|
Object.assign(t, this.baseMapStyle.default);
|
|
|
//是否展示名称
|
|
@@ -190,6 +202,7 @@ export default {
|
|
|
parser.wallList.forEach((t) => {
|
|
|
// 是否显示
|
|
|
// t.visible = this.isShowWall;
|
|
|
+ t.visible = showBaseMap;
|
|
|
// 是否可选
|
|
|
t.selectable = false;
|
|
|
this.scene.addItem(t);
|
|
@@ -197,6 +210,7 @@ export default {
|
|
|
parser.virtualWallList.forEach((t) => {
|
|
|
// 是否显示
|
|
|
// t.visible = this.isShowVirtualWall;
|
|
|
+ t.visible = showBaseMap;
|
|
|
// 是否可选
|
|
|
t.selectable = false;
|
|
|
this.scene.addItem(t);
|
|
@@ -204,6 +218,7 @@ export default {
|
|
|
parser.doorList.forEach((t) => {
|
|
|
// 是否显示
|
|
|
// t.visible = this.isShowDoor;
|
|
|
+ t.visible = showBaseMap;
|
|
|
// 是否可选
|
|
|
t.selectable = false;
|
|
|
this.scene.addItem(t);
|
|
@@ -211,6 +226,7 @@ export default {
|
|
|
parser.columnList.forEach((t) => {
|
|
|
// 是否显示
|
|
|
// t.visible = this.isShowColumn;
|
|
|
+ t.visible = showBaseMap;
|
|
|
// 是否可选
|
|
|
t.selectable = false;
|
|
|
this.scene.addItem(t);
|
|
@@ -218,6 +234,7 @@ export default {
|
|
|
parser.casementList.forEach((t) => {
|
|
|
// 是否显示
|
|
|
// t.visible = this.isShowWindow;
|
|
|
+ t.visible = showBaseMap;
|
|
|
// 是否可选
|
|
|
t.selectable = false;
|
|
|
this.scene.addItem(t);
|
|
@@ -365,9 +382,62 @@ export default {
|
|
|
});
|
|
|
// 更改对齐方式
|
|
|
bus.$off("changeAlignItem");
|
|
|
- bus.$on("changeAlignItem", val => {
|
|
|
+ bus.$on("changeAlignItem", (val) => {
|
|
|
this.scene.changeAlignItem(val);
|
|
|
});
|
|
|
+ // 底图显隐
|
|
|
+ bus.$off("showBaseMap");
|
|
|
+ bus.$on("showBaseMap", (val) => {
|
|
|
+ this.showBaseMapFn(val);
|
|
|
+ });
|
|
|
+ // 更改背景色
|
|
|
+ bus.$off("changeBackgroundColor");
|
|
|
+ bus.$on("changeBackgroundColor", (val) => {
|
|
|
+ this.changeBackgroundColor(val);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 更改底图背景色
|
|
|
+ changeBackgroundColor(backgroundColor) {
|
|
|
+ // 更新 vuex 中 styleMap 下 defaultMapStyle 的 backgroundColor 值
|
|
|
+ this.ADDSTYLE({
|
|
|
+ id: "defaultMapStyle",
|
|
|
+ style: {
|
|
|
+ ...this.styleMap.defaultMapStyle,
|
|
|
+ backgroundColor, //背景色
|
|
|
+ },
|
|
|
+ });
|
|
|
+ this.scene.changeBackgroundColor(backgroundColor);
|
|
|
+ },
|
|
|
+ // 是否显示底图
|
|
|
+ showBaseMapFn(val) {
|
|
|
+ // 更新 vuex 中 styleMap 下 defaultMapStyle 的 showBaseMap 值
|
|
|
+ this.ADDSTYLE({
|
|
|
+ id: "defaultMapStyle",
|
|
|
+ style: {
|
|
|
+ ...this.styleMap.defaultMapStyle,
|
|
|
+ showBaseMap: val, //显隐值
|
|
|
+ },
|
|
|
+ });
|
|
|
+ const { parser } = this;
|
|
|
+ parser.spaceList.forEach((t) => {
|
|
|
+ //是否显示空间
|
|
|
+ t.visible = val;
|
|
|
+ });
|
|
|
+ parser.wallList.forEach((t) => {
|
|
|
+ t.visible = val;
|
|
|
+ });
|
|
|
+ parser.virtualWallList.forEach((t) => {
|
|
|
+ t.visible = val;
|
|
|
+ });
|
|
|
+ parser.doorList.forEach((t) => {
|
|
|
+ t.visible = val;
|
|
|
+ });
|
|
|
+ parser.columnList.forEach((t) => {
|
|
|
+ t.visible = val;
|
|
|
+ });
|
|
|
+ parser.casementList.forEach((t) => {
|
|
|
+ t.visible = val;
|
|
|
+ });
|
|
|
},
|
|
|
// 读取拓扑图
|
|
|
readPlanMsg() {
|
|
@@ -375,8 +445,16 @@ export default {
|
|
|
graphId: this.graphId,
|
|
|
id: this.id,
|
|
|
};
|
|
|
- planerRead(obj).then((res) => {
|
|
|
- this.getDataSuc(res);
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ planerRead(obj).then((res) => {
|
|
|
+ // resolve 是否显示底图,供 parserData 使用
|
|
|
+ if (res?.content?.style?.defaultMapStyle?.showBaseMap === false) {
|
|
|
+ resolve(false);
|
|
|
+ } else {
|
|
|
+ resolve(true);
|
|
|
+ }
|
|
|
+ this.getDataSuc(res);
|
|
|
+ });
|
|
|
});
|
|
|
},
|
|
|
// 读图成功回调
|
|
@@ -402,13 +480,20 @@ export default {
|
|
|
} else {
|
|
|
this.INITSTYLE({});
|
|
|
}
|
|
|
-
|
|
|
+ // 底图背景颜色
|
|
|
+ if (this.scene) {
|
|
|
+ const backgroundColor = res.content.style?.defaultMapStyle?.backgroundColor
|
|
|
+ ? res.content.style?.defaultMapStyle?.backgroundColor
|
|
|
+ : "#00000000";
|
|
|
+ this.changeBackgroundColor(backgroundColor);
|
|
|
+ // 初始化保存图背景色
|
|
|
+ }
|
|
|
// 加载规则,显示实例数据
|
|
|
if (res.content.ruleList?.length) {
|
|
|
this.INITRULELIST(res.content.ruleList);
|
|
|
this.ruleNum = res.content.ruleList.length;
|
|
|
|
|
|
- const ruleList = res.content.ruleList
|
|
|
+ const ruleList = res.content.ruleList;
|
|
|
// 同步执行规则,进行设备/设备组/空间的添加,删除
|
|
|
for (let index = 0; index < ruleList.length; index++) {
|
|
|
const rule = ruleList[index];
|
|
@@ -426,20 +511,23 @@ export default {
|
|
|
this.loadedRuleNum++;
|
|
|
if (this.ruleNum === this.loadedRuleNum) this.loadMarkRelation();
|
|
|
}
|
|
|
- } else if (rule.commond && rule.commond === "delete") { // 删除规则
|
|
|
+ } else if (rule.commond && rule.commond === "delete") {
|
|
|
+ // 删除规则
|
|
|
// console.error("删除命令!!!", rule);
|
|
|
// 删除设备实例
|
|
|
if (rule?.returnType === "equip") {
|
|
|
- const classCode = rule?.params?.classCode
|
|
|
+ const classCode = rule?.params?.classCode;
|
|
|
if (classCode) {
|
|
|
- this.removeEquipment(classCode)
|
|
|
+ this.removeEquipment(classCode);
|
|
|
}
|
|
|
- } else if (rule?.returnType === "zone") { // 删除空间实例
|
|
|
- const classCode = rule?.params?.classCode
|
|
|
+ } else if (rule?.returnType === "zone") {
|
|
|
+ // 删除空间实例
|
|
|
+ const classCode = rule?.params?.classCode;
|
|
|
if (classCode) {
|
|
|
- this.removeZone(classCode)
|
|
|
+ this.removeZone(classCode);
|
|
|
}
|
|
|
- } else if (rule?.returnType === "equipGroup") { // 删除设备组
|
|
|
+ } else if (rule?.returnType === "equipGroup") {
|
|
|
+ // 删除设备组
|
|
|
//
|
|
|
this.loadedRuleNum++;
|
|
|
if (this.ruleNum === this.loadedRuleNum) this.loadMarkRelation();
|
|
@@ -491,17 +579,17 @@ export default {
|
|
|
},
|
|
|
/**
|
|
|
* 删除设备实例
|
|
|
- *
|
|
|
+ *
|
|
|
* @param { string } classCode 删除的设备类code值
|
|
|
*/
|
|
|
removeEquipment(classCode) {
|
|
|
for (const key in this.equipItemMap) {
|
|
|
- const equipItem = this.equipItemMap[key]
|
|
|
+ const equipItem = this.equipItemMap[key];
|
|
|
if (equipItem?.legendData?.classCode === classCode) {
|
|
|
// 删除vuex中保存的设备实例
|
|
|
this.REMOVEEQUIP(equipItem);
|
|
|
// 删除图上的设备实例
|
|
|
- this.scene.removeItem(equipItem)
|
|
|
+ this.scene.removeItem(equipItem);
|
|
|
}
|
|
|
}
|
|
|
this.view.update();
|
|
@@ -537,17 +625,17 @@ export default {
|
|
|
},
|
|
|
/**
|
|
|
* 删除设备实例
|
|
|
- *
|
|
|
+ *
|
|
|
* @param { string } classCode 删除的设备类code值
|
|
|
*/
|
|
|
removeZone(classCode) {
|
|
|
for (const key in this.zoneIteMap) {
|
|
|
- const zoneItem = this.zoneIteMap[key]
|
|
|
+ const zoneItem = this.zoneIteMap[key];
|
|
|
if (zoneItem?.legendData?.classCode === classCode) {
|
|
|
// 删除vuex中保存的空间实例
|
|
|
this.REMOVEZONE(zoneItem);
|
|
|
// 删除图上的空间实例
|
|
|
- this.scene.removeItem(zoneItem)
|
|
|
+ this.scene.removeItem(zoneItem);
|
|
|
}
|
|
|
}
|
|
|
this.view.update();
|
|
@@ -621,7 +709,7 @@ export default {
|
|
|
this.initScale = this.view.scale;
|
|
|
bus.$emit("initScale", this.view.scale);
|
|
|
// 关闭顶部的loading提示
|
|
|
- this.planLoading = false
|
|
|
+ this.planLoading = false;
|
|
|
},
|
|
|
// 生成快照并保存草稿
|
|
|
savePlanDraft() {
|