From 4156fed8a32e81a61b706b8a17876f7a1fdcabb7 Mon Sep 17 00:00:00 2001 From: xufenglei <xufenglei> Date: Wed, 27 Dec 2017 15:45:16 +0800 Subject: [PATCH] 安装 用户更新 --- src/app/routes/users/installer/edit/edit.component.ts | 23 +++++------ src/app/routes/users/installer/installer.component.html | 7 +-- src/app/routes/users/installer/installer.component.ts | 17 ++++---- src/app/routes/systems/account/account.component.ts | 21 ++-------- src/app/routes/systems/account/account.component.html | 10 ++-- 5 files changed, 33 insertions(+), 45 deletions(-) diff --git a/src/app/routes/systems/account/account.component.html b/src/app/routes/systems/account/account.component.html index 8c84cc4..09d86a2 100644 --- a/src/app/routes/systems/account/account.component.html +++ b/src/app/routes/systems/account/account.component.html @@ -1,6 +1,6 @@ <pro-header [title]="'������������'"></pro-header> <nz-card [nzBordered]="false"> - <form nz-form [nzLayout]="'inline'"> + <form nz-form (ngSubmit)="load(true)" [nzLayout]="'inline'"> <div nz-row [nzGutter]="24"> <div nz-col [nzSpan]="8" class="mb-md"> <div nz-form-item class="d-flex"> @@ -28,9 +28,9 @@ <label>������������</label> </div> <div nz-form-control class="flex-1"> - <nz-select [(ngModel)]="query.isDelete" name="isDelete" [nzSize]="'large'" > + <nz-select [(ngModel)]="query.isDelete" name="isDelete" [nzSize]="'large'"> <nz-option *ngFor="let option of options" [nzLabel]="option.label" [nzValue]="option.value" ></nz-option> - </nz-select> + </nz-select> </div> </div> </div> @@ -47,7 +47,7 @@ <i class="anticon anticon-plus"></i><span>������</span> </button> <ng-container *ngIf="selectedRows.length > 0"> - <button nz-button [nzSize]="'large'" (click)="remove()">������������</button> + <button nz-button [nzSize]="'large'" (click)="remove()">������������</button> </ng-container> </div> @@ -89,7 +89,7 @@ <tbody nz-tbody> <tr nz-tbody-tr *ngFor="let account of nzTable.data"> <td nz-td [nzCheckbox]="true"> - <label nz-checkbox [(ngModel)]="account.checked" (ngModelChange)="refreshStatus($event)"></label> + <label nz-checkbox [(ngModel)]="account.checked" (ngModelChange)="refreshStatus($event)" [nzDisabled]="account.isDelete == '1'? true : false"></label> </td> <td nz-td>{{account.accountName}}</td> <td nz-td>{{account.mobile}}</td> diff --git a/src/app/routes/systems/account/account.component.ts b/src/app/routes/systems/account/account.component.ts index 9078ab4..7d925d8 100644 --- a/src/app/routes/systems/account/account.component.ts +++ b/src/app/routes/systems/account/account.component.ts @@ -22,14 +22,13 @@ query: any = { pageIndex: 1, - pageSize: 3, + pageSize: 10, isDelete: this.options[1].value }; data: any[] = []; total: 0; selectedRows: any[] = []; - curRows: any[] = []; allChecked = false; indeterminate = false; sortMap: any = {}; @@ -50,7 +49,7 @@ this.data = res.data.data; this.total = res.data.total; - this.dataChange(this.data); + this.refreshStatus(); }); } @@ -95,20 +94,15 @@ } checkAll(value: boolean) { - this.curRows.forEach(i => { + this.data.forEach(i => { i.checked = value; }); this.refreshStatus(); } - dataChange(res: any) { - this.curRows = res; - this.refreshStatus(); - } - refreshStatus() { - const allChecked = this.curRows.every(value => value.checked); - const allUnChecked = this.curRows.every(value => !value.checked); + const allChecked = this.data.every(value => value.checked); + const allUnChecked = this.data.every(value => !value.checked); this.allChecked = allChecked; this.indeterminate = (!allChecked) && (!allUnChecked); this.selectedRows = this.data.filter(value => value.checked); @@ -118,11 +112,6 @@ this.sortMap = {}; this.sortMap[field] = value; this.query.sorter = value ? `${field} ${value}` : ''; - this.load(true); - } - - reset(ls: any[]) { - for (const item of ls) item.value = false; this.load(true); } diff --git a/src/app/routes/users/installer/edit/edit.component.ts b/src/app/routes/users/installer/edit/edit.component.ts index 71e0c3b..fa8d5ff 100644 --- a/src/app/routes/users/installer/edit/edit.component.ts +++ b/src/app/routes/users/installer/edit/edit.component.ts @@ -22,20 +22,19 @@ public http: HttpClient) { } ngOnInit() { - if (this.user.id > 0) { - this.http.get(environment.SERVER_BASH_URL + '/user/operate_user/' + this.user.id).subscribe((res: any) => { - this.user = res; - 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'); - } +// if (this.user.id > 0) { +// this.http.get(environment.SERVER_BASH_URL + '/user/operate_user/' + this.user.id).subscribe((res: any) => { +// this.user = res; +// 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() { - console.log(this.user); if (this.user.name == null || this.user.name === '') { this.msgSrv.error('���������������'); } else if (this.user.mobile == null || this.user.mobile === '') { @@ -45,7 +44,7 @@ } 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.http.post(environment.SERVER_BASH_URL + '/operateUser/operateUser', this.user).subscribe(() => { this.subject.next('true'); this.close(); }); diff --git a/src/app/routes/users/installer/installer.component.html b/src/app/routes/users/installer/installer.component.html index ceab058..4e66c78 100644 --- a/src/app/routes/users/installer/installer.component.html +++ b/src/app/routes/users/installer/installer.component.html @@ -40,14 +40,13 @@ </nz-alert> </div> <nz-table #nzTable - [nzDataSource]="data" + [nzAjaxData]="data" [nzLoading]="http.loading" [nzTotal]="total" [(nzPageIndex)]="q.pi" [nzPageSize]="q.ps" [nzShowTotal]="true" - (nzPageIndexChange)="load()" - (nzDataChange)="dataChange($event)"> + (nzPageIndexChange)="load()"> <thead nz-thead> <tr> <th nz-th [nzCheckbox]="true"> @@ -62,7 +61,7 @@ <th nz-th><span>������������</span></th> <th nz-th> <span>������������</span> - <nz-table-sort [(nzValue)]="sortMap.updatedAt" (nzValueChange)="sort('expireTime', $event)"></nz-table-sort> + <nz-table-sort [(nzValue)]="sortMap.updatedAt" (nzValueChange)="sort('expire_time', $event)"></nz-table-sort> </th> <th nz-th><span>������</span></th> </tr> diff --git a/src/app/routes/users/installer/installer.component.ts b/src/app/routes/users/installer/installer.component.ts index 99bf082..2f52de4 100644 --- a/src/app/routes/users/installer/installer.component.ts +++ b/src/app/routes/users/installer/installer.component.ts @@ -15,7 +15,7 @@ q: any = { pi: 1, - ps: 10, + ps: 1, sorter: '', u_name: '', u_mobile: '' @@ -43,7 +43,7 @@ if (reload) { this.q.pi = 1; } - this.http.get(environment.SERVER_BASH_URL + '/user/operate_user', this.q).subscribe((res: any) => { + this.http.get(environment.SERVER_BASH_URL + '/operateUser/list', {params: this.q}).subscribe((res: any) => { // let data = res.data; // const total = res.total; // @@ -68,8 +68,10 @@ // this.data = data.slice(start, start + this.q.ps); // this.total = total; - this.data = res.data; - this.total = res.total; + this.data = res.data.data; + this.total = res.data.total; + this.dataChange(this.data); + }); } @@ -89,7 +91,7 @@ } delete(user) { - this.http.delete(environment.SERVER_BASH_URL + '/user/operate_user/' + user.id).subscribe((res: any) => { + this.http.post(environment.SERVER_BASH_URL + '/operateUser/operateUser/id',user).subscribe((res: any) => { this.msgSrv.success('���������������������������'); this.load(true); }); @@ -100,8 +102,7 @@ this.selectedRows.forEach(i => { ids.push(i.id); }); - console.log(ids); - this.http.post(environment.SERVER_BASH_URL + '/user/operate_user/deleteList', ids).subscribe((res: any) => { + this.http.post(environment.SERVER_BASH_URL + '/operateUser/operateUsers/ids', ids).subscribe((res: any) => { this.load(true); }); } @@ -129,7 +130,7 @@ sort(field: string, value: any) { this.sortMap = {}; this.sortMap[field] = value; - this.q.sorter = value ? `${field}_${value}` : ''; + this.q.sorter = value ? `${field} ${value}` : ''; this.load(true); } -- Gitblit v1.8.0