|
|
@ -2,14 +2,12 @@ |
|
|
|
import { systemList } from "./system"; |
|
|
|
// import { DwHttpApiInterceptor } from "@webdpt/framework/http";
|
|
|
|
/* eslint-disable quotes */ |
|
|
|
import { Component, OnInit } from "@angular/core"; |
|
|
|
import { Component, ElementRef, OnInit, Renderer2 } from "@angular/core"; |
|
|
|
import { |
|
|
|
DigiMiddlewareAuthApp, |
|
|
|
DigiMiddlewareAuthUser, |
|
|
|
} from "app/config/app-auth-token"; |
|
|
|
import { CommonService } from "../service/common.service"; |
|
|
|
import { log } from "console"; |
|
|
|
import { menuData } from './../menu/model/menu.model'; |
|
|
|
|
|
|
|
@Component({ |
|
|
|
selector: "app-layout", |
|
|
@ -18,25 +16,51 @@ import { menuData } from './../menu/model/menu.model'; |
|
|
|
}) |
|
|
|
export class LayoutComponent implements OnInit { |
|
|
|
// 登出: https://iam-test.digiwincloud.com.cn/api/iam/v2/identity/logout
|
|
|
|
userToken: string; |
|
|
|
systemMaps = {}; |
|
|
|
user_info = { |
|
|
|
userId: "", // 当前用户账号
|
|
|
|
tenantId: "", // 当前用户租户id
|
|
|
|
productKey: "", // json字段的头部
|
|
|
|
}; |
|
|
|
queryDisplayList = []; |
|
|
|
constructor(private commonService: CommonService) { } |
|
|
|
USER_ID = ''; |
|
|
|
|
|
|
|
dragEnable: boolean = false; |
|
|
|
|
|
|
|
isDragging: boolean = false; |
|
|
|
|
|
|
|
layoutUsers = ['digiwin0001', 'digiwin0002', 'digiwin0003', 'digiwin0004', 'digiwin0005', 'default', |
|
|
|
'digiwin0006', 'digiwin0007', 'digiwin0008', 'digiwin0009', 'digiwin0010', 'dongsk@digiwin.com']; |
|
|
|
|
|
|
|
divContent = { |
|
|
|
sysId: '', |
|
|
|
top: '', |
|
|
|
left: '', |
|
|
|
height: '', |
|
|
|
width: '', |
|
|
|
userId: 'default', |
|
|
|
tenantId: '', |
|
|
|
topPercent: '', |
|
|
|
leftPercent: '', |
|
|
|
heightPercent: '', |
|
|
|
widthPercent: '' |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
constructor(private commonService: CommonService, private el: ElementRef, private renderer: Renderer2) { } |
|
|
|
ngOnInit(): void { |
|
|
|
this.systemMaps = systemList; |
|
|
|
this.initSystemBySemcSSO(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 通过请求queryDisplayList接口登录 |
|
|
|
*/ |
|
|
|
initSystemBySemcSSO() { |
|
|
|
|
|
|
|
|
|
|
|
const DwUserInfo = JSON.parse(sessionStorage.getItem("DwUserInfo")); |
|
|
|
|
|
|
|
this.USER_ID = DwUserInfo.userId; |
|
|
|
this.dragEnable = this.USER_ID === 'dongsk@digiwin.com'; |
|
|
|
|
|
|
|
console.log(this.dragEnable); |
|
|
|
|
|
|
|
const headers = { |
|
|
|
"Digi-Middleware-Auth-App": DigiMiddlewareAuthApp, |
|
|
|
"Digi-Middleware-Auth-User": DigiMiddlewareAuthUser, |
|
|
@ -55,15 +79,64 @@ export class LayoutComponent implements OnInit { |
|
|
|
url: item.cloudwebsite, |
|
|
|
applicationAppId: item.applicationAppId |
|
|
|
}; |
|
|
|
|
|
|
|
// 非管理员加载
|
|
|
|
this.divContent.userId = this.USER_ID; |
|
|
|
if (this.USER_ID === 'dongsk@digiwin.com') { |
|
|
|
this.divContent.userId = "default"; |
|
|
|
} |
|
|
|
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); |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
jumpToSystem(key: string) { |
|
|
|
|
|
|
|
console.log(this.systemMaps); |
|
|
|
|
|
|
|
const DwUserInfo = JSON.parse(sessionStorage.getItem("DwUserInfo")); |
|
|
|
|
|
|
|
if (DwUserInfo.userId === 'dongsk@digiwin.com') { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (this.systemMaps[key] == null) { |
|
|
|
return; |
|
|
|
} |
|
|
@ -72,12 +145,10 @@ export class LayoutComponent implements OnInit { |
|
|
|
|
|
|
|
// 免密跳转
|
|
|
|
if (item.linkLogin) { |
|
|
|
window.open(item.url,'_blank'); |
|
|
|
window.open(item.url, '_blank'); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
const DwUserInfo = JSON.parse(sessionStorage.getItem("DwUserInfo")); |
|
|
|
|
|
|
|
const headers = { |
|
|
|
"Digi-Middleware-Auth-App": DigiMiddlewareAuthApp, |
|
|
|
"Digi-Middleware-Auth-User": DigiMiddlewareAuthUser, |
|
|
@ -129,4 +200,107 @@ export class LayoutComponent implements OnInit { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
handleElementDrag(data: any) { |
|
|
|
// console.log(data);
|
|
|
|
|
|
|
|
if (data.type === 'mousedown') { |
|
|
|
this.isDragging = true; |
|
|
|
this.divContent.height = data.height; |
|
|
|
this.divContent.width = data.width; |
|
|
|
this.divContent.top = data.top; |
|
|
|
this.divContent.left = data.left; |
|
|
|
this.divContent.sysId = data.id; |
|
|
|
} |
|
|
|
|
|
|
|
if (data.type !== 'mouseup') { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (data.left === '' || data.top === '') { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
const DwUserInfo = JSON.parse(sessionStorage.getItem("DwUserInfo")); |
|
|
|
|
|
|
|
this.divContent.sysId = data.id; |
|
|
|
this.divContent.top = data.top; |
|
|
|
this.divContent.left = data.left; |
|
|
|
this.divContent.height = data.height; |
|
|
|
this.divContent.width = data.width; |
|
|
|
this.divContent.tenantId = DwUserInfo.tenantId; |
|
|
|
|
|
|
|
console.log(this.divContent); |
|
|
|
// this.commonService.postWithHeaders(this.commonService.apiUrl + "/restful/standard/demo/api/517/config/save",
|
|
|
|
// divContentX,
|
|
|
|
// {
|
|
|
|
// "Digi-Middleware-Auth-App": DigiMiddlewareAuthApp,
|
|
|
|
// "Digi-Middleware-Auth-User": DigiMiddlewareAuthUser,
|
|
|
|
// }
|
|
|
|
// ).then(res => {
|
|
|
|
// if (res && res.response) {
|
|
|
|
// alert('sucess!');
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
this.isDragging = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
changeDiv(type: String) { |
|
|
|
|
|
|
|
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 === '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 === '') { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 计算百分比
|
|
|
|
const windowWidth: number = window.innerWidth; |
|
|
|
const windowHeight: number = window.innerHeight; |
|
|
|
|
|
|
|
const top = parseFloat(this.divContent.top.replace("px", "")); |
|
|
|
const left = parseFloat(this.divContent.left.replace("px", "")); |
|
|
|
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 = ''; |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |