| | |
| | | import { environment } from '../../../../../environments/environment'; |
| | | import { DateService } from '../../../../core/services/date.service'; |
| | | import { Component, OnInit } from '@angular/core'; |
| | | import { ModalHelper } from '@delon/theme'; |
| | | import { NzModalSubject, NzMessageService } from 'ng-zorro-antd'; |
| | | import {NzModalSubject} from 'ng-zorro-antd'; |
| | | import {Component, OnInit} from '@angular/core'; |
| | | import {HttpClient} from '@angular/common/http'; |
| | | import {environment} from '../../../../../environments/environment'; |
| | | import {FormGroup, FormBuilder, FormControl, Validators} from '@angular/forms'; |
| | | |
| | | @Component({ |
| | | selector: 'app-alarm-user-edit', |
| | |
| | | export class AlarmUserEditComponent implements OnInit { |
| | | |
| | | alarmUser: any; |
| | | validateForm: FormGroup; |
| | | searchOptions = []; |
| | | |
| | | constructor(private modalHelper: ModalHelper, |
| | | constructor( |
| | | private subject: NzModalSubject, |
| | | public dateSrv: DateService, |
| | | public msgSrv: NzMessageService, |
| | | public http: HttpClient) {} |
| | | public http: HttpClient, |
| | | private formBuilder: FormBuilder |
| | | ) {} |
| | | |
| | | ngOnInit() { |
| | | } |
| | | |
| | | save() { |
| | | this.http.post(environment.SERVER_BASH_URL + '/alarmUser/alarmUser', this.alarmUser).subscribe(() => { |
| | | this.subject.next('true'); |
| | | this.close(); |
| | | this.validateForm = this.formBuilder.group({ |
| | | name: [this.alarmUser.name], |
| | | mobile: [this.alarmUser.mobile, [Validators.pattern("^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\\d{8}$")]], |
| | | email: [this.alarmUser.email,[Validators.email]], |
| | | weixin: [this.alarmUser.weixin], |
| | | organizationId: [this.alarmUser.organizationId], |
| | | expireTime: [this.alarmUser.expireTime], |
| | | id: [this.alarmUser.id] |
| | | }); |
| | | this.searchOptions = this.alarmUser.organization ? [this.alarmUser.organization] : []; |
| | | } |
| | | |
| | | save() { |
| | | if (this.validateForm.valid) { |
| | | for (const i in this.validateForm.controls) { |
| | | this.validateForm.controls[i].disable(); |
| | | } |
| | | this.http.post(environment.SERVER_BASH_URL + '/alarmUser/alarmUser', this.validateForm.value).subscribe(() => { |
| | | this.subject.next('true'); |
| | | this.close(); |
| | | }); |
| | | } else { |
| | | for (const i in this.validateForm.controls) { |
| | | this.validateForm.controls[i].markAsDirty(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | close() { |
| | | this.subject.destroy(); |
| | | } |
| | | |
| | | searchChange(searchText) { |
| | | if (searchText) { |
| | | const query = encodeURI(searchText); |
| | | if (query) { |
| | | this.http.get(environment.SERVER_BASH_URL + '/organization/list/' + query).subscribe((res: any) => { |
| | | this.searchOptions = res.data; |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |