From 929e401e8bcde05be8edf193f53ad999f3e18c84 Mon Sep 17 00:00:00 2001
From: 沈斌 <bluelazysb@hotmail.com>
Date: Sun, 17 Dec 2017 16:53:21 +0800
Subject: [PATCH] updates
---
src/app/routes/users/installer/installer.component.html | 165 ++++++++++++++++++++++++++++++++
src/app/routes/users/users.module.ts | 5
src/app/routes/users/installer/installer.component.ts | 117 +++++++++++++++++++++++
3 files changed, 282 insertions(+), 5 deletions(-)
diff --git a/src/app/routes/users/installer/installer.component.html b/src/app/routes/users/installer/installer.component.html
index afe0b7b..82a9368 100644
--- a/src/app/routes/users/installer/installer.component.html
+++ b/src/app/routes/users/installer/installer.component.html
@@ -1,3 +1,162 @@
-<p>
- installer works!
-</p>
+<pro-header [title]="'������������������'"></pro-header>
+<nz-card [nzBordered]="false">
+ <form nz-form (ngSubmit)="getData()" [nzLayout]="'inline'">
+ <div nz-row [nzGutter]="24">
+ <div nz-col [nzSpan]="8" class="mb-md">
+ <div nz-form-item class="d-flex">
+ <div nz-form-label><label for="no">������������</label></div>
+ <div nz-form-control class="flex-1">
+ <nz-input [(ngModel)]="q.no" name="no" [nzSize]="'large'" [nzPlaceHolder]="'���������'" nzId="no"></nz-input>
+ </div>
+ </div>
+ </div>
+ <div nz-col [nzSpan]="8" class="mb-md">
+ <div nz-form-item class="d-flex">
+ <div nz-form-label><label for="status">������������</label></div>
+ <div nz-form-control class="flex-1">
+ <nz-select [(ngModel)]="q.status" name="status" nzId="status" [nzPlaceHolder]="'���������'" [nzShowSearch]="true" [nzSize]="'large'">
+ <nz-option *ngFor="let i of status; let idx = index" [nzLabel]="i.text" [nzValue]="idx"></nz-option>
+ </nz-select>
+ </div>
+ </div>
+ </div>
+ <div *ngIf="expandForm" nz-col [nzSpan]="8" class="mb-md">
+ <div nz-form-item class="d-flex">
+ <div nz-form-label><label for="callNo">������������</label></div>
+ <div nz-form-control class="flex-1">
+ <nz-input [nzSize]="'large'" nzId="callNo"></nz-input>
+ </div>
+ </div>
+ </div>
+ <div *ngIf="expandForm" nz-col [nzSpan]="8" class="mb-md">
+ <div nz-form-item class="d-flex">
+ <div nz-form-label><label for="updatedAt">������������</label></div>
+ <div nz-form-control class="flex-1">
+ <nz-datepicker [nzSize]="'large'" [nzPlaceHolder]="'���������������������'" nzId="updatedAt" class="d-block"></nz-datepicker>
+ </div>
+ </div>
+ </div>
+ <div *ngIf="expandForm" nz-col [nzSpan]="8" class="mb-md">
+ <div nz-form-item class="d-flex">
+ <div nz-form-label><label for="status2">������������</label></div>
+ <div nz-form-control class="flex-1">
+ <nz-select [nzPlaceHolder]="'���������'" nzId="status2" [nzShowSearch]="true" [nzSize]="'large'">
+ <nz-option *ngFor="let i of status; let idx = index" [nzLabel]="i.text" [nzValue]="idx"></nz-option>
+ </nz-select>
+ </div>
+ </div>
+ </div>
+ <div *ngIf="expandForm" nz-col [nzSpan]="8" class="mb-md">
+ <div nz-form-item class="d-flex">
+ <div nz-form-label><label for="status3">������������</label></div>
+ <div nz-form-control class="flex-1">
+ <nz-select [nzPlaceHolder]="'���������'" nzId="status3" [nzShowSearch]="true" [nzSize]="'large'">
+ <nz-option *ngFor="let i of status; let idx = index" [nzLabel]="i.text" [nzValue]="idx"></nz-option>
+ </nz-select>
+ </div>
+ </div>
+ </div>
+ <div nz-col [nzSpan]="expandForm ? 24 : 8" class="mb-md" [class.text-right]="expandForm">
+ <button nz-button type="submit" [nzType]="'primary'" [nzLoading]="loading" [nzSize]="'large'">������</button>
+ <button nz-button type="reset" (click)="getData()" [nzSize]="'large'" class="mx-sm">������</button>
+ <a (click)="expandForm=!expandForm">
+ {{expandForm ? '������' : '������'}}
+ <i class="anticon" [class.anticon-down]="!expandForm" [class.anticon-up]="expandForm"></i>
+ </a>
+ </div>
+ </div>
+ </form>
+ <div class="mb-md">
+ <button nz-button (click)="add()" [nzType]="'primary'" [nzSize]="'large'">
+ <i class="anticon anticon-plus"></i><span>������</span>
+ </button>
+ <ng-container *ngIf="selectedRows.length > 0">
+ <button nz-button [nzSize]="'large'">������������</button>
+ <nz-dropdown [nzPlacement]="'bottomLeft'">
+ <button nz-button nz-dropdown [nzSize]="'large'">
+ ������������ <i class="anticon anticon-down"></i>
+ </button>
+ <ul nz-menu>
+ <li nz-menu-item (click)="remove()">������</li>
+ <li nz-menu-item (click)="approval()">������������</li>
+ </ul>
+ </nz-dropdown>
+ </ng-container>
+ </div>
+ <div class="mb-md">
+ <nz-alert [nzType]="'info'" [nzShowIcon]="true">
+ <span alert-body>
+ ��������� <strong class="text-primary">{{selectedRows.length}}</strong> ���
+ ������������������ <strong>{{totalCallNo}}</strong> ���
+ <a *ngIf="totalCallNo > 0" (click)="clear()" class="ml-lg">������</a>
+ </span>
+ </nz-alert>
+ </div>
+ <nz-table #nzTable [nzDataSource]="data" [nzPageSize]="q.ps" [nzLoading]="loading"
+ (nzDataChange)="dataChange($event)"
+ (nzPageIndexChange)="pageChange($event)">
+ <thead nz-thead>
+ <tr>
+ <th nz-th [nzCheckbox]="true">
+ <label nz-checkbox [(ngModel)]="allChecked" [nzIndeterminate]="indeterminate"
+ (ngModelChange)="checkAll($event)"></label>
+ </th>
+ <th nz-th><span>������������</span></th>
+ <th nz-th><span>������</span></th>
+ <th nz-th>
+ <span>������������������</span>
+ <nz-table-sort [(nzValue)]="sortMap.callNo" (nzValueChange)="sort('callNo',$event)"></nz-table-sort>
+ </th>
+ <th nz-th>
+ <span>������</span>
+ <nz-dropdown [nzTrigger]="'click'">
+ <i class="anticon anticon-filter" nz-dropdown></i>
+ <ul nz-menu>
+ <li nz-menu-item *ngFor="let i of status">
+ <label nz-checkbox [(ngModel)]="i.value"><span>{{i.text}}</span></label>
+ </li>
+ </ul>
+ <div nz-table-filter>
+ <span nz-table-filter-confirm (click)="getData()">������</span>
+ <span nz-table-filter-clear (click)="reset(status)">������</span>
+ </div>
+ </nz-dropdown>
+ </th>
+ <th nz-th>
+ <span>������������</span>
+ <nz-table-sort [(nzValue)]="sortMap.updatedAt" (nzValueChange)="sort('updatedAt',$event)"></nz-table-sort>
+ </th>
+ <th nz-th><span>������</span></th>
+ </tr>
+ </thead>
+ <tbody nz-tbody>
+ <tr nz-tbody-tr *ngFor="let i of nzTable.data">
+ <td nz-td [nzCheckbox]="true">
+ <label nz-checkbox [nzDisabled]="i.disabled" [(ngModel)]="i.checked" (ngModelChange)="refreshStatus($event)">
+ </label>
+ </td>
+ <td nz-td>{{i.no}}</td>
+ <td nz-td>{{i.description}}</td>
+ <td nz-td class="text-center">{{i.callNo}} ���</td>
+ <td nz-td><nz-badge [nzStatus]="i.statusType" [nzText]="i.statusText"></nz-badge></td>
+ <td nz-td>{{i.updatedAt | _date}}</td>
+ <td nz-td>
+ <a (click)="msg.success('������' + i.no)">������</a>
+ <span nz-table-divider></span>
+ <a (click)="msg.success('������������' + i.no)">������������</a>
+ </td>
+ </tr>
+ </tbody>
+ </nz-table>
+</nz-card>
+<nz-modal [nzVisible]="modalVisible" [nzTitle]="'������������'" [nzConfirmLoading]="loading" [nzContent]="modalContent"
+ (nzOnCancel)="modalVisible=false" (nzOnOk)="save()">
+ <ng-template #modalContent>
+ <div nz-form-item class="d-flex">
+ <div nz-form-label><label for="no">������</label></div>
+ <div nz-form-control class="flex-1">
+ <nz-input [(ngModel)]="description" name="description" [nzSize]="'large'" [nzPlaceHolder]="'���������'" nzId="no"></nz-input>
+ </div>
+ </div>
+ </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 08b11e7..bc9de9a 100644
--- a/src/app/routes/users/installer/installer.component.ts
+++ b/src/app/routes/users/installer/installer.component.ts
@@ -1,4 +1,6 @@
import { Component, OnInit } from '@angular/core';
+import { NzMessageService } from 'ng-zorro-antd';
+import { getRule, saveRule, removeRule } from '../../../../../_mock/rule.service';
@Component({
selector: 'app-installer',
@@ -7,9 +9,122 @@
})
export class InstallerComponent implements OnInit {
- constructor() { }
+ q: any = {
+ pi: 1,
+ ps: 10,
+ sorter: '',
+ status: -1,
+ statusList: []
+ };
+ data: any[] = [];
+ loading = false;
+ selectedRows: any[] = [];
+ curRows: any[] = [];
+ totalCallNo = 0;
+ allChecked = false;
+ indeterminate = false;
+ status = [
+ { text: '������', value: false, type: 'default' },
+ { text: '���������', value: false, type: 'processing' },
+ { text: '���������', value: false, type: 'success' },
+ { text: '������', value: false, type: 'error' }
+ ];
+ sortMap: any = {};
+ expandForm = false;
+ modalVisible = false;
+ description = '';
+
+ constructor(public msg: NzMessageService) {}
ngOnInit() {
+ this.getData();
+ }
+
+ getData() {
+ this.pageChange(1).then(() => {
+ this.q.statusList = this.status.map((i, index) => i.value ? index : -1).filter(w => w !== -1);
+ if (this.q.status && this.q.status > -1) this.q.statusList.push(this.q.status);
+ console.log(this.q);
+ this.data = getRule(this.q).map(i => {
+ const statusItem = this.status[i.status];
+ i.statusText = statusItem.text;
+ i.statusType = statusItem.type;
+ return i;
+ });
+ });
+ }
+
+ add() {
+ this.modalVisible = true;
+ this.description = '';
+ }
+
+ save() {
+ this.loading = true;
+ saveRule(this.description);
+ this.getData();
+ setTimeout(() => this.modalVisible = false, 500);
+ }
+
+ remove() {
+ this.selectedRows.forEach(i => removeRule(i.no));
+ this.getData();
+ this.clear();
+ }
+
+ approval() {
+ this.msg.success(`��������� ${this.selectedRows.length} ���`);
+ }
+
+ clear() {
+ this.selectedRows = [];
+ this.totalCallNo = 0;
+ this.data.forEach(i => i.checked = false);
+ this.refreshStatus();
+ }
+
+ checkAll(value: boolean) {
+ this.curRows.forEach(i => {
+ if (!i.disabled) i.checked = value;
+ });
+ this.refreshStatus();
+ }
+
+ refreshStatus() {
+ const allChecked = this.curRows.every(value => value.disabled || value.checked);
+ const allUnChecked = this.curRows.every(value => value.disabled || !value.checked);
+ this.allChecked = allChecked;
+ this.indeterminate = (!allChecked) && (!allUnChecked);
+ this.selectedRows = this.data.filter(value => value.checked);
+ this.totalCallNo = this.selectedRows.reduce((total, cv) => total + cv.callNo, 0);
+ }
+
+ sort(field: string, value: any) {
+ this.sortMap = {};
+ this.sortMap[field] = value;
+ this.q.sorter = value ? `${field}_${value}` : '';
+ this.getData();
+ }
+
+ dataChange(res: any) {
+ this.curRows = res;
+ this.refreshStatus();
+ }
+
+ pageChange(pi: number): Promise<any> {
+ this.q.pi = pi;
+ this.loading = true;
+ return new Promise((resolve) => {
+ setTimeout(() => {
+ this.loading = false;
+ resolve();
+ }, 500);
+ });
+ }
+
+ reset(ls: any[]) {
+ for (const item of ls) item.value = false;
+ this.getData();
}
}
diff --git a/src/app/routes/users/users.module.ts b/src/app/routes/users/users.module.ts
index a3cd480..859a284 100644
--- a/src/app/routes/users/users.module.ts
+++ b/src/app/routes/users/users.module.ts
@@ -1,7 +1,9 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { InstallerComponent } from './installer/installer.component';
-import {RouterModule, Routes} from '@angular/router';
+import { RouterModule, Routes } from '@angular/router';
+import { SharedModule } from '@shared/shared.module';
+
import { ReceiverComponent } from './receiver/receiver.component';
const routes: Routes = [
@@ -17,6 +19,7 @@
@NgModule({
imports: [
CommonModule,
+ SharedModule,
RouterModule.forChild(routes)
],
declarations: [
--
Gitblit v1.8.0