From fb73a14c658ce113721542c415402321a985d25b Mon Sep 17 00:00:00 2001
From: xufenglei <xufenglei>
Date: Tue, 10 Apr 2018 09:12:32 +0800
Subject: [PATCH] 注册码 管理

---
 src/app/routes/systems/organization/organization-list/organization-list.component.ts   |    4 ++
 src/app/routes/systems/registration/registration.component.ts                          |   72 ++++++++++++++++++++++++++++++++++++
 src/app/routes/systems/systems.module.ts                                               |    7 ++-
 src/app/routes/systems/organization/organization-list/organization-list.component.html |    2 +
 src/assets/app-data.json                                                               |    7 +++
 src/app/routes/systems/registration/registration.component.html                        |   27 +++++++++++++
 6 files changed, 116 insertions(+), 3 deletions(-)

diff --git a/src/app/routes/systems/organization/organization-list/organization-list.component.html b/src/app/routes/systems/organization/organization-list/organization-list.component.html
index 033bdb6..e1ed4eb 100644
--- a/src/app/routes/systems/organization/organization-list/organization-list.component.html
+++ b/src/app/routes/systems/organization/organization-list/organization-list.component.html
@@ -58,6 +58,8 @@
                               <nz-popconfirm [nzTitle]="'������������������'+grid.title+'���?'" [nzOkText]="'Yes'" [nzCancelText]="'No'" (nzOnConfirm)="delete(row.id)" >
                                 <a nz-popconfirm>������</a>
                               </nz-popconfirm>
+                            <span nz-table-divider></span>
+                            <a [routerLink]="['/systems/registration']" (click)="registration(row)">���������</a>
                      </td>
                 </tr>
               </tbody>
diff --git a/src/app/routes/systems/organization/organization-list/organization-list.component.ts b/src/app/routes/systems/organization/organization-list/organization-list.component.ts
index abe84f8..b1f794a 100644
--- a/src/app/routes/systems/organization/organization-list/organization-list.component.ts
+++ b/src/app/routes/systems/organization/organization-list/organization-list.component.ts
@@ -227,4 +227,8 @@
       this.organizationService.title = '������������';
     });
   }
+  
+  registration(row){
+      sessionStorage.setItem("organization", JSON.stringify(row));
+  }
 }
