|
@@ -9,7 +9,6 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import eventBus from "./bus.js";
|
|
|
import { SGraphyView } from "@saga-web/graphy/lib";
|
|
|
import { DivideFloorScene } from "@saga-web/cad-engine/lib"
|
|
|
import { SColor, SPoint } from "@saga-web/draw/lib";
|
|
@@ -30,6 +29,7 @@ export default {
|
|
|
modelId: '',
|
|
|
FloorID: '',
|
|
|
Outline: [],
|
|
|
+ floorData: {}
|
|
|
};
|
|
|
},
|
|
|
props: {
|
|
@@ -41,61 +41,79 @@ export default {
|
|
|
},
|
|
|
id: {
|
|
|
default: 0
|
|
|
+ },
|
|
|
+ dialog: {
|
|
|
+ default: false
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
this.FloorID = this.$route.query.FloorID;
|
|
|
- this.OutlineFlag = this.$route.query.OutlineFlag;
|
|
|
+ if (!this.dialog) {
|
|
|
+ this.getFloorData();
|
|
|
+ }
|
|
|
},
|
|
|
mounted() {
|
|
|
this.cadWidth = document.getElementById(`drawFloor${this.id}`).offsetWidth;
|
|
|
this.cadHeight = document.getElementById(`drawFloor${this.id}`).offsetHeight;
|
|
|
},
|
|
|
methods: {
|
|
|
- initGraphy(ModelId) {
|
|
|
+ // 初始化canvas
|
|
|
+ initGraphy(Id, type) {
|
|
|
+ // type=1 => id:模型id
|
|
|
+ // type=2 => id:floormap
|
|
|
let that = this;
|
|
|
- that.modelId = ModelId;
|
|
|
+ that.modelId = Id;
|
|
|
that.clearGraphy()
|
|
|
that.drawMainScene = new DivideFloorScene();
|
|
|
that.canvasLoading = true;
|
|
|
- that.drawMainScene.getFloorData('/modelapi/base-graph/query', { ModelId: ModelId }).then(res => {
|
|
|
- that.canvasLoading = false;
|
|
|
- if (res.Result == 'failure') {
|
|
|
- that.showTools = false;
|
|
|
- that.$message.warning(res.Message);
|
|
|
- return;
|
|
|
- }
|
|
|
- let Elements = res.EntityList[0].Elements;
|
|
|
- let flag = false;
|
|
|
- for (let key in Elements) {
|
|
|
- if (Elements[key].length > 0) {
|
|
|
- flag = true;
|
|
|
- }
|
|
|
- }
|
|
|
- if (flag) {
|
|
|
- that.view.scene = that.drawMainScene
|
|
|
- that.view.fitSceneToView();
|
|
|
- that.drawMainScene.isSpaceSelectable = false;
|
|
|
- if (that.$refs.canvasFun) {
|
|
|
- that.view.maxScale = that.view.scale * 10;
|
|
|
- that.view.minScale = that.view.scale;
|
|
|
- that.$refs.canvasFun.everyScale = that.view.scale;
|
|
|
- }
|
|
|
- if (that.OutlineFlag) {
|
|
|
- that.getFloorData()
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
+ if (type == 1) {
|
|
|
+ that.drawMainScene.getFloorData('/modelapi/base-graph/query', { ModelId: Id }).then(res => {
|
|
|
+ that.getGraphtSuc(res)
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ that.drawMainScene.loadUrl(`/image-service/common/file_get?systemId=revit&key=${Id}`).then(res => {
|
|
|
+ that.getGraphtSuc(res)
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ // 获取底图成功
|
|
|
+ getGraphtSuc(res) {
|
|
|
+ this.canvasLoading = false;
|
|
|
+ if (res == 'error') {
|
|
|
+ this.FloorMap = '';
|
|
|
+ this.$message.warning('数据解析异常');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (res.Result == 'failure') {
|
|
|
+ this.showTools = false;
|
|
|
+ this.$message.warning(res.Message);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.view.scene = this.drawMainScene;
|
|
|
+ this.view.fitSceneToView();
|
|
|
+ this.drawMainScene.isSpaceSelectable = false;
|
|
|
+
|
|
|
+ if (this.$refs.canvasFun) {
|
|
|
+ this.view.maxScale = this.view.scale * 10;
|
|
|
+ this.view.minScale = this.view.scale;
|
|
|
+ this.$refs.canvasFun.everyScale = this.view.scale;
|
|
|
+ }
|
|
|
+ if (this.floorData.Outline && this.floorData.Outline.length) {
|
|
|
+ let newArr = this.floorData.Outline.map(t => {
|
|
|
+ return new SPoint(t.X, t.Y);
|
|
|
+ })
|
|
|
+ this.drawMainScene.addSceneMark(newArr)
|
|
|
+ }
|
|
|
},
|
|
|
+ // 获取楼层数据
|
|
|
getFloorData() {
|
|
|
let pa = {
|
|
|
Filters: `FloorID='${this.FloorID}'`
|
|
|
}
|
|
|
floorQuery(pa, res => {
|
|
|
- let newArr = res.Content[0].Outline.map(t => {
|
|
|
- return new SPoint(t.X, t.Y);
|
|
|
- })
|
|
|
- this.drawMainScene.addSceneMark(newArr)
|
|
|
+ this.floorData = res.Content[0];
|
|
|
+ this.initGraphy(this.floorData.StructureInfo.FloorMap, 2)
|
|
|
})
|
|
|
},
|
|
|
// 清空平面图
|