|  |  |  | 
|---|
|  |  |  | 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(); | 
|---|
|  |  |  | const alarmUser = this.alarmUser; | 
|---|
|  |  |  | this.validateForm = this.formBuilder.group({ | 
|---|
|  |  |  | name: [alarmUser.name], | 
|---|
|  |  |  | mobile: [alarmUser.mobile, [Validators.pattern('^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\\d{8}$')]], | 
|---|
|  |  |  | email: [alarmUser.email, [Validators.email]], | 
|---|
|  |  |  | weixin: [alarmUser.weixin], | 
|---|
|  |  |  | organizationId: [alarmUser.organizationId], | 
|---|
|  |  |  | expireTime: [alarmUser.expireTime], | 
|---|
|  |  |  | id: [alarmUser.id] | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | this.searchOptions = alarmUser.organization ? [alarmUser.organization] : []; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | save() { | 
|---|
|  |  |  | const validateForm = this.validateForm; | 
|---|
|  |  |  | const controls = validateForm.controls; | 
|---|
|  |  |  | if (validateForm.valid) { | 
|---|
|  |  |  | for (const i in controls) { | 
|---|
|  |  |  | controls[i].disable(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | this.http.post(environment.SERVER_BASH_URL + '/alarmUser/alarmUser', validateForm.value).subscribe(() => { | 
|---|
|  |  |  | this.subject.next('true'); | 
|---|
|  |  |  | this.close(); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | for (const i in controls) { | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|