From 234f914507b05a3b1a92435f5067df6ca4e5eee0 Mon Sep 17 00:00:00 2001 From: fengxiang <110431245@qq.com> Date: Tue, 13 Mar 2018 14:22:16 +0800 Subject: [PATCH] 数据报表 --- src/app/routes/systems/account/account-edit/account-edit.component.ts | 65 ++++++++++++++++++++++---------- 1 files changed, 45 insertions(+), 20 deletions(-) diff --git a/src/app/routes/systems/account/account-edit/account-edit.component.ts b/src/app/routes/systems/account/account-edit/account-edit.component.ts index b4999f5..01a6157 100644 --- a/src/app/routes/systems/account/account-edit/account-edit.component.ts +++ b/src/app/routes/systems/account/account-edit/account-edit.component.ts @@ -1,10 +1,8 @@ -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} from '@angular/forms'; +import {FormGroup, FormBuilder, FormControl, Validators} from '@angular/forms'; @Component({ selector: 'app-account-edit', @@ -15,11 +13,10 @@ account: any; validateForm: FormGroup; + searchOptions = []; - constructor(private modalHelper: ModalHelper, + constructor( private subject: NzModalSubject, - public dateSrv: DateService, - public msgSrv: NzMessageService, public http: HttpClient, private formBuilder: FormBuilder ) { @@ -27,29 +24,33 @@ } 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 = account.organization ? [account.organization] : []; } 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(); } } } @@ -58,4 +59,28 @@ this.subject.destroy(); } + check(accountName) { + 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) { + 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; + }); + } + } + } + } -- Gitblit v1.8.0