Browse Source

[新增]新增修改密码功能

dev
邵佳豪 3 years ago
parent
commit
6734913210
  1. 27
      src/app/pages/change-password/change-password.component.html
  2. 0
      src/app/pages/change-password/change-password.component.scss
  3. 22
      src/app/pages/change-password/change-password.component.ts
  4. 5
      src/app/pages/home/home.component.html
  5. 50
      src/app/pages/home/home.component.ts
  6. 5
      src/app/pages/pages.module.ts

27
src/app/pages/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="text" 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/pages/change-password/change-password.component.scss

22
src/app/pages/change-password/change-password.component.ts

@ -0,0 +1,22 @@
import { Component, OnInit, Input } from '@angular/core';
import { NzModalRef } from 'ng-zorro-antd/modal';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { HttpClient } from '@angular/common/http';
@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 {
this.validateForm = this.fb.group({
oldpassword: [null, [Validators.required]],
newpassword: [null, [Validators.required]],
affirmpassword: [null, [Validators.required]]
});
}
}

5
src/app/pages/home/home.component.html

@ -55,6 +55,7 @@
<ul nz-menu nzSelectable> <ul nz-menu nzSelectable>
<li *ngIf="isGasStation" nz-menu-item (click)="navChange('/oliStationInfo')">基本信息</li> <li *ngIf="isGasStation" nz-menu-item (click)="navChange('/oliStationInfo')">基本信息</li>
<li *ngIf="isGasStation" nz-menu-item (click)="navChange('/equipmentInfo')">器材信息</li> <li *ngIf="isGasStation" nz-menu-item (click)="navChange('/equipmentInfo')">器材信息</li>
<li nz-menu-item (click)="changePassword()">修改密码</li>
<li *ngIf="userName == 'admin'" nz-menu-item (click)="navChange('/system/organization')">系统管理</li> <li *ngIf="userName == 'admin'" nz-menu-item (click)="navChange('/system/organization')">系统管理</li>
<li nz-menu-item (click)="signOut()">退出系统</li> <li nz-menu-item (click)="signOut()">退出系统</li>
</ul> </ul>
@ -88,7 +89,3 @@
</div> </div>
</div> </div>
</ng-template> </ng-template>
<!--
<nz-modal [(nzVisible)]="isVisible">
<app-get-out-of-line-details [data]="modalData"></app-get-out-of-line-details>
</nz-modal> -->

50
src/app/pages/home/home.component.ts

@ -1,6 +1,5 @@
import { Component, OnInit, ViewChild, TemplateRef, ViewContainerRef } from '@angular/core'; import { Component, OnInit, ViewChild, TemplateRef, ViewContainerRef } from '@angular/core';
import { Router, NavigationEnd, ActivatedRoute } from '@angular/router'; import { Router, NavigationEnd } from '@angular/router';
import { Title } from '@angular/platform-browser'
import { filter } from 'rxjs/operators'; import { filter } from 'rxjs/operators';
import { NavChangeService } from '../../service/navChange.service'; import { NavChangeService } from '../../service/navChange.service';
import { CacheTokenService } from '../../service/cache-token.service' //引入服务 import { CacheTokenService } from '../../service/cache-token.service' //引入服务
@ -11,6 +10,7 @@ import { NzNotificationService } from 'ng-zorro-antd/notification';
import { GetOutOfLineDetailsComponent } from '../today-warning/get-out-of-line-details/get-out-of-line-details.component'; import { GetOutOfLineDetailsComponent } from '../today-warning/get-out-of-line-details/get-out-of-line-details.component';
import { NzModalService } from 'ng-zorro-antd/modal'; import { NzModalService } from 'ng-zorro-antd/modal';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { ChangePasswordComponent } from '../change-password/change-password.component';
declare var abp: any declare var abp: any
@Component({ @Component({
@ -260,4 +260,50 @@ export class HomeComponent implements OnInit {
} }
this.isfullscreen = false; this.isfullscreen = false;
} }
//修改密码
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 = {
currentPassword: instance.validateForm.value.oldpassword,
newPassword: instance.validateForm.value.newpassword
}
this.http.post('/api/services/app/User/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));
}
} }

5
src/app/pages/pages.module.ts

@ -53,11 +53,12 @@ import { DispositionComponent } from './disposition/disposition.component';
import { OilUnloadingProcessComponent } from './oil-unloading-process/oil-unloading-process.component'; import { OilUnloadingProcessComponent } from './oil-unloading-process/oil-unloading-process.component';
import { HomePageComponent } from './home-page/home-page.component'; import { HomePageComponent } from './home-page/home-page.component';
import { OilUnloadingProcessListComponent } from './oil-unloading-process-list/oil-unloading-process-list.component'; import { OilUnloadingProcessListComponent } from './oil-unloading-process-list/oil-unloading-process-list.component';
import { ChangePasswordComponent } from './change-password/change-password.component';
@NgModule({ @NgModule({
declarations: [LoginComponent, RegisterComponent, HomeComponent, PlanComponent, TodayWarningComponent, CriminalRecordsComponent, declarations: [LoginComponent, RegisterComponent, HomeComponent, PlanComponent, TodayWarningComponent, CriminalRecordsComponent,
TodayWarningAdminComponent, CriminalRecordsAdminComponent, LeftDomainComponent, EquipmentInfoComponent, OilStationInfoComponent, TodayWarningAdminComponent, CriminalRecordsAdminComponent, LeftDomainComponent, EquipmentInfoComponent, OilStationInfoComponent,
AddequipmentComponent, EditequipmentComponent,PlanAdminComponent, GetOutOfLineDetailsComponent, DispositionComponent, OilUnloadingProcessComponent, HomePageComponent, OilUnloadingProcessListComponent], AddequipmentComponent, EditequipmentComponent,PlanAdminComponent, GetOutOfLineDetailsComponent, DispositionComponent, OilUnloadingProcessComponent, HomePageComponent, OilUnloadingProcessListComponent, ChangePasswordComponent],
imports: [ imports: [
@ -98,7 +99,7 @@ import { OilUnloadingProcessListComponent } from './oil-unloading-process-list/o
NzPopconfirmModule, NzPopconfirmModule,
NzBadgeModule NzBadgeModule
], ],
entryComponents: [AddequipmentComponent, EditequipmentComponent,GetOutOfLineDetailsComponent,DispositionComponent,OilUnloadingProcessComponent], entryComponents: [AddequipmentComponent, EditequipmentComponent,GetOutOfLineDetailsComponent,DispositionComponent,OilUnloadingProcessComponent,ChangePasswordComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA] schemas: [CUSTOM_ELEMENTS_SCHEMA]
}) })

Loading…
Cancel
Save