YZProjectCloud/yanzhu-ui-vue3/src/views/bim/bimSetting/index.vue

370 lines
10 KiB
Vue
Raw Normal View History

2025-04-22 00:07:38 +08:00
<template>
2025-06-10 16:17:24 +08:00
<div class="bim-setting-page app-container2">
<div id="bimSettingContainer"></div>
2025-07-24 18:25:45 +08:00
<div class="bim-cfg-tools">
<el-switch v-model="showGis" @change="doChangeGis"></el-switch>GIS
</div>
2025-07-25 16:53:07 +08:00
<model-floor-tree ref="modelFloorTree" :me="this" @change="doChange" @modelAdd="modelAdded" :projectMessage="models"
2025-07-24 18:25:45 +08:00
v-if="showTree"></model-floor-tree>
2025-06-10 16:17:24 +08:00
<div class="footer-box" v-if="showModels.length > 0">
2025-07-17 15:52:12 +08:00
<el-tooltip placement="top" content="主视图">
2025-06-12 18:38:47 +08:00
<div class="footer-btn" @click="doMenu(0)" :class="activeMenu == 0 ? 'is-active' : ''">
2025-06-10 16:17:24 +08:00
<svg-icon icon-class="home" />
2025-04-25 23:14:21 +08:00
</div>
2025-07-17 15:52:12 +08:00
</el-tooltip>
<el-tooltip placement="top" content="第一人称漫游">
2025-06-12 18:38:47 +08:00
<div class="footer-btn" @click="doMenu(1)" :class="activeMenu == 1 ? 'is-active' : ''">
2025-06-10 16:17:24 +08:00
<svg-icon icon-class="roam" />
2025-05-27 00:14:58 +08:00
</div>
2025-07-17 15:52:12 +08:00
</el-tooltip>
<el-tooltip placement="top" content="自定义视点漫游">
2025-06-12 18:38:47 +08:00
<div class="footer-btn" @click="doMenu(2)" :class="activeMenu == 2 ? 'is-active' : ''">
2025-06-10 16:17:24 +08:00
<svg-icon icon-class="view" />
</div>
2025-07-17 15:52:12 +08:00
</el-tooltip>
<el-tooltip placement="top" content="视点管理">
2025-06-12 18:38:47 +08:00
<div class="footer-btn" @click="doMenu(3)" :class="activeMenu == 3 ? 'is-active' : ''">
2025-06-10 16:17:24 +08:00
<svg-icon icon-class="camera" />
</div>
2025-07-17 15:52:12 +08:00
</el-tooltip>
<el-tooltip placement="top" content="构件隐藏">
2025-06-12 18:38:47 +08:00
<div class="footer-btn" @click="doMenu(4)" :class="activeMenu == 4 ? 'is-active' : ''">
2025-06-10 16:17:24 +08:00
<svg-icon icon-class="hide" />
</div>
2025-07-17 15:52:12 +08:00
</el-tooltip>
2025-07-24 18:25:45 +08:00
<el-tooltip placement="top" content="模型偏移">
<div class="footer-btn" @click="doMenu(5)" :class="activeMenu == 5 ? 'is-active' : ''">
<svg-icon icon-class="position" />
</div>
</el-tooltip>
2025-04-22 00:07:38 +08:00
</div>
2025-07-24 18:25:45 +08:00
<div class="bim-setting-tools" v-show="(activeMenu > 0 && activeMenu != 5)">
2025-06-10 16:17:24 +08:00
<div class="tools-title">
<svg-icon icon-class="roam" v-if="activeMenu == 1" />
<svg-icon icon-class="view" v-if="activeMenu == 2" />
<svg-icon icon-class="camera" v-if="activeMenu == 3" />
<svg-icon icon-class="hide" v-if="activeMenu == 4" />
{{ param.title }}
</div>
2025-06-12 18:38:47 +08:00
<el-icon @click="doToolsClose" style="color: #000; font-size: 20px; cursor: pointer" class="tools-close">
2025-06-10 16:17:24 +08:00
<Close />
</el-icon>
2025-06-12 18:38:47 +08:00
<person-roaming v-if="activeMenu == 1" ref="personRoaming" :me="this"></person-roaming>
<custom-viewpoint v-if="activeMenu == 2" ref="customViewpoint" :me="this"></custom-viewpoint>
2025-06-10 16:17:24 +08:00
<viewpoint v-if="activeMenu == 3" ref="viewpoint" :me="this"></viewpoint>
2025-07-25 16:53:07 +08:00
<HideFeature v-show="activeMenu == 4" ref="hideFeature" :me="this"></HideFeature>
2025-06-10 16:17:24 +08:00
</div>
2025-07-24 18:25:45 +08:00
<div class="bim-setting-tools" v-show="showMove">
<div class="tools-title">
<svg-icon icon-class="position" />
{{ param.title }}
</div>
<el-icon @click="doCloseMove" style="color: #000; font-size: 20px; cursor: pointer" class="tools-close">
<Close />
</el-icon>
<MoveModel ref="moveModel" :me="this"></MoveModel>
</div>
2025-06-10 16:17:24 +08:00
</div>
2025-04-22 00:07:38 +08:00
</template>
<script>
2025-06-10 16:17:24 +08:00
import useUserStore from "@/store/modules/user";
import { listBimModel } from "@/api/bim/bimModel";
2025-07-24 18:25:45 +08:00
import { getDefaultViewPoint } from '@/api/bim/bim';
2025-06-10 16:17:24 +08:00
import ModelFloorTree from "./ModelFloorTree.vue";
import PersonRoaming from "./PersonRoaming.vue";
import CustomViewpoint from "./CustomViewpoint.vue";
import Viewpoint from "./Viewpoint.vue";
2025-07-24 18:25:45 +08:00
import MoveModel from "./MoveModel.vue";
import HideFeature from "./HideFeature.vue";
2025-07-17 15:52:12 +08:00
import { ElMessage, ElTooltip } from 'element-plus';
2025-07-25 16:53:07 +08:00
import { getProjectBimConfig } from "@/api/manage/proProjectInfo.js";
2025-07-25 18:52:01 +08:00
import SAPITools from './sapiTools.js'
import APITools from './apiTools.js'
2025-04-22 00:07:38 +08:00
export default {
2025-06-10 16:17:24 +08:00
components: {
ModelFloorTree,
PersonRoaming,
CustomViewpoint,
Viewpoint,
2025-07-24 18:25:45 +08:00
ElTooltip,
MoveModel,
HideFeature,
2025-06-10 16:17:24 +08:00
},
data() {
return {
userStore: {},
isAdmin: false,
projects: [],
currentPrjId: null,
currentComId: null,
subDepts: [],
models: [],
isMobile: false,
showTree: false,
initSuccess: false,
activeMenu: 0,
showModels: [],
param: {},
2025-07-24 18:25:45 +08:00
viewPoint: null,
showGis: false,
movePoint: null,
moveModelId: null,
isMove: false,
showMove: false,
2025-07-25 16:53:07 +08:00
hideParts: [],
bimCfg: {}
2025-06-10 16:17:24 +08:00
};
},
beforeUnmount() {
document.body.classList.remove("is-sapi");
},
mounted() {
document.body.classList.add("is-sapi");
this.userStore = useUserStore();
this.isAdmin = this.userStore.isAdmin;
this.currentPrjId = this.userStore.currentPrjId;
this.currentComId = this.userStore.currentComId;
this.initLoadModel();
2025-07-25 18:52:01 +08:00
2025-07-25 16:53:07 +08:00
getProjectBimConfig(this.currentPrjId).then(d => {
let config = this.$tryToJson(d.msg, {});
this.bimCfg = {
background: config.background || "",
showGis: config.showGis || false,
clientApi: config.clientApi || false
}
2025-07-25 18:52:01 +08:00
if (this.bimCfg.clientApi) {
APITools.initEngine(this);
} else {
SAPITools.initEngine(this);
}
2025-07-25 16:53:07 +08:00
});
2025-06-10 16:17:24 +08:00
},
methods: {
2025-07-24 18:25:45 +08:00
doCloseMove() {
2025-07-25 16:53:07 +08:00
this.$refs.moveModel.resetPosition();
2025-07-24 18:25:45 +08:00
this.showMove = false;
this.activeMenu = -1;
},
modelAdded(point) {
if (this.viewPoint != null) {
this.viewPoint = point;
}
},
doChangeGis() {
if (this.showGis) {
2025-07-25 18:52:01 +08:00
if (this.bimCfg.clientApi) {
api.Public.setGisState(true);
} else {
api.Public.setGisState(true);
api.Public.setTerrainState(false, "http://113.201.2.107:9304/layer.json", false)
api.Public.setGisState(true);
}
2025-07-24 18:25:45 +08:00
} else {
2025-07-25 16:53:07 +08:00
let color = this.bimCfg.background || "rgba(135 ,206 ,250,1)"
api.Public.setGisState(false, color);
api.Public.setSkyBoxState(0)
}
2025-06-12 18:38:47 +08:00
},
2025-06-10 16:17:24 +08:00
doChange() {
this.showModels = api.m_model.keys().toArray();
console.log("--change--");
},
resetScene() {
if (this.$refs.personRoaming) {
this.$refs.personRoaming.isRoaming = false;
}
api.Camera.stopImmersiveRoam();
api.Model.location(api.m_model.keys().toArray()[0]);
api.Plugin.deleteMiniMap();
2025-07-24 18:25:45 +08:00
if (this.viewPoint) {
2025-06-12 18:38:47 +08:00
api.Camera.setViewPort(this.viewPoint);
}
2025-04-22 00:07:38 +08:00
},
2025-06-10 16:17:24 +08:00
doMenu(n) {
2025-07-24 18:25:45 +08:00
if (this.activeMenu == 4) {
api.Public.clearHandler();
api.Feature.getByEvent(false);
}
2025-06-10 16:17:24 +08:00
if (n == this.activeMenu) {
if (n == 0) {
this.resetScene();
2025-07-24 18:25:45 +08:00
if (this.isMove) {
this.activeMenu = 5;
}
2025-04-22 00:07:38 +08:00
}
2025-06-10 16:17:24 +08:00
return;
}
2025-07-25 16:53:07 +08:00
if (this.activeMenu == 5) {
this.doCloseMove()
}
2025-06-10 16:17:24 +08:00
this.activeMenu = n;
if (n == 0) {
this.resetScene();
2025-07-24 18:25:45 +08:00
if (this.isMove) {
this.activeMenu = 5;
}
2025-06-10 16:17:24 +08:00
}
if (n == 1) {
this.param.title = "第一人称漫游";
}
if (n == 2) {
this.param.title = "自定义视点漫游";
}
if (n == 3) {
this.param.title = "视点管理";
}
2025-07-24 18:25:45 +08:00
if (n == 4) {
this.param.title = "构件隐藏管理";
setTimeout(() => {
2025-07-25 16:53:07 +08:00
this.$refs.hideFeature.doHideFeatures(this.hideParts);
2025-07-24 18:25:45 +08:00
}, 800);
}
if (n == 5) {
this.param.title = "模型偏移管理";
this.isMove = true;
this.doModelMove();
} else {
if (this.isMove) {
this.isMove = false;
this.showMove = false;
api.Public.clearHandler(),
api.Public.pickupCoordinate(false);
}
}
},
doModelMove() {
ElMessage.info("请在场景中选择要移动的模型!");
2025-07-25 18:52:01 +08:00
if(this.bimCfg.clientApi){
APITools.doModelMove(this);
}else{
SAPITools.doModelMove(this);
}
2025-07-24 18:25:45 +08:00
},
2025-07-25 16:53:07 +08:00
2025-06-10 16:17:24 +08:00
NotificationPopup(parameter) {
this.param = parameter;
2025-07-24 18:25:45 +08:00
2025-04-23 23:43:26 +08:00
},
2025-06-10 16:17:24 +08:00
doToolsClose() {
this.activeMenu = 0;
this.resetScene();
2025-04-22 00:07:38 +08:00
},
2025-06-10 16:17:24 +08:00
notifClose() {
this.activeMenu = -1;
},
2025-07-25 18:52:01 +08:00
2025-06-10 16:17:24 +08:00
initLoadModel() {
2025-07-24 18:25:45 +08:00
getDefaultViewPoint(this.currentPrjId, 1).then(d => {
let pt = "";
if (d.data && d.data.length > 0) {
pt = d.data[0].viewPosition;
pt = this.$tryToJson(pt, null);
}
2025-07-24 18:25:45 +08:00
if (pt) {
this.viewPoint = pt;
}
});
2025-06-10 16:17:24 +08:00
listBimModel({
pageNum: 1,
pageSize: 10,
comId: this.currentComId,
projectId: this.currentPrjId,
}).then((d) => {
2025-07-24 18:25:45 +08:00
this.models = (d.rows || []).map((it) => {
2025-07-03 16:07:46 +08:00
it.modelId = it.lightweightName;
2025-07-25 16:53:07 +08:00
it.bimCfg = this.$tryToJson(it.bimConfig || "{}", {});
2025-07-24 18:25:45 +08:00
it.visible = false;
2025-07-03 16:07:46 +08:00
it.checked = true;
it.gis = this.$tryToJson(it.gisJson || "{}", {});
return it;
});
2025-06-10 16:17:24 +08:00
if (this.models.length == 0) {
2025-07-17 15:52:12 +08:00
ElMessage.error("暂无模型,请先关联模型");
2025-06-10 16:17:24 +08:00
} else {
this.showTree = true;
}
});
},
},
};
2025-04-22 00:07:38 +08:00
</script>
<style lang="scss">
.bim-setting-page {
2025-06-10 16:17:24 +08:00
position: relative;
height: 100%;
2025-07-24 18:25:45 +08:00
.bim-cfg-tools {
position: absolute;
left: 340px;
top: 20px;
}
2025-06-10 16:17:24 +08:00
#bimSettingContainer {
2025-04-23 23:43:26 +08:00
height: 100%;
2025-06-10 16:17:24 +08:00
}
2025-07-24 18:25:45 +08:00
2025-06-10 16:17:24 +08:00
.footer-box {
position: absolute;
bottom: 10vh;
left: 50%;
margin-left: -75px;
background: #274754;
border-radius: 4px;
2025-07-24 18:25:45 +08:00
2025-06-10 16:17:24 +08:00
.footer-btn {
display: inline-flex;
width: 40px;
height: 40px;
justify-content: center;
align-items: center;
cursor: pointer;
2025-07-24 18:25:45 +08:00
2025-06-10 16:17:24 +08:00
svg {
width: 20px;
height: 20px;
fill: #fff;
}
2025-07-24 18:25:45 +08:00
2025-06-10 16:17:24 +08:00
&:hover {
background: #408edb97;
}
2025-07-24 18:25:45 +08:00
2025-06-10 16:17:24 +08:00
&.is-active {
svg {
fill: rgb(0, 255, 174);
2025-04-25 23:14:21 +08:00
}
2025-06-10 16:17:24 +08:00
}
2025-04-25 23:14:21 +08:00
}
2025-06-10 16:17:24 +08:00
}
2025-07-24 18:25:45 +08:00
2025-06-10 16:17:24 +08:00
.bim-setting-tools {
position: absolute;
top: 80px;
right: 10px;
background: rgba(255, 255, 255, 0.5);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
min-width: 300px;
min-height: 400px;
2025-07-24 18:25:45 +08:00
2025-06-10 16:17:24 +08:00
.tools-title {
padding: 10px;
color: #114c5f;
size: 24px;
2025-05-27 00:14:58 +08:00
}
2025-07-24 18:25:45 +08:00
2025-06-10 16:17:24 +08:00
.tools-close {
position: absolute;
top: 10px;
right: 10px;
cursor: pointer;
2025-04-23 23:43:26 +08:00
}
2025-06-10 16:17:24 +08:00
}
2025-04-22 00:07:38 +08:00
}
2025-06-10 16:17:24 +08:00
</style>