From 325fcff34959e7b184675fdbafa14d439cf6b066 Mon Sep 17 00:00:00 2001
From: xufenglei <xufenglei>
Date: Tue, 09 Jan 2018 16:31:45 +0800
Subject: [PATCH] 报警用户管理

---
 src/app/routes/systems/account/account-edit/account-edit.component.ts |   36 ++++++++++++++++++++++++++++--------
 1 files changed, 28 insertions(+), 8 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..4964b13 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
   ) {
@@ -34,8 +31,9 @@
       weixin: [this.account.weixin],
       organizationId: [this.account.organizationId],
       expireTime: [this.account.expireTime],
-      id:[this.account.id]
+      id: [this.account.id]
     });
+    this.searchOptions = this.account.organization ? [this.account.organization] : [];
   }
 
   save() {
@@ -58,4 +56,26 @@
     this.subject.destroy();
   }
 
+  check(accountName) {
+    if (accountName) {
+      this.http.get(environment.SERVER_BASH_URL + '/account/' + accountName).subscribe((res: any) => {
+        if (res.data > 0) {
+          this.validateForm.controls.accountName.setErrors({unique: true});
+        }
+      });
+    } else {
+      this.validateForm.controls.accountName.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