修改模型的懒加载

dev_xd
lj7788@126.com 2025-07-02 14:35:03 +08:00
parent ca25764569
commit 8c25c8d18a
8 changed files with 462 additions and 181 deletions

View File

@ -22,7 +22,8 @@
}" }"
node-key="key" node-key="key"
@check="onCheckTree" @check="onCheckTree"
:data="modelTrees" :load="loadNode"
lazy
show-checkbox></el-tree> show-checkbox></el-tree>
</div> </div>
</div> </div>
@ -261,6 +262,72 @@ export default {
this.initEngine(); this.initEngine();
}, },
methods: { methods: {
loadNode(node, resolve) {
let that = this;
if (node.level == 0) {
let nd = [
{
title: "项目模型",
level: 0,
type: "root",
key: "root",
children: [],
hadLoad: true,
},
];
resolve(nd);
setTimeout(() => {
document.querySelectorAll(".bim-briefing .model-tree .el-tree-node")[0].click();
}, 1000);
} else if (node.level == 1) {
let nd = [];
that.models.forEach((d) => {
let mnd = {
title: d.modelName,
level: 1,
type: "model",
hasLoad: false,
modelId: d.lightweightName,
key: d.lightweightName,
externalId: "0",
glid: "",
children: [],
data: d,
};
nd.push(mnd);
});
resolve(nd);
} else {
this.getTreeChildren(node, resolve);
}
},
getTreeChildren(node, resolve) {
let that = this;
let data = node.data;
this.$api.bim.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("\\", "");
it.title = title;
it.key = it.glid;
it.modelId = data.modelId;
it.type = "data";
it.leaf = +it.externalId != 0;
let o = this.convertFeatureInfo(it, data.modelId);
return o;
});
resolve(tmps);
});
},
convertFeatureInfo(o, modelId) {
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}`;
return o;
},
doSelectMenu(index) { doSelectMenu(index) {
this.selectMenu = index; this.selectMenu = index;
briefingTools.clearEvent(this); briefingTools.clearEvent(this);
@ -301,69 +368,77 @@ export default {
break; break;
} }
}, },
onCheckTree(node, event) { async onCheckTree(node, event) {
let api = bimBriefingApi;
let that = this;
if (!this.modelLoaded) { if (!this.modelLoaded) {
this.$message.error("模型未加载完成,请稍后重试"); this.$message.error("模型未加载完成,请稍后重试");
return; return;
} }
this.playCancle();
let checked = event.checkedNodes.includes(node); let checked = event.checkedNodes.includes(node);
console.log(node, event, checked);
if (node.type == "root") { if (node.type == "root") {
//bimBriefingApi
node.children.forEach((m) => {
if (bimBriefingApi.m_model.has(m.modelId)) {
bimBriefingApi.Model.remove(m.modelId);
}
if (checked) {
this.addModel(m.modelId);
}
});
} else if (node.type == "model") {
if (bimBriefingApi.m_model.has(node.modelId)) {
bimBriefingApi.Model.remove(node.modelId);
}
if (checked) { if (checked) {
this.addModel(node.modelId); that.models.forEach((it) => {
} api.Model.setVisible(it.modelId, true);
} else { api.Model.original(it.modelId);
if (bimBriefingApi.m_model.size == 0) {
let modelId = checkNode.modelId;
this.addModel(modelId, () => {
this.showItem(node, event, checked);
}); });
} else { } else {
this.showItem(node, event, checked); that.models.forEach((it) => {
api.Model.setVisible(it.modelId, false);
});
}
} else if (node.type == "model") {
if (checked) {
api.Model.setVisible(node.modelId, true);
api.Model.original(node.modelId);
} else {
api.Model.setVisible(node.modelId, false);
}
} else {
let isPartLoad = false;
if (event.checkedKeys.length == 1 && checked) {
isPartLoad = true;
}
let selFeatureIds = [];
if (node.leaf) {
selFeatureIds = [node.featureId];
} else {
if (!node.leafs) {
let leafs = await this.getNodeLeafs(node);
node.leafs = leafs;
}
selFeatureIds = node.leafs.map((f) => f.featureId);
}
let tmps = selFeatureIds;
if (!checked) {
this.setFeatueVisible(tmps, false);
} else {
if (isPartLoad) {
api.Model.setVisible(node.modelId, true);
api.Model.original(node.modelId);
let tmpsIds2 = tmps.splice(0, 1000);
api.Feature.showFeatures(tmpsIds2.join("#"));
this.setFeatueVisible(tmps, true);
} else {
this.setFeatueVisible(tmps, true);
}
} }
} }
}, },
async showItem(checkNode, event, checked) { setFeatueVisible(featureIds, show) {
let len = 1000;
let api = bimBriefingApi; let api = bimBriefingApi;
api.Model.setVisible(checkNode.modelId, true); let cnt = featureIds.length;
let externalId = checkNode.externalId; for (let i = 0; i < cnt; i += len) {
if (externalId != 0) { api.Feature.setVisible(featureIds.slice(i, i + len).join("#"), show);
if (checked) {
this.visibleList.push(externalId);
api.Feature.setVisible(this.visibleList.join("#"), true, checkNode.modelId, false);
} else {
this.visibleList = this.visibleList.filter((item) => item !== externalId);
api.Feature.setVisible(externalId, false, checkNode.modelId);
}
} else {
const res = await this.$api.bim.getTreeAllLeafChild(checkNode.modelId, checkNode.glid);
let nodes = res.data || [];
if (nodes.length > 0) {
if (checked) {
this.visibleList = MergeArray(nodes, this.visibleList);
api.Model.setVisible(checkNode.modelId, true);
api.Feature.setVisible(this.visibleList.join("#"), true, checkNode.modelId, false);
} else {
this.visibleList = DelArray(this.visibleList, nodes);
api.Feature.setVisible(nodes.join("#"), false, checkNode.modelId);
}
}
} }
}, },
async getNodeLeafs(node) {
const res = await this.$api.bim.getTreeAllLeafChild(node.modelId, node.glid);
return (res.data || []).map((f) => {
return this.convertFeatureInfo(f, node.modelId);
});
},
arrowRetract() { arrowRetract() {
if (this.leftShow == true) { if (this.leftShow == true) {
this.rightSrc = "./images/arrow_right_open.png"; this.rightSrc = "./images/arrow_right_open.png";
@ -458,10 +533,15 @@ export default {
this.$message.error("暂无模型,请先关联模型"); this.$message.error("暂无模型,请先关联模型");
} else { } else {
this.models.forEach((item) => { this.models.forEach((item) => {
item.modelId = item.lightweightName;
item.gis = JSON.parse(item.gisJson);
this.addModel(item.lightweightName); this.addModel(item.lightweightName);
this.loadModelTree();
this.doSelectMenu(7); this.doSelectMenu(7);
setTimeout(() => {
this.$refs.tree.setChecked(item.lightweightName, true, true);
}, 3000);
}); });
this.treeKey++;
} }
}); });
this.init(); this.init();

View File

@ -472,7 +472,8 @@ export default {
} }
this.getProjectInfo(); this.getProjectInfo();
this.costOutputSelectYearAndMonth(); this.costOutputSelectYearAndMonth();
this.groupByCraftType(); //this.groupByCraftType();
this.loadAttendanceData();
this.getRootScheduleNode(); this.getRootScheduleNode();
this.getFinishRate(); this.getFinishRate();
this.selectLastPhotography(); this.selectLastPhotography();
@ -553,6 +554,60 @@ export default {
this.prj.accumulatedCost = d.totalMonth || 0; this.prj.accumulatedCost = d.totalMonth || 0;
}); });
}, },
loadAttendanceData() {
if (this.selProject.vendorsCode != "uni") {
this.loadJhAttendanceData();
} else {
this.loadUniAttendanceData();
}
},
loadJhAttendanceData() {
let data = {
id: 0,
projectId: this.selProject.id,
attendanceTime: this.$dt(new Date()).format("YYYY-MM-DD"),
};
let ajax = this.$api.detail.groupAllByComany;
ajax(data).then((d) => {
let tmps = d.data || [];
const func = (ids) => {
let sum = 0;
tmps
.filter((it) => ids.includes(it.companyTypeId))
.map((it) => it.id)
.forEach((it) => {
sum += it * 1;
});
return sum;
};
this.workerInfo = [
{ text: "劳务人员", value: func(["4", "5"]) },
{ text: "监理人员", value: func(["2"]) },
{ text: "总包人员", value: func(["1"]) },
];
console.log(this.attendanceData)
});
},
loadUniAttendanceData() {
let ajax = this.$api.detail.groupByCraftType;
let posData = {
comId: this.selProject.comId,
projectId: this.selProject.id,
};
ajax(posData).then((d) => {
this.workerInfo = (d.data || []).map((it) => {
return {
text: it.createBy,
value: it.id || 0,
id: it.craftType,
};
});
});
},
groupByCraftType() { groupByCraftType() {
let ajax = this.$api.detail.groupByCraftType; let ajax = this.$api.detail.groupByCraftType;
let posData = { let posData = {
@ -1019,7 +1074,7 @@ export default {
position: absolute; position: absolute;
top: calc(80vh - 50px); top: calc(80vh - 50px);
left: 50%; left: 50%;
margin-left:-170px; margin-left: -170px;
display: flex; display: flex;
background: #00000080; background: #00000080;
border-radius: 10px; border-radius: 10px;
@ -1078,7 +1133,8 @@ export default {
td, td,
th { th {
border: solid 1px #6ea9ab68; border: solid 1px #6ea9ab68;
padding: 4px; padding: 7px 4px;
font-size: 12px;
} }
th { th {
color: #b0cfff; color: #b0cfff;
@ -1380,7 +1436,7 @@ export default {
th { th {
border: solid 1px #6ea9ab68; border: solid 1px #6ea9ab68;
padding: 4px; padding: 4px;
font-size: 12px; font-size: 10px;
} }
} }
} }
@ -1560,8 +1616,8 @@ export default {
td, td,
th { th {
border: solid 1px #6ea9ab68; border: solid 1px #6ea9ab68;
padding: 8px; padding: 10px;
font-size: 24px; font-size: 20px;
} }
} }
} }

View File

@ -19,10 +19,12 @@
:props="{ :props="{
children: 'children', children: 'children',
label: 'title', label: 'title',
isLeaf: 'leaf',
}" }"
node-key="key" node-key="key"
@check="onCheckTree" @check="onCheckTree"
:data="modelTrees" :load="loadNode"
lazy
show-checkbox></el-tree> show-checkbox></el-tree>
</div> </div>
</div> </div>
@ -112,7 +114,7 @@ export default {
models: [], models: [],
treeKey: 0, treeKey: 0,
modelTrees: [], modelTrees: [],
viewPoint:[], viewPoint: [],
treeExpendedKeys: [], treeExpendedKeys: [],
visibleList: [], visibleList: [],
viewpointList: [], viewpointList: [],
@ -122,9 +124,11 @@ export default {
roamingLoading: true, roamingLoading: true,
selectedRoam: null, selectedRoam: null,
modelLoaded: false, modelLoaded: false,
isPlay:false,
}; };
}, },
mounted() { mounted() {
window.bimRoaming = this;
this.$store.dispatch("ChangeNav", 702); this.$store.dispatch("ChangeNav", 702);
this.dpi = this.$dpi(); this.dpi = this.$dpi();
window.addEventListener("resize", () => { window.addEventListener("resize", () => {
@ -144,15 +148,84 @@ export default {
this.initEngine(); this.initEngine();
}, },
methods: { methods: {
loadNode(node, resolve) {
let that = this;
if (node.level == 0) {
let nd = [
{
title: "项目模型",
level: 0,
type: "root",
key: "root",
children: [],
hadLoad: true,
},
];
resolve(nd);
setTimeout(() => {
document.querySelectorAll(".bim-roaming .model-tree .el-tree-node")[0].click();
}, 1000);
} else if (node.level == 1) {
let nd = [];
that.models.forEach((d) => {
let mnd = {
title: d.modelName,
level: 1,
type: "model",
hasLoad: false,
modelId: d.lightweightName,
key: d.lightweightName,
externalId: "0",
glid: "",
children: [],
data: d,
};
nd.push(mnd);
});
resolve(nd);
} else {
this.getTreeChildren(node, resolve);
}
},
getTreeChildren(node, resolve) {
let that = this;
let data = node.data;
this.$api.bim.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("\\", "");
it.title = title;
it.key = it.glid;
it.modelId = data.modelId;
it.type = "data";
it.leaf = +it.externalId != 0;
let o = this.convertFeatureInfo(it, data.modelId);
return o;
});
resolve(tmps);
});
},
convertFeatureInfo(o, modelId) {
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}`;
return o;
},
playIRPause(data) { playIRPause(data) {
data.play = 2; data.play = 2;
this.isPlay=false;
bimRoadmApi.Camera.pauseImmersiveRoam(false); bimRoadmApi.Camera.pauseImmersiveRoam(false);
}, },
playContinue(data) { playContinue(data) {
data.play = 1; data.play = 1;
this.isPlay=true;
bimRoadmApi.Camera.pauseImmersiveRoam(true); bimRoadmApi.Camera.pauseImmersiveRoam(true);
}, },
playCancle(data) { playCancle(data) {
this.isPlay = false;
if (data) { if (data) {
data.play = 0; data.play = 0;
this.selectedRoam = null; this.selectedRoam = null;
@ -188,80 +261,93 @@ export default {
api.Camera.startImmersiveRoam([65.702301, 670.785328, 851.817162]); api.Camera.startImmersiveRoam([65.702301, 670.785328, 851.817162]);
setTimeout(() => { setTimeout(() => {
this.selectedRoam = data; this.selectedRoam = data;
this.isPlay=true;
api.Camera.playImmersiveRoam({ api.Camera.playImmersiveRoam({
records: record, records: record,
isLoopPlay: this.autoPlay, isLoopPlay: this.autoPlay,
complete: function () { complete: function () {
this.selectedRoam = null; this.selectedRoam = null;
data.play = 0; data.play = 0;
this.isPlay=false;
}, },
}); });
}, 400); }, 400);
}, 100); }, 100);
}, },
onCheckTree(node, event) { async onCheckTree(node, event) {
let api = bimRoadmApi;
let that = this;
if (!this.modelLoaded) { if (!this.modelLoaded) {
this.$message.error("模型未加载完成,请稍后重试"); this.$message.error("模型未加载完成,请稍后重试");
return; return;
} }
this.playCancle(); if(this.isPlay){
this.playCancle();
}
let checked = event.checkedNodes.includes(node); let checked = event.checkedNodes.includes(node);
console.log(node, event, checked);
if (node.type == "root") { if (node.type == "root") {
//bimRoadmApi
node.children.forEach((m) => {
if (bimRoadmApi.m_model.has(m.modelId)) {
bimRoadmApi.Model.remove(m.modelId);
}
if (checked) {
this.addModel(m.modelId);
}
});
} else if (node.type == "model") {
if (bimRoadmApi.m_model.has(node.modelId)) {
bimRoadmApi.Model.remove(node.modelId);
}
if (checked) { if (checked) {
this.addModel(node.modelId); that.models.forEach((it) => {
} api.Model.setVisible(it.modelId, true);
} else { api.Model.original(it.modelId);
if (bimRoadmApi.m_model.size == 0) {
let modelId = checkNode.modelId;
this.addModel(modelId, () => {
this.showItem(node, event, checked);
}); });
} else { } else {
this.showItem(node, event, checked); that.models.forEach((it) => {
api.Model.setVisible(it.modelId, false);
});
}
} else if (node.type == "model") {
if (checked) {
api.Model.setVisible(node.modelId, true);
api.Model.original(node.modelId);
} else {
api.Model.setVisible(node.modelId, false);
}
} else {
let isPartLoad = false;
if (event.checkedKeys.length == 1 && checked) {
isPartLoad = true;
}
let selFeatureIds = [];
if (node.leaf) {
selFeatureIds = [node.featureId];
} else {
if (!node.leafs) {
let leafs = await this.getNodeLeafs(node);
node.leafs = leafs;
}
selFeatureIds = node.leafs.map((f) => f.featureId);
}
let tmps = selFeatureIds;
if (!checked) {
this.setFeatueVisible(tmps, false);
} else {
if (isPartLoad) {
api.Model.setVisible(node.modelId, true);
api.Model.original(node.modelId);
let tmpsIds2 = tmps.splice(0, 1000);
api.Feature.showFeatures(tmpsIds2.join("#"));
this.setFeatueVisible(tmps, true);
} else {
this.setFeatueVisible(tmps, true);
}
} }
} }
}, },
async showItem(checkNode, event, checked) { setFeatueVisible(featureIds, show) {
let len = 1000;
let api = bimRoadmApi; let api = bimRoadmApi;
api.Model.setVisible(checkNode.modelId, true); let cnt = featureIds.length;
let externalId = checkNode.externalId; for (let i = 0; i < cnt; i += len) {
if (externalId != 0) { api.Feature.setVisible(featureIds.slice(i, i + len).join("#"), show);
if (checked) {
this.visibleList.push(externalId);
api.Feature.setVisible(this.visibleList.join("#"), true, checkNode.modelId, false);
} else {
this.visibleList = this.visibleList.filter((item) => item !== externalId);
api.Feature.setVisible(externalId, false, checkNode.modelId);
}
} else {
const res = await this.$api.bim.getTreeAllLeafChild(checkNode.modelId, checkNode.glid);
let nodes = (res.data || []).map((item) => item.glid);
if (nodes.length > 0) {
if (checked) {
this.visibleList = MergeArray(nodes, this.visibleList);
api.Model.setVisible(checkNode.modelId, true);
api.Feature.setVisible(this.visibleList.join("#"), true, checkNode.modelId, false);
} else {
this.visibleList = DelArray(this.visibleList, nodes);
api.Feature.setVisible(nodes.join("#"), false, checkNode.modelId);
}
}
} }
}, },
async getNodeLeafs(node) {
const res = await this.$api.bim.getTreeAllLeafChild(node.modelId, node.glid);
return (res.data || []).map((f) => {
return this.convertFeatureInfo(f, node.modelId);
});
},
arrowRetract() { arrowRetract() {
if (this.leftShow == true) { if (this.leftShow == true) {
@ -352,9 +438,14 @@ export default {
this.$modal.error("暂无模型,请先关联模型"); this.$modal.error("暂无模型,请先关联模型");
} else { } else {
this.models.forEach((item) => { this.models.forEach((item) => {
item.modelId = item.lightweightName;
item.gis = JSON.parse(item.gisJson);
this.addModel(item.lightweightName); this.addModel(item.lightweightName);
this.loadModelTree(); setTimeout(() => {
this.$refs.tree.setChecked(item.lightweightName, true, true);
}, 3000);
}); });
this.treeKey++;
} }
}); });
this.init(); this.init();

