diff --git a/public/bimBase.html b/public/bimBase.html index d6a71ea9..de4633a9 100644 --- a/public/bimBase.html +++ b/public/bimBase.html @@ -37,6 +37,8 @@ hideArr: [], colorArr: [], }; + let firstEnter = 0; + let dealArr = []; async function main() { // 创建实例需要传入的参数,部署环境serviceConfig 和 用户有效期getAccessToken const applicationOptions = { @@ -68,7 +70,59 @@ obvDocument: obvDocument, viewer3dItem: viewer3dItems[0], }); - // 设置监听事件 + // 监听模型树加载完成,可以查询模型树(getObjectTree) + obvApi.addEventListener( + OBV.ViewerEventTypes.V3dModelTreeLoadedEvent, + (event) => { + console.log("V3dModelTreeLoadedEvent", event); + + // 设置监听事件(主要用于模型树隐藏) + obvApi.addEventListener( + OBV.ViewerEventTypes.V3dHideEvent, + (event) => { + console.log(event); + // obvApi + // .getObjectTree(event.nodeIdArray[0].modelId) + // .then(async (modelTreeData) => { + // console.log(JSON.parse(JSON.stringify(modelTreeData))); + // let responseData = JSON.parse(JSON.stringify(modelTreeData)) + // dealArr.push({modelId: responseData.modelId, dbId: responseData.rootId}) + // await dealArrData(responseData.root.children); + // // 往父级传递 + // window.parent.postMessage({ msg: dealArr, tip: 'hidden' }); + // }); + // 往父级传递 + window.parent.postMessage({ + msg: event.nodeIdArray, + tip: "hidden", + }); + } + ); + // 设置监听事件(主要用于模型树显示) + obvApi.addEventListener( + OBV.ViewerEventTypes.V3dShowEvent, + (event) => { + console.log(event); + // obvApi + // .getObjectTree(event.nodeIdArray[0].modelId) + // .then(async (modelTreeData) => { + // console.log(JSON.parse(JSON.stringify(modelTreeData))); + // let responseData = JSON.parse(JSON.stringify(modelTreeData)) + // dealArr.push({dbId: responseData.rootId}) + // await dealArrData(responseData.root.children); + // // 往父级传递 + // window.parent.postMessage({ msg: dealArr, tip: 'hidden' }); + // }); + // 往父级传递 + window.parent.postMessage({ + msg: event.nodeIdArray, + tip: "show", + }); + } + ); + } + ); + // 设置监听事件(构件选择) obvApi.addEventListener( OBV.ViewerEventTypes.V3dSelectionChangedEvent, (event) => { @@ -77,44 +131,60 @@ window.parent.postMessage({ msg: event.nodeIdArray }); } ); - // 监听相机改变 obvApi.addEventListener( OBV.ViewerEventTypes.V3dCameraChangeEvent, (event) => { console.log("V3dCameraChangeEvent", event); - // 操作模型 - renderConfigModel(obvApi); + if (firstEnter == 0) { + // 首次进入才操作模型 + // 操作模型 + renderConfigModel(obvApi); + } } ); } + // 处理数据 + function dealArrData(arr) { + arr.map((item) => { + if (item.children && item.children.length > 0) { + dealArrData(item.children); + } + dealArr.push({ dbId: item.dbId }); + }); + } function renderConfigModel(obvApi) { console.log(obvApi); console.log(configValue.hideArr); + ++firstEnter; // 避免多次调用 // 隐藏构件 if (configValue.hideArr.length > 0) { obvApi.hide(configValue.hideArr); - } else { - obvApi.showAll(); } + // else { + // obvApi.showAll(); + // } // 构件着色 if (configValue.colorArr.length > 0) { configValue.colorArr.map((item) => { - let firstIndex = item.color.indexOf(","); - let secondIndex = item.color.indexOf(",", firstIndex + 1); - let thirdIndex = item.color.indexOf(")", -1); - // 构件着色 - obvApi.setObjectsColor( - [item], - item.color.substring(4, firstIndex), - item.color.substring(firstIndex + 2, secondIndex), - item.color.substring(secondIndex + 2, thirdIndex), - 1 - ); + if (item.modelId) { + let firstIndex = item.color.indexOf(","); + let secondIndex = item.color.indexOf(",", firstIndex + 1); + let thirdIndex = item.color.indexOf(")", -1); + // 构件着色 + obvApi.setObjectsColor( + [item], + item.color.substring(4, firstIndex), + item.color.substring(firstIndex + 2, secondIndex), + item.color.substring(secondIndex + 2, thirdIndex), + 1 + ); + } }); - } else { - obvApi.restoreObjectsColor(); } + // else { + // obvApi.restoreObjectsColor(); + // } } // 访问的令牌 getAccessToken 和 令牌有效期 expiresIn function getAccessToken(callBack) { @@ -127,6 +197,7 @@ const data = e.data || {}; console.log(data.token); console.log(data.urn); + firstEnter = 0; if (data.token && data.urn) { configValue.viewToken = data.token; configValue.urn = data.urn; diff --git a/public/bimBaseProgressModel.html b/public/bimBaseProgressModel.html index 5c06c8c1..808bc964 100644 --- a/public/bimBaseProgressModel.html +++ b/public/bimBaseProgressModel.html @@ -89,10 +89,17 @@ } function renderConfigModel(obvApi) { console.log(obvApi); + console.log(configValue.bimComponent); // 构件着色 if (configValue.bimComponent.length > 0) { // 构件着色 - obvApi.setObjectsColor(configValue.bimComponent, 51, 122, 183, 1); + configValue.bimComponent.map((item) => { + if(item.modelId){ + // 构件着色 + obvApi.setObjectsColor([item], 51, 122, 183, 1); + } + }); + // obvApi.setObjectsColor(configValue.bimComponent, 51, 122, 183, 1); } else { obvApi.restoreObjectsColor(); } diff --git a/src/assets/js/http.js b/src/assets/js/http.js index 02bacf96..34c8caed 100644 --- a/src/assets/js/http.js +++ b/src/assets/js/http.js @@ -67,7 +67,7 @@ if (process.env.NODE_ENV == 'development') { // axios.defaults.baseURL = 'http://183.234.150.152:9090/' //华发 huaxin 123456789 // axios.defaults.baseURL = 'http://182.90.224.147:18170' //瑞士恒通线上 // axios.defaults.baseURL = 'http://58.250.210.9:9090/' //深汕线上 - // axios.defaults.baseURL = 'http://101.43.164.214:11111/' //百色线上 + axios.defaults.baseURL = 'http://101.43.164.214:11111/' //百色线上 // axios.defaults.baseURL = 'http://101.43.164.214:12345/'//内蒙古线上 // axios.defaults.baseURL = 'http://121.196.214.246/api/'//金林湾线上新 // axios.defaults.baseURL = 'http://42.194.144.62:8088/'//中建四局线上(新)地址 diff --git a/src/views/projectFront/BIMBASECenter/overviewTwo.vue b/src/views/projectFront/BIMBASECenter/overviewTwo.vue index fbb0d555..de7c237b 100644 --- a/src/views/projectFront/BIMBASECenter/overviewTwo.vue +++ b/src/views/projectFront/BIMBASECenter/overviewTwo.vue @@ -11,10 +11,19 @@ :value="item.value" /> + + 保存 -
+ +