diff --git a/yanzhu-ui-vue3/src/assets/icons/svg/save.svg b/yanzhu-ui-vue3/src/assets/icons/svg/save.svg new file mode 100644 index 00000000..22b8f349 --- /dev/null +++ b/yanzhu-ui-vue3/src/assets/icons/svg/save.svg @@ -0,0 +1 @@ + \ 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 deleted file mode 100644 index 7752fda8..00000000 --- a/yanzhu-ui-vue3/src/views/manage/plan/bimSelectTools.js +++ /dev/null @@ -1,353 +0,0 @@ -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)"); - if (!that.showMode) { - api.Feature.setVisible(featureId, false); - } - that.selectItems.push(featureId); - } -} - -function hideFeatures(that) { - let tmps = that.allBimData.filter((it) => it.id != that.plan.id); - tmps.forEach((it) => { - it.bim.forEach((it) => { - hideFeature(that, it); - }); - }); -} - -function getHideFeatures(that, checkedKeys) { - let result = []; - let tmps = that.allBimData.filter((it) => it.id != that.plan.id); - tmps.forEach((it) => { - it.bim.forEach((it) => { - result.push(it); - }); - }); - if (checkedKeys.length > 0) { - tmps = that.allFeatures - .filter((d) => !checkedKeys.includes(d.glid)) - .filter((d) => d != "0") - .map((d) => d.featureId); - tmps.forEach((d) => { - result.push(d); - }); - } - return result; -} - -function hideFeature(that, featureId) { - let api = bimSelectionDlgApi; - api.Feature.setVisible(featureId, false); -} - -function selectSingle(that) { - let api = bimSelectionDlgApi; - api.Public.clearHandler(); - api.Feature.getByEvent(true, (n) => { - if (n && n["id"]) { - let featureId = n.id; - let modelId = featureId.split("^")[0]; - selectFeature(that, featureId); - } - }); -} - -function clearAllSelection(that) { - that.$modal.confirm("确定清除所有已选择构件吗?").then(() => { - let api = bimSelectionDlgApi; - that.selectItems.forEach((d) => { - api.Feature.setColor(d, "rgba(255,255,255,1)"); - }); - that.selectItems = []; - this.selEl++; - }); -} - -function initBim(that) { - let tmps = that.allBimData.filter((it) => it.id == that.plan.id); - if (tmps.length > 0) { - 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) => { - that.viewPoint = p; - that.$message.info("模型加载完成"); - that.bimLoaded = true; - that.doMenu(2); - initBim(that); - }, - { - FlyTo: true, - } - ); - } - } - if (featureIds.length == 0) { - setTimeout(() => { - that.$refs.tree.setChecked("root", true, true); - }, 1000); - - loadModels(that); - let func = () => { - if (that.loadedModelCount == that.models.length) { - setTimeout(() => { - setFeatueShowOrHide(that, []); - }, 1000); - } else { - setTimeout(func, 100); - } - }; - func(); - } -} - -//构建树形数据 -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"); - that.$message.info("模型构件信息加载完成"); -} - -//获取模型所有构件 -function getModelFeatures(that, modelId, node) { - let tmps = that.allBimData.filter((it) => it.id != that.plan.id); - tmps.forEach((it) => { - 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)); -} - -//树上点击事件 -function onCheckTree(that, node, event) { - let api = bimSelectionDlgApi; - - if (that.partLoad) { - that.$refs.tree.setChecked("root", false, true); - that.partLoad = false; - that.models.forEach((it) => { - api.Model.remove(it.modelId); - }); - return; - } - if (loadModels(that) > 0) { - let func = () => { - if (that.loadedModelCount == that.models.length) { - setTimeout(() => { - setTreeNodeChecked(that, node, event); - }, 1000); - } else { - setTimeout(func, 100); - } - }; - func(); - } else { - setTreeNodeChecked(that, node, event); - } -} -//根据选择控制构件的隐藏和显示 -function setTreeNodeChecked(that, node, event) { - let api = bimSelectionDlgApi; - let checked = event.checkedNodes.includes(node); - if (node.type == "root") { - if (checked) { - that.models.forEach((it) => { - api.Model.setVisible(it.modelId, true); - api.Model.original(it.modelId); - }); - } else { - 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 { - api.Model.original(node.modelId); - } - setFeatueShowOrHide(that, event.checkedKeys); -} - -//处理构件的隐藏和显示 -function setFeatueShowOrHide(that, checkedKeys) { - let api = bimSelectionDlgApi; - //隐藏构件 - let hideFeatures = getHideFeatures(that, checkedKeys); - api.Feature.setVisible(hideFeatures.join("#"), false); - - //标注已选择的构件 - that.selectItems.forEach((it) => { - api.Feature.setColor(it, "rgba(255,0,255,1)"); - if (!that.showMode) { - api.Feature.setVisible(it, false); - } - }); - - api.Feature.setVisible(that.hideParts.join("#"), false); -} - -//加载模型 -function loadModels(that) { - let api = bimSelectionDlgApi; - let modelIds = that.models.map((it) => it.lightweightName); - let cnt = 0; - that.loadedModelCount = 0; - modelIds.forEach((modelId) => { - if (!api.m_model.has(modelId)) { - cnt++; - that.addModel(modelId); - return; - } - }); - return cnt; -} - -//框选构件 -function boxSelection(that) { - let api = bimSelectionDlgApi; - api.Feature.boxSelect((data) => { - data.forEach((featureId) => { - selectFeature(that, featureId); - }); - }); -} -//隐藏构件选择 -function hideSelection(that) { - let api = bimSelectionDlgApi; - api.Public.clearHandler(); - api.Feature.getByEvent(true, (n) => { - if (n && n["id"]) { - let featureId = n.id; - that.hideParts.push(featureId); - api.Feature.setVisible(featureId, false); - that.hideEl++; - } - }); -} -export default { - selectSingle, - initBim, - clearAllSelection, - partLoadModel, - buildTreeData, - onCheckTree, - boxSelection, - hideSelection, -}; diff --git a/yanzhu-ui-vue3/src/views/manage/plan/bimSelectTools3.js b/yanzhu-ui-vue3/src/views/manage/plan/bimSelectTools3.js new file mode 100644 index 00000000..c60036a9 --- /dev/null +++ b/yanzhu-ui-vue3/src/views/manage/plan/bimSelectTools3.js @@ -0,0 +1,642 @@ +import { modelTreeAllChild } from "@/api/bim/bim"; +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) { + let api = bimSelectionDlgApi; + let featureInfo = getFeatureInfo(that, featureId); + let tmps = that.selectItems.filter((f) => f.featureId == featureId); + if (tmps.length > 0) { + api.Feature.setColor(featureId, "rgba(255,255,255,1)"); + let index = that.selectItems.indexOf(tmps[0]); + if (index > -1) { + that.selectItems.splice(index, 1); + } + } else { + api.Feature.setColor(featureId, "rgba(255,0,255,1)"); + if (!that.showMode) { + api.Feature.setVisible(featureId, false); + } + that.selectItems.push(featureInfo); + } +} + +function getHideFeatures(that) { + let result = []; + that.readlyParts.forEach((d) => { + result.push(d); + }); + that.hideFeatures.forEach((d) => { + result.push(d); + }); + return result; +} + +function hideFeature(that, featureId) { + let api = bimSelectionDlgApi; + api.Feature.setVisible(featureId, false); +} + +function selectSingle(that) { + let api = bimSelectionDlgApi; + api.Public.clearHandler(); + api.Feature.getByEvent(true, async (n) => { + if (n && n["id"]) { + let featureId = n.id; + let modelId = featureId.split("^")[0]; + await getServerFeatureInfo(that, featureId); + selectFeature(that, featureId); + } + }); +} + +//将模型信息转换为构件信息 +function 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; +} + +function getFeatureInfo(that, featureId) { + let tmps = that.allFeatures.filter((d) => d.featureId == featureId); + return tmps.length > 0 ? tmps[0] : null; +} +//根据FeatureId获取模型信息,并存入allFeatures数组中 +async function getServerFeatureInfo(that, featureId) { + if (getFeatureInfo(that, featureId)) { + return; + } + let tmps = featureId.split("^"); + if (tmps.length < 2) { + return; + } + let modelId = tmps[0]; + let externalId = tmps[1]; + let res = await getModelFeatureInfo(modelId, externalId); + convertServerDataToFeatureInfo(that, res, modelId); +} + +function convertServerDataToFeatureInfo(that, res, modelId) { + (res.data || []).forEach((o) => { + o = convertFeatureInfo(o, modelId); + if (o.externalId != "0") { + if (!that.allParts.includes(o.featureId)) { + that.allParts.push(o.featureId); + } + } + that.allFeatures.push({ + featureId: o.featureId, + info: o.info, + }); + }); +} + +async function getServerFeatureInfos(that, ids) { + if (ids.length == 0) { + return; + } + let tmps = ids[0].split("^"); + if (tmps.length < 2) { + return; + } + let modelId = tmps[0]; + let externalIds = ids.map((it) => it.split("^")[1]); + let res = await getModelFeatureInfos(modelId, externalIds); + convertServerDataToFeatureInfo(that, res, modelId); +} + +function clearAllSelection(that) { + that.$modal.confirm("确定清除所有已选择构件吗?").then(() => { + let api = bimSelectionDlgApi; + that.selectItems.forEach((d) => { + api.Feature.setColor(d.featureId, "rgba(255,255,255,1)"); + }); + that.selectItems = []; + that.selEl++; + }); +} + +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 + ) { + 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); + } + }); + }); +} + +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 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(); + } +} + +//构建树形数据 +function buildTreeData(that) { + that.allFeatures = []; + that.models.forEach((d) => { + getModelFeatures(that, d.lightweightName); + }); +} + +//获取模型所有构件 +function getModelFeatures(that, modelId) { + //获取模型构件 + modelTreeAllChild(modelId, "").then((res) => { + let objs = res.data || []; + + objs.forEach((o) => { + o = convertFeatureInfo(o, modelId); + let featureId = o.modelId + "^" + o.externalId; + if (!that.allParts.includes(featureId)) { + that.allParts.push(featureId); + } + that.allFeatures.push(o); + }); + }); +} + +//树上点击事件 +function onCheckTree(that, node, event) { + let api = bimSelectionDlgApi; + + if (that.partLoad) { + that.$refs.tree.setChecked("root", false, true); + that.partLoad = false; + that.models.forEach((it) => { + api.Model.remove(it.modelId); + }); + return; + } + if (loadModels(that) > 0) { + let func = () => { + if (that.loadedModelCount == that.models.length) { + setTimeout(() => { + setTreeNodeChecked(that, node, event); + }, 1000); + } else { + setTimeout(func, 100); + } + }; + func(); + } else { + setTreeNodeChecked(that, node, event); + } +} + +let maxLen = 500; +//根据选择控制构件的隐藏和显示 +async function setTreeNodeChecked(that, node, event) { + let api = bimSelectionDlgApi; + let checked = event.checkedNodes.includes(node); + if (node.type == "root") { + if (checked) { + that.models.forEach((it) => { + api.Model.setVisible(it.modelId, true); + it.visible = true; + api.Model.original(it.modelId); + }); + } else { + that.models.forEach((it) => { + api.Model.setVisible(it.modelId, false); + it.visible = false; + }); + } + } else if (node.type == "model") { + if (checked) { + api.Model.setVisible(node.modelId, true); + that.models.find((d) => d.modelId == node.modelId).visible = true; + api.Model.original(node.modelId); + } else { + api.Model.setVisible(node.modelId, false); + that.models.find((d) => d.modelId == node.modelId).visible = false; + } + } else { + let isPartLoad = false; + if ( + !that.models.find((d) => d.modelId == node.modelId).visible && + checked + ) { + isPartLoad = true; + } + let selFeatureIds = []; + if (node.leaf) { + selFeatureIds = [node.featureId]; + } else { + if (!node.leafs) { + let leafs = await getNodeLeafs(that, node); + node.leafs = leafs; + } + selFeatureIds = node.leafs.map((f) => f.featureId); + } + let selitemsFeatureIds = that.selectItems.map((it) => it.featureId); + 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 { + if (isPartLoad) { + selitemsFeatureIds.forEach((it) => { + tmps.push(it); + }); + if (tmps.length == 0) { + return; + } + let func = () => { + let tmpsIds2 = tmps.splice(0, maxLen); + api.Feature.showFeatures(tmpsIds2.join("#")); + setFeatueVisible(tmps, true); + }; + if (!api.m_model.has(node.modelId)) { + that.addModel(node.modelId, func); + } else { + api.Model.setVisible(node.modelId, true); + that.models.find((d) => d.modelId == node.modelId).visible = true; + api.Model.original(node.modelId); + func(); + } + } else { + setFeatueVisible(tmps, true); + } + } + } + setFeatueShowOrHide(that); +} + +function setFeatueVisible(featureIds, show) { + let len = maxLen; + let api = bimSelectionDlgApi; + let cnt = featureIds.length; + if (cnt == 0) { + return; + } + for (let i = 0; i < cnt; i += len) { + api.Feature.setVisible(featureIds.slice(i, i + len).join("#"), show); + } +} + +async function getNodeLeafs(that, node) { + const res = await getTreeAllLeafChild(node.modelId, node.glid); + return (res.data || []).map((f) => { + let o = convertFeatureInfo(f, node.modelId); + if (o.externalId != "0") { + if (!that.allParts.includes(o.featureId)) { + that.allParts.push(o.featureId); + } + } + that.allFeatures.push({ + featureId: o.featureId, + info: o.info, + }); + return o; + }); +} + +//处理构件的隐藏和显示 +function setFeatueShowOrHide(that) { + let api = bimSelectionDlgApi; + //隐藏构件 + let hideFeatures = getHideFeatures(that); + api.Feature.setVisible(hideFeatures.join("#"), false); + + //标注已选择的构件 + that.selectItems.forEach((it) => { + api.Feature.setColor(it.featureId, "rgba(255,0,255,1)"); + if (!that.showMode) { + api.Feature.setVisible(it, false); + } + }); + + api.Feature.setVisible(that.hideParts.join("#"), false); +} + +//加载模型 +function loadModels(that) { + let api = bimSelectionDlgApi; + let modelIds = that.models.map((it) => it.lightweightName); + let cnt = 0; + that.loadedModelCount = 0; + modelIds.forEach((modelId) => { + if (!api.m_model.has(modelId)) { + cnt++; + that.addModel(modelId); + return; + } + }); + return cnt; +} + +//框选构件 +function boxSelection(that) { + let api = bimSelectionDlgApi; + api.Feature.getByEvent(false); + ElMessage.info("右键取消选择"); + api.Public.event("RIGHT_CLICK", (res) => { + api.Feature.closeBoxSelect(); + that.activeMenu = -1; + }); + api.Feature.boxSelect(async (data) => { + await getServerFeatureInfos(that, data); + data.forEach((featureId) => { + selectFeature(that, featureId); + }); + }); +} +//隐藏构件选择 +function hideSelection(that) { + let api = bimSelectionDlgApi; + api.Public.clearHandler(); + api.Feature.getByEvent(false); + api.Feature.getByEvent(true, async (n) => { + if (n && n["id"]) { + let featureId = n.id; + await getServerFeatureInfo(that, featureId); + that.hideParts.push(featureId); + api.Feature.setVisible(featureId, false); + that.hideEl++; + } + }); +} +//异步加载树 +function loadNode(that, node, resolve) { + if (!that.show) { + return; + } + if (node.level == 0) { + let nd = [ + { + title: "项目模型", + level: 0, + type: "root", + key: "root", + children: [], + hadLoad: true, + }, + ]; + + resolve(nd); + setTimeout(() => { + document + .querySelectorAll(".bim-selection-dialog .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 { + getTreeChildren(that, node, resolve); + } +} + +function getTreeChildren(that, node, resolve) { + let data = node.data; + 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 = convertFeatureInfo(it, data.modelId); + if ( + that.allFeatures.filter((item) => item.featureId == it.featureId) + .length == 0 + ) { + that.allFeatures.push({ + featureId: it.featureId, + info: it.info, + }); + } + if (o.externalId != "0") { + if (!that.allParts.includes(o.featureId)) { + that.allParts.push(o.featureId); + } + } + + return o; + }); + //addToAllFeatures(that, tmps); + resolve(tmps); + }); +} + +function addToAllFeatures(that, features) { + features.forEach((it) => { + if (!that.allFeatures.has(it.glid)) { + that.allFeatures.push(it); + } + }); +} + +async function selectTreeData(that) { + let api = bimSelectionDlgApi; + let nodes = that.$refs.tree.getCheckedNodes(); + if (nodes.length == 0) { + return; + } + let obj = {}; + nodes.forEach((d) => { + let modelId = d.modelId; + if (modelId) { + if (!obj[modelId]) { + obj[modelId] = []; + } + if (d.glid) { + obj[modelId].push(d.glid); + } + } + }); + for (let modelId in obj) { + let glids = obj[modelId]; + if (glids.length > 0) { + let res = await modelTreeAllLeafChildByGlids(modelId, glids); + (res.data || []).forEach((o) => { + o = convertFeatureInfo(o, modelId); + if (o.externalId != "0") { + if (!that.allParts.includes(o.featureId)) { + that.allParts.push(o.featureId); + } + } + that.allFeatures.push({ + 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) + ) { + that.selectItems.push(o); + api.Feature.setColor(o.featureId, "rgba(255,0,255,1)"); + } + }); + } + } +} + +//构建树数据 +function makePlanTree(that) { + let objs = []; + const func = (datas) => { + datas.forEach((data) => { + data.checked = false; + data.bim = that.$tryToJson(data.bimId || "[]", []); + data.hasBim = data.bim && data.bim.length > 0; + data.children = that.planList.filter((it) => it.parentId == data.taskId); + func(data.children); + }); + return datas; + }; + objs = func(that.planList.filter((it) => it.parentId == 0)); + that.planTree = objs; + that.planTreeKey++; +} + +//根据选择的计划显示构件 +function showPlanFeatchure(that) { + let api = bimSelectionDlgApi; + if (that.plan.hasBim) { + //已绑定BIM模型 显示已绑定的构件 + let featureIds = that.plan.bim.map((it) => it.featureId); + if (featureIds.length > 0) { + let tmpsIds2 = featureIds.splice(0, 1000); + api.Feature.showFeatures(tmpsIds2.join("#")); + that.selectItems = that.plan.bim.map((it) => it); + featureIds = that.plan.bim.map((it) => it.featureId); + api.Feature.setColor(featureIds.join("#"), "rgba(255,0,255,1)"); + } + } else { + //未绑定BIM模型 显示所有可以绑定的构件 + } +} + +export default { + selectSingle, + initBim, + clearAllSelection, + partLoadModel, + buildTreeData, + onCheckTree, + boxSelection, + hideSelection, + loadNode, + selectTreeData, + makePlanTree, + showPlanFeatchure, +}; diff --git a/yanzhu-ui-vue3/src/views/manage/plan/bimSelectionDialog.vue b/yanzhu-ui-vue3/src/views/manage/plan/bimSelectionDialog3.vue similarity index 62% rename from yanzhu-ui-vue3/src/views/manage/plan/bimSelectionDialog.vue rename to yanzhu-ui-vue3/src/views/manage/plan/bimSelectionDialog3.vue index 3f8d362f..537e3e57 100644 --- a/yanzhu-ui-vue3/src/views/manage/plan/bimSelectionDialog.vue +++ b/yanzhu-ui-vue3/src/views/manage/plan/bimSelectionDialog3.vue @@ -1,5 +1,12 @@ - + @@ -7,7 +14,7 @@ - + + :load="loadNode" + lazy + show-checkbox + > - + {{ it.info }} @@ -37,7 +51,11 @@ 删除所有 - + {{ it.info }} @@ -47,64 +65,155 @@ - - + + + + + + + + + + + + + {{ plan.taskName }}[{{ plan.hasBim ? "已" : "未" }}绑定] + + 无选择数据 + + + + + + {{ node.label }} + + + [{{ data.hasBim ? "已" : "未" }}绑定] + + + + + + +