From 926df773be0a0e67c79d1fde58547f07433dd428 Mon Sep 17 00:00:00 2001 From: dingcui Date: Mon, 6 May 2024 10:29:23 +0800 Subject: [PATCH] =?UTF-8?q?fix(111):=20=E8=A7=A3=E5=86=B3=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E9=97=AA=E7=8E=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../layout/layout.component.html | 2 +- .../layout/layout.component.less | 12 +- .../implementation/layout/layout.component.ts | 351 ++++++++++-------- 3 files changed, 205 insertions(+), 160 deletions(-) diff --git a/digital-future-summit/src/app/implementation/layout/layout.component.html b/digital-future-summit/src/app/implementation/layout/layout.component.html index 2695023..279803e 100644 --- a/digital-future-summit/src/app/implementation/layout/layout.component.html +++ b/digital-future-summit/src/app/implementation/layout/layout.component.html @@ -32,7 +32,7 @@ -
+
{ - this.queryDisplayList = res.response; - this.queryDisplayList.forEach(item => { - this.systemMaps["SSO_" + item.id] = { - key: item.id, - id: item.id, - title: item.name, - mockLogin: false, - ssoLogin: true, - callBackUrl: item.callBackUrl, - url: item.cloudwebsite, - applicationAppId: item.applicationAppId - }; - - // 非管理员加载 - this.divContent.userId = this.USER_ID; - if (this.USER_ID === 'dongsk@digiwin.com' || this.USER_ID === 'M00020') { - this.divContent.userId = "default"; - } - - }); - - // 初始化布局 - this.initSysLayout(); - console.log("systemMaps", this.systemMaps); + const url = + this.commonService.semcUrl + "/tenant/semc/applink/queryDisplayList"; + this.commonService + .getRequestWithHeaders(url, headers) + .then((res) => { + this.queryDisplayList = res.response; + this.queryDisplayList.forEach((item) => { + this.systemMaps["SSO_" + item.id] = { + key: item.id, + id: item.id, + title: item.name, + mockLogin: false, + ssoLogin: true, + callBackUrl: item.callBackUrl, + url: item.cloudwebsite, + applicationAppId: item.applicationAppId, + }; + + // 非管理员加载 + this.divContent.userId = this.USER_ID; + if ( + this.USER_ID === "dongsk@digiwin.com" || + this.USER_ID === "M00020" + ) { + this.divContent.userId = "default"; + } + }); - }).catch((error) => console.error(error)); + // 初始化布局 + this.initSysLayout(); + console.log("systemMaps", this.systemMaps); + }) + .catch((error) => console.error(error)); } - initSysLayout() { - if (!this.layoutUsers.includes(this.divContent.userId)) { return; } const DwUserInfo = JSON.parse(sessionStorage.getItem("DwUserInfo")); - this.commonService.postWithHeaders(this.commonService.apiUrl + "/restful/standard/demo/api/517/config/list", - { - userId: this.divContent.userId, - tenantId: DwUserInfo.tenantId, - sysId: '' - }, - { - "Digi-Middleware-Auth-App": DigiMiddlewareAuthApp, - "Digi-Middleware-Auth-User": DigiMiddlewareAuthUser, - } - ).then(res => { - if (res && res.response) { - res.response.forEach(item => { - // console.log(item); - const sysEL = this.el.nativeElement.querySelector('#' + item.sysId); - // this.renderer.setStyle(sysEL, 'top', item.top); - // this.renderer.setStyle(sysEL, 'left', item.left); - // this.renderer.setStyle(sysEL, 'width', item.width); - // this.renderer.setStyle(sysEL, 'height', item.height); - - this.renderer.setStyle(sysEL, 'top', item.topPercent); - this.renderer.setStyle(sysEL, 'left', item.leftPercent); - this.renderer.setStyle(sysEL, 'width', item.widthPercent); - this.renderer.setStyle(sysEL, 'height', item.heightPercent); - }); - } - }); + this.commonService + .postWithHeaders( + this.commonService.apiUrl + + "/restful/standard/demo/api/517/config/list", + { + userId: this.divContent.userId, + tenantId: DwUserInfo.tenantId, + sysId: "", + }, + { + "Digi-Middleware-Auth-App": DigiMiddlewareAuthApp, + "Digi-Middleware-Auth-User": DigiMiddlewareAuthUser, + } + ) + .then((res) => { + if (res && res.response) { + res.response.forEach((item) => { + // console.log(item); + const sysEL = this.el.nativeElement.querySelector("#" + item.sysId); + // this.renderer.setStyle(sysEL, 'top', item.top); + // this.renderer.setStyle(sysEL, 'left', item.left); + // this.renderer.setStyle(sysEL, 'width', item.width); + // this.renderer.setStyle(sysEL, 'height', item.height); + + this.renderer.setStyle(sysEL, "top", item.topPercent); + this.renderer.setStyle(sysEL, "left", item.leftPercent); + this.renderer.setStyle(sysEL, "width", item.widthPercent); + this.renderer.setStyle(sysEL, "height", item.heightPercent); + this.showElement = true; + }); + } + }); } jumpToSystem(key: string) { - - const DwUserInfo = JSON.parse(sessionStorage.getItem("DwUserInfo")); - if (DwUserInfo.userId === 'dongsk@digiwin.com' || DwUserInfo.userId === 'M00020') { + if ( + DwUserInfo.userId === "dongsk@digiwin.com" || + DwUserInfo.userId === "M00020" + ) { return; } @@ -154,7 +183,7 @@ export class LayoutComponent implements OnInit, AfterViewInit { // 免密跳转 if (item.linkLogin) { - window.open(item.url, '_blank'); + window.open(item.url, "_blank"); return; } @@ -165,54 +194,64 @@ export class LayoutComponent implements OnInit, AfterViewInit { // 单点登录 if (item.ssoLogin) { - - this.commonService.postWithHeaders(this.commonService.iamUrl + "/api/iam/v2/oauth2/authorize", - { - "appId": item.applicationAppId, - "callbackUrl": item.callBackUrl - }, - headers - ).then(res => { - if (res && res.data && res.data.code) { - window.open(item.url + "&code=" + res.data.code); - } - }); + this.commonService + .postWithHeaders( + this.commonService.iamUrl + "/api/iam/v2/oauth2/authorize", + { + appId: item.applicationAppId, + callbackUrl: item.callBackUrl, + }, + headers + ) + .then((res) => { + if (res && res.data && res.data.code) { + window.open(item.url + "&code=" + res.data.code); + } + }); return; } // 模拟登录 if (item.mockLogin) { - - this.commonService.postWithHeaders(this.commonService.apiUrl + "/restful/standard/demo/api/default/login", - { - userId: DwUserInfo.userId, - tenantId: DwUserInfo.tenantId, - productKey: item.id - }, headers - ).then(res => { - if (res && res.response) { - window.open(item.url + "/sso-login?userToken=" + res.response.user_token); - } - }); - + this.commonService + .postWithHeaders( + this.commonService.apiUrl + + "/restful/standard/demo/api/default/login", + { + userId: DwUserInfo.userId, + tenantId: DwUserInfo.tenantId, + productKey: item.id, + }, + headers + ) + .then((res) => { + if (res && res.response) { + window.open( + item.url + "/sso-login?userToken=" + res.response.user_token + ); + } + }); } else { - // 切换租户登录 - this.commonService.postWithHeaders(this.commonService.iamUrl + "/api/iam/v2/identity/token/refresh/tenant", - { tenantSid: item.sid }, - headers - ).then(res => { - if (res) { - window.open(item.url + "/sso-login?userToken=" + res.user_token); - } - }); + this.commonService + .postWithHeaders( + this.commonService.iamUrl + + "/api/iam/v2/identity/token/refresh/tenant", + { tenantSid: item.sid }, + headers + ) + .then((res) => { + if (res) { + window.open(item.url + "/sso-login?userToken=" + res.user_token); + } + }); } } handleElementDrag(data: any) { // console.log(data); - if (data.type === 'mousedown') { + if (data.type === "mousedown") { this.isDragging = true; this.divContent.height = data.height; this.divContent.width = data.width; @@ -221,11 +260,11 @@ export class LayoutComponent implements OnInit, AfterViewInit { this.divContent.sysId = data.id; } - if (data.type !== 'mouseup') { + if (data.type !== "mouseup") { return; } - if (data.left === '' || data.top === '') { + if (data.left === "" || data.top === "") { return; } @@ -251,36 +290,38 @@ export class LayoutComponent implements OnInit, AfterViewInit { // } // }); this.isDragging = false; - } changeDiv(type: String) { - - const sysEL = this.el.nativeElement.querySelector('#' + this.divContent.sysId); + const sysEL = this.el.nativeElement.querySelector( + "#" + this.divContent.sysId + ); if (sysEL === null) { return; } - if (type === 'W') { - this.renderer.setStyle(sysEL, 'width', this.divContent.width); + if (type === "W") { + this.renderer.setStyle(sysEL, "width", this.divContent.width); } - if (type === 'H') { - this.renderer.setStyle(sysEL, 'height', this.divContent.width); + if (type === "H") { + this.renderer.setStyle(sysEL, "height", this.divContent.width); } - } save() { - if (!this.layoutUsers.includes(this.divContent.userId)) { return; } - if (this.divContent.left === '' || this.divContent.top === '' || this.divContent.sysId === '' || - this.divContent.width === '' || this.divContent.height === '') { + if ( + this.divContent.left === "" || + this.divContent.top === "" || + this.divContent.sysId === "" || + this.divContent.width === "" || + this.divContent.height === "" + ) { return; } - // 计算百分比 const windowWidth: number = window.innerWidth; const windowHeight: number = window.innerHeight; @@ -290,26 +331,32 @@ export class LayoutComponent implements OnInit, AfterViewInit { const width = parseFloat(this.divContent.width.replace("px", "")); const height = parseFloat(this.divContent.height.replace("px", "")); - this.divContent.topPercent = (Number((top / windowHeight).toFixed(4)) * 100).toString() + "%"; - this.divContent.leftPercent = (Number((left / windowWidth).toFixed(4)) * 100).toString() + "%"; - this.divContent.widthPercent = (Number((width / windowWidth).toFixed(4)) * 100).toString() + "%"; - this.divContent.heightPercent = (Number((height / windowHeight).toFixed(4)) * 100).toString() + "%"; - - console.log('--save--divContent--', this.divContent); - - this.commonService.postWithHeaders(this.commonService.apiUrl + "/restful/standard/demo/api/517/config/save", - this.divContent, - { - "Digi-Middleware-Auth-App": DigiMiddlewareAuthApp, - "Digi-Middleware-Auth-User": DigiMiddlewareAuthUser, - } - ).then(res => { - if (res && res.response) { - alert('sucess!'); - this.divContent.sysId = ''; - } - }); - + this.divContent.topPercent = + (Number((top / windowHeight).toFixed(4)) * 100).toString() + "%"; + this.divContent.leftPercent = + (Number((left / windowWidth).toFixed(4)) * 100).toString() + "%"; + this.divContent.widthPercent = + (Number((width / windowWidth).toFixed(4)) * 100).toString() + "%"; + this.divContent.heightPercent = + (Number((height / windowHeight).toFixed(4)) * 100).toString() + "%"; + + console.log("--save--divContent--", this.divContent); + + this.commonService + .postWithHeaders( + this.commonService.apiUrl + + "/restful/standard/demo/api/517/config/save", + this.divContent, + { + "Digi-Middleware-Auth-App": DigiMiddlewareAuthApp, + "Digi-Middleware-Auth-User": DigiMiddlewareAuthUser, + } + ) + .then((res) => { + if (res && res.response) { + alert("sucess!"); + this.divContent.sysId = ""; + } + }); } - }