diff --git a/src/app/pages/change-password/change-password.component.ts b/src/app/pages/change-password/change-password.component.ts index 8735ca7..62d64b3 100644 --- a/src/app/pages/change-password/change-password.component.ts +++ b/src/app/pages/change-password/change-password.component.ts @@ -1,7 +1,8 @@ import { Component, OnInit, Input } from '@angular/core'; import { NzModalRef } from 'ng-zorro-antd/modal'; -import { FormBuilder, FormGroup, Validators } from '@angular/forms'; +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', @@ -12,11 +13,33 @@ 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]], - affirmpassword: [null, [Validators.required]] + newpassword: [null, [Validators.required, password]], + affirmpassword: [null, [Validators.required, password]] }); } } + +export type MyErrorsOptions = { 'zh-cn': string; en: string } & Record; +export type MyValidationErrors = Record; +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); +} diff --git a/src/app/pages/login/login.component.ts b/src/app/pages/login/login.component.ts index 6aaddf3..4b99c36 100644 --- a/src/app/pages/login/login.component.ts +++ b/src/app/pages/login/login.component.ts @@ -3,10 +3,11 @@ import { HttpClient } from '@angular/common/http' import { Router, ActivatedRoute } from '@angular/router' import { CacheTokenService } from '../../service/cache-token.service'//引入服务 import { CookieService } from 'ngx-cookie-service';//cookie插件 -import { FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { AbstractControl, FormBuilder, FormGroup, Validators } from '@angular/forms'; import { NzMessageService } from 'ng-zorro-antd/message'; import { Base64 } from 'js-base64'; import { NzNotificationService } from 'ng-zorro-antd/notification'; +import { NzSafeAny } from 'ng-zorro-antd/core/types'; declare var abp: any @Component({ @@ -18,15 +19,18 @@ declare var abp: any export class LoginComponent implements OnInit { validateForm!: FormGroup; - constructor(private http: HttpClient, private router: Router, private route: ActivatedRoute, public token: CacheTokenService, private cookieService: CookieService, private fb: FormBuilder, private message: NzMessageService, private notificationService: NzNotificationService) { } - - ngOnInit() { + constructor(private http: HttpClient, private router: Router, private route: ActivatedRoute, public token: CacheTokenService, private cookieService: CookieService, private fb: FormBuilder, private message: NzMessageService, private notificationService: NzNotificationService) { + const { password } = MyValidators; this.validateForm = this.fb.group({ userName: [null, [Validators.required]], - password: [null, [Validators.required]], + password: [null, [Validators.required, password]], remember: [null], autologin: [null], }); + } + + ngOnInit() { + //如果本地储存了账号密码信息,那就回显在输入框 let account = localStorage.getItem('account') let password = localStorage.getItem('password') @@ -157,3 +161,24 @@ export class LoginComponent implements OnInit { this.message.create('warning', `请联系管理员`); } } +export type MyErrorsOptions = { 'zh-cn': string; en: string } & Record; +export type MyValidationErrors = Record; +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); +} + diff --git a/src/app/pages/oil-unloading-process-list/oil-unloading-process-list.component.html b/src/app/pages/oil-unloading-process-list/oil-unloading-process-list.component.html index fd460bf..244bb6a 100644 --- a/src/app/pages/oil-unloading-process-list/oil-unloading-process-list.component.html +++ b/src/app/pages/oil-unloading-process-list/oil-unloading-process-list.component.html @@ -103,13 +103,13 @@
序号
-
+
油站名称
公司名称
-
+
区域
@@ -124,9 +124,9 @@
操作中准备预警节点数量
-
+
状态
@@ -139,13 +139,13 @@
{{key + 1}}
-
+
{{item.gasStation.stationName}}
{{item.gasStation.companyName}}
-
+
{{item.gasStation.locationName}}
@@ -160,9 +160,9 @@
{{item.proccessingCount}}
-
+
diff --git a/src/app/pages/warning-statistics-list/warning-statistics-list.component.html b/src/app/pages/warning-statistics-list/warning-statistics-list.component.html index ca27158..198d224 100644 --- a/src/app/pages/warning-statistics-list/warning-statistics-list.component.html +++ b/src/app/pages/warning-statistics-list/warning-statistics-list.component.html @@ -104,16 +104,16 @@ overflow:hidden; text-overflow:ellipsis;">序号
-
+
预警类别
-
+
预警内容
公司名称
-
+
区域名称
@@ -134,7 +134,7 @@
{{key+1}}
-
+
办理提醒 临期提醒 @@ -144,7 +144,7 @@ 逾期报警
-
+
{{item.desc}}办理提醒 {{item.desc}}临期提醒 @@ -154,13 +154,13 @@ 消防设备逾期报警
-
+
{{item.gasStation.companyName ? item.gasStation.companyName : '/'}}
-
+
{{item.gasStation.locationName ? item.gasStation.locationName : '/'}}
-
+
{{item.gasStation.stationName ? item.gasStation.stationName : '/'}}