From ebb8f65ee840cd3a066c41af63408af6d244d83c Mon Sep 17 00:00:00 2001 From: cpf <1105965053@qq.com> Date: Tue, 30 Nov 2021 15:11:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=B7=AF=E7=94=B1=E5=AE=88?= =?UTF-8?q?=E5=8D=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/pages/init3D.guard.ts | 39 ++++++++++++++++++++++++++ src/app/pages/pages-routing.module.ts | 3 +- src/app/pages/plan/plan.component.html | 2 +- src/app/pages/plan/plan.component.scss | 8 ++---- src/app/pages/plan/plan.component.ts | 8 ++---- 5 files changed, 47 insertions(+), 13 deletions(-) create mode 100644 src/app/pages/init3D.guard.ts diff --git a/src/app/pages/init3D.guard.ts b/src/app/pages/init3D.guard.ts new file mode 100644 index 0000000..651a426 --- /dev/null +++ b/src/app/pages/init3D.guard.ts @@ -0,0 +1,39 @@ +import { HttpClient } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { Component, OnInit, Inject } from '@angular/core'; +import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Router } from '@angular/router'; +import { ModeManager } from '../babylon/controller/mode-manager'; +import { NzMessageService } from 'ng-zorro-antd/message'; + +@Injectable({ + providedIn: 'root' +}) +export class init3DGuard implements CanActivate { + + constructor(private router: Router, private http: HttpClient, private message: NzMessageService,) { } + + // 路由守卫 + canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot,): Promise { + return this.getGasStationBaseInfo().then((res: any) => { + sessionStorage.setItem("3dSceneData", JSON.stringify(res)) + let isMakeMode = ModeManager.s_isMakeMode + if (isMakeMode || res.hasBuildingInfo) { + return true + } else if (!res.hasBuildingInfo) { + this.message.info("当前站点没有数字油站!"); + return false + } + }); + } + + //获取 当前加油站基本信息 + getGasStationBaseInfo() { + return new Promise((resolve, reject) => { + let params = { organizationUnitId: (JSON.parse(sessionStorage.getItem('userdataOfgasstation'))).organization.id } + this.http.get('/api/services/app/GasStation/Get', { params: params }).subscribe((data: any)=>{ + resolve(data.result) + }) + }) + } + +} \ No newline at end of file diff --git a/src/app/pages/pages-routing.module.ts b/src/app/pages/pages-routing.module.ts index 0986da5..be6673f 100644 --- a/src/app/pages/pages-routing.module.ts +++ b/src/app/pages/pages-routing.module.ts @@ -10,11 +10,12 @@ import { OilStationInfoComponent } from './oil-station-info/oil-station-info.com import { EquipmentInfoComponent } from './equipment-info/equipment-info.component'; import { PlanAdminComponent } from './plan-admin/plan-admin.component'; import { HomePageComponent } from './home-page/home-page.component'; +import { init3DGuard } from './init3D.guard'; const routes: Routes = [ { path: 'homepage', component: HomePageComponent }, { path: 'plan', component: PlanAdminComponent }, - { path: 'plan/petrolStation', component: PlanComponent }, + { path: 'plan/petrolStation', component: PlanComponent, canActivate: [init3DGuard], }, { path: 'warning', component: TodayWarningAdminComponent }, { path: 'warning/petrolStation', component: TodayWarningComponent }, { path: 'records', component: CriminalRecordsAdminComponent }, diff --git a/src/app/pages/plan/plan.component.html b/src/app/pages/plan/plan.component.html index c013d57..c46bbb3 100644 --- a/src/app/pages/plan/plan.component.html +++ b/src/app/pages/plan/plan.component.html @@ -104,7 +104,7 @@ -
+
diff --git a/src/app/pages/plan/plan.component.scss b/src/app/pages/plan/plan.component.scss index 6b561f5..48f1eb0 100644 --- a/src/app/pages/plan/plan.component.scss +++ b/src/app/pages/plan/plan.component.scss @@ -227,13 +227,11 @@ //右侧图标栏 .rightIcons{ - width: 100px; - height: 70%; + width: 60px; + height: 260px; position: absolute; - top: 0; - bottom: 0; + top: 10%; right: 1%; - margin: auto;/*这行代码是关键*/ color: #fff; background: linear-gradient(360deg, #000D21 0%, rgba(0, 59, 110, 0.8) 100%); overflow: hidden; diff --git a/src/app/pages/plan/plan.component.ts b/src/app/pages/plan/plan.component.ts index 6cb954e..69b4a8e 100644 --- a/src/app/pages/plan/plan.component.ts +++ b/src/app/pages/plan/plan.component.ts @@ -80,7 +80,6 @@ export class PlanComponent implements OnInit { ngAfterViewInit(): void { this.getGasStationBaseInfo().then((res: any) => { //获取单位 基本信息 - // console.log(res, "当前加油站信息") let simpleData: InsitutionDataSimple = new InsitutionDataSimple(); simpleData.id = res.id || 6; //来自选中的单位的信息 ,测试:1 simpleData.key = `${res.id}` || "ceshi"; //测试:"ceshi" @@ -91,7 +90,6 @@ export class PlanComponent implements OnInit { if (ModeManager.institutionDemoKey == ModeManager.c_demoKey_null) { //无指定测试单位,则为正式启动,根据当前单位key寻找 if (has3dData) { //如果已经有三维数据,直接进入 this.beforeOneSatus = StatusManager.getStatus(LoginSatus); - // console.log("进入三维单位", simpleData); this.beforeOneSatus.onSelectInsSuccess(simpleData) } else { //如果没有三维数据 if (ModeManager.s_isMakeMode) //内部制作模式下,询问新建 @@ -131,10 +129,8 @@ export class PlanComponent implements OnInit { //获取 当前加油站基本信息 getGasStationBaseInfo() { return new Promise((resolve, reject) => { - let params = { organizationUnitId: this.companyData.id } - this.http.get('/api/services/app/GasStation/Get', { params: params }).subscribe((data: any) => { - resolve(data.result) - }) + let result = JSON.parse(sessionStorage.getItem("3dSceneData")) + resolve(result) }) }