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();
|
}
|
});
|
}
|
}
|