Browse Source

[修改]将导航菜单与网盘页面从父子嵌套方式变为非嵌套方式

master
邵佳豪 5 years ago
parent
commit
0be938c838
  1. 3
      src/app/app.module.ts
  2. 11
      src/app/component-service.service.ts
  3. 4
      src/app/navigation/navigation.component.html
  4. 10
      src/app/navigation/navigation.component.ts
  5. 9
      src/app/ui/all-file/all-file.component.ts

3
src/app/app.module.ts

@ -17,6 +17,7 @@ import { httpInterceptorProviders } from './http-interceptors/index'
import {CacheTokenService} from './http-interceptors/cache-token.service'
import { TreeService } from'./http-interceptors/tree.service'
import { IsLoginService } from './is-login.service';
import { ComponentServiceService } from './component-service.service';
@NgModule({
declarations: [
@ -35,7 +36,7 @@ import { IsLoginService } from './is-login.service';
FormsModule,
HttpClientModule
],
providers: [httpInterceptorProviders, CacheTokenService,TreeService],
providers: [httpInterceptorProviders, CacheTokenService,TreeService,ComponentServiceService],
bootstrap: [AppComponent]
})
export class AppModule { }

11
src/app/component-service.service.ts

@ -0,0 +1,11 @@
import { Injectable, EventEmitter, OnInit } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class ComponentServiceService {
public eventEmit: any;
constructor() {
this.eventEmit = new EventEmitter();
}
}

4
src/app/navigation/navigation.component.html

@ -62,8 +62,8 @@
<div class="example-sidenav-content">
<app-tabbar (toggleDarkTheme)="switchTheme($event)" (defaulttheme)="defaulttheme()" (redtheme)="redtheme()"></app-tabbar>
<!-- <router-outlet></router-outlet> -->
<app-all-file #child></app-all-file>
<router-outlet></router-outlet>
<!-- <app-all-file #child></app-all-file> -->
</div>
</mat-sidenav-container>

10
src/app/navigation/navigation.component.ts

@ -6,6 +6,8 @@ import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dial
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';
import { IsLoginService } from '../is-login.service'
import { AllFileComponent } from '../ui/all-file/all-file.component';
import { ComponentServiceService } from '../component-service.service';
import { Router,ActivatedRoute } from '@angular/router'
@Component({
selector: 'app-navigation',
templateUrl: './navigation.component.html',
@ -13,7 +15,7 @@ import { AllFileComponent } from '../ui/all-file/all-file.component';
})
export class NavigationComponent implements OnInit {
constructor(public navmenus:CacheTokenService,private http: HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar,public islogin:IsLoginService) { }
constructor(private router:Router,public emitService: ComponentServiceService,public navmenus:CacheTokenService,private http: HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar,public islogin:IsLoginService) { }
@ViewChild('child') child:AllFileComponent; //父组件中获得子组件的引用
@ -134,8 +136,10 @@ export class NavigationComponent implements OnInit {
clickLi(item){
this.selectedDataBank = item.id
//触发子组件的方法
this.child.getALLFileList(item.id);
this.child.selection.clear();
// this.child.getALLFileList(item.id);
// this.child.selection.clear();
this.router.navigate([`/home`])
this.emitService.eventEmit.emit(item.id);
}

9
src/app/ui/all-file/all-file.component.ts

@ -7,6 +7,7 @@ import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';
import { IsLoginService } from '../../is-login.service'
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import {UploadFilesComponent} from '../upload-files/upload-files.component'
import { ComponentServiceService } from '../../component-service.service'
@Component({
selector: 'app-all-file',
templateUrl: './all-file.component.html',
@ -16,7 +17,7 @@ export class AllFileComponent {
displayedColumns: string[] = ['select', 'name', 'weight', 'time'];
dataSource:any = new MatTableDataSource;
constructor(private http: HttpClient,public snackBar: MatSnackBar,public downloadFile:IsLoginService,public dialog: MatDialog,private zone: NgZone) { }
constructor(public emitService: ComponentServiceService,private http: HttpClient,public snackBar: MatSnackBar,public downloadFile:IsLoginService,public dialog: MatDialog,private zone: NgZone) { }
isCancel:boolean = false //搜索框的X是否显示
searchData:any = "搜索您的文件" //搜索框内容
isClickFile:boolean = false //是否点击过文件
@ -66,6 +67,12 @@ export class AllFileComponent {
this.dataSource.sort = this.sort;
// this.getAllDataBank()
this.getALLFileList("支队级-主官")
// 接收发射过来的数据
this.emitService.eventEmit.subscribe((value: any) => {
this.getALLFileList(value)
this.selection.clear();
});
}
//获得所有资料库,默认显示第一个资料库的文件

Loading…
Cancel
Save