|
|
|
import { Component, OnInit ,Inject,ViewChild} from '@angular/core';
|
|
|
|
import { CacheTokenService } from '../http-interceptors/cache-token.service'//引入服务
|
|
|
|
import { HttpClient,HttpHeaders } from '@angular/common/http';
|
|
|
|
import { FormControl } from '@angular/forms';
|
|
|
|
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
|
|
|
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',
|
|
|
|
styleUrls: ['./navigation.component.scss']
|
|
|
|
})
|
|
|
|
export class NavigationComponent implements OnInit {
|
|
|
|
|
|
|
|
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; //父组件中获得子组件的引用
|
|
|
|
|
|
|
|
allDataBank:any //所有的资料库
|
|
|
|
selectedDataBank:any //当前选中的资料库
|
|
|
|
hoverDataBank:any //当前鼠标移入的资料库
|
|
|
|
isOneClick:boolean //是否第一次进入网页
|
|
|
|
|
|
|
|
//支队级菜单
|
|
|
|
detachmentMenus:any = [
|
|
|
|
{ id:"支队级-主官", name:"主官" },
|
|
|
|
{ id:"支队级-副官", name:"副官" },
|
|
|
|
{ id:"支队级-灭火救援指挥岗位", name:"灭火救援指挥岗位" },
|
|
|
|
{ id:"支队级-政工岗位", name:"政工岗位" },
|
|
|
|
{ id:"支队级-后勤与保障岗位", name:"后勤与保障岗位" },
|
|
|
|
{ id:"支队级-防火监督岗位", name:"防火监督岗位" },
|
|
|
|
{ id:"支队级-指挥中心", name:"指挥中心" },
|
|
|
|
{ id:"支队级-安全员", name:"安全员" },
|
|
|
|
]
|
|
|
|
//大队级菜单
|
|
|
|
brigadeMenus:any = [
|
|
|
|
{ id:"大队级-主官", name:"主官" },
|
|
|
|
{ id:"大队级-副官", name:"副官" },
|
|
|
|
{ id:"大队级-灭火救援指挥岗位", name:"灭火救援指挥岗位" },
|
|
|
|
{ id:"大队级-政工岗位", name:"政工岗位" },
|
|
|
|
{ id:"大队级-后勤与保障岗位", name:"后勤与保障岗位" },
|
|
|
|
{ id:"大队级-防火监督岗位", name:"防火监督岗位" },
|
|
|
|
{ id:"大队级-安全员", name:"安全员" },
|
|
|
|
]
|
|
|
|
//消防救援站菜单
|
|
|
|
rescueStationMenus:any = [
|
|
|
|
{ id:"消防救援站-消防站指挥员", name:"消防站指挥员" },
|
|
|
|
{ id:"消防救援站-站长助理", name:"站长助理" },
|
|
|
|
{ id:"消防救援站-战斗员", name:"战斗员" },
|
|
|
|
{ id:"消防救援站-供水源", name:"供水源" },
|
|
|
|
{ id:"消防救援站-训导员", name:"训导员" },
|
|
|
|
{ id:"消防救援站-通信员", name:"通信员" },
|
|
|
|
{ id:"消防救援站-无人机飞手", name:"无人机飞手" },
|
|
|
|
{ id:"消防救援站-消防车驾驶员", name:"消防车驾驶员" },
|
|
|
|
{ id:"消防救援站-装备技师", name:"装备技师" }
|
|
|
|
]
|
|
|
|
|
|
|
|
//系统管理菜单
|
|
|
|
systemManagement:any = [
|
|
|
|
{ id:"用户管理", name:"用户管理" },
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
// this.http.get('/api/DataBanks').subscribe((data:any) => {
|
|
|
|
// if(data && data.length != 0){
|
|
|
|
// this.selectedDataBank = data[0].id
|
|
|
|
// }
|
|
|
|
// })
|
|
|
|
// this.getAllDataBank()
|
|
|
|
this.selectedDataBank = "支队级-主官"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
darktheme = false;//黑夜主题
|
|
|
|
switchTheme(dark) {
|
|
|
|
this.darktheme = dark;
|
|
|
|
}
|
|
|
|
defaulttheme(){
|
|
|
|
this.darktheme = false
|
|
|
|
}
|
|
|
|
redtheme(){
|
|
|
|
this.darktheme = true
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//点击用户管理
|
|
|
|
clickUser(item){
|
|
|
|
this.selectedDataBank = item.id
|
|
|
|
this.router.navigate([`/home/userManagement`])
|
|
|
|
}
|
|
|
|
|
|
|
|
//新增资料库
|
|
|
|
// addDataBank(){
|
|
|
|
// const dialogRef = this.dialog.open(AddDataBank, {//调用open方法打开对话框并且携带参数过去
|
|
|
|
// width: '260px',
|
|
|
|
// data: {}
|
|
|
|
// });
|
|
|
|
// dialogRef.afterClosed().subscribe(
|
|
|
|
// (data:any)=>{
|
|
|
|
// if(data){
|
|
|
|
// let headers = new HttpHeaders({
|
|
|
|
// 'Content-Type': 'text/json'
|
|
|
|
// });
|
|
|
|
// let options = {
|
|
|
|
// headers
|
|
|
|
// };
|
|
|
|
// let body = JSON.stringify(data.name);
|
|
|
|
// this.http.post('/api/DataBanks',body,options).subscribe(data => {
|
|
|
|
// this.getAllDataBank()
|
|
|
|
// const config = new MatSnackBarConfig();
|
|
|
|
// config.verticalPosition = 'top';
|
|
|
|
// config.duration = 3000
|
|
|
|
// this.snackBar.open('创建资料库成功','确定',config);
|
|
|
|
// },
|
|
|
|
// err => {
|
|
|
|
// const config = new MatSnackBarConfig();
|
|
|
|
// config.verticalPosition = 'top';
|
|
|
|
// config.duration = 3000
|
|
|
|
// this.snackBar.open(err,'确定',config);
|
|
|
|
// })
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// );
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
//获得所有资料库
|
|
|
|
// getAllDataBank(){
|
|
|
|
// this.http.get('/api/DataBanks').subscribe(data => {
|
|
|
|
// this.allDataBank = data
|
|
|
|
// // console.log(123,data)
|
|
|
|
// }
|
|
|
|
// ,
|
|
|
|
// err=>{
|
|
|
|
// // console.log(456,err)
|
|
|
|
// })
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
//点击资料库
|
|
|
|
clickLi(item){
|
|
|
|
this.selectedDataBank = item.id
|
|
|
|
//触发子组件的方法
|
|
|
|
// this.child.getALLFileList(item.id);
|
|
|
|
// this.child.selection.clear();
|
|
|
|
this.router.navigate([`/home`])
|
|
|
|
this.emitService.eventEmit.emit(item.id);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//鼠标移入资料库
|
|
|
|
liEnter(item){
|
|
|
|
this.hoverDataBank = item.id
|
|
|
|
}
|
|
|
|
//鼠标移出资料库
|
|
|
|
liLeave(item){
|
|
|
|
this.hoverDataBank = ""
|
|
|
|
}
|
|
|
|
//修改资料库名称
|
|
|
|
editDataBankName(e,item){
|
|
|
|
e.stopPropagation()
|
|
|
|
const dialogRef = this.dialog.open(EditDataBankName, {//调用open方法打开对话框并且携带参数过去
|
|
|
|
width: '260px',
|
|
|
|
data: {name:item.name}
|
|
|
|
});
|
|
|
|
dialogRef.afterClosed().subscribe(
|
|
|
|
(data:any)=>{
|
|
|
|
if(data){
|
|
|
|
if(data != item.name){
|
|
|
|
let headers = new HttpHeaders({
|
|
|
|
'Content-Type': 'text/json'
|
|
|
|
});
|
|
|
|
let options = {
|
|
|
|
headers
|
|
|
|
};
|
|
|
|
let body = JSON.stringify(data.name);
|
|
|
|
this.http.put(`/api/DataBanks/${item.id}`,body,options).subscribe(data => {
|
|
|
|
// this.getAllDataBank()
|
|
|
|
const config = new MatSnackBarConfig();
|
|
|
|
config.verticalPosition = 'top';
|
|
|
|
config.duration = 3000
|
|
|
|
this.snackBar.open('修改资料库名称成功','确定',config);
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
//删除资料库
|
|
|
|
deleteDataBank(e,item){
|
|
|
|
e.stopPropagation()
|
|
|
|
var r = confirm(`您确定要删除 ${item.name} 资料库吗?`);
|
|
|
|
if (r == true) {
|
|
|
|
this.http.delete(`/api/DataBanks/${item.id}`).subscribe(data => {
|
|
|
|
// this.getAllDataBank()
|
|
|
|
let config = new MatSnackBarConfig();
|
|
|
|
config.verticalPosition = 'top';
|
|
|
|
config.duration = 3000
|
|
|
|
this.snackBar.open('删除成功','确定',config);
|
|
|
|
},
|
|
|
|
err=>{
|
|
|
|
let config = new MatSnackBarConfig();
|
|
|
|
config.verticalPosition = 'top';
|
|
|
|
config.duration = 3000
|
|
|
|
this.snackBar.open('删除失败,请联系管理员','确定',config);
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//新增资料库
|
|
|
|
@Component({
|
|
|
|
selector: 'adddatabank',
|
|
|
|
templateUrl: './adddatabank.html',
|
|
|
|
styleUrls: ['./navigation.component.scss']
|
|
|
|
})
|
|
|
|
export class AddDataBank {
|
|
|
|
myControl = new FormControl();
|
|
|
|
constructor(private http: HttpClient,public dialogRef: MatDialogRef<AddDataBank>,@Inject(MAT_DIALOG_DATA) public data,public snackBar: MatSnackBar) {}
|
|
|
|
|
|
|
|
onNoClick(): void {
|
|
|
|
this.dialogRef.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
onSubmit(value){
|
|
|
|
if ( value.name.includes('/') ) {
|
|
|
|
let config = new MatSnackBarConfig();
|
|
|
|
config.verticalPosition = 'top';
|
|
|
|
config.duration = 3000
|
|
|
|
this.snackBar.open('名称不允许有特殊字符','确定',config);
|
|
|
|
} else {
|
|
|
|
this.dialogRef.close(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//更改资料库名称
|
|
|
|
@Component({
|
|
|
|
selector: 'editdatabankname',
|
|
|
|
templateUrl: './editdatabankname.html',
|
|
|
|
styleUrls: ['./navigation.component.scss']
|
|
|
|
})
|
|
|
|
export class EditDataBankName {
|
|
|
|
myControl = new FormControl();
|
|
|
|
constructor(private http: HttpClient,public dialogRef: MatDialogRef<EditDataBankName>,@Inject(MAT_DIALOG_DATA) public data,public snackBar: MatSnackBar) {}
|
|
|
|
|
|
|
|
dataBankName:any = this.data.name//要修改的资料库原名称
|
|
|
|
|
|
|
|
onNoClick(): void {
|
|
|
|
this.dialogRef.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
onSubmit(value){
|
|
|
|
if ( value.name.includes('/') ) {
|
|
|
|
let config = new MatSnackBarConfig();
|
|
|
|
config.verticalPosition = 'top';
|
|
|
|
config.duration = 3000
|
|
|
|
this.snackBar.open('名称不允许有特殊字符','确定',config);
|
|
|
|
} else {
|
|
|
|
this.dialogRef.close(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|