diff --git a/src/app/routes/systems/registration/registration.component.html b/src/app/routes/systems/registration/registration.component.html
new file mode 100644
index 0000000..b9ac9c9
--- /dev/null
+++ b/src/app/routes/systems/registration/registration.component.html
@@ -0,0 +1,27 @@
+<div class="content__title">
+	<h1>���������������({{organization.name}})</h1>
+</div>
+<nz-card [nzBordered]="false">
+	<div class="mb-md">
+		<button nz-button [nzType]="'primary'" [nzSize]="'large'" (click)="isVisible=true">
+			<i class="anticon anticon-plus"></i><span>������</span>
+		</button>
+	</div>
+	<simple-table #simpleTable [data]="dataUrl" [extraParams]="extraParams" [columns]="columns" [showTotal]="true" [ps]="10" [reqReName]="{pi: 'pageIndex',ps: 'pageSize'}" [resReName]="{list: 'data',total: 'total'}">
+	</simple-table> 
+</nz-card>
+
+<nz-modal [nzVisible]="isVisible" [nzTitle]="'���������������'" [nzContent]="modalContent" (nzOnCancel)="isVisible=false" (nzOnOk)="registrationOk()">
+    <ng-template #modalContent>
+		<form nz-form >
+			<div nz-form-item nz-row>
+				<div nz-form-label nz-col [nzSm]="6" [nzXs]="24">
+				    <label nz-form-item-required>������������</label>
+				</div>
+				<div nz-col [nzSm]="14" [nzXs]="24">
+					<nz-datepicker style="width: 100%;" [(ngModel)]="_date" name='_date' [nzFormat]="'YYYY-MM-DD'" [nzDisabledDate]="_disabledDate" [nzAllowClear]="false"></nz-datepicker>
+				</div>
+			</div>
+		</form>
+    </ng-template>
+</nz-modal>
diff --git a/src/app/routes/systems/registration/registration.component.ts b/src/app/routes/systems/registration/registration.component.ts
new file mode 100644
index 0000000..7a00abc
--- /dev/null
+++ b/src/app/routes/systems/registration/registration.component.ts
@@ -0,0 +1,72 @@
+import {environment} from "../../../../environments/environment";
+import {Component, OnInit, ViewChild} from '@angular/core';
+import {SimpleTableColumn} from "@delon/abc";
+import {_HttpClient} from '@delon/theme';
+import {Subject} from "rxjs";
+import * as moment from 'moment';
+import {NzMessageService} from "ng-zorro-antd";
+@Component({
+  selector: 'app-registration',
+  templateUrl: './registration.component.html',
+})
+export class RegistrationComponent implements OnInit {
+  constructor(
+    public msgSrv: NzMessageService,
+    private http: _HttpClient
+  ) {}
+
+  @ViewChild('simpleTable') simpleTable: {load: Function};
+
+  dataUrl = environment.SERVER_BASH_URL + 'machineactivate/list';
+
+  queryTextStream: Subject<string> = new Subject<string>();
+
+  extraParams: any = {};
+  organization: any = {};
+  columns: SimpleTableColumn[] = [
+    {title: '���������', index: 'activationCode'},
+    {
+      title: '������������', index: 'isUsed', format: function(machineActivate) {
+        return machineActivate.isUsed == 1 ? '���' : '���';
+      }
+    },
+    {
+      title: '������������', type: 'date', index: 'createTime', format: function(machineActivate) {
+        return moment(machineActivate.createTime).format('YYYY-MM-DD HH:mm:ss');
+      }
+    },
+    {
+      title: '������������', type: 'date', index: 'expireDate', format: function(machineActivate) {
+        return moment(machineActivate.expireDate).format('YYYY-MM-DD');
+      }
+    },
+  ];
+  isVisible: boolean = false;
+  _date = new Date(Date.now() + 3600 * 24 * 1 * 1000);
+
+  ngOnInit() {
+    const organization = this.organization = JSON.parse(sessionStorage.getItem("organization"));
+    this.extraParams.organizationId = organization.id;
+    this.queryTextStream.debounceTime(900).distinctUntilChanged().subscribe(value => {
+      this.load();
+    });
+  }
+
+  load() {
+    this.simpleTable.load();
+  }
+
+  _disabledDate(current: Date): boolean {
+    return current && current.getTime() < Date.now();
+  }
+
+  registrationOk() {
+    this.http.get(environment.SERVER_BASH_URL + '/machineactivate/machine', {organizationId: this.organization.id, expireDate: moment(this._date).format('YYYY-MM-DD')}).subscribe((res: any) => {
+      if (res.code == 1 && res.data == 1) {
+        this.isVisible = false;
+        this.msgSrv.success('������������������������');
+        this.load();
+      }
+    });
+  }
+}
diff --git a/src/app/routes/systems/systems.module.ts b/src/app/routes/systems/systems.module.ts
index d1f3d49..37edebf 100644
--- a/src/app/routes/systems/systems.module.ts
+++ b/src/app/routes/systems/systems.module.ts
@@ -15,6 +15,7 @@
 import { AreacodeService } from '@business/services/http/areacode.service';
 import { OrganizationConfigComponent } from './organization/organization-config/organization-config.component';
 import { OrganizationListComponent } from './organization/organization-list/organization-list.component';
+import { RegistrationComponent } from "./registration/registration.component";
 import { SensorsService } from '@business/services/http/sensors.service';
 import { BusinessModule } from '@business/business.module';
 
@@ -23,7 +24,8 @@
     path: '',
     children: [
       { path: 'account', component: AccountComponent },
-      { path: 'organization', component: OrganizationComponent }
+      { path: 'organization', component: OrganizationComponent },
+      { path: 'registration', component: RegistrationComponent }
     ]
   }
 ];
@@ -45,7 +47,8 @@
     AccountEditComponent,
     OrganizationComponent,
     OrganizationConfigComponent,
-    OrganizationListComponent
+    OrganizationListComponent,
+    RegistrationComponent
   ],
   providers: [ToolsService, SensorsService, OrganizationService, _HttpClient, FormBuilder, AreacodeService],
   entryComponents: COMPONENTS_NOROUNT
diff --git a/src/assets/app-data.json b/src/assets/app-data.json
index 9877414..1e7d1a2 100644
--- a/src/assets/app-data.json
+++ b/src/assets/app-data.json
@@ -79,7 +79,12 @@
                   {
                     "text": "������������",
                     "link": "/systems/organization"
-                    }
+                    },
+	                {
+		                "text": "���������������",
+		                "link": "/systems/registration",
+		                "hide": true
+	                }
                 ]
               }
             ]

--
Gitblit v1.8.0