|
@@ -65,9 +65,9 @@
|
|
|
<script>
|
|
|
import canvasFun from "./canvasFun"
|
|
|
import { mapGetters, mapActions } from "vuex";
|
|
|
-import { SGraphyView } from "@saga-web/graphy/lib";
|
|
|
import { SColor, SPoint } from "@saga-web/draw/lib";
|
|
|
import { DivideFloorScene, SpaceItem, ZoneItem } from "@saga-web/cad-engine/lib";
|
|
|
+import { FloorView } from "@saga-web/cad-engine/lib/FloorView";
|
|
|
import unRelateBSP from "./unRelateBSP";
|
|
|
import createBSP from "./createBSP";
|
|
|
import {
|
|
@@ -105,7 +105,7 @@ export default {
|
|
|
type: 1, // 默认操作模式
|
|
|
search: '',//搜索
|
|
|
num: 0, // 未关联空间的业务空间条数
|
|
|
- buildFloor: [],
|
|
|
+ buildFloor: ['', ''],
|
|
|
FloorObj: {}, //楼层对象
|
|
|
FloorMap: '', //楼层底图
|
|
|
tab: {},
|
|
@@ -123,6 +123,7 @@ export default {
|
|
|
BIMIDToSID: {}, //bimid映射元空间id
|
|
|
curZoneItem: {}, //当前选中的业务空间item
|
|
|
allUnRelatISP: [], //
|
|
|
+ zoneList: [], // 业务空间-canvas图中
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
@@ -136,10 +137,21 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
// 初始化
|
|
|
- init() {
|
|
|
+ init(initType) {
|
|
|
this.type = 1;
|
|
|
- // 获取当前分区下的业务空间
|
|
|
- this.getBusinessSpace();
|
|
|
+ if (this.scene) {
|
|
|
+ this.scene.isZoneSelectable = true;
|
|
|
+ this.scene.isSpaceSelectable = true;
|
|
|
+ this.scene.clearSpaceSelection();
|
|
|
+ this.scene.clearZoneSelection();
|
|
|
+ }
|
|
|
+ if (initType == 1) {
|
|
|
+ // 底图
|
|
|
+ this.getGraphy();
|
|
|
+ } else {
|
|
|
+ // 业务空间
|
|
|
+ this.getBusinessSpace();
|
|
|
+ }
|
|
|
// 获取未关联平面图的业务空间统计
|
|
|
this.getUnrelateCount();
|
|
|
// 获取当前楼层的元空间
|
|
@@ -165,8 +177,8 @@ export default {
|
|
|
},
|
|
|
// 搜索
|
|
|
querySearch(queryString, cb) {
|
|
|
- var restaurants = this.zoneList;
|
|
|
- var results = queryString ?
|
|
|
+ let restaurants = this.zoneList;
|
|
|
+ let results = queryString ?
|
|
|
restaurants.filter(this.createFilter(queryString)) :
|
|
|
restaurants;
|
|
|
// 调用 callback 返回建议列表的数据
|
|
@@ -190,12 +202,16 @@ export default {
|
|
|
},
|
|
|
// 父组件调用
|
|
|
getData(buildFloor, FloorObj, tab) {
|
|
|
+ let initType = 1;
|
|
|
+ if (FloorObj.FloorID == this.FloorObj.FloorID) {
|
|
|
+ initType = 2;
|
|
|
+ }
|
|
|
this.buildFloor = buildFloor;
|
|
|
this.FloorObj = FloorObj;
|
|
|
this.FloorMap = FloorObj.StructureInfo ? FloorObj.StructureInfo.FloorMap : ''
|
|
|
this.tab = tab;
|
|
|
console.log(arguments)
|
|
|
- this.init();
|
|
|
+ this.init(initType);
|
|
|
},
|
|
|
// 获取未关联平面图的业务空间统计
|
|
|
getUnrelateCount() {
|
|
@@ -237,18 +253,6 @@ export default {
|
|
|
return;
|
|
|
}
|
|
|
that.view.scene = that.scene;
|
|
|
- // 绘制业务空间
|
|
|
- let tempArr = this.BSPRelaISPList.map((t, i) => {
|
|
|
- return {
|
|
|
- RoomLocalName: t.RoomLocalName,
|
|
|
- OutLine: t.Outline,
|
|
|
- RoomID: t.RoomID,
|
|
|
- Color: new SColor(colorArr[i % colorArr.length]),
|
|
|
- }
|
|
|
- })
|
|
|
- that.scene.addZoneList(tempArr);
|
|
|
- that.scene.click(that, that.canvasClick);
|
|
|
- that.zoneList = that.scene.zoneList;
|
|
|
// 蒙版
|
|
|
if (this.FloorObj.Outline) {
|
|
|
let newArr = this.FloorObj.Outline.map(t => {
|
|
@@ -256,6 +260,8 @@ export default {
|
|
|
})
|
|
|
this.scene.addSceneMark(newArr)
|
|
|
}
|
|
|
+ // 绘制业务空间
|
|
|
+ that.getBusinessSpace();
|
|
|
that.view.fitSceneToView();
|
|
|
that.view.maxScale = that.view.scale * 10;
|
|
|
that.view.minScale = that.view.scale;
|
|
@@ -264,20 +270,27 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+ // 清空绘制业务空间
|
|
|
+ clearZoneCanvas() {
|
|
|
+ this.zoneList.map(t => {
|
|
|
+ this.scene.removeItem(t);
|
|
|
+ })
|
|
|
+ },
|
|
|
// 获取当前分区下的业务空间
|
|
|
getBusinessSpace() {
|
|
|
- this.isLoading = true
|
|
|
+ this.canvasLoading = true
|
|
|
let pa = {
|
|
|
zone: this.tab.code,
|
|
|
data: {
|
|
|
Filters: ``,
|
|
|
Orders: "createTime desc, RoomID asc",
|
|
|
- PageSize: 500
|
|
|
+ PageSize: 1000
|
|
|
}
|
|
|
}
|
|
|
if (this.buildFloor.length && this.buildFloor.length > 1) {
|
|
|
pa.data.Filters = `BuildingId='${this.buildFloor[0]}';FloorId='${this.buildFloor[1]}'`
|
|
|
}
|
|
|
+ this.clearZoneCanvas();
|
|
|
queryZone(pa, res => {
|
|
|
// 所有业务空间
|
|
|
this.businessSpaceList = res.Content;
|
|
@@ -292,9 +305,20 @@ export default {
|
|
|
this.BSPUnrelaISPList.push(t)
|
|
|
}
|
|
|
})
|
|
|
- // 获取底图
|
|
|
- this.getGraphy();
|
|
|
- this.isLoading = false;
|
|
|
+ // 绘制业务空间
|
|
|
+ let tempArr = this.BSPRelaISPList.map((t, i) => {
|
|
|
+ return {
|
|
|
+ RoomLocalName: t.RoomLocalName,
|
|
|
+ OutLine: t.Outline,
|
|
|
+ RoomID: t.RoomID,
|
|
|
+ Color: new SColor(colorArr[i % colorArr.length]),
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.scene.zoneList = [];
|
|
|
+ this.scene.addZoneList(tempArr);
|
|
|
+ this.scene.click(this, this.canvasClick);
|
|
|
+ this.zoneList = this.scene.zoneList;
|
|
|
+ this.canvasLoading = false;
|
|
|
})
|
|
|
},
|
|
|
// canvas点击事件
|
|
@@ -332,69 +356,77 @@ export default {
|
|
|
},
|
|
|
// 取消(所有取消公用)
|
|
|
cancelGraphy() {
|
|
|
- this.type = 1;
|
|
|
- this.init();
|
|
|
+ this.init(2);
|
|
|
},
|
|
|
// 批量创建业务空间
|
|
|
groupCreateBSpace() {
|
|
|
let text = []
|
|
|
let Spaces = this.allUnRelatISP.map(t => {
|
|
|
- text.push(t.RoomLocalName || t.RoomName)
|
|
|
- return {
|
|
|
- IspaceId: t.RoomID,
|
|
|
- RoomLocalName: t.RoomLocalName || t.RoomName,
|
|
|
- Outline: [t.Outline],
|
|
|
- BuildingId: this.buildFloor[0],
|
|
|
- FloorId: this.buildFloor[1]
|
|
|
- }
|
|
|
- });
|
|
|
- this.$confirm(
|
|
|
- "<p>确定根据未关联业务空间的空间批量创建业务空间</p>" +
|
|
|
- "<p>涉及的空间:</p>" +
|
|
|
- "<p style='line-height:20px;max-height:60px;overflow-y:auto;'>" +
|
|
|
- text.toString() +
|
|
|
- "</p>",
|
|
|
- "提示", {
|
|
|
- dangerouslyUseHTMLString: true,
|
|
|
- confirmButtonText: "确定",
|
|
|
- cancelButtonText: "取消",
|
|
|
- type: "warning"
|
|
|
- }
|
|
|
- ).then(() => {
|
|
|
- let pa = {
|
|
|
- zone: this.tab.code,
|
|
|
- data: {
|
|
|
- Content: Spaces
|
|
|
+ if (t.Outline) {
|
|
|
+ text.push(t.RoomLocalName || t.RoomName)
|
|
|
+ return {
|
|
|
+ IspaceId: t.RoomID,
|
|
|
+ RoomLocalName: t.RoomLocalName || t.RoomName,
|
|
|
+ Outline: [t.Outline],
|
|
|
+ BuildingId: this.buildFloor[0],
|
|
|
+ FloorId: this.buildFloor[1],
|
|
|
+ Height: t.Height || 0
|
|
|
}
|
|
|
+ } else {
|
|
|
+ return undefined
|
|
|
}
|
|
|
- this.canvasLoading = true;
|
|
|
- createZone(pa, res => {
|
|
|
- res.EntityList.map(t => {
|
|
|
- Spaces = Spaces.map(item => {
|
|
|
- if (t.RoomLocalName == item.RoomLocalName) {
|
|
|
- item.SpaceId = t.RoomID
|
|
|
- }
|
|
|
- return item;
|
|
|
- })
|
|
|
- })
|
|
|
- let param = {
|
|
|
+ }).filter(item => item);
|
|
|
+ if (Spaces.length) {
|
|
|
+ this.$confirm(
|
|
|
+ "<p>确定根据未关联业务空间的空间批量创建业务空间</p>" +
|
|
|
+ "<p>涉及的空间:</p>" +
|
|
|
+ "<p style='line-height:20px;max-height:60px;overflow-y:auto;'>" +
|
|
|
+ text.toString() +
|
|
|
+ "</p>",
|
|
|
+ "提示", {
|
|
|
+ dangerouslyUseHTMLString: true,
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning"
|
|
|
+ }
|
|
|
+ ).then(() => {
|
|
|
+ let pa = {
|
|
|
+ zone: this.tab.code,
|
|
|
data: {
|
|
|
Content: Spaces
|
|
|
- },
|
|
|
- type: this.tab.code
|
|
|
+ }
|
|
|
}
|
|
|
- groupCreRelaZoneAndISp(param, res => {
|
|
|
- this.$message.success('创建成功')
|
|
|
- this.canvasLoading = false;
|
|
|
- this.init()
|
|
|
+ this.canvasLoading = true;
|
|
|
+ createZone(pa, res => {
|
|
|
+ res.EntityList.map(t => {
|
|
|
+ Spaces = Spaces.map(item => {
|
|
|
+ if (t.RoomLocalName == item.RoomLocalName) {
|
|
|
+ item.SpaceId = t.RoomID
|
|
|
+ }
|
|
|
+ return item;
|
|
|
+ })
|
|
|
+ })
|
|
|
+ let param = {
|
|
|
+ data: {
|
|
|
+ Content: Spaces
|
|
|
+ },
|
|
|
+ type: this.tab.code
|
|
|
+ }
|
|
|
+ groupCreRelaZoneAndISp(param, res => {
|
|
|
+ this.$message.success('创建成功')
|
|
|
+ this.canvasLoading = false;
|
|
|
+ this.init(2)
|
|
|
+ })
|
|
|
})
|
|
|
- })
|
|
|
- }).catch(() => {
|
|
|
- this.$message({
|
|
|
- type: "info",
|
|
|
- message: "已取消批量创建"
|
|
|
+ }).catch(() => {
|
|
|
+ this.$message({
|
|
|
+ type: "info",
|
|
|
+ message: "已取消批量创建"
|
|
|
+ });
|
|
|
});
|
|
|
- });
|
|
|
+ } else {
|
|
|
+ this.$message('没有未关联的元空间')
|
|
|
+ }
|
|
|
},
|
|
|
// 创建新的业务空间
|
|
|
createNewZone() {
|
|
@@ -412,10 +444,14 @@ export default {
|
|
|
// 创建新的业务空间-弹窗返回确认创建
|
|
|
createRoom(val) {
|
|
|
let arr = this.scene.getSelectedSpaces();
|
|
|
- let zoneObj = { Outline: [] }, IspaceIdList = [];
|
|
|
+ let zoneObj = { Outline: [], Height: 0 }, IspaceIdList = [];
|
|
|
arr.map(t => {
|
|
|
zoneObj.Outline.push(t.data.OutLine);
|
|
|
- IspaceIdList.push(this.BIMIDToSID[t.data.SourceId])
|
|
|
+ IspaceIdList.push(this.BIMIDToSID[t.data.SourceId]);
|
|
|
+ console.log(zoneObj.Height)
|
|
|
+ if (t.data.Height && (zoneObj.Height == 0 || t.data.Height < zoneObj.Height)) {
|
|
|
+ zoneObj.Height = t.data.Height;
|
|
|
+ }
|
|
|
})
|
|
|
zoneObj.RoomLocalName = val;
|
|
|
zoneObj.BuildingId = this.buildFloor[0];
|
|
@@ -432,10 +468,14 @@ export default {
|
|
|
},
|
|
|
// 从未关联平面图的业务空间中选择--按钮返回关联信号
|
|
|
createFromUnrelated(BSP) {
|
|
|
- BSP.Outline = []
|
|
|
+ BSP.Outline = [];
|
|
|
+ BSP.Height = 0;
|
|
|
let arr = this.scene.getSelectedSpaces();
|
|
|
arr.map(t => {
|
|
|
BSP.Outline.push(t.data.OutLine);
|
|
|
+ if (t.Height && (BSP.Height == 0 || t.Height < BSP.Height)) {
|
|
|
+ BSP.Height = t.Height;
|
|
|
+ }
|
|
|
})
|
|
|
let pa = {
|
|
|
zone: BSP.ObjectType,
|
|
@@ -446,7 +486,7 @@ export default {
|
|
|
}
|
|
|
updateZone(pa, res => {
|
|
|
this.$message.success('更新成功');
|
|
|
- this.init();
|
|
|
+ this.init(2);
|
|
|
})
|
|
|
},
|
|
|
// 编辑空间详情
|
|
@@ -460,6 +500,8 @@ export default {
|
|
|
// 重新划分业务空间
|
|
|
refactorBSP() {
|
|
|
this.type = 4;
|
|
|
+ // 清空选中空间
|
|
|
+ this.scene.clearSpaceSelection();
|
|
|
// 设置空间可选
|
|
|
this.scene.isSpaceSelectable = true;
|
|
|
// 将已关联的设置不可选,并将当前选的隐藏
|
|
@@ -469,10 +511,13 @@ export default {
|
|
|
saveRefactorBSP() {
|
|
|
let arr = this.scene.getSelectedSpaces();
|
|
|
//更新业务空间
|
|
|
- let zoneObj = { Outline: [] }, IspaceIdList = [];
|
|
|
+ let zoneObj = { Outline: [], Height: 0 }, IspaceIdList = [];
|
|
|
arr.map(t => {
|
|
|
zoneObj.Outline.push(t.data.OutLine);
|
|
|
- IspaceIdList.push(this.BIMIDToSID[t.data.SourceId])
|
|
|
+ IspaceIdList.push(this.BIMIDToSID[t.data.SourceId]);
|
|
|
+ if (t.Height && (zoneObj.Height == 0 || t.Height < zoneObj.Height)) {
|
|
|
+ zoneObj.Height = t.Height;
|
|
|
+ }
|
|
|
})
|
|
|
zoneObj.RoomID = this.curZoneItem.data.RoomID;
|
|
|
if (!zoneObj.Outline.length) {
|
|
@@ -497,7 +542,7 @@ export default {
|
|
|
}
|
|
|
createRelateInZoneAndISp(pa, res => {
|
|
|
this.$message.success('创建成功');
|
|
|
- this.init();
|
|
|
+ this.init(2);
|
|
|
})
|
|
|
},
|
|
|
// canvas 获取焦点
|
|
@@ -506,11 +551,11 @@ export default {
|
|
|
},
|
|
|
// 清除canvas
|
|
|
clearGraphy() {
|
|
|
- if (this.view) {
|
|
|
+ if (this.view && this.view.scene) {
|
|
|
this.view.scene = null;
|
|
|
return
|
|
|
}
|
|
|
- this.view = new SGraphyView('floorCanvas')
|
|
|
+ this.view = new FloorView('floorCanvas')
|
|
|
},
|
|
|
// 工具栏操作
|
|
|
// 移动底图
|