From 106225127c6f48116b705203659bf8efa246f441 Mon Sep 17 00:00:00 2001 From: SHAOJIAHAO <55341701@qq.com> Date: Wed, 23 Feb 2022 13:57:58 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=96=B0=E5=A2=9E]=E6=96=B0=E5=A2=9E=E6=91=84?= =?UTF-8?q?=E5=83=8F=E5=A4=B4=E5=88=97=E8=A1=A8=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- proxy.config.json | 4 +- src/app/CustomReuseStrategy.ts | 58 +++++++ src/app/app-routing.module.ts | 7 - src/app/app.module.ts | 5 +- src/app/auth.guard.ts | 2 +- src/app/pages/home/home.component.html | 50 ------ src/app/pages/home/home.component.scss | 8 - src/app/pages/home/home.component.ts | 15 -- src/app/pages/login/login.component.ts | 23 +-- src/app/pages/pages.module.ts | 4 +- .../analysis-of-the-host.component.html | 34 +--- .../analysis-of-the-host.component.scss | 26 +-- .../analysis-of-the-host.component.ts | 155 +++--------------- .../host-config/host-config.component.html | 38 +++++ .../host-config/host-config.component.scss | 38 +++++ .../host-config/host-config.component.ts | 45 +++++ .../navigation/navigation.component.html | 2 +- .../organization/editor/editor.component.html | 2 +- .../organization/organization.component.html | 10 -- .../organization/organization.component.scss | 4 +- .../organization/organization.component.ts | 54 +++--- .../system-management-routing.module.ts | 2 + .../system-management.module.ts | 7 +- 23 files changed, 278 insertions(+), 315 deletions(-) create mode 100644 src/app/CustomReuseStrategy.ts delete mode 100644 src/app/pages/home/home.component.html delete mode 100644 src/app/pages/home/home.component.scss delete mode 100644 src/app/pages/home/home.component.ts create mode 100644 src/app/system-management/host-config/host-config.component.html create mode 100644 src/app/system-management/host-config/host-config.component.scss create mode 100644 src/app/system-management/host-config/host-config.component.ts diff --git a/proxy.config.json b/proxy.config.json index b147575..12f3cd9 100644 --- a/proxy.config.json +++ b/proxy.config.json @@ -1,11 +1,11 @@ { "/api": { - "target": "http://39.106.78.171:8906", + "target": "http://39.106.78.171:8920", "secure": false, "changeOrigin": true }, "/signalr": { - "target": "http://39.106.78.171:8906", + "target": "http://39.106.78.171:8920", "secure": false, "ws": true, "logLevel": "debug" diff --git a/src/app/CustomReuseStrategy.ts b/src/app/CustomReuseStrategy.ts new file mode 100644 index 0000000..8089987 --- /dev/null +++ b/src/app/CustomReuseStrategy.ts @@ -0,0 +1,58 @@ +import { RouteReuseStrategy, ActivatedRouteSnapshot, DetachedRouteHandle } from '@angular/router'; + +export class CustomReuseStrategy implements RouteReuseStrategy { + + public static handlers: { [key: string]: DetachedRouteHandle } = {}; + + /** 删除缓存路由快照的方法 */ + public static deleteRouteSnapshot(path: string): void { + const name = path.replace(/\//g, '_'); + if (CustomReuseStrategy.handlers[name]) { + delete CustomReuseStrategy.handlers[name]; + } + } + + /** 表示对所有路由允许复用 如果你有路由不想利用可以在这加一些业务逻辑判断 */ + shouldDetach(route: ActivatedRouteSnapshot): boolean { + console.log('shouldDetach======>', route); + return true; + } + + /** 当路由离开时会触发。按path作为key存储路由快照&组件当前实例对象 */ + store(route: ActivatedRouteSnapshot, handle: DetachedRouteHandle): void { + console.log('store======>', route, handle); + if(route.routeConfig.path == 'host'){ + CustomReuseStrategy.handlers[this.getRouteUrl(route)] = handle; + } + } + + /** 若 path 在缓存中有的都认为允许还原路由 */ + shouldAttach(route: ActivatedRouteSnapshot): boolean { + // console.debug('shouldAttach======>', route); + return !!CustomReuseStrategy.handlers[this.getRouteUrl(route)]; + } + + /** 从缓存中获取快照,若无则返回nul */ + retrieve(route: ActivatedRouteSnapshot): DetachedRouteHandle { + // console.debug('retrieve======>', route); + if (!CustomReuseStrategy.handlers[this.getRouteUrl(route)]) { + return null; + } + + return CustomReuseStrategy.handlers[this.getRouteUrl(route)]; + } + + /** 进入路由触发,判断是否同一路由 */ + shouldReuseRoute(future: ActivatedRouteSnapshot, curr: ActivatedRouteSnapshot): boolean { + // console.debug('shouldReuseRoute======>', future, curr); + return future.routeConfig === curr.routeConfig && + JSON.stringify(future.params) === JSON.stringify(curr.params); + } + + /** 使用route的path作为快照的key */ + getRouteUrl(route: ActivatedRouteSnapshot) { + const path = route['_routerState'].url.replace(/\//g, '_'); + return path; + } + +} \ No newline at end of file diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index c46a6d8..f51da7c 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -1,19 +1,12 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; import { AuthGuard } from './auth.guard'; -import { HomeComponent } from './pages/home/home.component'; import { LoginComponent } from './pages/login/login.component'; import { NavigationComponent } from './system-management/navigation/navigation.component'; const routes: Routes = [ {path:'', redirectTo:'/login', pathMatch:'full'}, {path:'login',component: LoginComponent,}, - { - path:'',component: HomeComponent, - children:[ - {path:'home',loadChildren:() => import('./pages/pages.module').then(m => m.PagesModule)}, - ] - }, { path: '', component: NavigationComponent, canActivate: [AuthGuard], children: [ { path: 'system', loadChildren: () => import('./system-management/system-management.module').then(m => m.SystemManagementModule) } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 7599eb2..7fe27bd 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -12,6 +12,8 @@ import { CookieService } from 'ngx-cookie-service';//cookie插件 import { NzNotificationModule } from 'ng-zorro-antd/notification'; import { NzMessageModule } from 'ng-zorro-antd/message'; import { TreeService } from './service/tree.service'; +import { RouteReuseStrategy } from '@angular/router'; +import { CustomReuseStrategy } from './CustomReuseStrategy'; @NgModule({ declarations: [ AppComponent @@ -26,7 +28,8 @@ import { TreeService } from './service/tree.service'; NzNotificationModule, NzMessageModule ], - providers: [httpInterceptorProviders, CacheTokenService, TreeService, CookieService], + providers: [httpInterceptorProviders, CacheTokenService, TreeService, CookieService, + { provide: RouteReuseStrategy, useClass: CustomReuseStrategy }], bootstrap: [AppComponent] }) export class AppModule { } diff --git a/src/app/auth.guard.ts b/src/app/auth.guard.ts index af4d216..a906efa 100644 --- a/src/app/auth.guard.ts +++ b/src/app/auth.guard.ts @@ -22,7 +22,7 @@ export class AuthGuard implements CanActivate { } checkLogin(): boolean { - console.log('xxxxxxxxxxxx') + // console.log('xxxxxxxxxxxx') // 判断本地有没有token const token = this.cookieService.get("token") || sessionStorage.getItem('token'); diff --git a/src/app/pages/home/home.component.html b/src/app/pages/home/home.component.html deleted file mode 100644 index 3b81939..0000000 --- a/src/app/pages/home/home.component.html +++ /dev/null @@ -1,50 +0,0 @@ -
-
- -
-
- -
-
\ No newline at end of file diff --git a/src/app/pages/home/home.component.scss b/src/app/pages/home/home.component.scss deleted file mode 100644 index a07ac30..0000000 --- a/src/app/pages/home/home.component.scss +++ /dev/null @@ -1,8 +0,0 @@ -.content{ - width: 100%; - height: 100%; - overflow: hidden; - display: flex; - .leftMenu{ width: 300px; height: 100%; } - .rightContent{ flex: 1; overflow: hidden; } -} \ No newline at end of file diff --git a/src/app/pages/home/home.component.ts b/src/app/pages/home/home.component.ts deleted file mode 100644 index 73acf06..0000000 --- a/src/app/pages/home/home.component.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Component, OnInit } from '@angular/core'; - -@Component({ - selector: 'app-home', - templateUrl: './home.component.html', - styleUrls: ['./home.component.scss'] -}) -export class HomeComponent implements OnInit { - - constructor() { } - - ngOnInit(): void { - } - -} diff --git a/src/app/pages/login/login.component.ts b/src/app/pages/login/login.component.ts index 71a6774..e493d0e 100644 --- a/src/app/pages/login/login.component.ts +++ b/src/app/pages/login/login.component.ts @@ -48,10 +48,10 @@ export class LoginComponent implements OnInit { - //跳转注册页面 - toRegister() { - this.router.navigate(['/register']) - } + // //跳转注册页面 + // toRegister() { + // this.router.navigate(['/register']) + // } //记住密码 @@ -97,15 +97,18 @@ export class LoginComponent implements OnInit { return } this.isLoading = true; - this.http.post('/api/TokenAuth/Authenticate', { - userNameOrEmailAddress: this.validateForm.value.userName, + this.http.post('/api/Accounts/SignIn', { + username: this.validateForm.value.userName, password: this.validateForm.value.password }).subscribe( (data: any) => { - sessionStorage.setItem("token", data.result.accessToken); - sessionStorage.setItem("encryptedAccessToken", data.result.encryptedAccessToken); - this.cookieService.set("token", data.result.accessToken, null, '/'); - this.cookieService.set("refreshToken", data.result.encryptedAccessToken, null, '/'); + console.log('登录信息', data) + this.rememberInfo() + this.autoLogin() + sessionStorage.setItem("token", data.token); + sessionStorage.setItem("refreshToken", data.refreshToken); + this.cookieService.set("token", data.token, null, '/'); + this.cookieService.set("refreshToken", data.refreshToken, null, '/'); this.router.navigate(['/system/organization']) this.message.create('success', `登录成功`); }, diff --git a/src/app/pages/pages.module.ts b/src/app/pages/pages.module.ts index 11ddac6..01b11a0 100644 --- a/src/app/pages/pages.module.ts +++ b/src/app/pages/pages.module.ts @@ -14,13 +14,11 @@ import { NzButtonModule } from 'ng-zorro-antd/button'; import { NzInputModule } from 'ng-zorro-antd/input'; import { NzSelectModule } from 'ng-zorro-antd/select'; import { LoginComponent } from './login/login.component'; -import { HomeComponent } from './home/home.component'; import { NzMessageModule } from 'ng-zorro-antd/message'; import { NzCheckboxModule } from 'ng-zorro-antd/checkbox'; @NgModule({ declarations: [ - LoginComponent, - HomeComponent + LoginComponent ], imports: [ CommonModule, diff --git a/src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.html b/src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.html index 0d9a1d8..e9ef637 100644 --- a/src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.html +++ b/src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.html @@ -60,44 +60,12 @@ {{data.hostIPAddress}} 编辑 + 配置 删除 - \ No newline at end of file diff --git a/src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.scss b/src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.scss index b6dee8d..d7597fc 100644 --- a/src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.scss +++ b/src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.scss @@ -13,7 +13,7 @@ width: 375px; height: 100%; overflow-y: auto; - + display: flex; flex-direction: column; } @@ -65,17 +65,20 @@ } .treebox { - flex: 1; - overflow-y: auto; - border: 1px solid rgba(145, 204, 255, 0.2); - border-top: 0px; - box-sizing: border-box; - padding: 10px 6px; - tr{ - th,td{ - text-align: center!important; - } + flex: 1; + overflow-y: auto; + border: 1px solid rgba(145, 204, 255, 0.2); + border-top: 0px; + box-sizing: border-box; + padding: 10px 6px; + + tr { + + th, + td { + text-align: center !important; } + } } .nodebox { @@ -91,3 +94,4 @@ .tablebox { margin-top: 16px; } + diff --git a/src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.ts b/src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.ts index 9279087..d7bbf5e 100644 --- a/src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.ts +++ b/src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.ts @@ -9,6 +9,7 @@ import { AddhostComponent } from './addhost/addhost.component'; import { AddcameraComponent } from './addcamera/addcamera.component'; import { EdithostComponent } from './edithost/edithost.component'; import { EditcameraComponent } from './editcamera/editcamera.component'; +import { Router } from '@angular/router'; @Component({ selector: 'app-analysis-of-the-host', templateUrl: './analysis-of-the-host.component.html', @@ -16,7 +17,7 @@ import { EditcameraComponent } from './editcamera/editcamera.component'; }) export class AnalysisOfTheHostComponent implements OnInit { - constructor(private fb: FormBuilder, private http: HttpClient, private toTree: TreeService, private modal: NzModalService, private message: NzMessageService, private viewContainerRef: ViewContainerRef) { } + constructor(private router: Router, private fb: FormBuilder, private http: HttpClient, private toTree: TreeService, private modal: NzModalService, private message: NzMessageService, private viewContainerRef: ViewContainerRef) { } ngOnInit(): void { this.getAllOrganization() } @@ -26,22 +27,23 @@ export class AnalysisOfTheHostComponent implements OnInit { searchValue = ''; nzExpandAll = false; totalCount: string + getAllOrganization() { let OrganizationUnitId = '' let params = { - OrganizationUnitId: OrganizationUnitId, - IsContainsChildren: "true" + PageSize: 9999 } - this.http.get('/api/services/app/Organization/GetAll', { + this.http.get('/api/Organizations', { params: params }).subscribe((data: any) => { - this.totalCount = data.result.totalCount - data.result.items.forEach(element => { + this.totalCount = data.totalCount + data.items.forEach(element => { element.key = element.id - element.title = element.displayName + element.title = element.name element.selectable = false }); - this.nodes = [...this.toTree.toTree(data.result.items)] + this.nodes = [...this.toTree.toTree(data.items)] + this.defaultExpandedKeys = [this.nodes[0].id] this.defaultExpandedKeys = [...this.defaultExpandedKeys] }) } @@ -55,13 +57,12 @@ export class AnalysisOfTheHostComponent implements OnInit { nzSelectedKeys: any[] = [] selectedOilStation: any nzClick(event: NzFormatEmitEvent): void { - console.log(event.node.origin); if (event.node.origin['isGasStation']) {//如果点击的是加油站才生效 this.nzSelectedKeys[0] = event.node.origin.id this.nzSelectedKeys = [...this.nzSelectedKeys] this.selectedOilStation = event.node.origin + console.log(this.selectedOilStation) this.getHost() - // this.getCamera() } else { this.message.info('只有加油站才可以增加主机'); } @@ -70,31 +71,14 @@ export class AnalysisOfTheHostComponent implements OnInit { //获得加油站的主机 listOfData: any[] = []; getHost() { - this.http.get('/api/services/app/EdgeDevice/GetAll', { + this.http.get('/api/EdgeDevices', { params: { - organizationUnitId: this.selectedOilStation.id, - SkipCount: '0', - MaxResultCount: '100', + OrganizationId: this.selectedOilStation.id, + PageSize: 999 } }).subscribe((data: any) => { - console.log('主机列表', data.result.items) - this.listOfData = data.result.items - }) - } - - - //获得加油站摄像头 - listOfDataCamera: any[] = []; - getCamera() { - this.http.get('/api/services/app/Camera/GetAll', { - params: { - organizationUnitId: this.selectedOilStation.id, - SkipCount: '0', - MaxResultCount: '100', - } - }).subscribe((data: any) => { - // console.log('摄像头列表', data) - this.listOfDataCamera = data.result.items + console.log('主机列表', data.items) + this.listOfData = data.items }) } @@ -118,9 +102,9 @@ export class AnalysisOfTheHostComponent implements OnInit { console.log('表单信息', instance.validateForm) let body = { hostIPAddress: instance.validateForm.value.ip, - organizationUnitId: this.selectedOilStation.id + OrganizationId: this.selectedOilStation.id } - this.http.post('/api/services/app/EdgeDevice/Create', body).subscribe(data => { + this.http.post('/api/EdgeDevices', body).subscribe(data => { resolve(data) this.message.create('success', '创建成功!'); this.getHost() @@ -135,6 +119,7 @@ export class AnalysisOfTheHostComponent implements OnInit { }); const instance = modal.getContentComponent(); } + edit(data) { console.log(data) const modal = this.modal.create({ @@ -150,7 +135,7 @@ export class AnalysisOfTheHostComponent implements OnInit { await new Promise(resolve => { console.log('表单信息', instance.validateForm) data.hostIPAddress = instance.validateForm.value.ip, - this.http.put('/api/services/app/EdgeDevice/Update', data).subscribe(data => { + this.http.put(`/api/EdgeDevices/${data.id}`, data).subscribe(data => { resolve(data) this.message.create('success', '修改成功!'); this.getHost() @@ -165,6 +150,7 @@ export class AnalysisOfTheHostComponent implements OnInit { }); const instance = modal.getContentComponent(); } + delete(item) { console.log(item) this.modal.confirm({ @@ -172,11 +158,7 @@ export class AnalysisOfTheHostComponent implements OnInit { nzOkText: '确定', nzOkType: 'primary', nzOnOk: () => { - this.http.delete('/api/services/app/EdgeDevice/Delete', { - params: { - Id: item.id - } - }).subscribe(data => { + this.http.delete(`/api/EdgeDevices/${item.id}`).subscribe(data => { this.message.create('success', '删除成功!'); this.getHost() }) @@ -185,96 +167,9 @@ export class AnalysisOfTheHostComponent implements OnInit { }); } - - //摄像头 - addCamera() { - console.log(this.selectedOilStation) - const modal = this.modal.create({ - nzTitle: '新增加油站摄像头', - nzContent: AddcameraComponent, - nzViewContainerRef: this.viewContainerRef, - nzWidth: 288, - nzComponentParams: {}, - nzOnOk: async () => { - if (instance.validateForm.valid) { - await new Promise(resolve => { - console.log('表单信息', instance.validateForm) - let body = { - organizationUnitId: this.selectedOilStation.id, - ipAdress: instance.validateForm.value.ip, - code: instance.validateForm.value.code, - name: instance.validateForm.value.name, - // description: "", - } - this.http.post('/api/services/app/Camera/Create', body).subscribe(data => { - resolve(data) - this.message.create('success', '创建成功!'); - this.getCamera() - return true - }, err => { - return false - }) - }) - } else { - this.message.create('warning', '请填写完整!'); - return false - } - } - }); - const instance = modal.getContentComponent(); - } - editCamera(data) { - + config(data) { console.log(data) - const modal = this.modal.create({ - nzTitle: '编辑加油站摄像头', - nzContent: EditcameraComponent, - nzViewContainerRef: this.viewContainerRef, - nzWidth: 288, - nzComponentParams: { - data: data - }, - nzOnOk: async () => { - if (instance.validateForm.valid) { - await new Promise(resolve => { - console.log('表单信息', instance.validateForm) - data.name = instance.validateForm.value.name - data.code = instance.validateForm.value.code - data.ipAdress = instance.validateForm.value.ip - this.http.put('/api/services/app/Camera/Update', data).subscribe(data => { - resolve(data) - this.message.create('success', '编辑成功!'); - this.getCamera() - return true - }, err => { - return false - }) - }) - } else { - this.message.create('warning', '请填写完整!'); - return false - } - } - }); - const instance = modal.getContentComponent(); - } - deleteCamera(item) { - console.log(item) - this.modal.confirm({ - nzTitle: `确定要删除${item.name}这个摄像头吗?`, - nzOkText: '确定', - nzOkType: 'primary', - nzOnOk: () => { - this.http.delete('/api/services/app/Camera/Delete', { - params: { - Id: item.id - } - }).subscribe(data => { - this.message.create('success', '删除成功!'); - this.getCamera() - }) - }, - nzCancelText: '取消' - }); + this.router.navigate([`/system/host/${data.id}`]) } + } diff --git a/src/app/system-management/host-config/host-config.component.html b/src/app/system-management/host-config/host-config.component.html new file mode 100644 index 0000000..695323d --- /dev/null +++ b/src/app/system-management/host-config/host-config.component.html @@ -0,0 +1,38 @@ +
+
+ +
+
+ 摄像头列表 + +
+ + + + 名称 + 用户名 + 密码 + 地址 + 类型 + 操作 + + + + + {{ data.name }} + {{ data.user }} + {{ data.password }} + {{ data.uri }} + {{ data.type }} + + 编辑 + + + + +
+
+
+ +
+
\ No newline at end of file diff --git a/src/app/system-management/host-config/host-config.component.scss b/src/app/system-management/host-config/host-config.component.scss new file mode 100644 index 0000000..0c80de2 --- /dev/null +++ b/src/app/system-management/host-config/host-config.component.scss @@ -0,0 +1,38 @@ +.box { + width: 100%; + height: 100%; + display: flex; + background: #fff; + font-size: 15px; + color: black; +} + +.leftbox { + width: 100%; + height: 100%; + border-right: 1px solid #F2F2F2; + box-sizing: border-box; + display: flex; + flex-direction: column; + .cameraList{ + flex: 1; + padding: 0 20px; + .title{ + width: 100%; + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 12px; + } + } +} + +.rightbox { + flex: 1; + box-sizing: border-box; + padding: 20px; +} +.blue{ + cursor: pointer; + color: #1890ff; +} \ No newline at end of file diff --git a/src/app/system-management/host-config/host-config.component.ts b/src/app/system-management/host-config/host-config.component.ts new file mode 100644 index 0000000..469b7dd --- /dev/null +++ b/src/app/system-management/host-config/host-config.component.ts @@ -0,0 +1,45 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute, Route, Router } from '@angular/router'; +import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; +import { NzFormTooltipIcon } from 'ng-zorro-antd/form'; +interface Camera { + name: string; + user: string; + password: string; + uri: string; + type: number +} + +@Component({ + selector: 'app-host-config', + templateUrl: './host-config.component.html', + styleUrls: ['./host-config.component.scss'] +}) + +export class HostConfigComponent implements OnInit { + + + constructor(private router: Router, private route: ActivatedRoute, private fb: FormBuilder) { } + + data + + ngOnInit(): void { + console.log(this.route.snapshot.params.id) + this.data = this.route.snapshot.params.id + } + listOfData: Camera[] = [ + { + name: '1', + user: 'John Brown', + password: '32', + uri: 'New York No. 1 Lake Park', + type: 0 + } + ]; + goback() { + history.go(-1) + } + addCamera(){ + + } +} diff --git a/src/app/system-management/navigation/navigation.component.html b/src/app/system-management/navigation/navigation.component.html index 8da84c5..acd8789 100644 --- a/src/app/system-management/navigation/navigation.component.html +++ b/src/app/system-management/navigation/navigation.component.html @@ -20,7 +20,7 @@ - Hey,欢迎登录加油站智能安全管理系统 + Hey,欢迎登录加油站边缘主机管理系统 diff --git a/src/app/system-management/organization/editor/editor.component.html b/src/app/system-management/organization/editor/editor.component.html index d2a5386..6455bd2 100644 --- a/src/app/system-management/organization/editor/editor.component.html +++ b/src/app/system-management/organization/editor/editor.component.html @@ -3,7 +3,7 @@ - + diff --git a/src/app/system-management/organization/organization.component.html b/src/app/system-management/organization/organization.component.html index 44c77bf..1667338 100644 --- a/src/app/system-management/organization/organization.component.html +++ b/src/app/system-management/organization/organization.component.html @@ -6,16 +6,6 @@ {{totalCount}}个单位
- diff --git a/src/app/system-management/organization/organization.component.scss b/src/app/system-management/organization/organization.component.scss index a365d13..84fe2ac 100644 --- a/src/app/system-management/organization/organization.component.scss +++ b/src/app/system-management/organization/organization.component.scss @@ -41,7 +41,7 @@ } .treeTitle { - width: 700px; + width: 100%; height: 36px; line-height: 36px; display: flex; @@ -49,7 +49,7 @@ color: #000D21; box-sizing: border-box; padding-left: 30px; - padding-right: 180px; + padding-right: 140px; background: rgba(145, 204, 255, 0.2); margin: 12px 0; } diff --git a/src/app/system-management/organization/organization.component.ts b/src/app/system-management/organization/organization.component.ts index dbb1c7f..1c67c4d 100644 --- a/src/app/system-management/organization/organization.component.ts +++ b/src/app/system-management/organization/organization.component.ts @@ -11,6 +11,7 @@ import { EditorComponent } from './editor/editor.component'; import { NzFormatBeforeDropEvent } from 'ng-zorro-antd/tree'; import { Observable, of } from 'rxjs'; import { delay } from 'rxjs/operators'; +import { CustomReuseStrategy } from 'src/app/CustomReuseStrategy'; @Component({ selector: 'app-organization', templateUrl: './organization.component.html', @@ -25,6 +26,11 @@ export class OrganizationComponent implements OnInit { search: [null] }); this.getAllOrganization() + + this.deleteRouteSnapshot(); + } + deleteRouteSnapshot() { + CustomReuseStrategy.deleteRouteSnapshot('/system/host'); } //搜索框提交 submitForm(): void { @@ -43,20 +49,23 @@ export class OrganizationComponent implements OnInit { getAllOrganization() { let OrganizationUnitId = '' let params = { - OrganizationUnitId: OrganizationUnitId, - IsContainsChildren: "true" + // OrganizationUnitId: OrganizationUnitId, + // IsContainsChildren: "true" + pageSize: 9999 } - this.http.get('/api/services/app/Organization/GetAll', { + this.http.get('/api/Organizations', { params: params }).subscribe((data: any) => { - this.totalCount = data.result.totalCount - data.result.items.forEach(element => { + console.log('组织机构列表', data) + this.totalCount = data.totalCount + data.items.forEach(element => { element.key = element.id - element.title = element.displayName + element.title = element.name element.selectable = false }); - this.allOrList = data.result.items - this.nodes = [...this.toTree.toTree(data.result.items)] + this.allOrList = data.items + this.nodes = [...this.toTree.toTree(data.items)] + this.defaultExpandedKeys = [this.nodes[0].id] this.defaultExpandedKeys = [...this.defaultExpandedKeys] }) } @@ -78,16 +87,14 @@ export class OrganizationComponent implements OnInit { nzWidth: 288, nzComponentParams: {}, nzOnOk: async () => { - console.log('hhhhhhh', instance.validateForm) if (instance.validateForm.valid) { await new Promise(resolve => { let body = { + name: instance.validateForm.value.name, parentId: node ? Number(node.key) : null, - // code: instance.validateForm.value.code, - displayName: instance.validateForm.value.name, isGasStation: instance.validateForm.value.isGasStation } - this.http.post('/api/services/app/Organization/Create', body).subscribe(data => { + this.http.post('/api/Organizations', body).subscribe(data => { resolve(data) this.message.create('success', '创建成功!'); this.nzTreeComponent.getExpandedNodeList().forEach((item) => { @@ -121,17 +128,14 @@ export class OrganizationComponent implements OnInit { data: node.origin, }, nzOnOk: async () => { - console.log('hhhhhhh', instance.validateForm) if (instance.validateForm.valid) { await new Promise(resolve => { let body = { - id: node.origin.id, - parentId: node.origin.parentId, - // code: instance.validateForm.value.code, - displayName: instance.validateForm.value.name, - isGasStation: instance.validateForm.value.isGasStation + name: instance.validateForm.value.name, + isGasStation: instance.validateForm.value.isGasStation, + parentId: node.origin.parentId } - this.http.put('/api/services/app/Organization/Update', body).subscribe(data => { + this.http.put(`/api/Organizations/${node.origin.id}`, body).subscribe(data => { resolve(data) this.message.create('success', '编辑成功!'); this.nzTreeComponent.getExpandedNodeList().forEach((item) => { @@ -163,11 +167,7 @@ export class OrganizationComponent implements OnInit { nzOkText: '确定', nzOkType: 'primary', nzOnOk: () => { - this.http.delete('/api/services/app/Organization/Delete', { - params: { - Id: item.origin.id - } - }).subscribe(data => { + this.http.delete(`/api/Organizations/${item.origin.id}`).subscribe(data => { this.nzTreeComponent.getExpandedNodeList().forEach((item) => { this.defaultExpandedKeys.push(item.key) }) @@ -200,13 +200,11 @@ export class OrganizationComponent implements OnInit { } let body = { - id: event.dragNode.key, parentId: parentId, - // code: instance.validateForm.value.code, - displayName: event.dragNode.origin.displayName, + name: event.dragNode.origin.name, isGasStation: event.dragNode.origin.isGasStation } - this.http.put('/api/services/app/Organization/Update', body).subscribe(data => { + this.http.put(`/api/Organizations/${event.dragNode.origin.id}`, body).subscribe(data => { this.message.create('success', '拖拽成功!'); this.nzTreeComponent.getExpandedNodeList().forEach((item) => { this.defaultExpandedKeys.push(item.key) diff --git a/src/app/system-management/system-management-routing.module.ts b/src/app/system-management/system-management-routing.module.ts index 857584d..7e21ebe 100644 --- a/src/app/system-management/system-management-routing.module.ts +++ b/src/app/system-management/system-management-routing.module.ts @@ -2,11 +2,13 @@ import { Routes, RouterModule } from '@angular/router'; import { NgModule } from '@angular/core'; import { OrganizationComponent } from './organization/organization.component'; import { AnalysisOfTheHostComponent } from './analysis-of-the-host/analysis-of-the-host.component'; +import { HostConfigComponent } from './host-config/host-config.component'; const routes: Routes = [ { path: 'organization', component: OrganizationComponent }, { path: 'host', component: AnalysisOfTheHostComponent }, + { path: 'host/:id', component: HostConfigComponent }, ]; @NgModule({ diff --git a/src/app/system-management/system-management.module.ts b/src/app/system-management/system-management.module.ts index c940b64..db3eeb9 100644 --- a/src/app/system-management/system-management.module.ts +++ b/src/app/system-management/system-management.module.ts @@ -26,8 +26,10 @@ import { AddhostComponent } from './analysis-of-the-host/addhost/addhost.compone import { EdithostComponent } from './analysis-of-the-host/edithost/edithost.component'; import { AddcameraComponent } from './analysis-of-the-host/addcamera/addcamera.component'; import { EditcameraComponent } from './analysis-of-the-host/editcamera/editcamera.component'; +import { HostConfigComponent } from './host-config/host-config.component'; +import { NzPageHeaderModule } from 'ng-zorro-antd/page-header'; @NgModule({ - declarations: [OrganizationComponent, NavigationComponent, AddorComponent, EditorComponent, AnalysisOfTheHostComponent, AddhostComponent, EdithostComponent, AddcameraComponent, EditcameraComponent], + declarations: [OrganizationComponent, NavigationComponent, AddorComponent, EditorComponent, AnalysisOfTheHostComponent, AddhostComponent, EdithostComponent, AddcameraComponent, EditcameraComponent, HostConfigComponent], imports: [ CommonModule, SystemRoutingModule, @@ -47,7 +49,8 @@ import { EditcameraComponent } from './analysis-of-the-host/editcamera/editcamer NzTreeModule, NzSpinModule, NzTreeSelectModule, - NzCheckboxModule + NzCheckboxModule, + NzPageHeaderModule ], entryComponents :[AddorComponent,EditorComponent,AddhostComponent,EdithostComponent,AddcameraComponent,EditcameraComponent]