BIM设置开发

dev_xd
lj7788@126.com 2025-07-25 16:53:07 +08:00
parent 7451283d13
commit add9f6a97a
6 changed files with 220 additions and 73 deletions

View File

@ -1,6 +1,21 @@
<template> <template>
<el-dialog title="项目BIM设置" width="600" :modal-append-to-body="false" :close-on-click-modal="false" v-model="show" <el-dialog title="项目BIM设置" width="300" :modal-append-to-body="false" :close-on-click-modal="false" v-model="show"
class="bim-config-dialog footer-center"> class="bim-config-dialog footer-center noscroll">
<el-form ref="form" :model="cfg" label-width="120px">
<el-form-item label="是否显示GIS" prop="showGis">
<el-switch v-model="cfg.showGis" active-text="是" inactive-text="否"></el-switch>
</el-form-item>
<el-form-item label="背景色" prop="background" v-show="!cfg.showGis" :key="cfg.showGis">
<el-color-picker v-model="cfg.background" show-alpha />
</el-form-item>
<el-form-item label="客户端渲染" prop="clientApi">
<el-switch v-model="cfg.clientApi" active-text="是" inactive-text="否"></el-switch>
</el-form-item>
</el-form>
<div class="footer-btn" style="text-align: center;">
<el-button type="primary" @click="onSubmit"></el-button>
<el-button @click="onCancel"></el-button>
</div>
</el-dialog> </el-dialog>
</template> </template>
@ -12,9 +27,29 @@ export default {
return { return {
show: false, show: false,
currentPrjId: null, currentPrjId: null,
cfg:{
showGis:false,
background:"",
clientApi:false,
}
} }
}, },
methods: { methods: {
onSubmit(){
this.$modal.confirm("确定保存吗?").then(() => {
updateProjectBimConfig(this.currentPrjId,{
showGis:this.cfg.showGis,
background:this.cfg.background,
clientApi:this.cfg.clientApi,
}).then(res=>{
this.$message.success("保存成功");
this.show=false;
})
})
},
onCancel(){
this.show=false;
},
showDialog() { showDialog() {
this.userStore = useUserStore(); this.userStore = useUserStore();
this.currentPrjId = this.userStore.currentPrjId; this.currentPrjId = this.userStore.currentPrjId;
@ -23,8 +58,13 @@ export default {
}, },
loadData(){ loadData(){
getProjectBimConfig(this.currentPrjId).then(d=>{ getProjectBimConfig(this.currentPrjId).then(d=>{
debugger;
console.log(d) if(d.msg){
let config=this.$tryToJson(d.msg,{});
this.cfg.background=config.background||"";
this.cfg.showGis=config.showGis||false;
this.cfg.clientApi=config.clientApi||false;
}
}) })
} }
} }

View File

@ -2,6 +2,7 @@
<div class="hide-features"> <div class="hide-features">
<div style="padding: 0px 10px 10px" v-show="hideParts.length > 0"> <div style="padding: 0px 10px 10px" v-show="hideParts.length > 0">
<el-button @click="delAllDelList"></el-button> <el-button @click="delAllDelList"></el-button>
<el-button @click="doSaveHide"></el-button>
</div> </div>
<div class="sel-list scroll hide-list" :key="hideEl"> <div class="sel-list scroll hide-list" :key="hideEl">
<div v-for="(it, idx) in hideParts" :key="idx" class="div-sel-item"> <div v-for="(it, idx) in hideParts" :key="idx" class="div-sel-item">
@ -16,7 +17,7 @@
<script> <script>
import { import {
getModelFeatureInfos, getModelFeatureInfos,updateBimModel
} from "@/api/bim/bimModel"; } from "@/api/bim/bimModel";
export default { export default {
props: { props: {
@ -32,7 +33,40 @@ export default {
hideEl: 0, hideEl: 0,
} }
}, },
watch:{
hideParts(val){
this.me.hideParts=val;
}
},
methods: { methods: {
doSaveHide(){
this.$modal.confirm("确定保存吗?").then(() => {
let obj={};
this.hideParts.forEach(it=>{
let modelId=it.modelId;
if(!obj[modelId]){
obj[modelId]=[];
}
obj[modelId].push({
featureId:it.featureId,
externalId:it.externalId,
modelId:it.modelId,
info:it.info
});
})
for(let modelId in obj){
let modelInfo=this.me.models.find(it=>it.modelId==modelId);
if(modelInfo){
modelInfo.bimCfg.hideParts=obj[modelId];
modelInfo.bimConfig=JSON.stringify(modelInfo.bimCfg);
updateBimModel(modelInfo).then(res => {
this.$message.success("保存成功");
});
}
}
});
},
delAllDelList() { delAllDelList() {
this.$modal.confirm("确定删除吗?").then(() => { this.$modal.confirm("确定删除吗?").then(() => {
api.Feature.setVisible(this.hideParts.map(it => it.featureId).join("#"), true); api.Feature.setVisible(this.hideParts.map(it => it.featureId).join("#"), true);
@ -44,8 +78,9 @@ export default {
api.Feature.setVisible(this.hideParts[idx].featureId, true); api.Feature.setVisible(this.hideParts[idx].featureId, true);
this.hideParts.splice(idx, 1); this.hideParts.splice(idx, 1);
}, },
doHideFeatures() { doHideFeatures(hideParts) {
let that = this; let that = this;
this.hideParts=hideParts||[];
api.Public.clearHandler(); api.Public.clearHandler();
api.Feature.getByEvent(false); api.Feature.getByEvent(false);
api.Feature.getByEvent(true, async (n) => { api.Feature.getByEvent(true, async (n) => {

View File

@ -23,6 +23,10 @@
import { getModelTree, getTreeAllLeafChild } from "@/api/bim/bimModel"; import { getModelTree, getTreeAllLeafChild } from "@/api/bim/bimModel";
export default { export default {
props: { props: {
me: {
type: Object,
default: () => ({}),
},
projectMessage: { projectMessage: {
type: Object, type: Object,
default: undefined, default: undefined,
@ -140,7 +144,6 @@ export default {
let o = this.convertFeatureInfo(it, data.modelId); let o = this.convertFeatureInfo(it, data.modelId);
return o; return o;
}); });
//addToAllFeatures(that, tmps);
resolve(tmps); resolve(tmps);
}); });
}, },
@ -186,7 +189,9 @@ export default {
api.Model.add( api.Model.add(
url, url,
modelId, modelId,
() => { }, () => {
console.log("加载模型成功2");
},
() => { () => {
console.log("加载模型成功"); console.log("加载模型成功");
let modelInfo = this.projectMessage.find(m => m.modelId == modelId); let modelInfo = this.projectMessage.find(m => m.modelId == modelId);
@ -202,6 +207,11 @@ export default {
if (rotateZ * 1 != 0) { if (rotateZ * 1 != 0) {
api.Model.rotate(0, 0, rotateZ, modelId) api.Model.rotate(0, 0, rotateZ, modelId)
} }
if (cfg && cfg.hideParts) {
cfg.hideParts.forEach(it => {
this.me.hideParts.push(it);
})
}
} }
cb && cb(); cb && cb();
this.$emit("change"); this.$emit("change");
@ -214,6 +224,22 @@ export default {
this.$emit("modelAdd", p); this.$emit("modelAdd", p);
}); });
} }
let hideCnt = 0;
let hideFn = () => {
hideCnt++;
if(hideCnt>30){
return;
}
setTimeout(() => {
let featureIds = (this.me.hideParts || []).map(it => it.featureId);
if (featureIds.length > 0) {
console.log(featureIds.join("#"))
api.Feature.setVisible(featureIds.join("#"), false);
}
hideFn();
}, 100)
};
hideFn();
}, 1000); }, 1000);
} }
); );

View File

@ -1,7 +1,15 @@
<template> <template>
<div class="move-model"> <div class="move-model">
<el-form ref="form" :model="form" label-width="40px"> <el-form ref="form" :model="form" label-width="40px">
<div class="nav-title">位置</div> <div class="move-button">
<el-button type="primary" @click="doModelMove">
<svg-icon icon-class="position" /> 在地图上移动模型
</el-button>
</div>
<div class="nav-title">位置
</div>
<el-form-item label="经度"> <el-form-item label="经度">
<el-input v-model="form.x"></el-input> <el-input v-model="form.x"></el-input>
</el-form-item> </el-form-item>
@ -33,6 +41,7 @@
</template> </template>
<script> <script>
import { ElMessage, ElTooltip } from 'element-plus';
import { updateBimModel } from "@/api/bim/bimModel" import { updateBimModel } from "@/api/bim/bimModel"
export default { export default {
props: { props: {
@ -58,11 +67,43 @@ export default {
y: 0, y: 0,
z: 0, z: 0,
rotateZ: 0 rotateZ: 0
} },
movePoint: null
} }
}, },
methods: { methods: {
doModelMove() {
ElMessage.info("左键单击选择移动位置,右键单击结束操作!");
let that = this;
api.Public.event("LEFT_CLICK", ((n) => {
api.Public.pickupCoordinate(true, ((n) => {
api.Public.convertWorldToCartographicLocation(n, m => {
api.Model.moveToPosition(m, 0, this.modelId)
if (this.saveData.rotateZ != 0) {
api.Model.rotate(0, 0, this.saveData.rotateZ, this.modelId)
}
that.movePoint = m;
});
}
))
}
)),
api.Public.event("RIGHT_CLICK", ((n) => {
api.Public.clearHandler(),
api.Public.pickupCoordinate(false);
ElMessage.info("已结束模型移动!"),
that.activeMenu = -1;
let pt = that.movePoint;
this.form.x = pt[0]
this.form.y = pt[1]
this.form.z = pt[2]
this.saveData.x = this.form.x;
this.saveData.y = this.form.y;
this.saveData.z = this.form.z;
}));
},
onCancel() { onCancel() {
this.resetPosition();
this.me.showMove = false; this.me.showMove = false;
this.me.activeMenu = -1; this.me.activeMenu = -1;
}, },
@ -71,6 +112,7 @@ export default {
let model = this.me.models.find(model => model.modelId == this.modelId); let model = this.me.models.find(model => model.modelId == this.modelId);
if (model) { if (model) {
model.bimConfig = JSON.stringify(this.saveData); model.bimConfig = JSON.stringify(this.saveData);
model.bimCfg = this.saveData;
updateBimModel(model).then(res => { updateBimModel(model).then(res => {
this.$message.success("保存成功"); this.$message.success("保存成功");
this.me.showMove = false; this.me.showMove = false;
@ -99,28 +141,30 @@ export default {
this.saveData.rotateZ = this.form.rotateZ; this.saveData.rotateZ = this.form.rotateZ;
}, },
init(pt, modelId) { resetPosition() {
if (pt) { let modelInfo = this.me.models.find(model => model.modelId == this.modelId);
this.form.x = pt[0] if (modelInfo) {
this.form.y = pt[1] let cfg = modelInfo.bimCfg;
this.form.z = pt[2] let x = cfg?.x || 0;
} else { let y = cfg?.y || 0;
this.form.x = 0 let z = cfg?.z || 0;
this.form.y = 0 let rotateZ = cfg?.rotateZ || 0;
this.form.z = 0 if (x * 1 + y * 1 + z * 1 != 0) {
api.Model.moveToPosition([x, y, z], 0, this.modelId)
}
if (rotateZ * 1 != 0) {
api.Model.rotate(0, 0, rotateZ, this.modelId)
}
} }
this.saveData.x = this.form.x;
this.saveData.y = this.form.y;
this.saveData.z = this.form.z;
let modelInfo = this.me.models.find(m => m.modelId == modelId);
this.form.rotateZ = modelInfo?.bimCfg?.rotateZ || 0;
this.modelId = modelId
}, },
updatePosition() { updatePosition() {
api.Model.moveToPosition([this.form.x, this.form.y, this.form.z], 0, this.modelId) api.Model.moveToPosition([this.form.x, this.form.y, this.form.z], 0, this.modelId)
this.saveData.x = this.form.x; this.saveData.x = this.form.x;
this.saveData.y = this.form.y; this.saveData.y = this.form.y;
this.saveData.z = this.form.z; this.saveData.z = this.form.z;
if (this.saveData.rotateZ != 0) {
api.Model.rotate(0, 0, this.saveData.rotateZ, this.modelId)
}
}, },
updateRotate() { updateRotate() {
@ -145,6 +189,12 @@ export default {
.move-model { .move-model {
padding: 0px 10px 20px; padding: 0px 10px 20px;
.move-button {
position: absolute;
right: 10px;
top: 45px;
}
.nav-title { .nav-title {
background: linear-gradient(45deg, #00000033, transparent); background: linear-gradient(45deg, #00000033, transparent);
line-height: 40px; line-height: 40px;

View File

@ -4,7 +4,7 @@
<div class="bim-cfg-tools"> <div class="bim-cfg-tools">
<el-switch v-model="showGis" @change="doChangeGis"></el-switch>GIS <el-switch v-model="showGis" @change="doChangeGis"></el-switch>GIS
</div> </div>
<model-floor-tree ref="modelFloorTree" @change="doChange" @modelAdd="modelAdded" :projectMessage="models" <model-floor-tree ref="modelFloorTree" :me="this" @change="doChange" @modelAdd="modelAdded" :projectMessage="models"
v-if="showTree"></model-floor-tree> v-if="showTree"></model-floor-tree>
<div class="footer-box" v-if="showModels.length > 0"> <div class="footer-box" v-if="showModels.length > 0">
<el-tooltip placement="top" content="主视图"> <el-tooltip placement="top" content="主视图">
@ -52,7 +52,7 @@
<person-roaming v-if="activeMenu == 1" ref="personRoaming" :me="this"></person-roaming> <person-roaming v-if="activeMenu == 1" ref="personRoaming" :me="this"></person-roaming>
<custom-viewpoint v-if="activeMenu == 2" ref="customViewpoint" :me="this"></custom-viewpoint> <custom-viewpoint v-if="activeMenu == 2" ref="customViewpoint" :me="this"></custom-viewpoint>
<viewpoint v-if="activeMenu == 3" ref="viewpoint" :me="this"></viewpoint> <viewpoint v-if="activeMenu == 3" ref="viewpoint" :me="this"></viewpoint>
<HideFeature v-if="activeMenu == 4" ref="hideFeature" :me="this"></HideFeature> <HideFeature v-show="activeMenu == 4" ref="hideFeature" :me="this"></HideFeature>
</div> </div>
<div class="bim-setting-tools" v-show="showMove"> <div class="bim-setting-tools" v-show="showMove">
@ -80,6 +80,7 @@ import Viewpoint from "./Viewpoint.vue";
import MoveModel from "./MoveModel.vue"; import MoveModel from "./MoveModel.vue";
import HideFeature from "./HideFeature.vue"; import HideFeature from "./HideFeature.vue";
import { ElMessage, ElTooltip } from 'element-plus'; import { ElMessage, ElTooltip } from 'element-plus';
import { getProjectBimConfig } from "@/api/manage/proProjectInfo.js";
export default { export default {
components: { components: {
ModelFloorTree, ModelFloorTree,
@ -111,6 +112,8 @@ export default {
moveModelId: null, moveModelId: null,
isMove: false, isMove: false,
showMove: false, showMove: false,
hideParts: [],
bimCfg: {}
}; };
}, },
beforeUnmount() { beforeUnmount() {
@ -124,9 +127,18 @@ export default {
this.currentComId = this.userStore.currentComId; this.currentComId = this.userStore.currentComId;
this.initLoadModel(); this.initLoadModel();
this.initEngine(); this.initEngine();
getProjectBimConfig(this.currentPrjId).then(d => {
let config = this.$tryToJson(d.msg, {});
this.bimCfg = {
background: config.background || "",
showGis: config.showGis || false,
clientApi: config.clientApi || false
}
});
}, },
methods: { methods: {
doCloseMove() { doCloseMove() {
this.$refs.moveModel.resetPosition();
this.showMove = false; this.showMove = false;
this.activeMenu = -1; this.activeMenu = -1;
}, },
@ -141,7 +153,9 @@ export default {
api.Public.setTerrainState(false, "http://113.201.2.107:9304/layer.json", false) api.Public.setTerrainState(false, "http://113.201.2.107:9304/layer.json", false)
api.Public.setGisState(true); api.Public.setGisState(true);
} else { } else {
api.Public.setGisState(false); let color = this.bimCfg.background || "rgba(135 ,206 ,250,1)"
api.Public.setGisState(false, color);
api.Public.setSkyBoxState(0)
} }
}, },
doChange() { doChange() {
@ -173,6 +187,9 @@ export default {
} }
return; return;
} }
if (this.activeMenu == 5) {
this.doCloseMove()
}
this.activeMenu = n; this.activeMenu = n;
if (n == 0) { if (n == 0) {
this.resetScene(); this.resetScene();
@ -192,13 +209,12 @@ export default {
if (n == 4) { if (n == 4) {
this.param.title = "构件隐藏管理"; this.param.title = "构件隐藏管理";
setTimeout(() => { setTimeout(() => {
this.$refs.hideFeature.doHideFeatures(); this.$refs.hideFeature.doHideFeatures(this.hideParts);
}, 800); }, 800);
} }
if (n == 5) { if (n == 5) {
this.param.title = "模型偏移管理"; this.param.title = "模型偏移管理";
//this.showMove = true;
this.isMove = true; this.isMove = true;
this.doModelMove(); this.doModelMove();
} else { } else {
@ -217,7 +233,6 @@ export default {
api.Feature.getByPosition([e.x, e.y], (n) => { api.Feature.getByPosition([e.x, e.y], (n) => {
if (n && n["id"]) { if (n && n["id"]) {
let modelId = n.id.split("^")[0]; let modelId = n.id.split("^")[0];
//this.modelMove(modelId);
this.showMove = true; this.showMove = true;
this.$refs.moveModel.initData(modelId) this.$refs.moveModel.initData(modelId)
} else { } else {
@ -227,32 +242,7 @@ export default {
}); });
}, },
modelMove(modelId) {
ElMessage.info("左键单击选择移动位置,右键单击结束操作!");
let that = this;
api.Public.event("LEFT_CLICK", ((n) => {
api.Public.pickupCoordinate(true, ((n) => {
api.Public.convertWorldToCartographicLocation(n, m => {
api.Model.moveToPosition(m, 0, modelId)
that.movePoint = m;
that.moveModelId = modelId;
});
}
))
}
)),
api.Public.event("RIGHT_CLICK", ((n) => {
api.Public.clearHandler(),
api.Public.pickupCoordinate(false);
ElMessage.info("已结束模型移动!"),
that.activeMenu = -1;
that.onmoveCilck(t)
}));
},
onmoveCilck() {
this.showMove = true;
this.$refs.moveModel.init(this.movePoint, this.moveModelId)
},
NotificationPopup(parameter) { NotificationPopup(parameter) {
this.param = parameter; this.param = parameter;
@ -310,6 +300,12 @@ export default {
showAxes: true, // XYZ线 showAxes: true, // XYZ线
}; };
api.Plugin.initNavCube(mapOptions); api.Plugin.initNavCube(mapOptions);
if (this.bimCfg.showGis) {
this.showGis = true;
this.doChangeGis();
} else if (this.bimCfg.background) {
api.Public.setGisState(false, this.bimCfg.background);
}
} }
); );
}, },

View File

@ -204,7 +204,7 @@ function handleBim(row) {
getPlan(row.id).then((response) => { getPlan(row.id).then((response) => {
row.bimId = response.data.bimId; row.bimId = response.data.bimId;
row.hadLoadBim=true; row.hadLoadBim=true;
row.bim = this.$tryToJson(row.bimId || "[]", []); row.bim = proxy.$tryToJson(row.bimId || "[]", []);
row.hasBim =row.bimId && row.bimId.length > 0; row.hasBim =row.bimId && row.bimId.length > 0;
loading.value = false; loading.value = false;
bimDlg.value.showDialog(row, data.planAll); bimDlg.value.showDialog(row, data.planAll);