进度计划和BIM绑定

dev_xd
lj7788@126.com 2025-06-27 18:14:29 +08:00
parent e34ff19559
commit d334651bd7
4 changed files with 314 additions and 25 deletions

View File

@ -93,3 +93,24 @@ export function updateBimInfo(data) {
data: data,
});
}
export function getPlanBimInfo(id){
return request({
url: `/manage/api/bim/plan/getBimInfo?id=${id}`,
method: "get"
});
}
export function getPlanAllBimInfo(prjId){
return request({
url: `/manage/api/bim/plan/getAllBimInfo?projectId=${prjId}`,
method: "get"
});
}
export function modelTreeAllChild (name, pid) {
return request({
url: "/manage/bim/modelInfo/modelTreeAllChild/" + name + "?pid=" + pid,
method: "get",
});
};

View File

@ -1,3 +1,32 @@
import { modelTreeAllChild } from "@/api/bim/bim";
function selectFeature(that, featureId) {
let api = bimSelectionDlgApi;
if (that.selectItems.includes(featureId)) {
api.Feature.setColor(featureId, "rgba(255,255,255,1)");
let index = that.selectItems.indexOf(featureId);
if (index > -1) {
that.selectItems.splice(index, 1);
}
} else {
api.Feature.setColor(featureId, "rgba(255,0,255,1)");
that.selectItems.push(featureId);
}
}
function hideFeatures(that) {
let tmps = that.allBimData.filter((it) => it.id != that.plan.id);
tmps.forEach((it) => {
console.log("hide-->", it.bim);
it.bim.forEach((it) => {
hideFeature(that, it);
});
});
}
function hideFeature(that, featureId) {
let api = bimSelectionDlgApi;
api.Feature.setVisible(featureId, false);
}
function selectSingle(that) {
let api = bimSelectionDlgApi;
api.Public.clearHandler();
@ -5,20 +34,164 @@ function selectSingle(that) {
if (n && n["id"]) {
let featureId = n.id;
let modelId = featureId.split("^")[0];
if(that.selectItems.includes(featureId)){
api.Feature.setColor(featureId, "rgba(255,255,255,1)");
let index = that.selectItems.indexOf(featureId);
if (index > -1) {
that.selectItems.splice(index, 1);
}
}else{
api.Feature.setColor(featureId, "rgba(255,0,255,1)");
that.selectItems.push(featureId);
}
selectFeature(that, featureId);
}
});
}
function clearAllSelection(that) {
let api = bimSelectionDlgApi;
api.Public.clearHandler();
that.selectItems.forEach((it) => {
selectFeature(that, it);
});
}
function initBim(that) {
console.log("initBim");
let tmps = that.allBimData.filter((it) => it.id == that.plan.id);
if (tmps.length > 0) {
console.log("selected-->", tmps[0].bim);
tmps[0].bim.forEach((it) => {
selectFeature(that, it);
});
}
}
function getSelectFeatureIds(that) {
let tmps = that.allBimData.filter((it) => it.id == that.plan.id);
if (tmps.length > 0) {
return tmps[0].bim || [];
}
return [];
}
// 加载部分模型(计划中绑定的模型)
function partLoadModel(that) {
let featureIds = getSelectFeatureIds(that);
let api = bimSelectionDlgApi;
let obj = {};
for (let i = 0; i < featureIds.length; i++) {
let it = featureIds[i];
let tmps = it.split("^");
let modelId = tmps[0];
if (!obj[modelId]) {
obj[modelId] = [];
}
obj[modelId].push(it);
}
for (let modelId in obj) {
let tmps = that.models.filter((it) => it.modelId == modelId);
setTimeout(() => {
that.$refs.tree.setChecked(modelId, true, true);
}, 1000);
if (tmps.length > 0) {
let url = `${window.config.modelUrl}/Tools/output/model/${modelId}/root.glt`;
that.partLoad = true;
api.Model.addPart(
url,
modelId,
obj[modelId].join("#"),
(res) => {},
(res) => {
console.log("load part success", res);
that.viewPoint = p;
that.$message.info("模型加载完成");
that.doMenu(2);
initBim(that);
},
{
FlyTo: true,
}
);
}
}
}
//构建树形数据
function buildTreeData(that) {
that.modelTrees = [
{
title: "项目模型",
level: 0,
type: "root",
key: "root",
children: [],
hadLoad: true,
},
];
that.models.forEach((d) => {
let node = {
title: d.modelName,
level: 1,
type: "model",
hasLoad: false,
modelId: d.lightweightName,
key: d.lightweightName,
externalId: "0",
glid: "",
children: [],
data: d,
};
that.modelTrees[0].children.push(node);
getModelFeatures(that, d.lightweightName, node);
});
that.treeExpendedKeys.push("root");
}
//获取模型所有构件
function getModelFeatures(that, modelId, node) {
let tmps = that.allBimData.filter((it) => it.id != that.plan.id);
tmps.forEach((it) => {
console.log("hide-->", it.bim);
it.bim.forEach((it) => {
if (!that.readlyParts.includes(it)) {
that.readlyParts.push(it);
}
});
});
//获取模型构件
modelTreeAllChild(modelId, "").then((res) => {
let objs = res.data || []
objs.forEach((o) => {
o.modelId=modelId
o.featureId=o.modelId+"^"+o.externalId
o.name=o.name||'';
o.name=o.name.replaceAll('"',"").replaceAll("'","").replaceAll('\\','');
o.info=`[${o.externalId}]${o.groupname}-${o.name}`
if(o.externalId == "0"){
return;
}
let featureId=o.modelId+"^"+o.externalId;
if (!that.allParts.includes(featureId)) {
that.allParts.push(featureId);
}
});
that.allFeatures = objs;
let makeTree = (tmps) => {
tmps.forEach((item) => {
item.children = objs.filter((it) => it.pglid == item.glid);
if (item.children.length > 0) {
makeTree(item.children);
}
item.hasLoad = true;
item.title = item.name;
item.key = item.glid;
item.modelId = node.modelId;
});
return tmps;
};
node.children = makeTree(objs.filter((item) => item.level == 0));
that.treeKey++;
});
that.showParts = that.allParts.filter((it) => !that.hideParts.includes(it));
}
export default {
selectSingle,
initBim,
clearAllSelection,
partLoadModel,
buildTreeData,
};

