[Frontend][系統監控] 增加讀取 forge 3D Loading 遮罩 | 總攬及電梯系統隱藏全部物件(不包含設備)程序建置 | [圖資管理] 階層新增選擇程序調整 | [全域功能] forge3D 增加讀取失敗回調 Callback | hideAllObjects 隱藏全物件 不包含某些 dbid 程序調整

This commit is contained in:
dev01 2023-01-04 18:49:37 +08:00
parent dd2a66075c
commit 58c95ae806
7 changed files with 87 additions and 84 deletions

View File

@ -16,7 +16,7 @@
<div class="d-flex" id="graTree"></div>
</div>
<div class="col-10">
<div class="row my-2">
<div class="row my-2 mx-0">
<a href="javascript:;" id="creGraMan" class="btn btn-success">
+新增
</a>
@ -65,7 +65,7 @@
</div>
</div>
<div class="col-md-12 mt-2">
<label>原設計</label>
<label>檔案</label>
</div>
<div class="col-md-12">
@ -278,8 +278,8 @@
let dowLoaEle = YT.Alert.Tip("準備下載中...", "show", true);
let rowData = graTable.row($(this).closest("tr")).data();
let apiUrl = baseApiUrl + `/File/Download?type=graph&savename=${rowData.oriSavName}&oriname=${rowData.oriOrgName}`;
let extname = rowData.oriOrgName?.split(".").slice(-1) || "dwg";
download(token, apiUrl, rowData.name + "_原設計圖" + "." + extname, function () {
download(token, apiUrl, rowData.oriOrgName, function () {
$(dowLoaEle.ele).YTAlert().hide();
});
})
@ -390,8 +390,8 @@
Create: {
label: "新增",
_disabled: function (data) {
if (depth >= 3) {
return true; //第層後無法新增
if (depth >= 4) {
return true; //第層後無法新增
}
return false;
},
@ -405,6 +405,12 @@
},
Rename: {
label: "重新命名",
_disabled: function (data) {
if ($node.id == "0") {
return true; //最上層無法編輯
}
return false;
},
action: function (obj) {
tree.edit($node);
/* tree.sort($node, true)*/
@ -412,6 +418,12 @@
},
Remove: {
label: "移除",
_disabled: function (data) {
if ($node.id == "0") {
return true; //最上層無法移除
}
return false;
},
action: function (obj) {
tree.delete_node($node);
}
@ -426,18 +438,27 @@
}
function treeEvent() {
let selectedNode = [];
$('#graTree').on("loaded.jstree", function (e, data) {
let topNode = $('#graTree').jstree(true).get_node("#");
let topNode = $('#graTree').jstree(true).get_node("0");
$('#graTree').jstree(true).select_node(topNode.children[0]);
$("#graTree").jstree("open_node", 0);
})
$('#graTree').on("select_node.jstree", function (e, data) {
dtAjaxResetSendData(graTable, { layer_id: parseInt(data.node.id) });
graTable.ajax.reload();
curLayerId = parseInt(data.node.id);
$("#graLayer").text(levelNameByNodeId(data.node));
$("#curLevText").text(levelNameByNodeId(data.node));
if (data.node.id != "0") {
dtAjaxResetSendData(graTable, { layer_id: parseInt(data.node.id) });
graTable.ajax.reload();
selectedNode.unshift(data.node.id);
if (selectedNode.length > 3) {
selectedNode.splice(selectedNode.length - 1, 1);
}
curLayerId = parseInt(data.node.id);
$("#graLayer").text(levelNameByNodeId(data.node));
$("#curLevText").text(levelNameByNodeId(data.node));
} else {
$("#graTree").jstree(true).deselect_node(data.node);
$("#graTree").jstree(true).select_node(selectedNode[0]);
}
})
$("#graTree").on('create_node.jstree', function (e, data) {
let main = {};
@ -537,14 +558,14 @@
let names = [];
let curNode = $('#graTree').jstree(true).get_node(node);
let parents = curNode.parents.reverse();
for (let i = parents.length - 1; i >= 0; i--) {
if (parents[i] != "#") {
if (parents[i] != "#") {
let node = $('#graTree').jstree(true).get_node(parents[i]);
names.push(node.text);
}
}
names.push(curNode.text);
return names.join("/");

View File

@ -2371,8 +2371,9 @@
//載入3D模型
function load3DModel() {
launchViewer(pageAct.urn, (viewer) => {
let elevOption = {
selector: "#forgeViewer",
viewer: viewer,
@ -2382,12 +2383,16 @@
// 電梯移動訂閱程序載入
let forge3DElev = new Forge3DElevFull(elevOption);
forge3DElev.bajaEndCallback = function () {
debugger
hideAllObjects(this.getNodeIds());
endPageLoading();
}
forge3DElev.bajaChaCallback = function (data) {
subDeviceSetStatus(data);
}
forge3DElev.init();
});
}

View File

@ -45,9 +45,7 @@
setLightColor();
}
if (arr.indexOf(3) != -1) {
getHotspotPoint(() => {
getLightDevice();
show3DModel(data.urn_3D);
});
@ -264,7 +262,11 @@
}
function show3DModel(urn) {
$(loadEle).Loading("start");
launchViewerForHotspot(urn, (viewer, nodeIds) => {
let devDbIds = allDevList.map(x => x.forge_dbid);
hideAllObjects(devDbIds);
$(loadEle).Loading("close");
let devices = allDevList.map(x => {
return {
roomDbId: !isNaN(parseInt(x.room_dbid)) ? parseInt(x.room_dbid) : -1,
@ -300,6 +302,8 @@
endPageLoading();
}
forge3DElev.init();
}, () => {
$(loadEle).Loading("close");
}, "[name=forgeViewer]");
}
@ -337,50 +341,11 @@
}
async function getLightDevice() {//callback = null
getLightData(null);
let url = baseApiUrl + "/api/GetDevNodeForCor";
let sendData = {
"device_area_tag": pageAct.AreaTag,
"device_building_tag": pageAct.buiTag,
"device_system_tag": pageAct.sysMainTag,
"device_name_tag": pageAct.sysSubTag,
};
objSendData.Data = sendData;
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
if (!res || res.code != "0000" || !res.data) {
} else {
let myLightList = [];
$.each(res.data, (idx, data) => {
let item = {};
item.position = {};
if (data.device_node_coordinate_3d != null && isJSON(data.device_node_coordinate_3d)) {
item.position = JSON.parse(data.device_node_coordinate_3d);
}
$.extend(item, data);
myLightList.push(item);
})
console.log("2", myLightList);
setLightList(myLightList);
//callback ? callback() : "";
}
}, null, "POST").send();
}
function setHotspotPoint(myDataList = []) {
console.log(myDataList)
getHopspotPoint(myDataList);
}
async function setLightList(myDataList = []) {
console.log(myDataList);
getLightData(myDataList);
}
var parentEle = "";
onEvent("autodesk:click:sprite", "[name=forgeViewer]", function (e, obj) {
forgeUnFocusAll();

View File

@ -1034,10 +1034,11 @@
// show 3D 模型
function show3DModel(urn) {
$(loadEle).Loading("start");
launchViewerForHotspot(urn, (viewer, nodeIds) => {
let nextFloor = getNextFloor(pageAct.floGuid);
let curFloTag = pageAct.floTag;
debugger
if (!nextFloor) {
toast_warning("超出樓層範圍");
return;
@ -1050,7 +1051,9 @@
nextFloor = nextFloor.split("U")[1];
}
getLevelsData(curFloTag, nextFloor);
getLevelsData(curFloTag, nextFloor, function () {
$(loadEle).Loading("close");
});
setHeatMap();
let elevOption = {
@ -1066,6 +1069,8 @@
endPageLoading();
}
forge3DElev.init();
});
}

View File

@ -140,7 +140,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
<!--we need this logo when user switches to nav-function-top-->
<div class="page-logo">
<a href="javascript:;" name="topFunBtn" data-page="dashboard" class="page-logo-link press-scale-down d-flex align-items-center position-relative">
<img name="webLogo" src="img/logo.png" alt="SmartAdmin WebApp" aria-roledescription="logo">
<img src="img/logo.png" alt="SmartAdmin WebApp" aria-roledescription="logo">
<!--<span class="page-logo-text mr-1">SmartAdmin WebApp</span>-->
<!--<span class="position-absolute text-white opacity-50 small pos-top pos-right mr-2 mt-n2"></span>
@ -824,7 +824,6 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
function isValidLogin() {
$("#app").load("_dashboard.html", loadCallback);
getLogo();
getUserInfo();
iniFroList();
showMainSys();
@ -1457,7 +1456,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
}
let li = creEle("li");
let a = creA(subSysObj.full_name, { "href": "javascript:;" }, [], `subSysBtn${subSysObj.sub_system_tag}`, { page: page, tabname: page }, "topFunBtn");
let a = creA(subSysObj.full_name, { "href": "javascript:;" }, [], `subSysBtn${subSysObj.sub_system_tag}`, { page: page, tabname: "systemMonitor" }, "topFunBtn");
li.append(a);
a.data("subSysObj", subSysObj)
subSysObj.main_system_tag = mainSysObj.main_system_tag;
@ -1468,17 +1467,6 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
}, null, "POST").send();
}
function getLogo() {
$.ajax({
method: "post",
url: 'api/GetLogo',
async: false,
success: function (rel) {
$('[name=webLogo]').attr('src', 'img/' + rel);
}
})
}
function getUserInfo() {
let url = baseApiUrl + varApiUrl + "getUserFull";

View File

@ -11,7 +11,7 @@ var levels;//剖面用
var lowerIdx;//剖面的下方樓層
var upperIdx;//剖面的上方樓層
function launchViewer(urn, callback, _selector = "#forgeViewer") {
function launchViewer(urn, callback,failCallback, _selector = "#forgeViewer") {
selector = _selector;
var options = {
env: 'AutodeskProduction',
@ -29,7 +29,9 @@ function launchViewer(urn, callback, _selector = "#forgeViewer") {
$(selector).on("autodesk:loaded", function (e, nodeIds) {
callback ? callback(viewer, nodeIds) : "";
})
$(selector).on("autodesk:loaded:fail", function (e) {
failCallback ? failCallback(viewer) : "";
})
//test
// for (let i = 0; i < urn.length; i++) {
@ -58,7 +60,7 @@ function launchViewer(urn, callback, _selector = "#forgeViewer") {
});
}
function launchViewerForHotspot(urn, callback, _selector = "#forgeViewer") {
function launchViewerForHotspot(urn, callback, failCallback, _selector = "#forgeViewer") {
selector = _selector;
var av = Autodesk.Viewing;
var options = {
@ -80,10 +82,14 @@ function launchViewerForHotspot(urn, callback, _selector = "#forgeViewer") {
$(selector).on("autodesk:loaded", function (e, nodeIds) {
callback ? callback(viewer, nodeIds) : "";
})
$(selector).on("autodesk:loaded:fail", function (e) {
failCallback ? failCallback(viewer) : "";
})
});
}
function launchViewerNoTools(urn, callback, _selector = "#forgeViewer") {
function launchViewerNoTools(urn, callback, failCallback, _selector = "#forgeViewer") {
selector = _selector;
var options = {
env: 'AutodeskProduction',
@ -101,6 +107,10 @@ function launchViewerNoTools(urn, callback, _selector = "#forgeViewer") {
$(selector).on("autodesk:loaded", function (e, nodeIds) {
callback ? callback(viewer, nodeIds) : "";
})
$(selector).on("autodesk:loaded:fail", function (e) {
failCallback ? failCallback(viewer) : "";
})
});
}
@ -495,7 +505,7 @@ function getAllDbIds(viewer) {
* Autodesk.Viewing.Document.load() failuire callback.
*/
function onDocumentLoadFailure(viewerErrorCode) {
$(selector).trigger("autodesk:loaded");
$(selector).trigger("autodesk:loaded:fail");
console.error("onDocumentLoadFailure() - errorCode:" + viewerErrorCode);
}
@ -1001,7 +1011,7 @@ async function getRemoteLevels() {
return levels2;
}
async function getLevelsData(lowerFloor, upperFloor) {
async function getLevelsData(lowerFloor, upperFloor, callback = null) {
// 樓層正規化 取得樓層
const floorRegex = /[\d|\w]+F/gmi;
const data = await this.getRemoteLevels();
@ -1015,7 +1025,7 @@ async function getLevelsData(lowerFloor, upperFloor) {
}
}
this.levels = data;
profile();
profile(callback);
}
function getCutPlaneParam(idx, n) {
@ -1036,12 +1046,13 @@ function getCutPlaneParam(idx, n) {
return new THREE.Vector4(0, 0, n, d);
}
function profile() {
function profile(callback = null) {
//const upperIdx = 6;
const upperCutPlaneParam = this.getCutPlaneParam(upperIdx, 1);
//const lowerIdx = 7;
const lowerCutPlaneParam = this.getCutPlaneParam(lowerIdx, -1);
this.viewer.setCutPlanes([upperCutPlaneParam, lowerCutPlaneParam]);
callback ? callback() : "";
}
//----------------- end -----------------------------------------------
//新增燈光
@ -1090,12 +1101,16 @@ function changeColorTransparency(nodeId, color) {//變綠色
viewer.setThemingColor(nodeId, color);
}
//隱藏全物件
function hideAllObjects() {
//隱藏全物件 (篩選 dbids 除外)
function hideAllObjects(filDbids = []) {
//viewer.hide(4);//只針對一個物件(dbid為4)做隱藏
for (var i = 0; i < allDbIdsStr.length; i++) {
viewer.hide(parseInt(allDbIdsStr[i]));
}
for (var i = 0; i < filDbids.length; i++) {
viewer.show(parseInt(filDbids[i]), viewer.model);
}
}
//顯示全物件
function showAllObjects() {

View File

@ -604,4 +604,8 @@ class Forge3DElevFull {
}
}, null, "POST").send();
}
getNodeIds = function () {
return this.elev3DObj.map(x => x.nodeId);
}
}