创建基础数据服务
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClientService } from '../services/http-client.service';
|
||||
import { Subject } from 'rxjs'
|
||||
|
||||
@Injectable()
|
||||
export class BasicDataService{
|
||||
public checkin_group;
|
||||
public checkin_group_subject = new Subject<any>();
|
||||
public gate;
|
||||
public gate_subject = new Subject<any>();
|
||||
public terminal;
|
||||
public terminal_subject = new Subject<any>();
|
||||
public chut;
|
||||
public chut_subject = new Subject<any>();
|
||||
public stand;
|
||||
public stand_subject = new Subject<any>();
|
||||
public carousel;
|
||||
public carousel_subject = new Subject<any>();
|
||||
public checkin_desk;
|
||||
public checkin_desk_subject = new Subject<any>();
|
||||
public airport;
|
||||
public airport_subject = new Subject<any>();
|
||||
public city;
|
||||
public city_subject = new Subject<any>();
|
||||
public aircraft_type;
|
||||
public aircraft_type_subject = new Subject<any>();
|
||||
public aircraft;
|
||||
public aircraft_subject = new Subject<any>();
|
||||
public terminal_area;
|
||||
public terminal_area_subject = new Subject<any>();
|
||||
public airline;
|
||||
public airline_subject = new Subject<any>();
|
||||
|
||||
constructor(
|
||||
private httpClient:HttpClientService
|
||||
){}
|
||||
|
||||
loadBasicData(){
|
||||
console.log('---')
|
||||
this.httpClient.get('/adminapi/basicdata/checkinGroups').subscribe(
|
||||
data=>{
|
||||
console.log(data)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core';
|
||||
import { ChangeDetectorRef } from '@angular/core';
|
||||
|
||||
import { HttpClientService } from '../../services/http-client.service';
|
||||
import {BasicDataService} from '../basic-data-service'
|
||||
|
||||
import dateFormatter from '../../utils/data-formatter';
|
||||
import routeType from '../../utils/route-type';
|
||||
@@ -18,9 +19,15 @@ import * as $ from 'jquery';
|
||||
export class MainComponent implements OnInit {
|
||||
|
||||
constructor(
|
||||
|
||||
private basicDataService:BasicDataService,
|
||||
private httpCilent: HttpClientService,
|
||||
private changeDetectorRef: ChangeDetectorRef
|
||||
) { }
|
||||
) {
|
||||
this.basicDataService.checkin_group_subject.subscribe(val=>{
|
||||
console.log(val)
|
||||
})
|
||||
}
|
||||
|
||||
public raw_data: Array<object> = []; //原始数据,即航班计划
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import { NgZorroAntdModule } from 'ng-zorro-antd'
|
||||
import { PipesModule } from '../../pipes/pipes.module';
|
||||
import { MainComponent } from './main.component';
|
||||
import { MainRoutingModule } from './main-routing.module'
|
||||
import {BasicDataService} from '../basic-data-service'
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
@@ -16,6 +17,7 @@ import { MainRoutingModule } from './main-routing.module'
|
||||
PipesModule,
|
||||
MainRoutingModule
|
||||
],
|
||||
declarations: [MainComponent]
|
||||
declarations: [MainComponent],
|
||||
providers:[BasicDataService]
|
||||
})
|
||||
export class MainModule { }
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Router, NavigationEnd, ActivatedRoute } from '@angular/router';
|
||||
import { BasicDataService } from './basic-data-service'
|
||||
|
||||
import { map, filter, mergeMap } from 'rxjs/operators';
|
||||
import { pipe } from 'rxjs'
|
||||
@@ -39,7 +40,7 @@ export class PagesComponent implements OnInit {
|
||||
"name": "基础数据",
|
||||
"icon": 'fa-database',
|
||||
"isExpend": false,
|
||||
"children":[
|
||||
"children": [
|
||||
{
|
||||
"name": "值机岛",
|
||||
"icon": "fa-eercast",
|
||||
@@ -184,17 +185,20 @@ export class PagesComponent implements OnInit {
|
||||
}]
|
||||
constructor(
|
||||
private router: Router,
|
||||
private basicDataService:BasicDataService,
|
||||
private activatedRoute: ActivatedRoute
|
||||
) { }
|
||||
) {
|
||||
this.basicDataService.loadBasicData();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
let activeRoute = this.router.url;
|
||||
this.selectActiveMenu(this.menuData,activeRoute);
|
||||
this.selectActiveMenu(this.menuData, activeRoute);
|
||||
|
||||
this.router.events.pipe(
|
||||
filter(event => event instanceof NavigationEnd),
|
||||
).subscribe((event) => {
|
||||
this.selectActiveMenu(this.menuData,event['urlAfterRedirects'])
|
||||
this.selectActiveMenu(this.menuData, event['urlAfterRedirects'])
|
||||
});
|
||||
|
||||
}
|
||||
@@ -207,7 +211,7 @@ export class PagesComponent implements OnInit {
|
||||
return !item.children || !item.children.length;
|
||||
}
|
||||
|
||||
selectActiveMenu(menuData,activeRoute) {
|
||||
selectActiveMenu(menuData, activeRoute) {
|
||||
menuData.forEach(item => {
|
||||
if (this.isLeaf(item)) {
|
||||
if (item.path === activeRoute) {
|
||||
@@ -215,8 +219,8 @@ export class PagesComponent implements OnInit {
|
||||
} else {
|
||||
item.isActive = false;
|
||||
}
|
||||
}else{
|
||||
this.selectActiveMenu(item.children,activeRoute)
|
||||
} else {
|
||||
this.selectActiveMenu(item.children, activeRoute)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -5,12 +5,15 @@ import { PagesRoutingModule } from './pages-routing.module'
|
||||
|
||||
import { ComponentsModule } from '../components/components.module'
|
||||
|
||||
import { BasicDataService } from './basic-data-service'
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
ComponentsModule,
|
||||
PagesRoutingModule,
|
||||
],
|
||||
declarations: [PagesComponent]
|
||||
declarations: [PagesComponent],
|
||||
providers: [BasicDataService]
|
||||
})
|
||||
export class PagesModule { }
|
||||
|
||||
Reference in New Issue
Block a user