|
@@ -1,15 +1,31 @@
|
|
|
<template>
|
|
|
- <div id="graphy" ref="graphy">
|
|
|
+ <div id="graphy" ref="graphy" v-loading="canvasLoading">
|
|
|
<div v-show="!FloorMap">
|
|
|
+ <div style="margin-right:10px;width: 100%;margin-bottom: 10px" v-if="showOtherFlag">
|
|
|
+ <!-- 平面图其他分区 -->
|
|
|
+ <el-button type="primary" @click="addZoneBtn">添加分区</el-button>
|
|
|
+ <el-select v-model="OtherValue" placeholder="请选择分区类型" @change="changeOtherZone">
|
|
|
+ <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </div>
|
|
|
<div class="center" style="height: 400px;padding-top:182px;box-sizing:border-box;">
|
|
|
<i class="icon-wushuju iconfont"></i>
|
|
|
暂无数据
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div class="canvas-box" v-show="FloorMap" v-loading="canvasLoading">
|
|
|
+ <div class="canvas-box" v-show="FloorMap">
|
|
|
<canvas id="floorCanvas" :width="canvasWidth" :height="canvasHeight" ref="canvas" tabindex="0"></canvas>
|
|
|
<!-- 初始两个按钮 -->
|
|
|
<el-row class="buttons-box">
|
|
|
+ <div style="margin-right:10px;width: 100%;margin-bottom: 10px" v-if="showOtherFlag">
|
|
|
+ <!-- 平面图其他分区 -->
|
|
|
+ <el-button type="primary" @click="addZoneBtn">添加分区</el-button>
|
|
|
+ <el-select v-model="OtherValue" placeholder="请选择分区类型" @change="changeOtherZone">
|
|
|
+ <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </div>
|
|
|
<div>
|
|
|
<el-autocomplete popper-class="my-autocomplete" v-model="search" :fetch-suggestions="querySearch" placeholder="输入平面图中已有的业务空间名称进行查找"
|
|
|
width="180px" @select="handleSelect">
|
|
@@ -35,6 +51,8 @@
|
|
|
<!-- 点击已经关联的业务空间 -->
|
|
|
<el-button type="primary" plain @click="refactorBSP" :disabled="zoneDisable" style="margin-left:10px;">重新划分业务空间</el-button>
|
|
|
<el-button type="primary" @click="editeSpaceDetail" :disabled="zoneDisable">编辑空间详情</el-button>
|
|
|
+ <el-button type="primary" plain @click="confirmZoneSpace" :disabled="zoneDisable||(!zoneDisable&&!curZoneItem.isInfected)">确认业务空间
|
|
|
+ </el-button>
|
|
|
<el-button plain @click="cancelGraphy" v-show="!zoneDisable">取 消</el-button>
|
|
|
</div>
|
|
|
<!-- 点击已经关联的业务空间 -->
|
|
@@ -50,15 +68,16 @@
|
|
|
<div v-show="type==4">
|
|
|
<el-button plain @click="cancelGraphy">取 消</el-button>
|
|
|
<el-button type="primary" @click="saveRefactorBSP">保存</el-button>
|
|
|
+ <el-button type="primary" v-show='curZoneItem.isInfected' @click="confirmAndSave">保存并确认业务空间</el-button>
|
|
|
</div>
|
|
|
<!-- 批量创建所选业务空间 -->
|
|
|
<div v-show="type==5">
|
|
|
<el-button type="primary" @click="groupCreateZone">批量创建所选业务空间</el-button>
|
|
|
<el-button plain @click="cancelGraphy">取 消</el-button>
|
|
|
</div>
|
|
|
- </div>
|
|
|
- <div style="position: absolute;right: 0;">
|
|
|
- <el-button type="text" @click="lookUnrelatBSpace(false)">未关联平面图的业务空间 {{num}} 条</el-button>
|
|
|
+ <div style="position: absolute;right: 10px;">
|
|
|
+ <el-button type="text" @click="lookUnrelatBSpace(false)">未关联平面图的业务空间 {{num}} 条</el-button>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</el-row>
|
|
|
<!-- 底部操作按钮 -->
|
|
@@ -75,6 +94,10 @@
|
|
|
<!-- 批量创建选择弹窗 -->
|
|
|
<el-dialog title="提示" :visible.sync="groupCreateDialogVis" width="30%">
|
|
|
<div id="autoRelate">
|
|
|
+ <p>批量创建面积大于此值的默认空间为业务空间:</p>
|
|
|
+ <div style="padding:10px 20px;margin:0 0 10px 0;">
|
|
|
+ <el-slider v-model="areaValue" :marks="areaMarks" :step="10" :format-tooltip='val=>val/100'> </el-slider>
|
|
|
+ </div>
|
|
|
<p>请选择批量创建方式:</p>
|
|
|
<p>
|
|
|
<el-radio v-model="groupCreateType" :label="1">批量将所有的空白空间创建业务空间</el-radio>
|
|
@@ -88,32 +111,36 @@
|
|
|
<el-button size="small" type="primary" @click="confirm">确认</el-button>
|
|
|
</span>
|
|
|
</el-dialog>
|
|
|
+ <dialogZone ref="zone" @createSuccess="getOtherType" />
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
import canvasFun from "./canvasFun"
|
|
|
-import { mapGetters, mapActions } from "vuex";
|
|
|
-import { SColor, SPoint } from "@saga-web/draw/lib";
|
|
|
-import { DivideFloorScene, SpaceItem, ZoneItem, FloorView } from "@saga-web/cad-engine/lib";
|
|
|
+import { mapGetters } from "vuex";
|
|
|
+import { SPoint } from "@saga-web/draw/lib";
|
|
|
+import { DivideFloorScene, FloorView, SpaceItem, ZoneItem } from "@saga-web/cad-engine/lib";
|
|
|
import { colorArr } from "@/utils/spaceColor"
|
|
|
import unRelateBSP from "./unRelateBSP";
|
|
|
import createBSP from "./createBSP";
|
|
|
+import dialogZone from "../../ledger/addDialog/dialogZone";
|
|
|
import {
|
|
|
- buildingQuery,
|
|
|
- queryZone,
|
|
|
- updateZone,
|
|
|
- createZone,
|
|
|
- countZone,
|
|
|
- getIspNotInSpace,
|
|
|
createRelateInZoneAndISp,
|
|
|
- groupCreRelaZoneAndISp
|
|
|
+ getIspNotInSpace,
|
|
|
+ groupCreRelaZoneAndISp,
|
|
|
+ queryAllZoneType,
|
|
|
+ queryZone,
|
|
|
+ zoneCount,
|
|
|
+ zoneCreate,
|
|
|
+ zoneQuery,
|
|
|
+ zoneUpdate
|
|
|
} from "@/api/scan/request"
|
|
|
|
|
|
export default {
|
|
|
components: {
|
|
|
canvasFun,
|
|
|
unRelateBSP,
|
|
|
- createBSP
|
|
|
+ createBSP,
|
|
|
+ dialogZone
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
@@ -148,7 +175,12 @@ export default {
|
|
|
groupCreateDialogVis: false, //批量创建业务空间弹窗
|
|
|
groupCreateType: 1, //批量创建方式
|
|
|
zoneDisable: true, // 重新划分是否禁用
|
|
|
- sourceIdToISP: {}
|
|
|
+ sourceIdToISP: {},
|
|
|
+ areaValue: 40,
|
|
|
+ areaMarks: { 0: '0m²', 100: '1m²' },
|
|
|
+ options: [], //其他分区类型
|
|
|
+ OtherValue: '',
|
|
|
+ showOtherFlag: false, //是否显示其他分区类型添加
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
@@ -156,8 +188,8 @@ export default {
|
|
|
},
|
|
|
created() { },
|
|
|
mounted() {
|
|
|
- this.canvasWidth = this.$refs.graphy.offsetWidth;
|
|
|
- this.canvasHeight = this.$refs.graphy.offsetHeight;
|
|
|
+ this.canvasWidth = this.$refs.graphy.offsetWidth - 20;
|
|
|
+ this.canvasHeight = this.$refs.graphy.offsetHeight - 20;
|
|
|
},
|
|
|
methods: {
|
|
|
// 初始化
|
|
@@ -194,7 +226,7 @@ export default {
|
|
|
// 查询未关联平面图的业务空间
|
|
|
this.getBSPunrelaISP();
|
|
|
},
|
|
|
- // 获取当前楼层的元空间
|
|
|
+ // 获取当前楼层的元空间-元空间接口不变
|
|
|
getFloorISpace() {
|
|
|
let pa = {
|
|
|
zone: 'Ispace',
|
|
@@ -215,6 +247,10 @@ export default {
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
+ //添加其他分区
|
|
|
+ addZoneBtn() {
|
|
|
+ this.$refs.zone.dialogFormVisible = true
|
|
|
+ },
|
|
|
// 搜索
|
|
|
querySearch(queryString, cb) {
|
|
|
let restaurants = this.zoneList;
|
|
@@ -251,9 +287,40 @@ export default {
|
|
|
this.FloorObj = FloorObj;
|
|
|
this.FloorMap = FloorObj.StructureInfo ? FloorObj.StructureInfo.FloorMap : ''
|
|
|
this.tab = tab;
|
|
|
- console.log(arguments)
|
|
|
+ console.log(arguments);
|
|
|
+ if (tab.code == "OtherZone") {
|
|
|
+ // 其他分区
|
|
|
+ this.showOtherFlag = true
|
|
|
+ this.getOtherType();
|
|
|
+ this.OtherValue = (localStorage.getItem('otherZone')) || ''
|
|
|
+ } else {
|
|
|
+ this.showOtherFlag = false;
|
|
|
+ }
|
|
|
this.init(initType);
|
|
|
},
|
|
|
+ // 其他分区类型查询
|
|
|
+ getOtherType() {
|
|
|
+ let pa = {
|
|
|
+ Cascade: [{ Name: 'zoneType', Filters: `ProjectId='${this.projectId}'` }],
|
|
|
+ Filters: `Code="OtherZone"`
|
|
|
+ }
|
|
|
+ queryAllZoneType(pa, res => {
|
|
|
+ if (res.Content[0].ZoneType && res.Content[0].ZoneType.length) {
|
|
|
+ this.options = res.Content[0].ZoneType.map(t => {
|
|
|
+ t.value = t.Code;
|
|
|
+ t.label = t.Name;
|
|
|
+ return t;
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.options = []
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 其他类型下拉change
|
|
|
+ changeOtherZone(val) {
|
|
|
+ this.init(2);
|
|
|
+ localStorage.setItem('otherZone', val)
|
|
|
+ },
|
|
|
// 获取未绑定业务空间的元空间
|
|
|
getISPSPUnrelaBSP() {
|
|
|
let pa = {
|
|
@@ -261,7 +328,7 @@ export default {
|
|
|
Filters: `FloorId='${this.buildFloor[1]}'`,
|
|
|
PageSize: 1000
|
|
|
},
|
|
|
- objectType: this.tab.code
|
|
|
+ objectType: this.tab.code == 'OtherZone' ? this.OtherValue : this.tab.code
|
|
|
}
|
|
|
this.allUnRelatISP = []
|
|
|
getIspNotInSpace(pa, res => {
|
|
@@ -302,18 +369,18 @@ export default {
|
|
|
// 获取当前分区下的业务空间
|
|
|
getBusinessSpace() {
|
|
|
this.canvasLoading = true
|
|
|
+ let ObjectType = this.tab.code == 'OtherZone' ? this.OtherValue : this.tab.code;
|
|
|
let pa = {
|
|
|
- zone: this.tab.code,
|
|
|
- data: {
|
|
|
- Filters: ``,
|
|
|
- Orders: "createTime desc, RoomID asc",
|
|
|
- PageSize: 1000
|
|
|
- }
|
|
|
+ ZoneType: ObjectType,
|
|
|
+ Filters: `not RoomID isNull`,
|
|
|
+ Orders: "createTime desc, RoomID asc",
|
|
|
+ PageSize: 10000
|
|
|
}
|
|
|
if (this.buildFloor.length && this.buildFloor.length > 1) {
|
|
|
- pa.data.Filters = `BuildingId='${this.buildFloor[0]}';FloorId='${this.buildFloor[1]}'`
|
|
|
+ pa.BuildingId = this.buildFloor[0];
|
|
|
+ pa.FloorId = this.buildFloor[1];
|
|
|
}
|
|
|
- queryZone(pa, res => {
|
|
|
+ zoneQuery(pa, res => {
|
|
|
// 所有业务空间
|
|
|
this.businessSpaceList = res.Content;
|
|
|
// 已关联元空间的业务空间
|
|
@@ -324,13 +391,15 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
// 绘制业务空间
|
|
|
+ let tempType = this.tab.code == 'OtherZone' ? this.OtherValue : this.tab.code;
|
|
|
let tempArr = this.BSPRelaISPList.map((t, i) => {
|
|
|
- if (t.FloorId == this.buildFloor[1] && t.ObjectType == this.tab.code) {
|
|
|
+ if (t.FloorId == this.buildFloor[1] && t.ObjectType == tempType) {
|
|
|
return {
|
|
|
RoomLocalName: t.RoomLocalName,
|
|
|
OutLine: t.Outline,
|
|
|
RoomID: t.RoomID,
|
|
|
Color: colorArr[i % colorArr.length],
|
|
|
+ Infected: t.State
|
|
|
}
|
|
|
} else {
|
|
|
console.log('internet slow')
|
|
@@ -341,6 +410,7 @@ export default {
|
|
|
this.scene.addZoneList(tempArr);
|
|
|
this.scene.click(this, this.canvasClick);
|
|
|
this.zoneList = this.scene.zoneList;
|
|
|
+ this.view._needDraw = true;
|
|
|
this.canvasLoading = false;
|
|
|
})
|
|
|
},
|
|
@@ -381,6 +451,7 @@ export default {
|
|
|
this.scene.isSpaceSelectable = true;
|
|
|
// 设置业务空间不可选
|
|
|
this.scene.isZoneSelectable = false
|
|
|
+ this.view._needDraw = true;
|
|
|
},
|
|
|
// 查看未关联的业务空间--flag--查看-or-选择
|
|
|
lookUnrelatBSpace(flag) {
|
|
@@ -424,6 +495,22 @@ export default {
|
|
|
let text = []
|
|
|
let Spaces = this.allUnRelatISP.map(t => {
|
|
|
if (t.Outline) {
|
|
|
+ let area = 0;
|
|
|
+ if (t.Outline[0]) {
|
|
|
+ area = this.getarea(t.Outline[0]);
|
|
|
+ if (t.Outline.length > 1) {
|
|
|
+ for (let i = 1; i < t.Outline.length; i++) {
|
|
|
+ let temp = this.getarea(t.Outline[i]);
|
|
|
+ area = area - temp
|
|
|
+ }
|
|
|
+ }
|
|
|
+ area = (area / 1000000).toFixed(2);
|
|
|
+ if (area < (this.areaValue / 100)) {
|
|
|
+ return undefined
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return undefined;
|
|
|
+ }
|
|
|
text.push(t.RoomLocalName || t.RoomName)
|
|
|
return {
|
|
|
IspaceId: t.RoomID,
|
|
@@ -479,62 +566,62 @@ export default {
|
|
|
},
|
|
|
// 根据图创建新的业务空间-弹窗返回确认创建
|
|
|
createRoom(val) {
|
|
|
- // const zoneObj = { Outline: [], Height: 0 }, IspaceIdList = [];
|
|
|
- // let spaces = {};
|
|
|
- // if (this.scene.cutItem || this.scene.sceneMark) {
|
|
|
- // // 如果有划分,求交集
|
|
|
- // // 格式为Poly(先与业务空间求差集)
|
|
|
- // const obj = this.scene.getZoneDifference(true);
|
|
|
- // // 差集与楼层平面图或用户划分区域求交集
|
|
|
- // spaces = this.scene.getPloyIntersect(obj)
|
|
|
- // } else {
|
|
|
- // // 格式为SPoint[]
|
|
|
- // spaces = this.scene.getZoneDifference();
|
|
|
- // }
|
|
|
- // for (let key in spaces) {
|
|
|
- // spaces[key].map(t => {
|
|
|
- // let temp = t.map(item => {
|
|
|
- // return {
|
|
|
- // X: 1*item.x.toFixed(2),
|
|
|
- // Y: -item.y.toFixed(2),
|
|
|
- // Z: 0
|
|
|
- // }
|
|
|
- // })
|
|
|
- // zoneObj.Outline.push([temp]);
|
|
|
- // })
|
|
|
- // let curISP = this.sourceIdToISP[key];
|
|
|
- // if (curISP) {
|
|
|
- // curISP && IspaceIdList.push(curISP.RoomID);
|
|
|
- // zoneObj.Height = zoneObj.Height == 0 ? curISP.Height : zoneObj.Height > curISP.Height ? curISP.Height : zoneObj.Height;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // 数据计算导致浏览器奔溃,临时注释
|
|
|
- let zoneObj = { Outline: [], Height: 0 }, IspaceIdList = [];
|
|
|
- let selectSpaces = this.scene.getSelectedSpaces();
|
|
|
- selectSpaces.map(t => {
|
|
|
- zoneObj.Outline.push(t.data.OutLine);
|
|
|
- let key = t.data.SourceId;
|
|
|
- let curISP = this.sourceIdToISP[key];
|
|
|
- if (curISP) {
|
|
|
- IspaceIdList.push(curISP.RoomID);
|
|
|
- zoneObj.Height = zoneObj.Height == 0 ? curISP.Height : zoneObj.Height > curISP.Height ? curISP.Height : zoneObj.Height;
|
|
|
- }
|
|
|
- })
|
|
|
- // 如果有划分,求交集
|
|
|
+ const zoneObj = { Outline: [], Height: 0 }, IspaceIdList = [];
|
|
|
+ let spaces = {};
|
|
|
if (this.scene.cutItem || this.scene.sceneMark) {
|
|
|
- zoneObj.Outline = [];
|
|
|
- let arr = this.scene.getIntersect();
|
|
|
- arr.map(t => {
|
|
|
+ // 如果有划分,求交集
|
|
|
+ // 格式为Poly(先与业务空间求差集)
|
|
|
+ const obj = this.scene.getZoneDifference(true);
|
|
|
+ // 差集与楼层平面图或用户划分区域求交集
|
|
|
+ spaces = this.scene.getPloyIntersect(obj)
|
|
|
+ } else {
|
|
|
+ // 格式为SPoint[]
|
|
|
+ spaces = this.scene.getZoneDifference();
|
|
|
+ }
|
|
|
+ for (let key in spaces) {
|
|
|
+ spaces[key].map(t => {
|
|
|
let temp = t.map(item => {
|
|
|
return {
|
|
|
- X: 1 * item.x,
|
|
|
- Y: -item.y,
|
|
|
+ X: 1 * item.x.toFixed(2),
|
|
|
+ Y: -item.y.toFixed(2),
|
|
|
Z: 0
|
|
|
}
|
|
|
})
|
|
|
zoneObj.Outline.push([temp]);
|
|
|
})
|
|
|
+ let curISP = this.sourceIdToISP[key];
|
|
|
+ if (curISP) {
|
|
|
+ curISP && IspaceIdList.push(curISP.RoomID);
|
|
|
+ zoneObj.Height = zoneObj.Height == 0 ? curISP.Height : zoneObj.Height > curISP.Height ? curISP.Height : zoneObj.Height;
|
|
|
+ }
|
|
|
}
|
|
|
+ // 数据计算导致浏览器奔溃,临时注释(测试计算未崩溃改好)
|
|
|
+ // let zoneObj = { Outline: [], Height: 0 }, IspaceIdList = [];
|
|
|
+ // let selectSpaces = this.scene.getSelectedSpaces();
|
|
|
+ // selectSpaces.map(t => {
|
|
|
+ // zoneObj.Outline.push(t.data.OutLine);
|
|
|
+ // let key = t.data.SourceId;
|
|
|
+ // let curISP = this.sourceIdToISP[key];
|
|
|
+ // if (curISP) {
|
|
|
+ // IspaceIdList.push(curISP.RoomID);
|
|
|
+ // zoneObj.Height = zoneObj.Height == 0 ? curISP.Height : zoneObj.Height > curISP.Height ? curISP.Height : zoneObj.Height;
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // // 如果有划分,求交集
|
|
|
+ // if (this.scene.cutItem || this.scene.sceneMark) {
|
|
|
+ // zoneObj.Outline = [];
|
|
|
+ // let arr = this.scene.getIntersect();
|
|
|
+ // arr.map(t => {
|
|
|
+ // let temp = t.map(item => {
|
|
|
+ // return {
|
|
|
+ // X: 1 * item.x,
|
|
|
+ // Y: -item.y,
|
|
|
+ // Z: 0
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // zoneObj.Outline.push([temp]);
|
|
|
+ // })
|
|
|
+ // }
|
|
|
// 至此
|
|
|
if (!zoneObj.Outline.length) {
|
|
|
zoneObj.Outline = null;
|
|
@@ -639,12 +726,35 @@ export default {
|
|
|
// 将当前业务空间的每个元素添加到场景中并选中
|
|
|
this.scene.addAllLikeSpace(this.curZoneItem.data.OutLine);
|
|
|
},
|
|
|
+ // 确认业务空间
|
|
|
+ confirmZoneSpace() {
|
|
|
+ let ObjectType = this.tab.code == 'OtherZone' ? this.OtherValue : this.tab.code;
|
|
|
+ let space = {
|
|
|
+ RoomID: this.curZoneItem.data.RoomID,
|
|
|
+ State: 0,
|
|
|
+ ObjectType: ObjectType
|
|
|
+ }
|
|
|
+ let pa = {
|
|
|
+ Content: [space],
|
|
|
+ Projection: ['State']
|
|
|
+ }
|
|
|
+ zoneUpdate(pa, res => {
|
|
|
+ this.curZoneItem.isInfected = false;
|
|
|
+ this.$emit('updateState');
|
|
|
+ this.$message.success('更新成功');
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 保存并确认业务空间
|
|
|
+ confirmAndSave() {
|
|
|
+ this.confirmAndSaveFlag = true;
|
|
|
+ this.saveRefactorBSP();
|
|
|
+ },
|
|
|
// 重新划分--保存
|
|
|
saveRefactorBSP() {
|
|
|
let selectSpace = this.scene.getSelectedSpaces();
|
|
|
let selectLikeSpace = this.scene.getSelectedLikeSpace();
|
|
|
//更新业务空间
|
|
|
- let zoneObj = { Outline: [], Height: 0 }, IspaceIdList = [];
|
|
|
+ let zoneObj = { Outline: [], Height: 0, State: this.confirmAndSaveFlag ? 0 : this.curZoneItem.isInfected ? 1 : 0 }, IspaceIdList = [];
|
|
|
// 空间
|
|
|
selectSpace.map(t => {
|
|
|
zoneObj.Outline.push(t.data.OutLine);
|
|
@@ -693,83 +803,133 @@ export default {
|
|
|
},
|
|
|
// 根据图批量创建所选业务空间
|
|
|
groupCreateZone() {
|
|
|
- // let arr = this.scene.getSelectedSpaces();
|
|
|
- // let createSpaces = [], spaces = {};
|
|
|
- // if (this.scene.cutItem || this.scene.sceneMark) {
|
|
|
- // // 如果有划分,求交集
|
|
|
- // // 格式为Poly(先与业务空间求差集)
|
|
|
- // const obj = this.scene.getZoneDifference(true);
|
|
|
- // // 差集与楼层平面图或用户划分区域求交集
|
|
|
- // spaces = this.scene.getPloyIntersect(obj)
|
|
|
- // } else {
|
|
|
- // // 格式为SPoint[]
|
|
|
- // spaces = this.scene.getZoneDifference();
|
|
|
- // }
|
|
|
- // for (let key in spaces) {
|
|
|
- // let zoneObj = { Outline: [], Height: 0 }
|
|
|
- // spaces[key].map(t => {
|
|
|
- // let temp = t.map(item => {
|
|
|
- // return {
|
|
|
- // X: 1 * item.x.toFixed(2),
|
|
|
- // Y: -item.y.toFixed(2),
|
|
|
- // Z: 0
|
|
|
- // }
|
|
|
- // })
|
|
|
- // zoneObj.Outline.push([temp]);
|
|
|
- // })
|
|
|
- // if (!zoneObj.Outline.length) {
|
|
|
- // continue
|
|
|
- // }
|
|
|
- // let curISP = this.sourceIdToISP[key];
|
|
|
- // if (curISP) {
|
|
|
- // zoneObj.Height = zoneObj.Height == 0 ? curISP.Height : zoneObj.Height > curISP.Height ? curISP.Height : zoneObj.Height;
|
|
|
- // zoneObj.IspaceId = curISP.RoomID;
|
|
|
- // zoneObj.RoomLocalName = curISP.RoomLocalName;
|
|
|
- // }
|
|
|
- // zoneObj.BuildingId = this.buildFloor[0];
|
|
|
- // zoneObj.FloorId = this.buildFloor[1];
|
|
|
- // createSpaces.push(zoneObj);
|
|
|
- // }
|
|
|
-
|
|
|
- // 改回之前逻辑
|
|
|
let arr = this.scene.getSelectedSpaces();
|
|
|
- let createSpaces = [];
|
|
|
- // 如果有划分,求交集
|
|
|
+ let createSpaces = [], spaces = {};
|
|
|
if (this.scene.cutItem || this.scene.sceneMark) {
|
|
|
- let outlines = this.scene.getIntersectInSpace();
|
|
|
- for (let k in outlines) {
|
|
|
- outlines[k] = outlines[k].map(t => {
|
|
|
- t = t.map(item => {
|
|
|
- item = item.map(j => {
|
|
|
- return { X: j.x, Y: -j.y, Z: 0 }
|
|
|
- })
|
|
|
- return item
|
|
|
- })
|
|
|
- return t;
|
|
|
+ // 如果有划分,求交集
|
|
|
+ // 格式为Poly(先与业务空间求差集)
|
|
|
+ const obj = this.scene.getZoneDifference(true);
|
|
|
+ // 差集与楼层平面图或用户划分区域求交集
|
|
|
+ spaces = this.scene.getPloyIntersect(obj)
|
|
|
+ } else {
|
|
|
+ // 格式为SPoint[]
|
|
|
+ spaces = this.scene.getZoneDifference();
|
|
|
+ }
|
|
|
+ for (let key in spaces) {
|
|
|
+ let zoneObj = { Outline: [], Height: 0 }
|
|
|
+ spaces[key].map(t => {
|
|
|
+ let temp = t.map(item => {
|
|
|
+ return {
|
|
|
+ X: 1 * item.x.toFixed(2),
|
|
|
+ Y: -item.y.toFixed(2),
|
|
|
+ Z: 0
|
|
|
+ }
|
|
|
})
|
|
|
+ zoneObj.Outline.push([temp]);
|
|
|
+ })
|
|
|
+ if (!zoneObj.Outline.length) {
|
|
|
+ continue
|
|
|
}
|
|
|
- createSpaces = arr.map(t => {
|
|
|
- return {
|
|
|
- IspaceId: this.BIMIDToSID[t.data.SourceId],
|
|
|
- RoomLocalName: this.BIMIDToSIName[t.data.SourceId],
|
|
|
- Outline: outlines[t.data.SourceId],
|
|
|
- BuildingId: this.buildFloor[0],
|
|
|
- FloorId: this.buildFloor[1],
|
|
|
- Height: t.data.Height > 100 ? (t.data.Height / 1000).toFixed(2) : t.data.Height || 0
|
|
|
- }
|
|
|
- }).filter(item => item.Outline && item.Outline.length)
|
|
|
- } else {
|
|
|
- createSpaces = arr.map(t => {
|
|
|
- return {
|
|
|
- IspaceId: this.BIMIDToSID[t.data.SourceId],
|
|
|
- RoomLocalName: this.BIMIDToSIName[t.data.SourceId],
|
|
|
- Outline: [t.data.OutLine],
|
|
|
- BuildingId: this.buildFloor[0],
|
|
|
- FloorId: this.buildFloor[1],
|
|
|
- Height: t.data.Height > 100 ? (t.data.Height / 1000).toFixed(2) : t.data.Height || 0
|
|
|
+ //计算面积
|
|
|
+ let area = 0, line = zoneObj.Outline;
|
|
|
+ for (let i = 0; i < line.length; i++) {
|
|
|
+ for (let j = 0; j < line[i].length; j++) {
|
|
|
+ if (j == 0) {
|
|
|
+ area += this.getarea(line[i][0]);
|
|
|
+ } else {
|
|
|
+ area -= this.getarea(line[i][j]);
|
|
|
+ }
|
|
|
}
|
|
|
- })
|
|
|
+ }
|
|
|
+ area = (area / 1000000).toFixed(2);
|
|
|
+ if (area < (this.areaValue / 100)) {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ //生成空间对象
|
|
|
+ let curISP = this.sourceIdToISP[key];
|
|
|
+ if (curISP) {
|
|
|
+ zoneObj.Height = zoneObj.Height == 0 ? curISP.Height : zoneObj.Height > curISP.Height ? curISP.Height : zoneObj.Height;
|
|
|
+ zoneObj.IspaceId = curISP.RoomID;
|
|
|
+ zoneObj.RoomLocalName = curISP.RoomLocalName;
|
|
|
+ }
|
|
|
+ zoneObj.BuildingId = this.buildFloor[0];
|
|
|
+ zoneObj.FloorId = this.buildFloor[1];
|
|
|
+ createSpaces.push(zoneObj);
|
|
|
}
|
|
|
+
|
|
|
+ // 改回之前逻辑
|
|
|
+ // let arr = this.scene.getSelectedSpaces();
|
|
|
+ // let createSpaces = [];
|
|
|
+ // // 如果有划分,求交集
|
|
|
+ // if (this.scene.cutItem || this.scene.sceneMark) {
|
|
|
+ // let outlines = this.scene.getIntersectInSpace();
|
|
|
+ // for (let k in outlines) {
|
|
|
+ // outlines[k] = outlines[k].map(t => {
|
|
|
+ // t = t.map(item => {
|
|
|
+ // item = item.map(j => {
|
|
|
+ // return { X: j.x, Y: -j.y, Z: 0 }
|
|
|
+ // })
|
|
|
+ // return item
|
|
|
+ // })
|
|
|
+ // return t;
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // createSpaces = arr.map(t => {
|
|
|
+ // let line = outlines[t.data.SourceId];
|
|
|
+ // if (!line || !line.length) {
|
|
|
+ // return undefined
|
|
|
+ // } else {
|
|
|
+ // let area = 0;
|
|
|
+ // for (let i = 0; i < line.length; i++) {
|
|
|
+ // for (let j = 0; j < line[i].length; j++) {
|
|
|
+ // if (j == 0) {
|
|
|
+ // area += this.getarea(line[i][0]);
|
|
|
+ // } else {
|
|
|
+ // area -= this.getarea(line[i][j]);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // area = (area / 1000000).toFixed(2);
|
|
|
+ // if (area < (this.areaValue / 100)) {
|
|
|
+ // return undefined;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // return {
|
|
|
+ // IspaceId: this.BIMIDToSID[t.data.SourceId],
|
|
|
+ // RoomLocalName: this.BIMIDToSIName[t.data.SourceId],
|
|
|
+ // Outline: line,
|
|
|
+ // BuildingId: this.buildFloor[0],
|
|
|
+ // FloorId: this.buildFloor[1],
|
|
|
+ // Height: t.data.Height > 100 ? (t.data.Height / 1000).toFixed(2) : t.data.Height || 0
|
|
|
+ // }
|
|
|
+ // }).filter(item => item)
|
|
|
+ // } else {
|
|
|
+ // createSpaces = arr.map(t => {
|
|
|
+ // let line = t.data.OutLine;
|
|
|
+ // if (!line || !line.length) {
|
|
|
+ // return undefined
|
|
|
+ // } else {
|
|
|
+ // let area = this.getarea(line[0]);
|
|
|
+ // if (line.length > 1) {
|
|
|
+ // for (let i = 1; i < line.length; i++) {
|
|
|
+ // area -= this.getarea(line[i]);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // area = (area / 1000000).toFixed(2);
|
|
|
+ // if (area < (this.areaValue / 100)) {
|
|
|
+ // return undefined;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // return {
|
|
|
+ // IspaceId: this.BIMIDToSID[t.data.SourceId],
|
|
|
+ // RoomLocalName: this.BIMIDToSIName[t.data.SourceId],
|
|
|
+ // Outline: [line],
|
|
|
+ // BuildingId: this.buildFloor[0],
|
|
|
+ // FloorId: this.buildFloor[1],
|
|
|
+ // Height: t.data.Height > 100 ? (t.data.Height / 1000).toFixed(2) : t.data.Height || 0
|
|
|
+ // }
|
|
|
+ // }).filter(item => item);
|
|
|
+ // }
|
|
|
if (createSpaces.length) {
|
|
|
this.canvasLoading = true;
|
|
|
this.groupCreateBSP(createSpaces)
|
|
@@ -779,24 +939,32 @@ export default {
|
|
|
},
|
|
|
// 更新业务空间和元空间的关系
|
|
|
relationInBSPandISP(SpaceId, IspaceIdList) {
|
|
|
+ let ObjectType = this.tab.code == 'OtherZone' ? this.OtherValue : this.tab.code;
|
|
|
let pa = {
|
|
|
data: { SpaceId: SpaceId, IspaceIdList: IspaceIdList },
|
|
|
- type: this.tab.code
|
|
|
+ type: ObjectType
|
|
|
}
|
|
|
createRelateInZoneAndISp(pa, res => {
|
|
|
this.$message.success('创建成功');
|
|
|
this.init(2);
|
|
|
+ if (this.confirmAndSaveFlag) {
|
|
|
+ this.confirmAndSaveFlag = false;
|
|
|
+ this.curZoneItem.selected = false;
|
|
|
+ this.curZoneItem = {};
|
|
|
+ this.$emit('updateState');
|
|
|
+ }
|
|
|
})
|
|
|
},
|
|
|
// 批量更新业务空间和元空间的关系
|
|
|
groupCreRelaZoneAndISp(Spaces) {
|
|
|
Spaces = Spaces.filter(item => item.IspaceId);
|
|
|
+ let ObjectType = this.tab.code == 'OtherZone' ? this.OtherValue : this.tab.code;
|
|
|
if (Spaces.length) {
|
|
|
let param = {
|
|
|
data: {
|
|
|
Content: Spaces
|
|
|
},
|
|
|
- type: this.tab.code
|
|
|
+ type: ObjectType
|
|
|
}
|
|
|
groupCreRelaZoneAndISp(param, res => {
|
|
|
this.$message.success('创建成功')
|
|
@@ -811,17 +979,16 @@ export default {
|
|
|
},
|
|
|
// 批量创建
|
|
|
groupCreateBSP(spaces) {
|
|
|
+ let ObjectType = this.tab.code == 'OtherZone' ? this.OtherValue : this.tab.code;
|
|
|
spaces = spaces.map(t => {
|
|
|
+ t.ObjectType = ObjectType;
|
|
|
t.BIMLocation = this.getAverageVal(t.Outline);
|
|
|
return t;
|
|
|
})
|
|
|
let pa = {
|
|
|
- zone: this.tab.code,
|
|
|
- data: {
|
|
|
- Content: spaces
|
|
|
- }
|
|
|
+ Content: spaces,
|
|
|
}
|
|
|
- createZone(pa, res => {
|
|
|
+ zoneCreate(pa, res => {
|
|
|
res.EntityList.map(t => {
|
|
|
spaces = spaces.map(item => {
|
|
|
if (t.RoomLocalName == item.RoomLocalName) {
|
|
@@ -835,40 +1002,35 @@ export default {
|
|
|
},
|
|
|
// 单个创建
|
|
|
createSingleBSP(space, IspaceIdList) {
|
|
|
+ let ObjectType = this.tab.code == 'OtherZone' ? this.OtherValue : this.tab.code;
|
|
|
space.BIMLocation = space.Outline ? this.getAverageVal(space.Outline) : null;
|
|
|
+ space.ObjectType = ObjectType;
|
|
|
let pa = {
|
|
|
- zone: this.tab.code,
|
|
|
- data: {
|
|
|
- Content: [space]
|
|
|
- }
|
|
|
+ Content: [space]
|
|
|
}
|
|
|
- createZone(pa, res => {
|
|
|
+ zoneCreate(pa, res => {
|
|
|
this.relationInBSPandISP(res.EntityList[0].RoomID, IspaceIdList)
|
|
|
})
|
|
|
},
|
|
|
// 更新业务空间区域
|
|
|
updateBSPOutline(zoneObj, IspaceIdList) {
|
|
|
+ let ObjectType = this.tab.code == 'OtherZone' ? this.OtherValue : this.tab.code;
|
|
|
zoneObj.BIMLocation = zoneObj.Outline ? this.getAverageVal(zoneObj.Outline) : null;
|
|
|
+ zoneObj.ObjectType = ObjectType;
|
|
|
let pa = {
|
|
|
- zone: this.tab.code,
|
|
|
- data: {
|
|
|
- Content: [zoneObj],
|
|
|
- Projection: ['Outline', 'BIMLocation']
|
|
|
- },
|
|
|
+ Content: [zoneObj]
|
|
|
}
|
|
|
- updateZone(pa, res => {
|
|
|
+ zoneUpdate(pa, res => {
|
|
|
this.relationInBSPandISP(zoneObj.RoomID, IspaceIdList)
|
|
|
})
|
|
|
},
|
|
|
// 查询未关联平面图的业务空间(项目下+当前分区)
|
|
|
getBSPunrelaISP() {
|
|
|
+ let ObjectType = this.tab.code == 'OtherZone' ? this.OtherValue : this.tab.code;
|
|
|
let pa = {
|
|
|
- zone: this.tab.code,
|
|
|
- data: {
|
|
|
- Filters: `Outline isNull`
|
|
|
- }
|
|
|
+ Filters: `Outline isNull;ObjectType="${ObjectType}"`
|
|
|
}
|
|
|
- countZone(pa, res => {
|
|
|
+ zoneCount(pa, res => {
|
|
|
this.num = res.Count;
|
|
|
})
|
|
|
},
|
|
@@ -890,6 +1052,19 @@ export default {
|
|
|
Z = (Z / len).toFixed(2);
|
|
|
return `${X},${Y},${Z}`
|
|
|
},
|
|
|
+ // 计算面积
|
|
|
+ getarea(arr) {
|
|
|
+ if (!arr.length) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ let sum = 0;
|
|
|
+ let n = arr.length;
|
|
|
+ arr[n] = arr[0];
|
|
|
+ for (let i = 1; i <= n; i++) {
|
|
|
+ sum += arr[i].X * arr[i - 1].Y - arr[i - 1].X * arr[i].Y;
|
|
|
+ }
|
|
|
+ return Math.abs(sum / 2)
|
|
|
+ },
|
|
|
// canvas 获取焦点
|
|
|
focus() {
|
|
|
document.getElementById(`floorCanvas`).focus()
|
|
@@ -994,6 +1169,8 @@ export default {
|
|
|
#graphy {
|
|
|
position: relative;
|
|
|
width: 100%;
|
|
|
+ box-sizing: border-box;
|
|
|
+ padding: 0 10px 10px;
|
|
|
height: calc(100% - 56px);
|
|
|
.canvas-box {
|
|
|
width: 100%;
|
|
@@ -1002,13 +1179,15 @@ export default {
|
|
|
.buttons-box {
|
|
|
position: absolute;
|
|
|
top: 0;
|
|
|
+ left: 0;
|
|
|
+ padding: 0 10px;
|
|
|
width: 100%;
|
|
|
z-index: 999;
|
|
|
& > div {
|
|
|
float: left;
|
|
|
}
|
|
|
/deep/ .el-autocomplete {
|
|
|
- display: block;
|
|
|
+ display: inline-block;
|
|
|
width: 320px;
|
|
|
margin-right: 10px;
|
|
|
}
|
|
@@ -1037,10 +1216,15 @@ export default {
|
|
|
}
|
|
|
.canvas-actions-box {
|
|
|
position: absolute;
|
|
|
- bottom: 20px;
|
|
|
+ bottom: 60px;
|
|
|
left: 50%;
|
|
|
transform: translateX(-50%);
|
|
|
- z-index: 999;
|
|
|
+ z-index: 99;
|
|
|
+ }
|
|
|
+ #autoRelate {
|
|
|
+ /deep/ .el-slider__marks-text:nth-child(2) {
|
|
|
+ width: 25px;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</style>
|