import { Component, OnInit } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; @Component({ selector: 'app-today-warning', templateUrl: './today-warning.component.html', styleUrls: ['./today-warning.component.scss'] }) export class TodayWarningComponent implements OnInit { validateForm!: FormGroup; constructor(private fb: FormBuilder) { } ngOnInit(): void { this.validateForm = this.fb.group({ level: [null], type: [null], site: [null], datePicker: [null] }); } submitForm(): void { for (const i in this.validateForm.controls) { this.validateForm.controls[i].markAsDirty(); this.validateForm.controls[i].updateValueAndValidity(); } console.log(this.validateForm) } resetForm(e: MouseEvent): void { e.preventDefault(); this.validateForm.reset(); for (const key in this.validateForm.controls) { this.validateForm.controls[key].markAsPristine(); this.validateForm.controls[key].updateValueAndValidity(); } } list: any = [ {level:1,type:'加油区违规',content:'工作人员倚靠加油机或者立柱',site:'加油区2号摄像头',time:'2021-10-12 09:28:13'}, {level:2,type:'加油区违规',content:'工作人员倚靠加油机或者立柱',site:'加油区2号摄像头',time:'2021-10-12 09:28:13'}, {level:3,type:'加油区违规',content:'工作人员倚靠加油机或者立柱',site:'加油区2号摄像头',time:'2021-10-12 09:28:13'}, {level:1,type:'加油区违规',content:'工作人员倚靠加油机或者立柱',site:'加油区2号摄像头',time:'2021-10-12 09:28:13'}, {level:1,type:'加油区违规',content:'工作人员倚靠加油机或者立柱',site:'加油区2号摄像头',time:'2021-10-12 09:28:13'}, {level:1,type:'加油区违规',content:'工作人员倚靠加油机或者立柱',site:'加油区2号摄像头',time:'2021-10-12 09:28:13'}, {level:1,type:'加油区违规',content:'工作人员倚靠加油机或者立柱',site:'加油区2号摄像头',time:'2021-10-12 09:28:13'}, {level:1,type:'加油区违规',content:'工作人员倚靠加油机或者立柱',site:'加油区2号摄像头',time:'2021-10-12 09:28:13'}, {level:1,type:'加油区违规',content:'工作人员倚靠加油机或者立柱',site:'加油区2号摄像头',time:'2021-10-12 09:28:13'}, {level:1,type:'加油区违规',content:'工作人员倚靠加油机或者立柱',site:'加油区2号摄像头',time:'2021-10-12 09:28:13'}, {level:1,type:'加油区违规',content:'工作人员倚靠加油机或者立柱',site:'加油区2号摄像头',time:'2021-10-12 09:28:13'}, {level:1,type:'加油区违规',content:'工作人员倚靠加油机或者立柱',site:'加油区2号摄像头',time:'2021-10-12 09:28:13'} ] isVisible = false; showModal(): void { this.isVisible = true; } handleOk(): void { console.log('Button ok clicked!'); this.isVisible = false; } handleCancel(): void { console.log('Button cancel clicked!'); this.isVisible = false; } }