| | |
| | | import {NzModalSubject, NzMessageService} from 'ng-zorro-antd'; |
| | | import {NzModalSubject} from 'ng-zorro-antd'; |
| | | import {Component, OnInit} from '@angular/core'; |
| | | import {ModalHelper} from '@delon/theme'; |
| | | import {HttpClient} from '@angular/common/http'; |
| | | import {environment} from '../../../../../environments/environment'; |
| | | import {DateService} from '../../../../core/services/date.service'; |
| | | import {FormGroup, FormBuilder, Validators, FormControl} from '@angular/forms'; |
| | | import {Jsonp} from '@angular/http'; |
| | | import {Observable} from 'rxjs'; |
| | | import {FormGroup, FormBuilder, FormControl, Validators} from '@angular/forms'; |
| | | import * as $ from 'jquery'; |
| | | |
| | | |
| | | @Component({ |
| | | selector: 'app-account-edit', |
| | |
| | | validateForm: FormGroup; |
| | | searchOptions = []; |
| | | |
| | | constructor(private modalHelper: ModalHelper, |
| | | constructor( |
| | | private subject: NzModalSubject, |
| | | public dateSrv: DateService, |
| | | public msgSrv: NzMessageService, |
| | | public http: HttpClient, |
| | | private formBuilder: FormBuilder |
| | | ) { |
| | |
| | | } |
| | | |
| | | ngOnInit() { |
| | | const account = this.account; |
| | | this.validateForm = this.formBuilder.group({ |
| | | accountName: [this.account.accountName], |
| | | mobile: [this.account.mobile], |
| | | email: [this.account.email], |
| | | weixin: [this.account.weixin], |
| | | organizationId: [this.account.organizationId], |
| | | expireTime: [this.account.expireTime], |
| | | id: [this.account.id]
|
| | | accountName: [account.accountName], |
| | | mobile: [account.mobile], |
| | | email: [account.email], |
| | | weixin: [account.weixin], |
| | | organizationId: [account.organizationId], |
| | | expireTime: [account.expireTime], |
| | | id: [account.id]
|
| | | }); |
| | | this.searchOptions = this.account.organization ? [this.account.organization] : []; |
| | | this.searchOptions = account.organization ? [account.organization] : []; |
| | | |
| | | $(document).keydown(function(event) { |
| | | switch (event.keyCode) { |
| | | case 13: return false; |
| | | } |
| | | }); |
| | | } |
| | | |
| | | save() { |
| | | if (this.validateForm.valid) { |
| | | for (const i in this.validateForm.controls) { |
| | | this.validateForm.controls[i].disable(); |
| | | 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 + '/account/account', this.validateForm.value).subscribe(() => { |
| | | this.http.post(environment.SERVER_BASH_URL + '/account/account', validateForm.value).subscribe(() => { |
| | | this.subject.next('true'); |
| | | this.close(); |
| | | }); |
| | | } else { |
| | | for (const i in this.validateForm.controls) { |
| | | this.validateForm.controls[i].markAsDirty(); |
| | | for (const i in controls) { |
| | | controls[i].markAsDirty(); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | check(accountName) { |
| | | this.http.get(environment.SERVER_BASH_URL + '/account/' + accountName).subscribe((res: any) => { |
| | | if (res.data > 0) { |
| | | this.validateForm.controls.accountName.setErrors({unique: true}); |
| | | } |
| | | }); |
| | | const controlsAccountName = this.validateForm.controls.accountName; |
| | | if (accountName) { |
| | | this.http.get(environment.SERVER_BASH_URL + '/account/' + accountName).subscribe((res: any) => { |
| | | if (res.data > 0) { |
| | | controlsAccountName.setErrors({unique: true}); |
| | | } |
| | | }); |
| | | } else { |
| | | controlsAccountName.setErrors({required: true}); |
| | | } |
| | | } |
| | | |
| | | searchChange(searchText) { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |