From 8815d4c3d666cbc96988087e9c21f9e1a9f64a06 Mon Sep 17 00:00:00 2001
From: fengxiang <110431245@qq.com>
Date: Thu, 10 May 2018 14:09:39 +0800
Subject: [PATCH] 安装用户密码修改

---
 src/app/routes/dashboard/workplace/workplace.component.ts |   13 +---
 src/app/routes/users/installer/installer.component.html   |   47 +++++++++++++++
 src/app/routes/users/installer/installer.component.ts     |   68 ++++++++++++++++++++++
 3 files changed, 118 insertions(+), 10 deletions(-)

diff --git a/src/app/routes/dashboard/workplace/workplace.component.ts b/src/app/routes/dashboard/workplace/workplace.component.ts
index d8d79af..bc27c03 100644
--- a/src/app/routes/dashboard/workplace/workplace.component.ts
+++ b/src/app/routes/dashboard/workplace/workplace.component.ts
@@ -20,7 +20,7 @@
 })
 export class DashboardWorkplaceComponent implements OnInit, OnDestroy {
 
-    totalDeviceCountList: any[] = [];
+    totalDeviceCountList = null;
     totalDeviceCount = '';
     avgDeviceCount = '';
     deviceCountLoading = true;
@@ -174,14 +174,9 @@
                     if (!!rWtihAvg.code && !!rWithToltal&&!!rWithList.code) {
                         this.avgDeviceCount = ToolsService.toThousands(rWtihAvg.data.toString());
                         this.totalDeviceCount = ToolsService.toThousands(rWithToltal.data.toString());
-                        rWithList.data.forEach( item =>{
-                            this.totalDeviceCountList.push(
-                                {
-                                    x:item.time,
-                                    y:item.count
-                                }
-                            );
-                        });
+                        this.totalDeviceCountList = rWithList.data.map(item => {
+                            return {x:item.time,y:item.count};
+                        })
                         this.operNormalPercent = Math.round(rWithNormal.data/rWithToltal.data*100);
                         this.deviceCountLoading = false;
                         this.operationLoading = false;
diff --git a/src/app/routes/users/installer/installer.component.html b/src/app/routes/users/installer/installer.component.html
index ae292f8..7d24dd6 100644
--- a/src/app/routes/users/installer/installer.component.html
+++ b/src/app/routes/users/installer/installer.component.html
@@ -96,8 +96,55 @@
           <nz-popconfirm [nzTitle]="'���������������������������?'" [nzOkText]="'Yes'" [nzCancelText]="'No'" (nzOnConfirm)="delete(i)" >
             <a nz-popconfirm>������</a>
           </nz-popconfirm>
+          <span nz-table-divider></span>
+          <nz-dropdown>
+              <a class="ant-dropdown-link" nz-dropdown>
+                  ������
+                  <i class="anticon anticon-down"></i>
+              </a>
+              <ul nz-menu>
+                  <li nz-menu-item>
+                      <a (click)="showResetPwdWindow(i)">������������</a>
+                  </li>
+              </ul>
+          </nz-dropdown>
       </td>
     </tr>
     </tbody>
   </nz-table>
 </nz-card>
+<!-- ������������������ -->
+<nz-modal [nzVisible]="resetPwdWindowIsVisible" [nzTitle]="'������������'" [nzContent]="modalContent" (nzOnCancel)="resetPwdCancel()"
+    (nzOnOk)="resetPwdOk()" [nzConfirmLoading]="isResetPwdLoading">
+    <ng-template #modalContent>
+        <form nz-form [formGroup]="resetPwdForm">
+            <div nz-form-item nz-row>
+                <div nz-form-label nz-col [nzSm]="6" [nzXs]="24">
+                    <label for="name" >������</label>
+                </div>
+                <div nz-form-control nz-col [nzSm]="14" [nzXs]="24">
+                    <h4 class="h4">{{ getFormControl('name').value }}</h4>
+                </div>
+            </div>
+            <div nz-form-item nz-row>
+                <div nz-form-label nz-col [nzSm]="6" [nzXs]="24">
+                    <label for="password" nz-form-item-required>������</label>
+                </div>
+                <div nz-form-control nz-col [nzSm]="14" [nzXs]="24" nzHasFeedback>
+                    <nz-input [nzSize]="'large'" formControlName="password" [nzType]="'password'" [nzId]="'password'" (ngModelChange)="updateConfirmValidator()"></nz-input>
+                    <div nz-form-explain *ngIf="getFormControl('password').dirty&&getFormControl('password').hasError('required')">���������������!</div>
+                </div>
+            </div>
+            <div nz-form-item nz-row>
+                <div nz-form-label nz-col [nzSm]="6" [nzXs]="24">
+                    <label for="checkPassword" nz-form-item-required>������������</label>
+                </div>
+                <div nz-form-control nz-col [nzSm]="14" [nzXs]="24" nzHasFeedback>
+                    <nz-input [nzSize]="'large'" formControlName="checkPassword" [nzType]="'password'" [nzId]="'checkPassword'"></nz-input>
+                    <div nz-form-explain *ngIf="getFormControl('checkPassword').dirty&&getFormControl('checkPassword').hasError('required')">���������������!</div>
+                    <div nz-form-explain *ngIf="getFormControl('checkPassword').dirty&&getFormControl('checkPassword').hasError('confirm')">���������������������!</div>
+                </div>
+            </div>
+        </form>
+    </ng-template>
+</nz-modal>
diff --git a/src/app/routes/users/installer/installer.component.ts b/src/app/routes/users/installer/installer.component.ts
index 64e6c98..56af9e0 100644
--- a/src/app/routes/users/installer/installer.component.ts
+++ b/src/app/routes/users/installer/installer.component.ts
@@ -5,6 +5,8 @@
 import {UserInstallerEditComponent} from './edit/edit.component';
 import {environment} from 'environments/environment';
 import {DateService} from '@business/services/util/date.service';
+import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms';
+import { ResultBean } from '@business/entity/grid';
 
 @Component({
   selector: 'app-installer',
@@ -38,10 +40,18 @@
     public http: HttpClient,
     public dateSrv: DateService,
     public msgSrv: NzMessageService,
-    private modalHelper: ModalHelper) {}
+    private modalHelper: ModalHelper,
+    private fb: FormBuilder
+  ) {}
 
   ngOnInit() {
     this.load();
+    // ���������������������������
+    this.resetPwdForm = this.fb.group({
+      name    : [ null, [ Validators.email ] ],
+      password         : [ null, [ Validators.required ] ],
+      checkPassword    : [ null, [ Validators.required, this.confirmationValidator ] ]
+      });
   }
 
   load(reload: boolean = false) {
@@ -130,4 +140,60 @@
       return this.dateSrv.date_format(date, 'YYYY-MM-DD');
     }
   }
+  public resetPwdWindowIsVisible = false;
+  public isResetPwdLoading = false;
+  public resetPwdForm: FormGroup;
+  public resetPwdCancel() {
+    this.resetPwdWindowIsVisible = false;
+}
+public resetPwdOk() {
+  for (const i in this.resetPwdForm.controls) {
+    this.resetPwdForm.controls[ i ].markAsDirty();
+  }
+  if (this.resetPwdForm.valid) {
+     this.isResetPwdLoading = true;
+     const data = this.resetPwdForm.value;
+     data['name'] = null;
+     this.http.post(environment.SERVER_BASH_URL + '/operateUser/operateUser', data).subscribe((res: ResultBean<any>) => {
+       if ( res.code === 1 && res.data === 1 ) {
+        this.isResetPwdLoading = false;
+        this.resetPwdWindowIsVisible = false;
+        this.msgSrv.success('���������������������');
+       }
+    });
+  }
+}
+  /**
+   *  ������������������������
+   * @param account 
+   */
+  public showResetPwdWindow(install) {
+    this.resetPwdWindowIsVisible = true;
+    this.resetPwdForm = this.fb.group({
+      id               : [ install.id ],
+      name      : [ install.name],
+      password         : [ null, [ Validators.required ] ],
+      checkPassword    : [ null, [ Validators.required, this.confirmationValidator ] ]
+    });
+  }
+  confirmationValidator = (control: FormControl): { [s: string]: boolean } => {
+    if (!control.value) {
+      return { required: true };
+    } else if (control.value !== this.resetPwdForm.controls[ 'password' ].value) {
+      return { confirm: true, error: true };
+    }
+  }
+  /**
+   * ������ formControl������ ������ ���������������������
+   * @param name y
+   */
+  public getFormControl(name) {
+    return this.resetPwdForm.controls[ name ];
+  }
+  updateConfirmValidator() {
+    /** wait for refresh value */
+    setTimeout(_ => {
+      this.resetPwdForm.controls[ 'checkPassword' ].updateValueAndValidity();
+    });
+  }
 }

--
Gitblit v1.8.0