Browse Source

Merge branch 'master' of http://121.36.37.70:3000/shaojiahao/Jinan_project

非煤矿山灾害智能感知和预警系统
邵佳豪 2 years ago
parent
commit
8f520cd6f3
  1. 10967
      package-lock.json
  2. 4
      src/app/app.module.ts
  3. 27
      src/app/home/change-password/change-password.component.html
  4. 0
      src/app/home/change-password/change-password.component.scss
  5. 46
      src/app/home/change-password/change-password.component.ts
  6. 4
      src/app/home/home.module.ts
  7. 2
      src/app/home/nav/nav.component.html
  8. 5
      src/app/home/nav/nav.component.scss
  9. 54
      src/app/home/nav/nav.component.ts
  10. 6
      src/app/home/task/task.component.html
  11. 3
      src/app/home/task/task.component.ts

10967
package-lock.json generated

File diff suppressed because it is too large Load Diff

4
src/app/app.module.ts

@ -15,6 +15,7 @@ import { RouteReuseStrategy } from '@angular/router';
import { CustomReuseStrategy } from './CustomReuseStrategy';
import { ConfigFormDataService } from './service/configFormData.service';
import { registerLocaleData } from '@angular/common';
import { NzModalModule } from 'ng-zorro-antd/modal';
import zh from '@angular/common/locales/zh';
registerLocaleData(zh);
@NgModule({
@ -29,7 +30,8 @@ registerLocaleData(zh);
FormsModule,
HttpClientModule,
NzNotificationModule,
NzMessageModule
NzMessageModule,
NzModalModule
],
providers: [httpInterceptorProviders, CacheTokenService, TreeService, ConfigFormDataService,
{ provide: RouteReuseStrategy, useClass: CustomReuseStrategy }],

27
src/app/home/change-password/change-password.component.html

@ -0,0 +1,27 @@
<div class="box">
<form nz-form [formGroup]="validateForm">
<nz-form-item>
<nz-form-control nzErrorTip="">
<nz-input-group>
<input name="oldpassword" nz-input type="password" formControlName="oldpassword" placeholder="请输入原密码" autocomplete="off" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-control>
<nz-input-group>
<input name="newpassword" nz-input type="password" formControlName="newpassword" placeholder="请输入新密码"
autocomplete="off" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-control>
<nz-input-group>
<input name="affirmpassword" nz-input type="password" formControlName="affirmpassword" placeholder="确认新密码"
autocomplete="new-password" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
</form>
</div>

0
src/app/home/change-password/change-password.component.scss

46
src/app/home/change-password/change-password.component.ts

@ -0,0 +1,46 @@
import { Component, OnInit, Input } from '@angular/core';
import { NzModalRef } from 'ng-zorro-antd/modal';
import { AbstractControl, FormBuilder, FormGroup, Validators } from '@angular/forms';
import { HttpClient } from '@angular/common/http';
import { NzSafeAny } from 'ng-zorro-antd/core/types';
@Component({
selector: 'app-change-password',
templateUrl: './change-password.component.html',
styleUrls: ['./change-password.component.scss']
})
export class ChangePasswordComponent implements OnInit {
constructor(private modal: NzModalRef, private fb: FormBuilder, private http: HttpClient) { }
validateForm!: FormGroup;
ngOnInit(): void {
const { password } = MyValidators;
this.validateForm = this.fb.group({
oldpassword: [null, [Validators.required]],
newpassword: [null, [Validators.required, password]],
affirmpassword: [null, [Validators.required, password]]
});
}
}
export type MyErrorsOptions = { 'zh-cn': string; en: string } & Record<string, NzSafeAny>;
export type MyValidationErrors = Record<string, MyErrorsOptions>;
export class MyValidators extends Validators {
static password(control: AbstractControl): MyValidationErrors | null {
const value = control.value;
if (isEmptyInputValue(value)) {
return null;
}
return isPassword(value) ? null : { mobile: { 'zh-cn': `长度 12 位以上,包含①大写字母、②小写字母、③数字、④特殊字符四种中的三种组合`, en: `Password phone number is not valid` } };
}
}
function isEmptyInputValue(value: NzSafeAny): boolean {
return value == null || value.length === 0;
}
function isPassword(value: string): boolean {
return typeof value === 'string' && /^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\W_!@#$%^&*`~()-+=]+$)(?![a-z0-9]+$)(?![a-z\W_!@#$%^&*`~()-+=]+$)(?![0-9\W_!@#$%^&*`~()-+=]+$)[a-zA-Z0-9\W_!@#$%^&*`~()-+=]{12,99}$/.test(value);
}

4
src/app/home/home.module.ts

@ -55,6 +55,7 @@ import { LookTaskComponent } from './task/zhi-audit/look-task/look-task.componen
import { UnitEditComponent } from './basic-info/unit-edit/unit-edit.component';
import { NzSpinModule } from 'ng-zorro-antd/spin';
import { AllotPersonComponent } from './task/da-subordinate-audit/allot-person/allot-person.component';
import { ChangePasswordComponent } from './change-password/change-password.component';
@NgModule({
declarations: [
NavComponent,
@ -86,7 +87,8 @@ import { AllotPersonComponent } from './task/da-subordinate-audit/allot-person/a
ApplyLookComponent,
LookTaskComponent,
UnitEditComponent,
AllotPersonComponent
AllotPersonComponent,
ChangePasswordComponent
],
imports: [
CommonModule,

2
src/app/home/nav/nav.component.html

@ -19,11 +19,13 @@
</li>
</ul>
<div class="headerbtn">
<div>欢迎,{{user}}</div>
<a nz-dropdown [nzDropdownMenu]="menu" [nzTrigger]="'click'" [nzBackdrop]='false'>
<i nz-icon nzType="setting"></i>
</a>
<nz-dropdown-menu #menu="nzDropdownMenu">
<ul nz-menu nzSelectable>
<li nz-menu-item (click)="changePassword()">修改密码</li>
<li nz-menu-item (click)="signOut()">退出</li>
</ul>
</nz-dropdown-menu>

5
src/app/home/nav/nav.component.scss

@ -22,6 +22,11 @@ nz-header {
.headerbtn{
text-align: right;
width: 220px;
display: flex;
div{
flex: 1;
padding-right: 20px;
}
a{
color: #fff;
}

54
src/app/home/nav/nav.component.ts

@ -1,7 +1,10 @@
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, ViewContainerRef } from '@angular/core';
import { Router } from '@angular/router';
import { CacheTokenService } from 'src/app/service/cache-token.service';
import { HttpClient } from '@angular/common/http';
import { ChangePasswordComponent } from '../change-password/change-password.component';
import { NzModalService } from 'ng-zorro-antd/modal';
import { NzMessageService } from 'ng-zorro-antd/message';
@Component({
selector: 'app-nav',
templateUrl: './nav.component.html',
@ -9,11 +12,12 @@ import { CacheTokenService } from 'src/app/service/cache-token.service';
})
export class NavComponent implements OnInit {
constructor(private router: Router, public token: CacheTokenService) { }
constructor( private modal: NzModalService,private http: HttpClient,private message: NzMessageService,private viewContainerRef: ViewContainerRef,private router: Router, public token: CacheTokenService) { }
user:""
ngOnInit(): void {
//调用服务中的function刷新token
this.token.startUp()
this.user=JSON.parse(sessionStorage.getItem('userData')).organizationName
}
signOut() {
this.router.navigate(['/login'])
@ -21,4 +25,46 @@ export class NavComponent implements OnInit {
ngOnDestroy(): void {
this.token.delete()
}
changePassword() {
const modal: any = this.modal.create({
nzTitle: '修改密码',
nzContent: ChangePasswordComponent,
nzViewContainerRef: this.viewContainerRef,
nzWidth: 288,
nzComponentParams: {},
nzOnOk: async () => {
if (instance.validateForm.valid) {
if (instance.validateForm.value.newpassword != instance.validateForm.value.affirmpassword) {
this.message.create('warning', '两次密码输入不一致!');
return false
} else {
await new Promise((resolve, reject) => {
let body = {
oldPassword: instance.validateForm.value.oldpassword,
newPassword: instance.validateForm.value.newpassword
}
this.http.patch('/api/Accounts/ChangePassword', body).subscribe(data => {
resolve(data)
this.message.create('success', '修改成功!');
return true
}, err => {
this.message.create('warning', err.error.error.message);
modal.config.nzOkLoading = false
return false
})
})
}
} else {
this.message.create('warning', '请填写完整!');
return false
}
}
});
const instance = modal.getContentComponent();
modal.afterOpen.subscribe(() => console.log('[afterOpen] emitted!'));
// Return a result when closed
modal.afterClose.subscribe(result => console.log('[afterClose] The result is:', result));
}
}

6
src/app/home/task/task.component.html

@ -1,6 +1,6 @@
<div class="box">
<div class="nav">
<ul>
<ul *ngIf="level == 'brigade'">
<li [routerLink]="['/task/indicators']" routerLinkActive="router-link-active">
<i nz-icon nzType="book" nzTheme="outline"></i>
任务指标
@ -10,7 +10,7 @@
工作审批
</li>
</ul>
<ul>
<ul *ngIf="level == 'battalion'">
<li [routerLink]="['/task/monthlytaskoverview']" routerLinkActive="router-link-active">
<i nz-icon nzType="appstore" nzTheme="outline"></i>
月度任务总览
@ -24,7 +24,7 @@
本级计划
</li>
</ul>
<ul>
<ul *ngIf="level == 'squadron'">
<li [routerLink]="['/task/taskexecution']" routerLinkActive="router-link-active">
<i nz-icon nzType="file-protect" nzTheme="outline"></i>
任务执行

3
src/app/home/task/task.component.ts

@ -7,10 +7,11 @@ import { Router } from '@angular/router';
styleUrls: ['./task.component.scss']
})
export class TaskComponent implements OnInit {
level=""
constructor(private router: Router) { }
ngOnInit(): void {
this.router.navigate(['/task/indicators'])
this.level=JSON.parse(sessionStorage.getItem('userData')).organizationLevel
}
}

Loading…
Cancel
Save