修改计划绑定

dev_xd
haha 2025-07-16 00:30:20 +08:00
parent 1a947a0457
commit dc068003f7
6 changed files with 184 additions and 152 deletions

View File

@ -1,5 +1,11 @@
import { modelTreeAllChild } from "@/api/bim/bim";
import { getModelTree, getTreeAllLeafChild, getModelFeatureInfo, getModelFeatureInfos, modelTreeAllLeafChildByGlids } from "@/api/bim/bimModel";
import {
getModelTree,
getTreeAllLeafChild,
getModelFeatureInfo,
getModelFeatureInfos,
modelTreeAllLeafChildByGlids,
} from "@/api/bim/bimModel";
import { MergeArray, DelArray } from "@/utils/index";
import { ElMessage } from "element-plus";
function selectFeature(that, featureId) {
@ -123,56 +129,62 @@ function initBim(that) {
let tmps = that.allBimData.filter((it) => it.id == that.plan.id);
if (tmps.length > 0) {
tmps[0].bim.forEach((it) => {
if (that.allFeatures.filter((f) => f.featureId == it.featureId).length == 0) {
if (
that.allFeatures.filter((f) => f.featureId == it.featureId).length == 0
) {
that.allFeatures.push(it);
}
selectFeature(that, it.featureId);
});
}
tmps = that.allBimData.filter((it) => it.id != that.plan.id);
tmps.forEach((it) => {
it.bim.forEach((it) => {
if (that.readlyParts.filter((f) => f.featureId == it.featureId).length == 0) {
that.readlyParts.push(it.featureId);
}
});
});
// 合并that.readlyParts和tmps中的featureId并去重
const tmpsFeatureIds = tmps.flatMap((item) =>
item.bim.map((b) => b.featureId)
);
that.readlyParts = [...new Set([...that.readlyParts, ...tmpsFeatureIds])];
}
function getSelectFeatureIds(that) {
let tmps = that.allBimData.filter((it) => it.id == that.plan.id);
if (tmps.length > 0) {
return tmps[0].bim || [];
return (tmps[0].bim || []).map((it) => it.featureId);
}
return [];
}
function addAllModels(that, cb) {
let api = bimSelectionDlgApi;
loadModels(that);
setTimeout(() => {
that.models.forEach(model => {
api.Model.setVisible(model.modelId, true);
api.Model.original(model.modelId);
that.$refs.tree.setChecked(model.modelId, true, true)
let func = () => {
if (that.loadedModelCount == that.models.length) {
setTimeout(() => {
cb && cb();
}, 400)
});
}, 1000)
that.models.forEach((model) => {
api.Model.setVisible(model.modelId, true);
api.Model.original(model.modelId);
that.$refs.tree.setChecked(model.modelId, true, true);
setTimeout(() => {
cb && cb();
}, 400);
});
}, 1000);
} else {
setTimeout(func, 100);
}
};
func();
}
// 加载部分模型(计划中绑定的模型)
function partLoadModel(that) {
let featureIds = getSelectFeatureIds(that);
let api = bimSelectionDlgApi;
addAllModels(that, () => {
let featureIds = getSelectFeatureIds(that);
if (featureIds.length > 0) {
let tmps=featureIds.map(it=>it);
let tmpsIds2 = tmps.splice(0, 1000);
let tmps = featureIds.map((it) => it);
let tmpsIds2 = tmps.splice(0, 500);
api.Feature.showFeatures(tmpsIds2.join("#"));
setFeatueVisible(tmps, true);
initBim(that)
initBim(that);
api.Feature.setColor(featureIds.join("#"), "rgba(255,0,255,1)");
that.$message.info("模型加载完成");
that.bimLoaded = true;
@ -191,74 +203,7 @@ function partLoadModel(that) {
};
func();
}
})
}
// 加载部分模型(计划中绑定的模型)
function partLoadModelxxx(that) {
let featureInfos = getSelectFeatureIds(that);
let api = bimSelectionDlgApi;
let obj = {};
for (let i = 0; i < featureInfos.length; i++) {
let it = featureInfos[i].featureId;
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);
}, 3000);
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) => {
setTimeout(() => {
if (that.viewPoint) {
api.Camera.setViewPort(that.viewPoint);
} else {
api.Camera.getViewPort((p) => {
that.viewPoint = p;
});
}
}, 1000);
that.$message.info("模型加载完成");
that.bimLoaded = true;
that.doMenu(2);
initBim(that);
},
{
FlyTo: true,
}
);
}
}
if (featureInfos.length == 0) {
setTimeout(() => {
that.$refs.tree.setChecked("root", true, true);
}, 3000);
loadModels(that);
initBim(that);
let func = () => {
if (that.loadedModelCount == that.models.length) {
setTimeout(() => {
setFeatueShowOrHide(that, []);
}, 1000);
} else {
setTimeout(func, 100);
}
};
func();
}
});
}
//构建树形数据
@ -343,7 +288,10 @@ async function setTreeNodeChecked(that, node, event) {
}
} else {
let isPartLoad = false;
if (!that.models.find((d) => d.modelId == node.modelId).visible && checked) {
if (
!that.models.find((d) => d.modelId == node.modelId).visible &&
checked
) {
isPartLoad = true;
}
let selFeatureIds = [];
@ -447,9 +395,12 @@ function loadModels(that) {
that.loadedModelCount = 0;
modelIds.forEach((modelId) => {
if (!api.m_model.has(modelId)) {
cnt++;
that.addModel(modelId);
that.addModel(modelId, () => {
cnt++;
});
return;
} else {
that.loadedModelCount++;
}
});
return cnt;
@ -505,7 +456,9 @@ function loadNode(that, node, resolve) {
resolve(nd);
setTimeout(() => {
document.querySelectorAll(".bim-selection-dialog .model-tree .el-tree-node")[0].click();
document
.querySelectorAll(".bim-selection-dialog .model-tree .el-tree-node")[0]
.click();
}, 1000);
} else if (node.level == 1) {
let nd = [];
@ -535,14 +488,20 @@ function getTreeChildren(that, node, resolve) {
getModelTree(data.modelId, data.glid).then((d) => {
let tmps = (d.data || []).map((it) => {
let title = it.externalId == 0 ? it.name : it.externalId;
title = title.replaceAll('"', "").replaceAll("'", "").replaceAll("\\", "");
title = title
.replaceAll('"', "")
.replaceAll("'", "")
.replaceAll("\\", "");
it.title = title;
it.key = it.glid;
it.modelId = data.modelId;
it.type = "data";
it.leaf = +it.externalId != 0;
let o = convertFeatureInfo(it, data.modelId);
if (that.allFeatures.filter((item) => item.featureId == it.featureId).length == 0) {
if (
that.allFeatures.filter((item) => item.featureId == it.featureId)
.length == 0
) {
that.allFeatures.push({
featureId: it.featureId,
info: it.info,
@ -602,7 +561,11 @@ async function selectTreeData(that) {
featureId: o.featureId,
info: o.info,
});
if (!that.selectItems.find((it) => it.featureId == o.featureId) && !that.readlyParts.includes(o.featureId) && !that.hideParts.includes(o.featureId)) {
if (
!that.selectItems.find((it) => it.featureId == o.featureId) &&
!that.readlyParts.includes(o.featureId) &&
!that.hideParts.includes(o.featureId)
) {
that.selectItems.push(o);
api.Feature.setColor(o.featureId, "rgba(255,0,255,1)");
}

View File

@ -136,15 +136,12 @@ function initBim(that) {
});
}
tmps = that.allBimData.filter((it) => it.id != that.plan.id);
tmps.forEach((it) => {
it.bim.forEach((it) => {
if (
that.readlyParts.filter((f) => f.featureId == it.featureId).length == 0
) {
that.readlyParts.push(it.featureId);
}
});
});
// 合并that.readlyParts和tmps中的featureId并去重
const tmpsFeatureIds = tmps.flatMap((item) =>
item.bim.map((b) => b.featureId)
);
that.readlyParts = [...new Set([...that.readlyParts, ...tmpsFeatureIds])];
}
//构建树形数据
@ -536,13 +533,13 @@ function resetModel(that, cb) {
that.readlyParts = [];
that.hideFeatures = [];
that.allBimData = that.planList.filter((d) => d.hasBim);
that.models.forEach(model => {
that.models.forEach((model) => {
api.Model.setVisible(model.modelId, true);
api.Model.original(model.modelId);
that.$refs.tree.setChecked(model.modelId, true, true)
that.$refs.tree.setChecked(model.modelId, true, true);
setTimeout(() => {
cb && cb();
}, 1000)
}, 1000);
});
}
@ -557,7 +554,7 @@ function showPlanFeatchure(that) {
let tmpsIds2 = featureIds.splice(0, 1000);
api.Feature.showFeatures(tmpsIds2.join("#"));
setFeatueVisible(featureIds, true);
initBim(that)
initBim(that);
//that.selectItems = that.plan.bim.map((it) => it);
featureIds = that.plan.bim.map((it) => it.featureId);
@ -567,8 +564,8 @@ function showPlanFeatchure(that) {
that.selectItems = [];
//未绑定BIM模型 显示所有可以绑定的构件
initBim(that)
setFeatueVisible(that.readlyParts, false)
initBim(that);
setFeatueVisible(that.readlyParts, false);
}
});
}
@ -577,7 +574,6 @@ export default {
selectSingle,
initBim,
clearAllSelection,
partLoadModel,
buildTreeData,
onCheckTree,
boxSelection,

View File

@ -1,5 +1,12 @@
<template>
<el-dialog v-model="show" append-to-body :close-on-click-modal="false" :close-on-press-escape="false" :title="title" modal-class="bim-selection-dialog">
<el-dialog
v-model="show"
append-to-body
:close-on-click-modal="false"
:close-on-press-escape="false"
:title="title"
modal-class="bim-selection-dialog"
>
<div id="bimSelectionDlg">
<div id="bimSelectionDlgContainer" class="bimSelectionDlgContainer"></div>
</div>
@ -21,12 +28,17 @@
@check="onCheckTree"
:load="loadNode"
lazy
show-checkbox></el-tree>
show-checkbox
></el-tree>
</div>
</el-tab-pane>
<el-tab-pane label="已关联" name="a2">
<div class="sel-list scroll" :key="selEl">
<div v-for="(it, idx) in selectItems" :key="idx" class="div-sel-item">
<div
v-for="(it, idx) in selectItems"
:key="idx"
class="div-sel-item"
>
<el-tooltip placement="bottom" :content="it.info">
<div class="sel-item-info">{{ it.info }}</div>
</el-tooltip>
@ -39,7 +51,11 @@
<el-button @click="delAllDelList"></el-button>
</div>
<div class="sel-list scroll hide-list" :key="hideEl">
<div v-for="(it, idx) in getSelectItems(hideParts)" :key="idx" class="div-sel-item">
<div
v-for="(it, idx) in getSelectItems(hideParts)"
:key="idx"
class="div-sel-item"
>
<el-tooltip placement="bottom" :content="it.info">
<div class="sel-item-info">{{ it.info }}</div>
</el-tooltip>
@ -49,40 +65,68 @@
</el-tab-pane>
</el-tabs>
<div class="div-icon">
<el-icon v-show="leftExpend" @click="leftExpend = false"><ArrowUpBold /></el-icon>
<el-icon v-show="!leftExpend" @click="leftExpend = true"><ArrowDownBold /></el-icon>
<el-icon v-show="leftExpend" @click="leftExpend = false"
><ArrowUpBold
/></el-icon>
<el-icon v-show="!leftExpend" @click="leftExpend = true"
><ArrowDownBold
/></el-icon>
</div>
</div>
</div>
<div v-show="bimLoaded">
<div class="footer-box" v-if="models.length > 0">
<el-tooltip placement="top" content="主视图">
<div class="footer-btn" @click="doMenu(0)" :class="activeMenu == 0 ? 'is-active' : ''">
<div
class="footer-btn"
@click="doMenu(0)"
:class="activeMenu == 0 ? 'is-active' : ''"
>
<svg-icon icon-class="home" />
</div>
</el-tooltip>
<el-tooltip placement="top" content="取消所有关联">
<div class="footer-btn" @click="doMenu(1)" :class="activeMenu == 1 ? 'is-active' : ''">
<div
class="footer-btn"
@click="doMenu(1)"
:class="activeMenu == 1 ? 'is-active' : ''"
>
<svg-icon icon-class="cancel" />
</div>
</el-tooltip>
<el-tooltip placement="top" content="点选">
<div class="footer-btn" @click="doMenu(2)" :class="activeMenu == 2 ? 'is-active' : ''">
<div
class="footer-btn"
@click="doMenu(2)"
:class="activeMenu == 2 ? 'is-active' : ''"
>
<svg-icon icon-class="pointselect" />
</div>
</el-tooltip>
<el-tooltip placement="top" content="框选">
<div class="footer-btn" @click="doMenu(3)" :class="activeMenu == 3 ? 'is-active' : ''">
<div
class="footer-btn"
@click="doMenu(3)"
:class="activeMenu == 3 ? 'is-active' : ''"
>
<svg-icon icon-class="boundselect" />
</div>
</el-tooltip>
<el-tooltip placement="top" content="全选树上所有已选择构件">
<div class="footer-btn" @click="doMenu(5)" :class="activeMenu == 5 ? 'is-active' : ''">
<div
class="footer-btn"
@click="doMenu(5)"
:class="activeMenu == 5 ? 'is-active' : ''"
>
<svg-icon icon-class="skill" />
</div>
</el-tooltip>
<el-tooltip placement="top" content="隐藏构件">
<div class="footer-btn" @click="doMenu(4)" :class="activeMenu == 4 ? 'is-active' : ''">
<div
class="footer-btn"
@click="doMenu(4)"
:class="activeMenu == 4 ? 'is-active' : ''"
>
<svg-icon icon-class="hide" />
</div>
</el-tooltip>
@ -90,7 +134,15 @@
</div>
<div class="div-mode">
<el-switch v-model="showMode" class="ml-2" inline-prompt active-text="" inactive-text="" @change="doModeChange" style="--el-switch-off-color: #336699" />
<el-switch
v-model="showMode"
class="ml-2"
inline-prompt
active-text="显示模式"
inactive-text="隐藏模式"
@change="doModeChange"
style="--el-switch-off-color: #336699"
/>
</div>
<template #footer>
<div class="dialog-footer">
@ -104,7 +156,11 @@
import useUserStore from "@/store/modules/user";
import { listBimModel } from "@/api/bim/bimModel";
import bimTools from "./bimSelectTools2";
import { updateBimInfo, getPlanAllBimInfo, getDefaultViewPoint } from "@/api/bim/bim";
import {
updateBimInfo,
getPlanAllBimInfo,
getDefaultViewPoint,
} from "@/api/bim/bim";
import { ElMessage, ElMessageBox, ElStep } from "element-plus";
export default {
data() {
@ -170,7 +226,10 @@ export default {
},
doModeChange() {
let api = bimSelectionDlgApi;
api.Feature.setVisible(this.selectItems.map((f) => f.featureId).join("#"), this.showMode);
api.Feature.setVisible(
this.selectItems.map((f) => f.featureId).join("#"),
this.showMode
);
},
delSelectItem(idx) {
this.$modal.confirm("确定删除吗?").then(() => {
@ -192,7 +251,8 @@ export default {
doSave() {
updateBimInfo({
id: this.plan.id,
text: this.selectItems.length > 0 ? JSON.stringify(this.selectItems) : "",
text:
this.selectItems.length > 0 ? JSON.stringify(this.selectItems) : "",
}).then((res) => {
if (res.success) {
ElMessage.success("保存成功");
@ -235,8 +295,8 @@ export default {
break;
}
},
showDialog(plan) {
window.bimDlg = this;
showDialog(plan, planList) {
window.bimDlg2 = this;
this.plan = plan;
this.show = true;
this.activeTab = "a1";
@ -261,12 +321,13 @@ export default {
this.showMode = true;
this.loadedModelCount = 0;
getPlanAllBimInfo(this.plan.projectId).then((res) => {
this.allBimData = (res.data || []).map((it) => {
this.allBimData = planList
.map((it) => {
it.bim = this.$tryToJson(it.bimId || "[]", []);
return it;
});
});
})
.filter((d) => d.bim && d.bim.length > 0);
this.initEngine();
},
initEngine() {
@ -362,6 +423,9 @@ export default {
}
});
},
initPlan() {
bimTools.partLoadModel(this);
},
addModel(modelId, cb) {
let url = `${window.config.modelUrl}/Tools/output/model/${modelId}/root.glt`;
this.models.find((d) => d.modelId == modelId).visible = true;
@ -373,7 +437,6 @@ export default {
() => {
cb && cb();
console.log("加载模型成功");
this.loadedModelCount++;
setTimeout(() => {
if (this.viewPoint) {
api.Camera.setViewPort(this.viewPoint);
@ -385,6 +448,7 @@ export default {
this.$message.info("模型加载完成");
this.bimLoaded = true;
this.doMenu(2);
this.loadedModelCount++;
}, 1000);
}
);
@ -550,6 +614,9 @@ export default {
.el-checkbox {
color: #45fdfe;
}
.el-text {
color: #eee;
}
.el-tree-node {
&:focus {
& > .el-tree-node__content {

View File

@ -8,7 +8,10 @@
modal-class="bim-selection-dialog3"
>
<div id="bimSelectionDlg">
<div id="bimSelectionDlgContainer" class="bimSelectionDlgContainer"></div>
<div
id="bimSelectionDlgContainer3"
class="bimSelectionDlgContainer"
></div>
</div>
<div class="div-left" :class="{ 'is-hide': !leftExpend }">
<div class="div-left-title">
@ -309,22 +312,22 @@ export default {
});
},
doSave() {
if(!this.plan){
if (!this.plan) {
ElMessage.error("请选择计划");
return;
}
let text=
this.selectItems.length > 0 ? JSON.stringify(this.selectItems) : ""
let text =
this.selectItems.length > 0 ? JSON.stringify(this.selectItems) : "";
updateBimInfo({
id: this.plan.id,
text:text,
text: text,
}).then((res) => {
if (res.success) {
this.plan.bimId=text;
this.plan.bim=this.$tryToJson(text||"[]",[]);
this.plan.hasBim=this.plan && this.plan.bim.length>0;
this.plan.bimId = text;
this.plan.bim = this.$tryToJson(text || "[]", []);
this.plan.hasBim = this.plan && this.plan.bim.length > 0;
ElMessage.success("保存成功");
bimTools.showPlanFeatchure(this)
bimTools.showPlanFeatchure(this);
this.$emit("success");
} else {
ElMessage.error("保存失败");
@ -409,7 +412,7 @@ export default {
serverIP: window.config.serverIP, //ip
port: window.config.port, //HTTP
useHttps: window.config.useHttps, //使Https
container: "bimSelectionDlgContainer", //[]id
container: "bimSelectionDlgContainer3", //[]id
secretKey: window.config.secretKey,
openEarth: window.config.openEarth, //[]Gis
bgColor: window.config.bgColor, //[]bim,
@ -487,7 +490,7 @@ export default {
} else {
this.models.forEach((it) => {
this.addModel(it.modelId, () => {
this.$refs.tree.setChecked(it.modelId, true,true);
this.$refs.tree.setChecked(it.modelId, true, true);
});
});
}

View File

@ -288,7 +288,7 @@ function getList() {
}
function handleBim(row) {
bimDlg.value.showDialog(row);
bimDlg.value.showDialog(row, data.planAll);
}
function handleBindBim() {

View File

@ -10,7 +10,7 @@ export default defineConfig(({ mode, command }) => {
// 部署生产环境和开发环境下的URL。
// 默认情况下vite 会假设你的应用是被部署在一个域名的根路径上
// 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。
base: VITE_APP_ENV === "production" ? "/xd/" : "./xd/",
base: VITE_APP_ENV === "production" ? "./" : "./",
plugins: createVitePlugins(env, command === "build"),
resolve: {
// https://cn.vitejs.dev/config/#resolve-alias
@ -44,7 +44,10 @@ export default defineConfig(({ mode, command }) => {
rewrite: (p) => p.replace(/^\/dev-api/, ""),
},
"/statics": {
target: VITE_APP_ENV === "production" ? "http://62.234.3.186" : `http://localhost:9300`,
target:
VITE_APP_ENV === "production"
? "http://62.234.3.186"
: `http://localhost:9300`,
//target: 'http://62.234.3.186',
changeOrigin: true,
pathRewrite: {