|
@@ -108,6 +108,7 @@ export default {
|
|
|
"SETPROJECT",
|
|
|
"SETVERSION",
|
|
|
"ADDEQUIP",
|
|
|
+ "REMOVEEQUIP",
|
|
|
"ADDZONE",
|
|
|
"DELETEITEM",
|
|
|
"INITSTYLE",
|
|
@@ -323,6 +324,11 @@ export default {
|
|
|
bus.$on("addEquipment", (equipList) => {
|
|
|
this.mergeEquipData(equipList);
|
|
|
});
|
|
|
+ // 手动删除设备实例
|
|
|
+ bus.$off("removeEquipment");
|
|
|
+ bus.$on("removeEquipment", (equipList) => {
|
|
|
+ this.removeEquipment(equipList);
|
|
|
+ });
|
|
|
// 手动添加空间实例
|
|
|
bus.$off("addZone");
|
|
|
bus.$on("addZone", (zoneList) => {
|
|
@@ -362,7 +368,7 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
// 读图成功回调
|
|
|
- getDataSuc(res) {
|
|
|
+ async getDataSuc(res) {
|
|
|
if (res.result == "failure") return;
|
|
|
this.SETPROJECT(res.content);
|
|
|
this.planContent = res.content;
|
|
@@ -389,7 +395,11 @@ export default {
|
|
|
if (res.content.ruleList?.length) {
|
|
|
this.INITRULELIST(res.content.ruleList);
|
|
|
this.ruleNum = res.content.ruleList.length;
|
|
|
- res.content.ruleList.forEach(async (rule) => {
|
|
|
+
|
|
|
+ const ruleList = res.content.ruleList
|
|
|
+ // 同步执行规则,进行设备/设备组/空间的添加,删除
|
|
|
+ for (let index = 0; index < ruleList.length; index++) {
|
|
|
+ const rule = ruleList[index];
|
|
|
if (rule.commond && rule.commond === "query") {
|
|
|
const params = { ...rule.params, buildingId: this.buildingId, floorId: this.floorId };
|
|
|
if (rule?.returnType === "equip") {
|
|
@@ -399,21 +409,26 @@ export default {
|
|
|
const res = await spaceQuery(params);
|
|
|
if (res.result === "success") this.mergeZoneData(res.content);
|
|
|
} else if (rule?.returnType === "equipGroup") {
|
|
|
- setTimeout(() => {
|
|
|
- console.error("请求设备组数据");
|
|
|
- this.loadedRuleNum++;
|
|
|
- if (this.ruleNum === this.loadedRuleNum) this.loadMarkRelation();
|
|
|
- }, 1000);
|
|
|
+ console.error("请求设备组数据");
|
|
|
+ this.loadedRuleNum++;
|
|
|
+ if (this.ruleNum === this.loadedRuleNum) this.loadMarkRelation();
|
|
|
}
|
|
|
} else if (rule.commond && rule.commond === "delete") {
|
|
|
- /**
|
|
|
- * 暂未实现
|
|
|
- */
|
|
|
- console.error("删除命令!!!", rule);
|
|
|
- this.loadedRuleNum++;
|
|
|
- if (this.ruleNum === this.loadedRuleNum) this.loadMarkRelation();
|
|
|
+ // console.error("删除命令!!!", rule);
|
|
|
+ if (rule?.returnType === "equip") {
|
|
|
+ const classCode = rule?.params?.classCode
|
|
|
+ if (classCode) {
|
|
|
+ this.removeEquipment(classCode)
|
|
|
+ }
|
|
|
+ } else if (rule?.returnType === "zone") {
|
|
|
+ //
|
|
|
+ } else if (rule?.returnType === "equipGroup") {
|
|
|
+ //
|
|
|
+ this.loadedRuleNum++;
|
|
|
+ if (this.ruleNum === this.loadedRuleNum) this.loadMarkRelation();
|
|
|
+ }
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
} else {
|
|
|
this.INITRULELIST([]);
|
|
|
if (this.ruleNum === this.loadedRuleNum) this.loadMarkRelation();
|
|
@@ -457,6 +472,24 @@ export default {
|
|
|
this.loadedRuleNum++;
|
|
|
if (this.ruleNum === this.loadedRuleNum) this.loadMarkRelation();
|
|
|
},
|
|
|
+ /**
|
|
|
+ * 删除设备实例
|
|
|
+ * @param { string } classCode 删除的设备类code值
|
|
|
+ */
|
|
|
+ removeEquipment(classCode) {
|
|
|
+ for (const key in this.equipItemMap) {
|
|
|
+ const equipItem = this.equipItemMap[key]
|
|
|
+ if (equipItem?.legendData?.classCode === classCode) {
|
|
|
+ // 删除vuex中保存的设备实例
|
|
|
+ this.REMOVEEQUIP(equipItem);
|
|
|
+ // 删除图上的设备实例
|
|
|
+ this.scene.removeItem(equipItem)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.view.update();
|
|
|
+ this.loadedRuleNum++;
|
|
|
+ if (this.ruleNum === this.loadedRuleNum) this.loadMarkRelation();
|
|
|
+ },
|
|
|
// 解析空间数据
|
|
|
mergeZoneData(zoneList) {
|
|
|
zoneList.forEach((zone) => {
|