View File

@ -414,6 +414,7 @@
<img class="weather-img" :src="weathers[2].img" /> <img class="weather-img" :src="weathers[2].img" />
<span class="weather-temp">{{ weathers[2].highTemp }} {{ weathers[2].lowTemp }}</span> <span class="weather-temp">{{ weathers[2].highTemp }} {{ weathers[2].lowTemp }}</span>
</div> </div>
</div> </div>
<div class="weather-info"> <div class="weather-info">
<el-row> <el-row>
@ -422,10 +423,10 @@
<svg-icon icon-class="pressure"></svg-icon> <svg-icon icon-class="pressure"></svg-icon>
</div> </div>
<div class="wi-data"> <div class="wi-data">
<div class="wi-label">当前气压</div> <div class="wi-label">当前噪音</div>
<div class="wi-data-unit"> <div class="wi-data-unit">
<span class="wi-txt">{{ weatherInfo.pressure }}</span> <span class="wi-txt">67.2</span>
<span class="wi-unit">hPa</span> <span class="wi-unit">dB</span>
</div> </div>
</div> </div>
</el-col> </el-col>

View File

@ -29,16 +29,7 @@
</template> </template>
</a-tree>--> </a-tree>-->
<div class="scroll-box"> <div class="scroll-box">
<a-tree <a-tree ref="tree" v-model:expandedKeys="expandedKeys" @check="onCheckTree" v-model:selectedKeys="selectedKeys" :tree-data="modelTrees" checkable default-expand-all :load-data="loadTree"></a-tree>
ref="tree"
v-model:expandedKeys="expandedKeys"
@check="onCheckTree"
v-model:selectedKeys="selectedKeys"
:tree-data="modelTrees"
checkable
default-expand-all
:load-data="loadTree"
></a-tree>
</div> </div>
</div> </div>
</template> </template>
@ -124,6 +115,7 @@ export default {
externalId: e.externalId, externalId: e.externalId,
modelId: a.modelId, modelId: a.modelId,
type: "data", type: "data",
featureId: a.modelId + "^" + e.externalId,
children: [], children: [],
hasLoad: false, hasLoad: false,
isLeaf: e.externalId != 0, isLeaf: e.externalId != 0,
@ -144,11 +136,11 @@ export default {
console.log("加载模型成功"); console.log("加载模型成功");
cb && cb(); cb && cb();
this.$emit("change"); this.$emit("change");
setTimeout(()=>{ setTimeout(() => {
api.Camera.getViewPort(p=>{ api.Camera.getViewPort((p) => {
this.$emit("modelAdd",p); this.$emit("modelAdd", p);
}); });
},1000); }, 1000);
} }
); );
}, },
@ -214,13 +206,63 @@ export default {
if (api.m_model.size == 0) { if (api.m_model.size == 0) {
let modelId = checkNode.modelId; let modelId = checkNode.modelId;
this.addModel(modelId, () => { this.addModel(modelId, () => {
this.showItem(e); this.showItem(e, heckedKeys);
}); });
} else { } else {
this.showItem(e); this.showItem(e, heckedKeys);
} }
}, },
async showItem(e) { async showItem(e, checkedKeys) {
const node = e.node.dataRef;
const checked = e.checked;
let isPartLoad = false;
if (checkedKeys.length == 1 && checked) {
isPartLoad = true;
}
let selFeatureIds = [];
if (node.isLeaf) {
selFeatureIds.push(node.featureId);
} else {
if (!node.leafs) {
let leafs = await this.getNodeLeafs(node);
node.leafs = leafs;
}
selFeatureIds = node.leafs.map((f) => f.featureId);
}
let tmps = selFeatureIds;
if (!checked) {
this.setFeatueVisible(tmps, false);
} else {
if (isPartLoad) {
api.Model.setVisible(node.modelId, true);
api.Model.original(node.modelId);
let tmpsIds2 = tmps.splice(0, 1000);
api.Feature.showFeatures(tmpsIds2.join("#"));
this.setFeatueVisible(tmps, true);
} else {
this.setFeatueVisible(tmps, true);
}
}
},
setFeatueVisible(featureIds, show) {
let len = 1000;
let cnt = featureIds.length;
for (let i = 0; i < cnt; i += len) {
api.Feature.setVisible(featureIds.slice(i, i + len).join("#"), show);
}
},
async getNodeLeafs(node) {
const res = await getTreeAllLeafChild(node.modelId, node.glid);
return (res.data || []).map((o) => {
o.modelId = node.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}`;
return o;
});
},
async showItem2(e) {
const checkNode = e.node.dataRef; const checkNode = e.node.dataRef;
const checked = e.checked; const checked = e.checked;
api.Model.setVisible(checkNode.modelId, true); api.Model.setVisible(checkNode.modelId, true);
@ -229,36 +271,21 @@ export default {
if (externalId != 0) { if (externalId != 0) {
if (checked) { if (checked) {
this.visibleList.push(externalId); this.visibleList.push(externalId);
api.Feature.setVisible( api.Feature.setVisible(this.visibleList.join("#"), true, checkNode.modelId, false);
this.visibleList.join("#"),
true,
checkNode.modelId,
false
);
} else { } else {
this.visibleList = this.visibleList.filter( this.visibleList = this.visibleList.filter((item) => item !== externalId);
(item) => item !== externalId
);
api.Feature.setVisible(externalId, false, checkNode.modelId); api.Feature.setVisible(externalId, false, checkNode.modelId);
} }
} else { } else {
e.node.disableCheckbox = true; e.node.disableCheckbox = true;
const res = await getTreeAllLeafChild( const res = await getTreeAllLeafChild(checkNode.modelId, checkNode.glid);
checkNode.modelId,
checkNode.glid
);
let nodes = (res.data || []).map((d) => d.glid); let nodes = (res.data || []).map((d) => d.glid);
if (nodes.length > 0) { if (nodes.length > 0) {
if (checked) { if (checked) {
this.visibleList = this.MergeArray(nodes, this.visibleList); this.visibleList = this.MergeArray(nodes, this.visibleList);
api.Model.setVisible(checkNode.modelId, true); api.Model.setVisible(checkNode.modelId, true);
this.$emit("change"); this.$emit("change");
api.Feature.setVisible( api.Feature.setVisible(this.visibleList.join("#"), true, checkNode.modelId, false);
this.visibleList.join("#"),
true,
checkNode.modelId,
false
);
} else { } else {
this.visibleList = this.DelArray(this.visibleList, nodes); this.visibleList = this.DelArray(this.visibleList, nodes);
api.Feature.setVisible(nodes.join("#"), false, checkNode.modelId); api.Feature.setVisible(nodes.join("#"), false, checkNode.modelId);

View File

@ -1,5 +1,5 @@
import { modelTreeAllChild } from "@/api/bim/bim"; import { modelTreeAllChild } from "@/api/bim/bim";
import { getModelTree, getTreeAllLeafChild, getModelFeatureInfo,getModelFeatureInfos } from "@/api/bim/bimModel"; import { getModelTree, getTreeAllLeafChild, getModelFeatureInfo, getModelFeatureInfos } from "@/api/bim/bimModel";
import { MergeArray, DelArray } from "@/utils/index"; import { MergeArray, DelArray } from "@/utils/index";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
function selectFeature(that, featureId) { function selectFeature(that, featureId) {
@ -21,8 +21,6 @@ function selectFeature(that, featureId) {
} }
} }
function getHideFeatures(that) { function getHideFeatures(that) {
let result = []; let result = [];
that.readlyParts.forEach((d) => { that.readlyParts.forEach((d) => {
@ -78,10 +76,10 @@ async function getServerFeatureInfo(that, featureId) {
let modelId = tmps[0]; let modelId = tmps[0];
let externalId = tmps[1]; let externalId = tmps[1];
let res = await getModelFeatureInfo(modelId, externalId); let res = await getModelFeatureInfo(modelId, externalId);
convertServerDataToFeatureInfo(that,res,modelId); convertServerDataToFeatureInfo(that, res, modelId);
} }
function convertServerDataToFeatureInfo(that,res,modelId) { function convertServerDataToFeatureInfo(that, res, modelId) {
(res.data || []).forEach((o) => { (res.data || []).forEach((o) => {
o = convertFeatureInfo(o, modelId); o = convertFeatureInfo(o, modelId);
if (o.externalId != "0") { if (o.externalId != "0") {
@ -96,8 +94,8 @@ function convertServerDataToFeatureInfo(that,res,modelId) {
}); });
} }
async function getServerFeatureInfos(that,ids){ async function getServerFeatureInfos(that, ids) {
if(ids.length==0){ if (ids.length == 0) {
return; return;
} }
let tmps = ids[0].split("^"); let tmps = ids[0].split("^");
@ -105,9 +103,9 @@ async function getServerFeatureInfos(that,ids){
return; return;
} }
let modelId = tmps[0]; let modelId = tmps[0];
let externalIds=ids.map((it) => it.split("^")[1]); let externalIds = ids.map((it) => it.split("^")[1]);
let res=await getModelFeatureInfos(modelId,externalIds); let res = await getModelFeatureInfos(modelId, externalIds);
convertServerDataToFeatureInfo(that,res,modelId); convertServerDataToFeatureInfo(that, res, modelId);
} }
function clearAllSelection(that) { function clearAllSelection(that) {
@ -135,8 +133,8 @@ function initBim(that) {
tmps.forEach((it) => { tmps.forEach((it) => {
it.bim.forEach((it) => { it.bim.forEach((it) => {
if (that.readlyParts.filter((f) => f.featureId == it.featureId).length == 0) { if (that.readlyParts.filter((f) => f.featureId == it.featureId).length == 0) {
that.readlyParts.push(it.featureId); that.readlyParts.push(it.featureId);
} }
}); });
}); });
} }
@ -195,7 +193,7 @@ function partLoadModel(that) {
}, 3000); }, 3000);
loadModels(that); loadModels(that);
initBim(that); initBim(that);
let func = () => { let func = () => {
if (that.loadedModelCount == that.models.length) { if (that.loadedModelCount == that.models.length) {
setTimeout(() => { setTimeout(() => {
@ -232,7 +230,6 @@ function getModelFeatures(that, modelId) {
that.allFeatures.push(o); that.allFeatures.push(o);
}); });
console.log("====>", that.allFeatures);
}); });
} }
@ -263,11 +260,12 @@ function onCheckTree(that, node, event) {
setTreeNodeChecked(that, node, event); setTreeNodeChecked(that, node, event);
} }
} }
let maxLen=1000;
//根据选择控制构件的隐藏和显示 //根据选择控制构件的隐藏和显示
async function setTreeNodeChecked(that, node, event) { async function setTreeNodeChecked(that, node, event) {
let api = bimSelectionDlgApi; let api = bimSelectionDlgApi;
let checked = event.checkedNodes.includes(node); let checked = event.checkedNodes.includes(node);
console.log("===>", checked, node);
if (node.type == "root") { if (node.type == "root") {
if (checked) { if (checked) {
that.models.forEach((it) => { that.models.forEach((it) => {
@ -287,8 +285,10 @@ async function setTreeNodeChecked(that, node, event) {
api.Model.setVisible(node.modelId, false); api.Model.setVisible(node.modelId, false);
} }
} else { } else {
api.Model.original(node.modelId); let isPartLoad = false;
console.log("---->", node); if (event.checkedKeys.length == 1 && checked) {
isPartLoad = true;
}
let selFeatureIds = []; let selFeatureIds = [];
if (node.leaf) { if (node.leaf) {
selFeatureIds = [node.featureId]; selFeatureIds = [node.featureId];
@ -299,15 +299,41 @@ async function setTreeNodeChecked(that, node, event) {
} }
selFeatureIds = node.leafs.map((f) => f.featureId); selFeatureIds = node.leafs.map((f) => f.featureId);
} }
if (checked) { let selitemsFeatureIds = that.selectItems.map((it) => it.featureId);
that.hideFeatures = DelArray(that.hideFeatures, selFeatureIds); let tmps = selFeatureIds
.filter((it) => !that.hideFeatures.includes(it))
.filter((it) => !that.readlyParts.includes(it))
.filter((it) => !selitemsFeatureIds.includes(it));
if (!checked) {
setFeatueVisible(tmps,false);
} else { } else {
that.hideFeatures = MergeArray(that.hideFeatures, selFeatureIds); if (isPartLoad) {
api.Model.setVisible(node.modelId, true);
api.Model.original(node.modelId);
selitemsFeatureIds.forEach((it) => {
tmps.push(it);
});
let tmpsIds2=tmps.splice(0,maxLen);
api.Feature.showFeatures(tmpsIds2.join("#"));
setFeatueVisible(tmps,true)
} else {
setFeatueVisible(tmps,true);
}
} }
} }
setFeatueShowOrHide(that); setFeatueShowOrHide(that);
} }
function setFeatueVisible(featureIds,show){
let len=maxLen;
let api = bimSelectionDlgApi;
let cnt=featureIds.length;
for(let i=0;i<cnt;i+=len){
api.Feature.setVisible(featureIds.slice(i,i+len).join("#"),show);
}
}
async function getNodeLeafs(that, node) { async function getNodeLeafs(that, node) {
const res = await getTreeAllLeafChild(node.modelId, node.glid); const res = await getTreeAllLeafChild(node.modelId, node.glid);
return (res.data || []).map((f) => { return (res.data || []).map((f) => {
@ -321,7 +347,7 @@ async function getNodeLeafs(that, node) {
featureId: o.featureId, featureId: o.featureId,
info: o.info, info: o.info,
}); });
return f; return o;
}); });
} }
@ -334,7 +360,7 @@ function setFeatueShowOrHide(that) {
//标注已选择的构件 //标注已选择的构件
that.selectItems.forEach((it) => { that.selectItems.forEach((it) => {
api.Feature.setColor(it, "rgba(255,0,255,1)"); api.Feature.setColor(it.featureId, "rgba(255,0,255,1)");
if (!that.showMode) { if (!that.showMode) {
api.Feature.setVisible(it, false); api.Feature.setVisible(it, false);
} }
@ -363,14 +389,14 @@ function loadModels(that) {
function boxSelection(that) { function boxSelection(that) {
let api = bimSelectionDlgApi; let api = bimSelectionDlgApi;
api.Feature.getByEvent(false); api.Feature.getByEvent(false);
ElMessage.info("右键取消选择") ElMessage.info("右键取消选择");
api.Public.event("RIGHT_CLICK", (res) => { api.Public.event("RIGHT_CLICK", (res) => {
api.Feature.closeBoxSelect(); api.Feature.closeBoxSelect();
that.activeMenu=-1; that.activeMenu = -1;
}); });
api.Feature.boxSelect(async (data) => { api.Feature.boxSelect(async (data) => {
await getServerFeatureInfos(that, data); await getServerFeatureInfos(that, data);
data.forEach( (featureId) => { data.forEach((featureId) => {
selectFeature(that, featureId); selectFeature(that, featureId);
}); });
}); });
@ -380,7 +406,7 @@ function hideSelection(that) {
let api = bimSelectionDlgApi; let api = bimSelectionDlgApi;
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) => {
if (n && n["id"]) { if (n && n["id"]) {
let featureId = n.id; let featureId = n.id;
await getServerFeatureInfo(that, featureId); await getServerFeatureInfo(that, featureId);
@ -395,7 +421,6 @@ function loadNode(that, node, resolve) {
if (!that.show) { if (!that.show) {
return; return;
} }
console.log("node->", node);
if (node.level == 0) { if (node.level == 0) {
let nd = [ let nd = [
{ {
@ -459,7 +484,7 @@ function getTreeChildren(that, node, resolve) {
} }
} }
return it; return o;
}); });
//addToAllFeatures(that, tmps); //addToAllFeatures(that, tmps);
resolve(tmps); resolve(tmps);

View File

@ -100,7 +100,7 @@ import useUserStore from "@/store/modules/user";
import { listBimModel } from "@/api/bim/bimModel"; import { listBimModel } from "@/api/bim/bimModel";
import bimTools from "./bimSelectTools2"; import bimTools from "./bimSelectTools2";
import { updateBimInfo, getPlanAllBimInfo } from "@/api/bim/bim"; import { updateBimInfo, getPlanAllBimInfo } from "@/api/bim/bim";
import { ElMessage, ElMessageBox } from "element-plus"; import { ElMessage, ElMessageBox, ElStep } from "element-plus";
export default { export default {
data() { data() {
return { return {
@ -131,8 +131,8 @@ export default {
allFeatures: [], // allFeatures: [], //
allParts: [], //ID allParts: [], //ID
showParts: [], //ID showParts: [], //ID
hideParts:[], //ID() hideParts: [], //ID()
hideFeatures:[],//() hideFeatures: [], //()
readlyParts: [], //ID() readlyParts: [], //ID()
}; };
}, },
@ -165,7 +165,7 @@ export default {
}, },
doModeChange() { doModeChange() {
let api = bimSelectionDlgApi; 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) { delSelectItem(idx) {
this.$modal.confirm("确定删除吗?").then(() => { this.$modal.confirm("确定删除吗?").then(() => {
@ -329,6 +329,7 @@ export default {
}).then((d) => { }).then((d) => {
this.models = (d.rows || []).map((it) => { this.models = (d.rows || []).map((it) => {
it.modelId = it.lightweightName; it.modelId = it.lightweightName;
it.checked = true;
it.gis = this.$tryToJson(it.gisJson || "{}", {}); it.gis = this.$tryToJson(it.gisJson || "{}", {});
return it; return it;
}); });
@ -367,7 +368,7 @@ export default {
let api = bimSelectionDlgApi; let api = bimSelectionDlgApi;
api.Camera.stopImmersiveRoam(); api.Camera.stopImmersiveRoam();
api.Model.location(api.m_model.keys().toArray()[0]); api.Model.location(api.m_model.keys().toArray()[0]);
api.Feature.getByEvent(false); api.Feature.getByEvent(false);
api.Plugin.deleteMiniMap(); api.Plugin.deleteMiniMap();
if (this.viewPoint) { if (this.viewPoint) {
api.Camera.setViewPort(this.viewPoint); api.Camera.setViewPort(this.viewPoint);

View File

@ -69,7 +69,7 @@
<el-table-column label="负责人" align="center" prop="operator" width="120" /> <el-table-column label="负责人" align="center" prop="operator" width="120" />
<el-table-column label="班组名称" align="center" prop="groupName" width="120" /> <el-table-column label="班组名称" align="center" prop="groupName" width="120" />
</el-table> </el-table>
<bim-selection-dialog ref="bimDlg" @success="doSelectSuccess"></bim-selection-dialog>" <bim-selection-dialog ref="bimDlg" @success="doSelectSuccess"></bim-selection-dialog>
</div> </div>
</template> </template>