From 9917e7736b7c658ffed087d664acb47236c146c5 Mon Sep 17 00:00:00 2001
From: 沈斌 <bluelazysb@hotmail.com>
Date: Wed, 20 Dec 2017 14:43:58 +0800
Subject: [PATCH] updates

---
 src/app/core/services/date.service.ts                   |    4 ++++
 src/app/routes/users/installer/edit/edit.component.ts   |   22 ++++++++++++++++++----
 src/app/routes/users/installer/edit/edit.component.html |   16 ++++++++++------
 3 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/src/app/core/services/date.service.ts b/src/app/core/services/date.service.ts
index f49e6be..caf4534 100644
--- a/src/app/core/services/date.service.ts
+++ b/src/app/core/services/date.service.ts
@@ -8,4 +8,8 @@
   date_format(date: string, format: string) {
     return moment(date).format('YYYY-MM-DD');
   }
+
+  today(format: string) {
+    return moment().format('YYYY-MM-DD');
+  }
 }
diff --git a/src/app/routes/users/installer/edit/edit.component.html b/src/app/routes/users/installer/edit/edit.component.html
index 42e42ae..480658d 100644
--- a/src/app/routes/users/installer/edit/edit.component.html
+++ b/src/app/routes/users/installer/edit/edit.component.html
@@ -1,5 +1,5 @@
 <div class="modal-header">
-  <div class="modal-title">{{user.id > 0 ? '������' : '������'}}-������������</div>
+  <div class="modal-title">{{user.id > 0 ? '������' : '������'}} - ������������</div>
 </div>
 <form #f="ngForm" (ngSubmit)="save()" nz-form [nzType]="'horizontal'">
   <div nz-form-item nz-row class="mb-sm">
@@ -19,27 +19,31 @@
     </div>
     <div nz-form-label nz-col [nzSpan]="4"><label>���������</label></div>
     <div nz-form-control nz-col [nzSpan]="8">
-      <input nz-input [(ngModel)]="user.weixin" name="weixin" required />
+      <input nz-input [(ngModel)]="user.weixin" name="weixin" />
     </div>
   </div>
   <div nz-form-item nz-row class="mb-sm">
     <div nz-form-label nz-col [nzSpan]="4"><label>������</label></div>
     <div nz-form-control nz-col [nzSpan]="8">
-      <input nz-input [(ngModel)]="user.organizationId" name="organizationId" maxlength="50" placeholder="50���������" />
+      <input nz-input [(ngModel)]="user.organizationId" name="organizationId" maxlength="20" placeholder="20���������" />
     </div>
     <div nz-form-label nz-col [nzSpan]="4"><label>������</label></div>
     <div nz-form-control nz-col [nzSpan]="8">
-      <input nz-input [(ngModel)]="user.password" name="password" maxlength="50" placeholder="50���������" />
+      <input nz-input [(ngModel)]="user.password" name="password" maxlength="30" placeholder="30���������" required />
     </div>
   </div>
   <div nz-form-item nz-row class="mb-sm">
     <div nz-form-label nz-col [nzSpan]="4"><label>������������</label></div>
     <div nz-form-control nz-col [nzSpan]="8">
-      <input nz-input [(ngModel)]="user.createTime" name="createTime" maxlength="20" required />
+      <div nz-form-control [nzValidateStatus]="createTime">
+        <nz-datepicker [(ngModel)]="user.createTime" name="createTime"></nz-datepicker>
+      </div>
     </div>
     <div nz-form-label nz-col [nzSpan]="4"><label>������������</label></div>
     <div nz-form-control nz-col [nzSpan]="8">
-      <input nz-input [(ngModel)]="user.expireTime" name="expireTime" maxlength="20" required />
+      <div nz-form-control [nzValidateStatus]="expireTime">
+        <nz-datepicker [(ngModel)]="user.expireTime" name="expireTime"></nz-datepicker>
+      </div>
     </div>
   </div>
   <div class="modal-footer">
diff --git a/src/app/routes/users/installer/edit/edit.component.ts b/src/app/routes/users/installer/edit/edit.component.ts
index 9d5b573..71e0c3b 100644
--- a/src/app/routes/users/installer/edit/edit.component.ts
+++ b/src/app/routes/users/installer/edit/edit.component.ts
@@ -28,14 +28,28 @@
         this.user.createTime = this.dateSrv.date_format(this.user.createTime, 'YYYY-MM-DD');
         this.user.expireTime = this.dateSrv.date_format(this.user.expireTime, 'YYYY-MM-DD');
       });
+    } else {
+      this.user.createTime = this.dateSrv.today('YYYY-MM-DD');
+      this.user.expireTime = this.dateSrv.today('YYYY-MM-DD');
     }
   }
 
   save() {
-    this.http.post(environment.SERVER_BASH_URL + '/user/operate_user/save', this.user).subscribe(() => {
-      this.subject.next('true');
-      this.close();
-    });
+    console.log(this.user);
+    if (this.user.name == null || this.user.name === '') {
+      this.msgSrv.error('���������������');
+    } else if (this.user.mobile == null || this.user.mobile === '') {
+      this.msgSrv.error('���������������');
+    } else if (this.user.email == null || this.user.email === '') {
+      this.msgSrv.error('���������������������');
+    } else if (this.user.password == null || this.user.password === '') {
+      this.msgSrv.error('���������������');
+    } else {
+      this.http.post(environment.SERVER_BASH_URL + '/user/operate_user/save', this.user).subscribe(() => {
+        this.subject.next('true');
+        this.close();
+      });
+    }
   }
 
   close() {

--
Gitblit v1.8.0