View File

@ -6,11 +6,28 @@
<div class="div-left" :class="{ 'is-hide': !leftExpend }">
<div class="div-left-title">
<el-tabs v-model="activeTab">
<el-tab-pane label="结构树" name="a1"> </el-tab-pane>
<el-tab-pane label="结构树" name="a1">
<div class="model-tree scroll">
<el-tree
:key="treeKey"
ref="tree"
:default-expanded-keys="treeExpendedKeys"
:props="{
children: 'children',
label: 'title',
}"
node-key="key"
@check="onCheckTree"
:data="modelTrees"
show-checkbox></el-tree>
</div>
</el-tab-pane>
<el-tab-pane label="已关联" name="a2">
<div class="sel-list scroll">
<div v-for="(it, idx) in selectItems" :key="idx" class="div-sel-item">
<div>{{ it.split("^")[1] }}</div>
<div v-for="(it, idx) in getSelectItems(selectItems)" :key="idx" class="div-sel-item">
<el-tooltip placement="bottom" :content="it.info">
<div class="sel-item-info">{{ it.info }}</div>
</el-tooltip>
<el-button link>删除</el-button>
</div>
</div>
@ -63,13 +80,14 @@
import useUserStore from "@/store/modules/user";
import { listBimModel } from "@/api/bim/bimModel";
import bimTools from "./bimSelectTools";
import { updateBimInfo } from "@/api/bim/bim";
import { updateBimInfo, getPlanAllBimInfo } from "@/api/bim/bim";
import { ElMessage, ElMessageBox } from "element-plus";
export default {
data() {
return {
title: "任务计划绑定BIM",
show: false,
partLoad: false, //
plan: null,
currentPrjId: null,
currentComId: null,
@ -81,6 +99,14 @@ export default {
activeMenu: 0,
elId: 0,
selectItems: [],
allBimData: [],
treeKey: 0,
modelTrees: [],
treeExpendedKeys: [],
allFeatures: [], //
allParts: [], //ID
showParts: [], //ID
readlyParts: [], //ID
};
},
beforeDestroy() {
@ -92,17 +118,24 @@ export default {
}
},
methods: {
onCheckTree(node, event) {},
getSelectItems() {
return this.selectItems.map((it) => {
return this.allFeatures.find((item) => item.featureId == it);
});
},
doSave() {
updateBimInfo({
id: this.plan.id,
text: JSON.stringify(this.selectItems),
}).then((res) => {
console.log(res);
if(res.success){
ElMessage.success('保存成功')
this.show = false;
}else{
ElMessage.error('保存失败')
if (res.success) {
ElMessage.success("保存成功");
this.show = false;
this.$emit("success");
} else {
ElMessage.error("保存失败");
}
});
},
@ -113,6 +146,7 @@ export default {
this.resetScene();
break;
case 1:
bimTools.clearAllSelection(this);
break;
case 2:
bimTools.selectSingle(this);
@ -124,12 +158,30 @@ export default {
}
},
showDialog(plan) {
window.bimDlg = this;
this.plan = plan;
this.show = true;
this.activeTab = "a1";
this.userStore = useUserStore();
this.currentPrjId = this.userStore.currentPrjId;
this.currentComId = this.userStore.currentComId;
this.selectItems = [];
this.allBimData = [];
this.treeKey = 0;
this.partLoad = false;
this.modelTrees = [];
this.treeExpendedKeys = [];
this.allParts = [];
this.hideParts = [];
this.readlyParts = [];
this.allFeatures = [];
getPlanAllBimInfo(this.plan.projectId).then((res) => {
this.allBimData = (res.data || []).map((it) => {
it.bim = this.$tryToJson(it.bimId || "[]", []);
return it;
});
});
this.initEngine();
},
initEngine() {
@ -198,13 +250,19 @@ export default {
comId: this.currentComId,
projectId: this.currentPrjId,
}).then((d) => {
this.models = d.rows || [];
this.models = (d.rows || []).map((it) => {
it.modelId = it.lightweightName;
it.gis = this.$tryToJson(it.gisJson || "{}", {});
return it;
});
if (this.models.length == 0) {
this.$modal.msgError("暂无模型,请先关联模型");
} else {
this.models.forEach((item) => {
this.addModel(item.lightweightName);
});
bimTools.buildTreeData(this);
bimTools.partLoadModel(this);
// this.models.forEach((item) => {
// this.addModel(item.lightweightName);
// });
}
});
},
@ -222,6 +280,8 @@ export default {
bimSelectionDlgApi.Camera.getViewPort((p) => {
this.viewPoint = p;
this.$message.info("模型加载完成");
bimTools.initBim(this);
this.doMenu(2);
});
}, 1000);
}
@ -359,6 +419,13 @@ export default {
line-height: 30px;
padding: 0px 10px;
margin-top: 5px;
.sel-item-info {
width: calc(100% - 40px);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
cursor: pointer;
}
.el-button {
position: absolute;
right: 10px;
@ -367,6 +434,31 @@ export default {
}
}
}
.model-tree {
height: calc(100% - 36px);
overflow-y: auto;
.el-tree {
background: transparent;
color: #eee;
.el-checkbox {
color: #45fdfe;
}
.el-tree-node {
&:focus {
& > .el-tree-node__content {
background: #3489d966;
&:hover {
background: #3489d966;
}
}
}
.el-tree-node__content:hover {
background: #3489d966;
}
}
}
}
}
}
</style>

View File

@ -69,7 +69,7 @@
<el-table-column label="负责人" align="center" prop="operator" width="120" />
<el-table-column label="班组名称" align="center" prop="groupName" width="120" />
</el-table>
<bim-selection-dialog ref="bimDlg"></bim-selection-dialog>"
<bim-selection-dialog ref="bimDlg" @success="doSelectSuccess"></bim-selection-dialog>"
</div>
</template>
@ -141,6 +141,9 @@ const data = reactive({
const { queryParams, form, rules } = toRefs(data);
function doSelectSuccess(){
handleQuery();
}
function buildTree(all, id) {
let tmps = all.filter((d) => d.parentId == id);
if (tmps.length > 0) {