diff --git a/yanzhu-ui-vue3/src/api/bim/bim.js b/yanzhu-ui-vue3/src/api/bim/bim.js index 00d6f891..06e212a5 100644 --- a/yanzhu-ui-vue3/src/api/bim/bim.js +++ b/yanzhu-ui-vue3/src/api/bim/bim.js @@ -92,4 +92,25 @@ export function updateBimInfo(data) { method: "post", data: data, }); -} \ No newline at end of file +} + +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", + }); +}; \ No newline at end of file diff --git a/yanzhu-ui-vue3/src/views/manage/plan/bimSelectTools.js b/yanzhu-ui-vue3/src/views/manage/plan/bimSelectTools.js index c558df80..f771a550 100644 --- a/yanzhu-ui-vue3/src/views/manage/plan/bimSelectTools.js +++ b/yanzhu-ui-vue3/src/views/manage/plan/bimSelectTools.js @@ -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, }; diff --git a/yanzhu-ui-vue3/src/views/manage/plan/bimSelectionDialog.vue b/yanzhu-ui-vue3/src/views/manage/plan/bimSelectionDialog.vue index 955b16ce..2ca3b001 100644 --- a/yanzhu-ui-vue3/src/views/manage/plan/bimSelectionDialog.vue +++ b/yanzhu-ui-vue3/src/views/manage/plan/bimSelectionDialog.vue @@ -6,11 +6,28 @@